[SERVER-8180] Polygon running the length of the equator returns incorrect results using $within query and 2dsphere index Created: 15/Jan/13  Updated: 15/Feb/13  Resolved: 16/Jan/13

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Ian Bentley Assignee: hari.khalsa@10gen.com
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Steps To Reproduce:

var t = db.geo_s2oddshapes
t.drop()
t.ensureIndex(

{ geo : "2dsphere" }

);

var testPoint = {
name: "origin",
geo:

{ type: "Point", coordinates: [0.0, 0.0] }

};

var testHorizLine = {
name: "horiz",
geo:

{ type: "LineString", coordinates: [[-2.0, 10.0], [2.0, 10.0]] }

};

var testVertLine = {
name: "vert",
geo:

{ type: "LineString", coordinates: [[10.0, -2.0], [10.0, 2.0]] }

};

t.insert(testPoint);
t.insert(testHorizLine);
t.insert(testVertLine);
//Test a poly that runs horizontally along the equator.

var longPoly =

{type: "Polygon", coordinates: [ [[89.0, 1.0], [-89.0, 1.0], [-89.0, -1.0], [89.0, -1.0], [89.0, 1.0]] ]}

;

//We expect that the testPoint (at the origin) will be within this poly.
result = t.find({geo: {$within: {$geometry: longPoly}}});
assert.eq(result.count(), 1);
assert.eq(result[0].name, 'origin');

//We expect that the testPoint, and the testVertLine should geoIntersect
//with this poly.
result = t.find({geo: {$geoIntersects: {$geometry: longPoly}}});
assert.eq(result.count(), 2);
assert.eq(result[0].name, 'vert');
assert.eq(result[1].name, 'origin');*

Participants:

 Description   

$geoIntersects is also returning more results than expected.



 Comments   
Comment by hari.khalsa@10gen.com [ 16/Jan/13 ]

Plotting the stuff on the sphere contradicts the test. Updating the test. Hooray confusing spherical geometry.

Generated at Thu Feb 08 03:16:46 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.