My question seems unclear. Put it in details: I generate a pymongo database on client and in this database I have a collection of documents, which are all in this format:
{"_id": ...,
"latlng":{"type":"Polygon",
"coordinates":[[[-121.1,47.5],[-121.1,47.6],
[-121.2,47.6],[-121.2,47.5],
[-121.1,47.5]]]},
"self":{"school":1, "home":2}}
Actually, this collection is to segment a city into grids and each document describes a grid.
Now my problem is that: if given a new point (new coordinates),I need to determine which grid the point is in and I want to realize this as fast as possible (because the whole city is really large and I have 2 million grids).
So anyone knows a good method? (I want to realize this by querying the database and using GeoJSON since my grid coordinates are of GeoJSON format, however I didn't find a command (like geoWithin) that can match a point to a polygon containing it)
I notice that there are some similar questions but I am wondering whether someone has experience using pymongo database and dealing with the same problem. Thanks a lot if you could share your experience with me.