Questions tagged [geonear]

33 questions
5
votes
0 answers

Question for using $geoNear twice in mongodb

I want to make a mongodb query to search companies by applying following filter. { myLocation: [lng1, lat1], // That is to get distance from current location to companies on result. region: [lng2, lat2], //That is to get companies within a…
Excalibur
  • 325
  • 2
  • 5
  • 15
4
votes
3 answers

mongodb - using $geoNear gives "geo near accepts just one argument when querying for a GeoJSON point" when using maxDistance

This appears to be a common error but I can't seem to make it work with all the suggestions I've seen. This is my setup: // point.js (based on mongoose recommended subdocument pattern for reusing the GeoJSON definition // see here…
Uche Ozoemena
  • 816
  • 2
  • 10
  • 25
3
votes
1 answer

Two $Geonear in aggrigate Mongo

The collection has two geo fields: fromLocation and toLocation. But only one Geonear is allowed. The collection looks like: ............... fromLocation: { type: { type: String, default: "Point" }, coordinates: [Number], }, toLocation:…
2
votes
2 answers

Mongo aggregation use $sort in conjunction with $geoNear

Context : I'm trying to build an architecture displaying POIs which can be at different know locations over time. I have 2 collections, pois { _id: ObjectId, name: string } locations _id: ObjectId, point: { type: 'Point', …
Cyril CHAPON
  • 3,556
  • 4
  • 22
  • 40
2
votes
1 answer

MongoDB geoNear not working for some coordinates but working for others

I'm working on an API using MongoDB and the Node.js driver for mongoDB. One of the routes takes in coordinates and calls an aggregation pipeline that returns results sorted by closeness and a number of other factors. The code for the first step of…
Chris
  • 23
  • 3
2
votes
0 answers

Can I Use MongoDB Geospatial Query to Find Closest LineString to Point?

I have a collection of geoJSON LineString objects and need to determine which is closest to a point. I don't have much experience with Mongo DB, but have used the $geoNear to find closest points. Is there a way to adapt this to work with a…
MRip
  • 21
  • 3
2
votes
2 answers

MongoError: Can't extract geo keys

I'm facing a mongoose error during post data updation. The error is: MongoError: Can't extract geo keys I've tried to find the reason and the solution by searching on google but still I didn't get any proper solution. Posts Model const…
Chandan Chhajer
  • 303
  • 2
  • 7
2
votes
1 answer

How to return distance along result in two different sub values using $geoNear

I have this query: db.places.aggregate([ { "$geoNear" : { "near" : { "type" : "Point", "coordinates" : [23, 11] }, "distanceField" : "distance", "spherical" : true } }, { …
Emixam23
  • 3,854
  • 8
  • 50
  • 107
2
votes
1 answer

MongoError:"geoNear command failed: { ok: 0.0, errmsg: \"error processing query","code":16604,"codeName":"Location16604"

I am frustrated about mongodb geonear aggregate query, for each response i get error like this : {"name":"MongoError","message":"geoNear command failed: { ok: 0.0, errmsg: \"error processing query: ns=Lab.assoprofiles limit=100Tree: GEONEAR …
user3137766
1
vote
1 answer

mongodb loopup pipeline geoNear

I am running into an issue where I'm trying to grab some documents near the current document in a lookup. If I manually enter the lon/lat the following query will work but it fails with trying to use anything from the "let". How can I reference the…
Alkimia
  • 33
  • 1
  • 4
1
vote
1 answer

MongoDB $geoNear decrease accuracy of distance return value

I'm performing a query on my user model in MongoDB and want to order the search results first by their distance in kilometres (using the $geoNear operator), and then by their last login time. The problem is, the distance attribute is returned as…
Sam
  • 2,172
  • 3
  • 24
  • 43
1
vote
1 answer

Grouping nearest locations in Mongodb

Location point saved as { "location_point" : { "coordinates" : [ -95.712891, 37.09024 ], "type" : "Point" }, "location_point" : { "coordinates" : [ -95.712893, 37.09024 ], "type" : "Point" }, …
1
vote
0 answers

Searching Nearby Shop by using diagonal distance of Map

First, I want to get the nearby shop from the backend. For that, I am sending Center latitude and longitude of the map and the diagonal distance of map. By that, I am getting the nearby shop which is under my current viewport. But when I zoom in on…
Arindam
  • 61
  • 4
1
vote
1 answer

Better way to query multiple fields in $geoNear than using $or?

I have a list of events. I would like to search both the title and description fields for a certain phrase and return events in a given radius matching the query. I am currently using the $or operator, which seems to work. However, I am wondering if…
Matt
  • 2,953
  • 3
  • 27
  • 46
1
vote
1 answer

Filter on $geoNear (destination) and sort based on $geoNear( origin)

I want to show the places for riders within a given distance and sort them based on origin points. This is how the data looks like { "_id" : ObjectId("5b5a9cd706f9b02068ebc4a6"), "name" : "Bangalore to hyderabad", "locations" : [ { …
Narayan Singh
  • 1,234
  • 2
  • 13
  • 26
1
2 3