Hacker News new | past | comments | ask | show | jobs | submit login

This is a while ago but about 12 years ago I experimented with putting the whole of openstreetmap into Elasticsearch.

Reverse geocoding then becomes a problem of figuring out which polygons contain the point with a simple query and which POIs/streets/etc. are closest based on perpendicular distance. For that, I simply did a radius search and some post processing on any street segments. Probably not perfect for everything. But it worked well enough. My goal was actually being able to group things by neighborhood and microneighborhoods (e.g. squares, nightlife areas, etc.).

This should work well enough with anything that allows for geospatial queries. In a pinch you can use geohashes (I actually did this because geospatial search was still a bit experimental in ES).




There's a couple of options listed here https://wiki.openstreetmap.org/wiki/Geocoding "Photon" and "Pelias" which were built on ElasticSearch


What were some other problems you ran in to when putting OSM in to ES? (I've had this thought before too, I'm curious why/how you did it)


It was part of a bigger project. I still have some code related to converting OSM data to json on my github: https://github.com/jillesvangurp/osm2geojson

Mainly the problem isn't Elasticsearch but dealing with openstreetmap tags and reconstructing polygons from ways, nodes, and relations. Otherwise, even back then Elasticsearch scaled fine; so no issues on that front. And it's pretty well suited for this type of stuff.

We had a largish Hetzner server (50 euro/month) with 32 GB and a quad core xeon that did the indexing. But basically that part was fine. I wrote some simple code that simply pulled out nearby street segments and then calculated perpendicular distance to each of them using some simple high school math and simply picked the nearest. And from there a simple contains query would produce neighborhoods, cities, countries, etc.

The why part was that I was building a location data startup at the time and we were interested in figuring out localities, neighborhoods, and other areas of interest from raw data with coordinates. The startup failed but the idea was kind of cool. So this was a simple reverse geocoder that I knocked out because the existing ones were kind of limited (also rate limited). And Opencage did not exist yet.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: