origin icon indicating copy to clipboard operation
origin copied to clipboard

Syntax for within_polygon is slightly off

Open astjohn opened this issue 11 years ago • 0 comments

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 avatar Dec 12 '14 04:12 astjohn