Index that supports queries that calculate geometries on an earth-like sphere. It supports data stored as both GeoJSON objects and as legacy coordinate pairs.
Questions tagged [2dsphere]
69 questions
1
vote
2 answers
Mongoose setDefaultsOnInsert and 2dsphere index not working
I am having trouble trying to insert a new user in my database when using findOneAndUpdate with upsert and setDefaultsOnInsert set to true. What I am trying to do is to set the default values of the following schema:
var userSchema = new…

Jdruwe
- 3,450
- 6
- 36
- 57
1
vote
1 answer
Meteor - Update Collection with location object (in GeoJSON format)
Here is my schema (simple schema):
officelocation: {
type: String,
label: 'Location of Office',
autoform: {
type: 'map',
afFieldInput: {
type: 'map',
geolocation: true,
searchBox: true,
autolocate: true
}
}
},
location: {
…

Abhishek Sunku
- 41
- 2
- 8
1
vote
0 answers
MongoDB and nodeJS: high latency time using 2dsphere index
i am working on a nodeJS application with mongoDB and i am trying to get all users next to the current user...
my real problem is that my application works quiet well when my query is based on a "2d" index ( i got about 25000 responses in 1 min )…

Antonin
- 11
- 2
1
vote
0 answers
MongoDb $near and query
I have a collection of documents in structure as below
{ _id: ObjectId("54723e44ec73a702fc979fc9"),
Start: { type: "Point", coordinates: [ -0.15261409999993703, 51.4428311 ] },
End: { type: "Point", coordinates: [ -0.1258020000000215,…

peter pan
- 281
- 4
- 14
1
vote
2 answers
MongoDB version 2.6 still fails on 2dsphere geoindexing citing inability to extract geokeys and possible malformed geometry
I had been getting the referenced error under version 2.4 with a different lon/lat data set. I upgraded to 2.6 and was able to use 2dsphere index on that data set. However, with a different data set (excerpt below) I received the old error message…

ELamar
- 114
- 11
1
vote
1 answer
Exterior Shell of polygon is invalid - 2dSphere Polygon
Question, trying to index and getting the following error:
"Exterior shell of polygon is invalid"
However, I've tested the JSON on http://geojsonlint.com/ and it works
Here's my JSON
{
"type": "Polygon",
"coordinates": [
[
…

ist_lion
- 3,149
- 9
- 43
- 73
1
vote
2 answers
how to create a 2dsphere index via C# driver
i am trying to do sth like this
db.points.ensureIndex( { : "2dsphere" } )
http://docs.mongodb.org/manual/core/2dsphere/
via C# driver. but the API looks like only take the "key" as parameter, no way to specify the…

jojo
- 13,583
- 35
- 90
- 123
0
votes
1 answer
Define a Mongoose Schema index (2dsphere) on an optional parameter
I have an user model, which can be of two types : postulant and recruiter.
I want the postulants to have a geolocation field, but not the recruiter, and I have to make them in a single Model.
There's a part of my model :
const schema = new…

Shiroe
- 497
- 1
- 4
- 9
0
votes
0 answers
Cannot resolve overloaded method
in Query for Locations Near a GeoJSON Point
val refPoint = Point(Position(-73.9667, 40.78))
collection.find(Filters.near("geo.coordinates", refPoint, 5000.0, 1000.0)).printResults()
I have these errors:
-Cannot resolve overloaded method…

my user
- 1
- 1
0
votes
2 answers
how to retrieve an entity containing 2dsphere index from mongo database
the index created in mongo database
Field in the entity
@Indexed(name = "2dsphere")
private Point location;
This field in mongo db
"location":
{ "type": "Point",
"coordinates":
[ …

halil baydar
- 11
- 3
0
votes
1 answer
How to limit mongodb $near to coordinates polygon or sort $geowithin results by distance
I am designing a cab booking service using MongoDB. My schema looks like -
{
"_id": {
"$oid": "621ca96e2c7e7efcfba6ce34"
},
"registration_id": "Id1",
"location": [{
"$numberDouble": "13.197827893722762"
}, {
…

user3474393
- 33
- 4
0
votes
1 answer
How do I create a MongoDB 2dsphere index on a document containing an array of arrays of coordinates?
I am trying to build an index in MongoDB for a LineString object that has an array called coordinates that contains two or more arrays of coordinate pairs.
When I run db.infrastructure.createIndex({ "geometry.coordinates": "2dsphere" }) I get the…

bkleeman
- 109
- 1
- 14
0
votes
0 answers
Issue with geo index in mongoAtlas
I´ve migrating my last mLab application with heroku to the new MongoAtlas platform. I found some issues when trying to create geo indexes for my collections.
Here is how I used to integrate the index in the mLab tool:
db.OpenDataMadrid.createIndex(…
0
votes
0 answers
Mongoose 2dsphere not created and manual indexing works partially
I'm new to MongoDB and Mongoose. I'm trying to create a user model with location field indexed.
const userSchema = new mongoose.Schema({
/*...*/
location: {
type: { type: String },
coordinates: [Number],
},
…

Saravanan Sampathkumar
- 3,201
- 1
- 20
- 46
0
votes
1 answer
Unable to find index for $geoNear query, code: 2, code-name: 'badValue'
This is my Schema
const UserSchema = new Schema({
name: {
type: String,
required: true
},
email: {
type: String,
required: true
},
password: {
type: String,
required: true
…

Jai Parakh
- 5
- 5