简体   繁体   English

如何按城市或地区前缀获取所有可能的经纬度地址?

[英]How can I get all possible addresses with lat and long by city or district prefix?

I want to implement code like below:我想实现如下代码:

When I send request to endpoint with name of " Sig " (just an example),I need it to give me当我向名为“ Sig ”的端点发送请求时(只是一个例子),我需要它给我

[

 {
  "name ":"Sighisoara",
  "lat":"smth",
  "Long":"smth"

 },

 {
  "name ":"Sigulda",
  "lat":"smth",
  "Long":"smth"
 }
]

Currently, I use OpenStreetMap , It has no such functionality.目前,我使用OpenStreetMap ,它没有这样的功能。 To get a address, you should write exactly how the address is spelled.要获得地址,您应该准确地写出地址的拼写方式。 For example, to get Sighisoara , you need to write Sighisoara Any idea to do that or free api which provides such functionality.例如,要获得Sighisoara ,您需要编写Sighisoara Any idea 来执行此操作或免费提供此类功能的api

PS, I am using Python. PS,我正在使用 Python。

I think the point is for you to understand the structure of this dictionary that contains all the city names,and you can try to split the structures.我认为重点是让你理解这个包含所有城市名称的字典的结构,你可以尝试拆分结构。 For example, I got a dictionary of weather from an API here, and I want to print out the current temperature.例如,我从这里的 API 得到了天气字典,我想打印出当前温度。

weather ={'coord': {'lon': 113.25, 'lat': 23.1167}, 'weather': [{'id': 803, 'main': 'Clouds', 'description': 'broken clouds', 'icon': '04d'}], 'base': 'stations', 'main': {'temp': 298.18, 'feels_like': 298.31, 'temp_min': 295.37, 'temp_max': 299.82, 'pressure': 1018, 'humidity': 53}, 'visibility': 6000, 'wind': {'speed': 2, 'deg': 160}, 'clouds': {'all': 75}, 'dt': 1615355271, 'sys': {'type': 1, 'id': 9620, 'country': 'CN', 'sunrise': 1615329655, 'sunset': 1615372438}, 'timezone': 28800, 'id': 1809858, 'name': 'Guangzhou', 'cod': 200} This is the code I will use: current_temp = (weather['main']['temp']) The name of this dictionary is weather, inside of it, there are several lists of 'main', which contained the 'temp' I want. weather ={'coord': {'lon': 113.25, 'lat': 23.1167}, 'weather': [{'id': 803, 'main': 'Clouds', 'description': '破云', 'icon': '04d'}], 'base': 'stations', 'main': {'temp': 298.18, 'feels_like': 298.31, 'temp_min': 295.37, 'temp_max': 299.82, 'pressure' : 1018, '湿度': 53}, '能见度': 6000, '风': {'speed': 2, 'deg': 160}, 'clouds': {'all': 75}, 'dt': 1615355271, 'sys': {'type': 1, 'id': 9620, 'country': 'CN', 'sunrise': 1615329655, 'sunset': 1615372438}, 'timezone': 28800, 'id': 1809858, 'name': 'Guangzhou', 'cod': 200} 这是我将使用的代码: current_temp = (weather['main']['temp']) 这个字典的名字是weather,在里面,有几个'main'列表,其中包含我想要的'temp'。 So you can make sure if your code is correctly catch the structure.因此,您可以确保您的代码是否正确捕获了结构。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以从本地 OSM tile 服务器批量地理编码地址以获得纬度/经度吗? - Can I bulk gecode addresses from local OSM tile server to get lat/long? Python 为 Geopy 中的每个经纬度坐标获取 state 区和 state 列 - Python get state district and state column for each lat long coordinate in Geopy NOAA如何将City,St转换为长途? - How does NOAA convert City,St to lat long? 如何从 JSON 地图上的 csv 绘制地址(纬度/经度)。? - How to plot addresses (Lat/Long) from a csv on JSON map.? 如何使用经纬度获取用户当前位置 - How to get user current location with lat and long 如何使用 bitcoinlib 获取与我的公钥关联的所有地址? - How can I get all the addresses associated with my public key with bitcoinlib? Python openweather,json - 按城市名称获取天气 - 我怎么能说这个城市不合适? - Python openweather, json - get weather by city name - how can I say that the city is incorrrect? 如何获得Amazon S3上具有相同前缀的所有文件名的列表? - How can I get a list of all file names having same prefix on Amazon S3? 如何在OSM中使用python获取我的经纬度? - How can I use python to get my lat,lon in OSM? 如何在R中没有问题的情况下将Long-Long转换为FIPS县代码? - How can I convert Lat-Long to FIPS county code without problems in R?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM