This repository was archived by the owner on May 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
feat: Add support for $geoIntersects, $near and $nearSphere queries #11
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@durran Assuming you are happy with the changes, would you be okay with me publishing a minor package update to npm, and updating the mongodb-query-parser to use the new version? Given the timezone differences I can ask someone on the Charts team to approve the change to the downstream repo so I am not blocked waiting for async approvals.
@matt-d-rat
matt-d-rat
force-pushed
the
bug/CHARTS-2172-geo-operators-invalid
branch
2 times, most recently
from
February 28, 2019 23:00
f57d096 to
95c7650
Compare
...cation. Add array_number, geometry_type and geometry_coordinates operators.
...onal grammar helpers. - Add number_positive grammar - Add number_longitude grammar - Add number_latitude grammar - Add array_number grammar - Add legacy_coordinates grammar - Add $near/$nearSphere operator - Add $minDistance/$maxDistance operator - Updated unit test cases
@matt-d-rat
matt-d-rat
force-pushed
the
bug/CHARTS-2172-geo-operators-invalid
branch
from
March 1, 2019 01:07
95c7650 to
a5eb59a
Compare
shaketbaby
shaketbaby
approved these changes
Mar 1, 2019
@shaketbaby
shaketbaby
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Yes! Ship it. :)
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
This PR adds support for the following Geospatial Query operators:
$geoIntersects$near$nearSphereIn the case of
$nearand$nearSpheresupport has also been added for specifying the optional$minDistanceand$maxDistancelimits to the query.In addition, I have made some minor updates to the validation of
$geometrythat is used by all of the geo-operators to ensure that we check thetypeandcoordinatesvalues are correct. I have also added additional grammar for legacy coordinates, validating that the numbers provided in the array syntax are validlongitudeandlatitudenumbers.As such the following queries no longer throw a parser error (verified through unit tests and the online PEG.js parser):
$geoIntersects
{ "address.location": { "$geoIntersects": { "$geometry": { "type": "Polygon" , "coordinates": [ [ [ 0, 0 ], [ 3, 6 ], [ 6, 1 ], [ 0, 0 ] ] ] } } } }$near
{ "address.location": { "$near" : { "$geometry": { "type": "Point", "coordinates": [0,0] } } } }{ "address.location": { "$near" : [1, 90] } }{ "address.location": { "$near" : { "$geometry": { "type": "Point", "coordinates": [0,0] }, "$minDistance": 1000, "$maxDistance": 5000 } } }{ "address.location": { "$near" : [1, 90], "$maxDistance": 5000, "$minDistance": 1000 } }$nearSphere
{ "address.location": { "$nearSphere" : { "$geometry": { "type": "Point", "coordinates": [0,0] } } } }{ "address.location": { "$nearSphere" : [1, 90] } }{ "address.location": { "$nearSphere" : { "$geometry": { "type": "Point", "coordinates": [0,0] }, "$minDistance": 1000, "$maxDistance": 5000 } } }{ "address.location": { "$nearSphere" : [1, 90], "$maxDistance": 5000, "$minDistance": 1000 } }