如何以及如何保存Geocoder API响应

时间:2018-08-10 06:40:38

标签: openstreetmap geocoding geocode nominatim

作为API,我使用的是https://nominatim.openstreetmap.org/(基于OpenStreetMap的只读api),响应如下:

        [
            {
                "place_id": "178104436",
                "licence": "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright",
                "osm_type": "relation",
                "osm_id": "41485",
                "boundingbox": [
                    "41.6556417",
                    "42.1410285",
                    "12.2344669",
                    "12.8557603"
                ],
                "lat": "41.8933203",
                "lon": "12.4829321",
                "display_name": "Roma, RM, LAZ, Italia",
                "class": "place",
                "type": "city",
                "importance": 0.82686368688662,
                "icon": "https://nominatim.openstreetmap.org/images/mapicons/poi_place_city.p.20.png",
                "address": {
                    "city": "Roma",
                    "county": "RM",
                    "state": "LAZ",
                    "country": "Italia",
                    "country_code": "it"
                }
            },
            {
                "place_id": "178486693",
                "licence": "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright",
                "osm_type": "relation",
                "osm_id": "41313",
                "boundingbox": [
                    "41.4075808",
                    "42.2969953",
                    "11.7337425",
                    "13.2962768"
                ],
                "lat": "41.85233365",
                "lon": "12.6308541512038",
                "display_name": "RM, LAZ, Italia",
                "class": "boundary",
                "type": "administrative",
                "importance": 0.45,
                "icon": "https://nominatim.openstreetmap.org/images/mapicons/poi_boundary_administrative.p.20.png",
                "address": {
                    "county": "RM",
                    "state": "LAZ",
                    "country": "Italia",
                    "country_code": "it"
                }
            }
        ]

我需要将一些详细信息保存到关系数据库中,以备将来查询(Lat,Lon是必填项,并且对地点的描述也一样,但没关系)。

问题是:保存什么格式?保存什么格式(以后再执行有效查询)?

对数据库的查询将首先在描述字段中进行,因此我需要以尽可能智能的方式进行存储。

您有什么建议?全部保存在一个字段中?在不同领域中划分国家,地区,城市,地址?其他可能性或格式?

搜索将使用一个通用文本框完成,而不使用不同的输入(城市,州/省份)

最后我应该用经典的方式查询 SELECT .... WHERE place_description LIKE '%rome%'还是更有效率?

0 个答案:

没有答案