-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Add polygonContain to Query #3942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We need to introduce a new type to the schéma, i’m all Open for it as Long as we don’t break legacy points. We’ll also need to define those types in the client SDKs! |
I've also read the 2dsphere indexes can cover multiple geospatial fields in a document. It might get rid of that MongoDB only supports one GeoPoint field in a class error |
Yeah if using polygons obviously :) |
Maybe a tool to convert legacy to 2dsphere would help. |
Yeah but that imply migrating data in production more likely, which could be problematic at large scale. |
The main issue I see is $nearSphere. I can test for 2d vs 2dsphere but the rest format are different.
For polygonContain I could only use geojson for Type Polygon and keep geopoints 2d for now |
Also the indexes are different and I’m not sure you can index the same column 2 2D and 2dsphere |
You can have multiple geospatial indexes per collection. Unless you are using $geoNear which we aren't using. I just created both on the same collection without problems. https://docs.mongodb.com/manual/core/2dsphere/#geonear-and-geonear-restrictions |
I'll probably do 2dsphere indexes for legacy GeoPoints at a later date just closing this for now. |
Could the $nearSphere dilemma be solved by adding the equivalent SDK methods for a $geoWithin query? We could have |
@madsb do you wanna try adding a PR for it? Which version of mongodb do they start using those indexes? |
I'll try to take a stab at it. I think $geoWithin queries are supported from version 2.4 and upwards: https://docs.mongodb.com/manual/reference/operator/query/geoWithin/ |
@madsb What do you think? |
You're right about the sorting, I totally missed that (I'm not using sorting either in my app). Still a bit novice about the whole index 2d/2dsphere thing. Databases are not my strong suit. Would probably be up to @drew-gross or @flovilmart to decide if now is the time to support GeoJSON. My vote is squarely in the 'yes' camp 😄 |
Mongo has a $geoIntersects that I want to use to return all polygons that contains a single point. Unfortunately it only supports 2dsphere indexes and parse-server currently doesn't use geoJson.
Maybe we can reopen #524 to support legacy coordinates (2d) as well as geoJSON (2dsphere) indexes.
Adding Type Polygon to Schema?
The text was updated successfully, but these errors were encountered: