[SERVER-1618] geodb -bbox query coordinates Created: 11/Aug/10  Updated: 12/Jul/16  Resolved: 15/Jun/11

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 1.5.0, 1.8.1
Fix Version/s: 1.9.0

Type: Bug Priority: Major - P3
Reporter: sima lotfi Assignee: Greg Studer
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: Linux
Participants:

 Description   

im using /mongodb-linux-i686-1.6.0 and pymongo to do some geo-queries like bounding box on points and as it is said here:
http://api.mongodb.org/python/1.8%2B/examples/geo.html I have first search coordinate as lower-left and the second search coordinate as upper-right. but it doesn't work quite fine.

for instance this query :
geodb.point_collection.find({"addr:housenumber": "420","addr:street": "S Nevada St", "loc": {"$within":

{"$box": [[-179,-179], [90, 90]]}

}}):

returns:

{u'addr:housenumber': u'420', u'loc': [-117.372889, 33.192777],u'addr:city': u'Oceanside', u'is_in:country': u'United States ofAmerica', u'addr:postcode': u'92054', u'is_in:city': u'Oceanside',u'is_in:country_code': u'US', u'addr:country': u'US', 'is_in:state':u'California', u'source': u'SanGIS Addresses Public Domain (http://www.sangis.org/)', u'id': u'596715001', u'_id':ObjectId('4c62eb6634e1c779b800017c'), u'type': u'Point',u'is_in:state_code': u'CA', u'addr:street': u'S Nevada St'}

but this query
geodb.point_collection.find({"addr:housenumber": "420","addr:street": "S Nevada St", "loc": {"$within":

{"$box": [[-118, 33],[0, 34]]}

}}):

returns this error:
for doc in geodb.point_collection.find({"addr:housenumber": "420","addr:street": "S Nevada St", "loc": {"$within":

{"$box": [[-118, 33],[0, 34]]}

}}):
File "/usr/local/lib/python2.6/dist-packages/pymongo/cursor.py",
line 565, in next if len(self.__data) or self._refresh():
File "/usr/local/lib/python2.6/dist-packages/pymongo/cursor.py",
line 528, in refresh self.query_spec(), self._fields))
File "/usr/local/lib/python2.6/dist-packages/pymongo/cursor.py",
line 496, in _send_message self.as_class, self._tz_aware)
File "/usr/local/lib/python2.6/dist-packages/pymongo/helpers.py",
line 99, in _unpack_response error_object["$err"])
pymongo.errors.OperationFailure: database error: point not in range

so the bbox coordinates are not lower-left and upper-right. not sure
wat they are....

thanks,
sima



 Comments   
Comment by Greg Studer [ 13/Jun/11 ]

This may have to do with boundary conditions in 1.8.1 - can you reproduce the results if all your points are within [-178, 178]? In particular, the exact maximum bound can be translated to the minimum bound, which seems like it may be one of the issues here. As far as 90/90.1, can you try setting the "bits" option when creating the index to 32 as a workaround?
If you're willing to install v1.9, you should get better error messages which tell you exactly which value, if any, is still causing the problem (as well as fixing the boundary and 90 degree issues).

Comment by Ken Pratt [ 09/Jun/11 ]

Add the following to strange beavior - this time with version 1.8.1

query = { "Placemark.Point.coordinates" : { "$within" :

{ "$box" : [ [ 172.3265993445506 , 9.18637494622202] , [ 180.0 , 20.3450110477435]]}

}}
Fatal error: need an area > 0

The box does have an area.

Comment by Ken Pratt [ 09/Jun/11 ]

I am seeing similar behaviour. The following query should not fail. The 2d index is not specifying a max or min range. It is using the default of (-180,180].

> db.AirTraffic.find({"Placemark.Point.coordinates" : { "$within" :

{ "$box" : [ [ 90.1 , 9.0] , [ 179.0 , 20.0]]}

}})
> error:

{ "$err" : "point not in range", "code" : 13027 }

The point is in range and should not result in an error. If I change the first longitude from 90.1 to 80.1, all is well. The failure seems to be across the 90 boundary - which is lat and is still within the default range.

> db.serverBuildInfo()
{
"version" : "1.6.3",
"gitVersion" : "nogitversion",
"sysInfo" : "Linux allspice 2.6.24-28-server #1 SMP Wed Aug 18 21:17:51 UTC 2010 x86_64 BOOST_LIB_VERSION=1_42",
"bits" : 64,
"debug" : false,
"ok" : 1
}

Comment by auto [ 05/Oct/10 ]

Author:

{'login': 'astaple', 'name': 'Aaron', 'email': 'aaron@10gen.com'}

Message: SERVER-1618 remove debugging
http://github.com/mongodb/mongo/commit/7b24925eb9a94cbd9bb2652cf304b51e3ca48d0a

Comment by Richard Kreuter (Inactive) [ 16/Aug/10 ]

I am not able to reproduce this using mongodb 1.6.0 on a 64bit osx machine. I think this is an old bug that was fixed a number of weeks ago; if you're using a recent build, could you show the output of db.serverBuildInfo()?

> db.serverBuildInfo();
{
"version" : "1.6.0",
"gitVersion" : "2c7f164b653f0d703947572ede064aed41cc2185",
"sysInfo" : "Darwin erh2.10gen.cc 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_37",
"bits" : 64,
"ok" : 1
}
> use test
switched to db test
> db.s1618.save(

{'addr:housenumber': '420', 'loc': [-117.372889, 33.192777],'addr:city': 'Oceanside', 'is_in:country': 'United States ofAmerica', 'addr:postcode': '92054', 'is_in:city': 'Oceanside','is_in:country_code': 'US', 'addr:country': 'US', 'is_in:state':'California', 'source': 'SanGIS Addresses Public Domain (http://www.sangis.org/)', 'id': '596715001', '_id':ObjectId('4c62eb6634e1c779b800017c'), 'type': 'Point','is_in:state_code': 'CA', 'addr:street': 'S Nevada St'}

);
> db.s1618.ensureIndex(

{loc:"2d"}

);
> db.s1618.find({"addr:housenumber": "420","addr:street": "S Nevada St", "loc": {"$within":

{"$box": [[-118, 33],[0, 34]]}

}});

{ "_id" : ObjectId("4c62eb6634e1c779b800017c"), "addr:housenumber" : "420", "loc" : [ -117.372889, 33.192777 ], "addr:city" : "Oceanside", "is_in:country" : "United States ofAmerica", "addr:postcode" : "92054", "is_in:city" : "Oceanside", "is_in:country_code" : "US", "addr:country" : "US", "is_in:state" : "California", "source" : "SanGIS Addresses Public Domain (http://www.sangis.org/)", "id" : "596715001", "type" : "Point", "is_in:state_code" : "CA", "addr:street" : "S Nevada St" }
Comment by Richard Kreuter (Inactive) [ 11/Aug/10 ]

Could you paste the output of db.serverBuildInfo() at the mongo shell?

Generated at Thu Feb 08 02:57:33 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.