[SERVER-11830] geo near query does not cover entire length of equator Created: 22/Nov/13  Updated: 11/Jul/16  Resolved: 25/Nov/13

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

Type: Bug Priority: Major - P3
Reporter: Luke Lovett Assignee: Benety Goh
Resolution: Done Votes: 0
Labels: 26qa, nqf, query_triage
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

> db.serverBuildInfo()
{
"version" : "2.4.9-pre-",
"gitVersion" : "38b3b8f7395d6717efd570a62dc1c2c085d1b049",
"sysInfo" : "Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49",
"loaderFlags" : "-fPIC -pthread -rdynamic",
"compilerFlags" : "-Wnon-virtual-dtor -Woverloaded-virtual -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -Werror -pipe -fno-builtin-memcmp -O3",
"allocator" : "tcmalloc",
"versionArray" : [
2,
4,
9,
-100
],
"javascriptEngine" : "V8",
"bits" : 64,
"debug" : false,
"maxBsonObjectSize" : 16777216,
"ok" : 1
}
and
> db.serverBuildInfo()
{
"version" : "2.5.5-pre-",
"gitVersion" : "4d722953fa6e7f0cd8732601ed7c5c1cb8808bad",
"OpenSSLVersion" : "",
"sysInfo" : "Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49",
"loaderFlags" : "-fPIC -pthread -Wl,-z,now -rdynamic",
"compilerFlags" : "-Wnon-virtual-dtor -Woverloaded-virtual -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -Werror -pipe -O3 -Wno-unused-function -Wno-deprecated-declarations -fno-builtin-memcmp",
"allocator" : "tcmalloc",
"versionArray" : [
2,
5,
5,
-100
],
"javascriptEngine" : "V8",
"bits" : 64,
"debug" : false,
"maxBsonObjectSize" : 16777216,
"ok" : 1
}


Attachments: File server11830.js    
Issue Links:
Related
Operating System: ALL
Steps To Reproduce:

2.5.5-pre-

> db.c.insert({loc:{type:"Point",coordinates:[0,0]}})
Insert WriteResult({ "ok" : 1, "n" : 1 })
> db.c.insert({loc:{type:"Point",coordinates:[-1,0]}})
Insert WriteResult({ "ok" : 1, "n" : 1 })
> db.c.ensureIndex({loc:"2dsphere"})
> db.c.find({loc:{$nearSphere:{$geometry:{type:"Point",coordinates:[180,0]},$maxDistance:10e1000000}}})
{ "_id" : ObjectId("528fa9b06ce2fec2710a135b"), "loc" : { "type" : "Point", "coordinates" : [  -1,  0 ] } }
> db.c.find({loc:{$near:{$geometry:{type:"Point",coordinates:[180,0]},$maxDistance:10e1000000}}})
{ "_id" : ObjectId("528fa9b06ce2fec2710a135b"), "loc" : { "type" : "Point", "coordinates" : [  -1,  0 ] } }
> db.runCommand({geoNear:"c", near:{type:"Point",coordinates:[180,0]},spherical:true})
{
	"ns" : "georepro.c",
	"results" : [
		{
			"dis" : 19926073.25883961,
			"obj" : {
				"_id" : ObjectId("528fa9b06ce2fec2710a135b"),
				"loc" : {
					"type" : "Point",
					"coordinates" : [
						-1,
						0
					]
				}
			}
		}
	],
	"stats" : {
		"nscanned" : 2,
		"avgDistance" : 19926073.25883961,
		"maxDistance" : 19926073.25883961,
		"time" : 7
	},
	"ok" : 1
}

2.4.9-pre-

> db.c.insert({loc:{type:"Point",coordinates:[0,0]}})
> db.c.insert({loc:{type:"Point",coordinates:[-1,0]}})
> db.c.ensureIndex({loc:"2dsphere"})
> db.c.find({loc:{$nearSphere:{$geometry:{type:"Point",coordinates:[180,0]},$maxDistance:10e1000000}}})
{ "_id" : ObjectId("528fa9b05142cd7d1e23d1bb"), "loc" : { "type" : "Point", "coordinates" : [  -1,  0 ] } }
{ "_id" : ObjectId("528fa99e5142cd7d1e23d1ba"), "loc" : { "type" : "Point", "coordinates" : [  0,  0 ] } }
> db.c.find({loc:{$near:{$geometry:{type:"Point",coordinates:[180,0]},$maxDistance:10e1000000}}})
{ "_id" : ObjectId("528fa9b05142cd7d1e23d1bb"), "loc" : { "type" : "Point", "coordinates" : [  -1,  0 ] } }
{ "_id" : ObjectId("528fa99e5142cd7d1e23d1ba"), "loc" : { "type" : "Point", "coordinates" : [  0,  0 ] } }
> db.runCommand({geoNear:"c", near:{type:"Point",coordinates:[180,0]},spherical:true})
{
	"ns" : "georepro.c",
	"results" : [
		{
			"dis" : 19926073.261345826,
			"obj" : {
				"_id" : ObjectId("528fa9b05142cd7d1e23d1bb"),
				"loc" : {
					"type" : "Point",
					"coordinates" : [
						-1,
						0
					]
				}
			}
		},
		{
			"dis" : 20037392.09826071,
			"obj" : {
				"_id" : ObjectId("528fa99e5142cd7d1e23d1ba"),
				"loc" : {
					"type" : "Point",
					"coordinates" : [
						0,
						0
					]
				}
			}
		}
	],
	"stats" : {
		"time" : 5,
		"nscanned" : 2,
		"avgDistance" : 19981732.679803267,
		"maxDistance" : 20037392.09826071
	},
	"ok" : 1
}

Participants:

 Description   

It seems that $near, $nearSphere and geoNear in version 2.5 of mongodb won't return documents whose longitude is 180 degrees away from that in the coordinates given in the query. Version 2.4 will return these documents.



 Comments   
Comment by Githook User [ 26/Nov/13 ]

Author:

{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}

Message: SERVER-11830 keep annulus bounds open on _outerRadius except for the last one
Branch: master
https://github.com/mongodb/mongo/commit/6015f1f2706201e52f66eede33ef41114dec5550

Comment by Githook User [ 25/Nov/13 ]

Author:

{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}

Message: SERVER-11830 handle geo near with two points on opposite sides of equator
Branch: master
https://github.com/mongodb/mongo/commit/fe45bf70ca9ebd865dad424b581e0bab10e16cb0

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