skip to Main Content

SITUATION

I have a database with 2,000,000 cities. All of them have coordinates of the city center and mostly all – GeoJSON boundaries. I’m trying to implement a geocoding service that would find cities that intersect with a given point using node.js, mongodb, redis, memcached (and golang, if that is necessary, cause I’m just totally new to it )

PROBLEM

I know how to work with points (lat and lng) since both MongoDB and Redis support geoindexes but I’ve never seen anything about polygons.

I guess MongoDB won’t really help cause of its speed (since it work on disks), but any memory database should deal with this problem. The thing is I can’t even think of any way to implement it.

I’ll be happy if someone point me how to make it. Thanks.

2

Answers


  1. geo.lua (https://github.com/RedisLabs/geo.lua) works with the requirements you have here but it’s not very performant (not sure what has changed since last i checked).

    Login or Signup to reply.
  2. You may implement a point-in-polygon algorithm yourself. I’ve done something similar on https://api.3geonames.org

    First do a bounding box to identify candidate polygons, then run a PIP. https://en.wikipedia.org/wiki/Point_in_polygon

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search