Answer the question
In order to leave comments, you need to log in
Determination of the city by coordinates?
I am using the geonames database .
It is necessary to find the nearest city by the user's coordinates. To do this, I filled in all the cities in mongodb and created a geographic index. There was a problem: according to the point located in the north of St. Petersburg, there is the nearest point - the village of Bugry (a suburb of St. Petersburg), because the point is closer to the suburbs than to the center of St. Petersburg.
There are also districts of the city (with coordinates) in the geonames database, if I also search for them, then the "Grazhdanka" district is closer to my point, which is a district of St. Petersburg, and this would increase the accuracy of determining the city to the one I need, but the problem is the fact that in the geonames database it is for some reason listed as a district of the village of Bugry. The same problem with other areas of St. Petersburg, for some reason they are listed in the database as areas of other suburbs. There is an opinion that the same problem is with areas of other cities.
Now I see two options for solving the problem:
1) download the osm database and extract the coordinates of the borders of all cities from it.
2) using api osm to go through the database of districts (about 100k) in geonames and fix the binding of districts to cities (get the city in osm using the coordinates of the district from the geonames database
) I don’t want to always use someone else’s api (osm, googlemaps) for geocoding, because it is expected heavy load, and the best conditions are 1 request per second in osm (and Google only has 2500 requests per day). Installing Nominatim
on the server is not an option, because it has too large requirements (hundreds of gigabytes of hard disk and tens of gigabytes of RAM), and I only need city borders from this entire database, I don’t need streets, houses and roads, etc. .
What other options are there?
Answer the question
In order to leave comments, you need to log in
And it requires local search, maybe use the site's api? In principle, it would be useful / interesting to implement it in the OpenStreetMap.RU api (jointly). Again, if the server will not hold the load, deploy it at home too, but there is postgresql (if this is a problem)
I did this:
1. downloaded the OSM database
2. ripped out the coordinates of settlements from there and uploaded them to "my" database (VK)
3. I use the search by the given coordinates from this guide
Result:
since the bases with objects are initially different, it was impossible to get the coordinates for each of us. item in my database from OSM data. Of the 2 million records with coordinates, I have only 187 thousand. The task was to determine the expected city of the user, so this accuracy turned out to be more than enough for me. This is about an urban-type settlement.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question