简体   繁体   中英

how to get the city name from shapefiles in java

I am having the hard time to understand the concept of shapefiles. 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). 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. 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. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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