[DOCS-4486] $geoWithin and $geoIntersects's Behavior Created: 08/Dec/14  Updated: 09/Dec/14  Resolved: 09/Dec/14

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: None
Fix Version/s: v1.3.15

Type: Improvement Priority: Major - P3
Reporter: Siyuan Zhou Assignee: Kay Kim (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Screenshot 2014-12-08 15.04.01.png    
Participants:
Days since reply: 9 years, 10 weeks, 1 day ago

 Description   

The behavior section sounds ambiguous to me.
http://docs.mongodb.org/manual/reference/operator/query/geoIntersects/
http://docs.mongodb.org/manual/reference/operator/query/geoWithin/

Behavior
Any geometry specified with GeoJSON to $geoIntersects queries must fit within a single hemisphere. MongoDB interprets geometries larger than half of the sphere as queries for the smaller of the complementary geometries.

A geometry in query doesn't have to fit within a single hemisphere. For exmaple, let's imagine we have a band around the equator as following. Visualize it by dragging the GeoJSON definition to http://map.visualzhou.com, or see the screenshot attached. It's impossible to cover this band with any hemisphere cap, no matter North/South hemisphere or any hemisphere. However, since its area is less than half of the surface area of the earth, MongoDB/S2 still interpret it as the band we want. So the area matters, rather than the span.

var band = {
  "type" : "Polygon",
  "coordinates" : [
    [
      [-170, 10 ],
      [-85, 10 ],
      [0, 10 ],
      [85, 10 ],
      [170, 10 ],
      [170, -10 ],
      [85, -10 ],
      [0, -10 ],
      [-85, -10 ],
      [-170, -10 ],
      [-170, 10 ]
    ]
  ]
}
 
var coll = db.geo_hemisphere;
coll.drop();
assert.writeOK(coll.insert({loc: [0, 0]}));
assert.commandWorked(coll.ensureIndex({loc: "2dsphere"}));
 
assert.eq(1, coll.find({loc: { $geoWithin: {$geometry: band}}}).count());



 Comments   
Comment by Githook User [ 09/Dec/14 ]

Author:

{u'username': u'kay-kim', u'name': u'kay', u'email': u'kay.kim@10gen.com'}

Message: DOCS-4486 geojson area restrictions
Branch: master
https://github.com/mongodb/docs/commit/e0679dcf524be53082b0838efd97fb473a935762

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