mongomock
mongomock copied to clipboard
Support for Geospatial operators?
It'd be awesome to have support for some of the Geospatial operators such as $near or $geoWithin - https://docs.mongodb.com/manual/reference/operator/query-geospatial/
Is this something you guys even have on your mind? Or shall I just try and have a go at it?
I think it will be a bit engineering heavy to support this feature, possibly add shapely, even rtree, which makes the package a bit difficult to install.
any one else have a better implementation idea?
Maybe use harvesine?
GeographicLib has some pretty fantastic stuff in it: https://geographiclib.sourceforge.io/1.46/python/
I've only used it in C++, but I have a friend who has used it in Python and it went very smoothly for him, and only requires a pip install. This is probably the best option for computing distances.
As for rtree, etc., hopefully the average user doesn't need that level of optimization in unit tests, so you could probably ignore creating an index like that initially. I'd rather have something O(n) than nothing at all. And in the spirit of anything-is-better-than-nothing, writing up a handful of appropriate intersection algorithms (such as the ones found here: http://geomalgorithms.com/) and such in python will be far slower than something like shapely or any other pylib relying on C/C++ libs under the hood but would provide the desired functionality (and probably work perfectly fine for the majority of test cases).
Depending on what you guys say, I might fork and take a crack at this, as there are probably quite a few people who take advantage of mongo's cool geospatial query stuff.
Still no support?