[SERVER-23927] geonear aggregation error for coordinates with negative values Created: 26/Apr/16  Updated: 26/Apr/16  Resolved: 26/Apr/16

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

Type: Bug Priority: Major - P3
Reporter: shibimukesh Assignee: Kelsey Schubert
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Steps To Reproduce:

{"_id" : 5,"driver_id" : 685,"status" : "F","shift_status" : "OUT","update_date" : "0000-00-00 00:00:00","loc" : {"type" : "Point","coordinates" : [-118.25,34.05]},"driverinfo":[]}
 
{"_id" : 2,"driver_id" : 680,"status" : "F","shift_status" : "OUT","update_date" : "2015-03-11 19:42:36","loc":{"type" : "Point","coordinates" : [76.918805,11.02214]},"driverinfo":[]}

query
-------

db.collectionname.aggregate(
{$geoNear: {near: {coordinates: [ 77.0107990 , 11.0249990 ] },
    distanceField:"distance",
    spherical: true}}
)//.itcount();

Participants:

 Description   

While using geonear aggregation it returns the distance for only for lat and long with postive coordinates



 Comments   
Comment by Kelsey Schubert [ 26/Apr/16 ]

Hi shibish,

I was not able to reproduce this issue using MongoDB 3.2.5. I've included the shell output from my attempt below:

> db.foo.insert({"_id" : 5,"driver_id" : 685,"status" : "F","shift_status" : "OUT","update_date" : "0000-00-00 00:00:00","loc" : {"type" : "Point","coordinates" : [-118.25,34.05]},"driverinfo":[]})
WriteResult({ "nInserted" : 1 })
> db.foo.insert({"_id" : 2,"driver_id" : 680,"status" : "F","shift_status" : "OUT","update_date" : "2015-03-11 19:42:36","loc":{"type" : "Point","coordinates" : [76.918805,11.02214]},"driverinfo":[]})
> db.foo.createIndex({loc:"2dsphere"})
{
	"createdCollectionAutomatically" : false,
	"numIndexesBefore" : 1,
	"numIndexesAfter" : 2,
	"ok" : 1
}
> db.foo.aggregate( {$geoNear: {near: {coordinates: [ 77.0107990 , 11.0249990 ] },     distanceField:"distance",     spherical: true}})
{ "_id" : 2, "driver_id" : 680, "status" : "F", "shift_status" : "OUT", "update_date" : "2015-03-11 19:42:36", "loc" : { "type" : "Point", "coordinates" : [ 76.918805, 11.02214 ] }, "driverinfo" : [ ], "distance" : 10056.748423814743 }
{ "_id" : 5, "driver_id" : 685, "status" : "F", "shift_status" : "OUT", "update_date" : "0000-00-00 00:00:00", "loc" : { "type" : "Point", "coordinates" : [ -118.25, 34.05 ] }, "driverinfo" : [ ], "distance" : 14766316.516652213 }

If you can provide additional information to reproduce this issue you describe, we can take another look.

Kind regards,
Thomas

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