mongomock icon indicating copy to clipboard operation
mongomock copied to clipboard

Support for Geospatial operators?

Open pedropregueiro opened this issue 8 years ago • 4 comments

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?

pedropregueiro avatar Mar 23 '17 19:03 pedropregueiro

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?

DeoLeung avatar Mar 26 '17 15:03 DeoLeung

Maybe use harvesine?

drorasaf avatar Jun 22 '17 13:06 drorasaf

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.

nkentNTIA avatar Jul 25 '17 18:07 nkentNTIA

Still no support?

aemonge avatar Jul 11 '23 14:07 aemonge