Questions tagged [mongodb-geospatial]
38 questions
3
votes
0 answers
MongoDB - $geoNear and includeLocs with multiple matches in same document
I have a collection that looks like this:
Mongodb Collection Data:
/* 1 */
{
"_id" : "X1255",
"member" : {
"id" : "X1255",
"address" : [
{
"place" : "TEST1",
"location" : {
…

Divya.R
- 31
- 2
3
votes
0 answers
How to do a bounding box query with MongoDB?
I can't seem to get a bounding box query working with MongoDB, that actually uses the spatial index.
Here's my indexes:
[
{
"v" : 2,
"key" : {
"_id" : 1
},
"name" : "_id_",
"ns" :…

RPM1984
- 72,246
- 58
- 225
- 350
2
votes
0 answers
Why does mongoDB driver seem to fallback to MarshalJSON but not UnmarshalJSON in Go
I noticed when trying to insert an complex data type into a mongodb using Go without having MarshalBSON implemented, it falls back to MarshalJSON and inserts the struct correctly as a document in mongodb.
However, when I then try to retrieve that…

JC97
- 1,530
- 2
- 23
- 44
2
votes
1 answer
How to check if a vehicle entered into geofence or not using geospatial data in NodeJS using mongodb and mongoose?
I've been working on creating geo fences and alerting systems using Node.JS, mongoDB and mongoose framwork.
I've a vehicle with a sensor, which keep on sending the coordinates it travelling through.
Now, I need to check whether that vehicle entered…

Aravind
- 424
- 3
- 19
2
votes
0 answers
How to query Mongodb on Single Field with multiple ranges efficiently?
I am trying to build custom geospatial indexes using MongoDB's B-tree indexes, as I find Mongo's native implementation limiting for my own case. In order to fulfill my geospatial queries which will effectively search Mongo using a compound index, I…

Anıl Şimşek
- 61
- 5
1
vote
0 answers
MongoDB for big tile map game 1000x1000
I started learning mongodb and was trying to figure out which way is better suited for a large 2d tile map if I need to store a large number of tiles.
In my case, the player has to fill in the free 4 tiles (quad 2x2) - this is a kind of…

shreder
- 11
- 1
1
vote
1 answer
Mongodb geospacial aggregate returns different results using $match vs query
db.units.aggregate([
{
"$geoNear": {
"near": {
"type": "Point",
"coordinates": [ -3.70256, 40.4165 ]
},
"distanceField": "dist.calculated",
"spherical": true,
"maxDistance": 50000
}
},
{
…

Ignasi
- 5,887
- 7
- 45
- 81
1
vote
0 answers
Azure CosmosDB MongoDB Api GeoSpatial queries not working
I have CosmosDB MongoDB-API instance.
Mongo server version = 4.0.0
Inserted documents look like:
{
"_id": "111",
"fileName": "some.txt",
"type": "ONE",
"location": {
"type": "MultiPoint",
"coordinates": [
…

Dmitry D
- 13
- 3
1
vote
1 answer
MongoDB $geoNear Aggregation on another collection
I have a database with two collections like so:
[
{
"name": "Person A",
"location": {"type": "Point", "coordinates": [180, 90]}
},
{
"name": "Person B",
"location": {"type": "Point", "coordinates": [-180, -90]}
}
]
[
{
…

Mochi
- 47
- 1
- 8
1
vote
1 answer
MongoDB $geowithin not acting as expected
I am storing positions into a collection, and based on a bounding box, I would like to retrieve the positions that are within this bounding box.
For small bounding boxes, everything seems to work fine, but for larger bounding boxes, I'm not getting…

Kevin D
- 465
- 5
- 15
1
vote
1 answer
MongoDB and geospatial queries: unknown geo specifier: $geometry: null
i'm experimenting with mongodb and geospatial queries. I made the following collection:
shape> db.shape.find()
[
{
_id: ObjectId("61ab50d2056b5357b5e23e56"),
name: 'Point1',
structure: { type: 'Point', coordinates: [ 2.5, 2.5 ] }
},
…

rekotc
- 595
- 1
- 10
- 21
1
vote
1 answer
MongoDB GeoSpatial Data: Loop is not valid: Edges 8 and 10 cross
I am trying to insert a polygon into a MongoDB DBMS. The polygon is self intersecting in one point. The polygon is the following:
{
"type": "FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" }…

Vitaly Olegovitch
- 3,509
- 6
- 33
- 49
1
vote
1 answer
MongoDB and .netCore Find nearest locations (unable to find index for $geoNear query)
I'm trying to find nearest other locations form my MongoDB database.
I'm using .net Core as rest API.
.net Core 5.0
This is my MDB Class
public class MdbTrip
{
[BsonId]
[BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
…

gamal
- 1,587
- 2
- 21
- 43
1
vote
1 answer
get the document with $box with mongodb and add distance field for each record with specific coordinate point
Case
I have store the location coordinates in MongoDB collection with 2dsphere index. I want to get the records which included into the specific bounds on map. I have one coordinate point which is fixed with latitude and longitude. I have used the…

Jaydipsinh Vaghela
- 115
- 2
- 15
1
vote
1 answer
Can I use other coordinate types to create a 2d index in MongoDB?
I am building a MongoDB database of property data in the Netherlands. I want to be able to perform geospatial queries on my dataset. Each document does not have longitude and latitude coordinates, but something called "Rijksdriehoeks" coordinates.…

Harm van den Brand
- 214
- 1
- 8