[DOCS-1653] Comment on: "manual/reference/operator/query-geospatial.txt" Created: 27/Jun/13  Updated: 03/Nov/17  Resolved: 28/Jun/13

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Thomas Rueckstiess Assignee: Sam Kleinman (Inactive)
Resolution: Done Votes: 0
Labels: collector-298ba4e7
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Location: http://docs.mongodb.org/manual/reference/operator/query-geospatial/#geospatial-query-compatibility-chart
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36
Referrer: http://docs.mongodb.org/manual/applications/geospatial-indexes/
Screen Resolution: 2560 x 1440
repo: docs
source: reference/operator/query-geospatial


Participants:
Days since reply: 10 years, 33 weeks, 6 days ago

 Description   

The example for $geoWithin with $center is not correct:

{ $geoWithin : {
  $center : [x1, y1],
  $maxDistance : d
} }

This is not the right syntax for $center. It doesn't support $maxDistance. That is for the $near operator.

Trying this in the shell returns:

> db.docs.find({loc: {$geoWithin: {$center: [15, 15], $maxDistance:10} }})
error: {
	"$err" : "Malformed geo query: { $geoWithin: { $center: [ 15.0, 15.0 ], $maxDistance: 10.0 } }",
	"code" : 16677
}

The correct syntax is explained on the $center page:

{ $geoWithin : {
  $center :
    [[x, y], radius]
} }

It is the same as the $centerSphere syntax.

That also works in the shell:

> db.docs.find({loc: {$geoWithin: {$center: [[15, 15], 10]}}})
{ "_id" : ObjectId("51cbb33a7645edc3cf1057cb"), "loc" : [  10,  20 ] }



 Comments   
Comment by Sam Kleinman (Inactive) [ 28/Jun/13 ]

Fixed in: https://github.com/mongodb/docs/commit/e29166781958d043fe262e30f4d1096ba2b564ee

Generated at Thu Feb 08 07:41:34 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.