简体   繁体   English

如何从Java中的shapefile获取城市名称

[英]how to get the city name from shapefiles in java

I am having the hard time to understand the concept of shapefiles. 我很难理解shapefile的概念。 I have downloaded the shape file and so far I have understood that I have to dump these file into mysql using some tool like geotool(I am using Java). 我已经下载了形状文件,到目前为止,我了解我必须使用诸如geotool(我正在使用Java)之类的工具将这些文件转储到mysql中。 My doubt is, if I have latitude and longitude , how can i get the city name in which these lat long falls? 我的疑问是,如果我有经度和纬度,我如何获得这些经久不衰的城市名称? I dont want to use google reverse geocoding. 我不想使用Google反向地理编码。 My knowledge in this area is pretty much limited, so if my question is unclear, do buzz me I will clear it more... Any link will be helpul.. Thanks 我在这方面的知识非常有限,因此,如果我的问题不清楚,请嗡嗡叫我,我将进一步清除它。任何链接都将是有帮助的..谢谢

You can store some structure to store the range of latitude, longitude a city covers. 您可以存储某种结构来存储城市覆盖的纬度和经度范围。 You can model that as x,y coordinates of rectangle or circle. 您可以将其建模为矩形或圆形的x,y坐标。 Then you make a test like 然后你做一个像

if(city.contains(latitude, longitude)

You can start by looking at GeoTools's Shapefile Datastore to read and manipulate your dataset. 您可以从查看GeoTools的Shapefile数据存储开始,以读取和操作您的数据集。

Now, in order to "get the city name", it's hard to know what you mean unless your provide some information about the data you're using. 现在,为了“获取城市名称”,除非您提供有关正在使用的数据的一些信息,否则很难知道您的意思。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM