Skip to content
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

Syntax for within_polygon is slightly off #102

Open
astjohn opened this issue Dec 12, 2014 · 0 comments
Open

Syntax for within_polygon is slightly off #102

astjohn opened this issue Dec 12, 2014 · 0 comments

Comments

@astjohn
Copy link

astjohn commented Dec 12, 2014

The mongo docs specify the query as:

loc: {
       $geoWithin: {
          $geometry: {
             type : "Polygon" ,
             coordinates: [ [ [ 0, 0 ], [ 3, 6 ], [ 6, 1 ], [ 0, 0 ] ] ]
          }
       }
     }

Note the triple brackets.
The current changlog (the first place I happened to stumble into the documentation as I was upgrading) shows usage as:

query.geo_spacial(:location.within_polygon => [[ 1, 10 ], [ 2, 10 ], [ 1, 10 ]])

Note only double brackets. I'm not sure if this is a typo in the changelog, or if the changelog has the correct syntax and this is a bug in the query. I had to add an extra containing array (triple brackets) to make the query work. I'm also not sure if this applies to any of the other geo_spacial queries.

astjohn added a commit to Sitata/origin that referenced this issue Dec 23, 2014
…ixes mongoid#102.

The correct query is to use triple brackets as specified in the specs and
in mongodb documentation. The example documentation for Origin was missing
a set of brackets.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant