Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

562
Views
No se pueden extraer claves geográficas, la longitud/latitud está fuera de los límites

Trabajando con MongoDB 2dsphere para almacenar GEOJSON y en ciertas tiendas de lat/lng sigo recibiendo el siguiente error:

 { "code": 16755, "index": 0, "errmsg": "Can't extract geo keys: { _id: ObjectId('586ff135b79aa00b84181bfb'), name: \"Austin\", slug: \"Austin\", description: \"\", twitter: \"\", facebook: \"\", instagram: \"\", author: ObjectId('57b60fed8620b56af460d5c5'), tags: [], created: new Date(1483731253640), location: { address: \"Austin, TX, United States\", coordinates: [ 30.267153, -97.74306079999997 ], type: \"Point\" }, __v: 0 } longitude/latitude is out of bounds, lng: 30.2672 lat: -97.7431", "op": { "name": "Austin", "slug": "Austin", "description": "", "twitter": "", "facebook": "", "instagram": "", "author": "57b60fed8620b56af460d5c5", "_id": "586ff135b79aa00b84181bfb", "tags": [ ], "created": "2017-01-06T19:34:13.640Z", "location": { "address": "Austin, TX, United States", "coordinates": [ 30.267153, -97.74306079999997 ], "type": "Point" }, "__v": 0 } }

Parece que no puedo entender por qué no le gustan algunas coordenadas lat/lng.

Aquí está mi esquema para el campo de ubicación:

 location: { type: { type: String, default: 'Point' }, coordinates: [Number], address: String },

y está indexado como 2dsphere :

storeSchema.index({ location: '2dsphere' });

Lo único extraño que puedo ver es que el mensaje de error:

longitude/latitude is out of bounds, lng: 30.2672 lat: -97.7431",

el lat/lng se acorta de lo que ingresé, no estoy seguro de si eso tiene algo que ver con eso.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Oh, vaya, no estoy seguro de quién decidió esto, pero Mongodb espera que almacene como [lng, lat] , no [lat,lng] como todo lo demás en este mundo.

:|

over 4 years ago · Santiago Trujillo Report

0

Así es como solucioné el problema sin tener que cambiar la secuencia [lat,lng] .

En algún lugar de su código, está haciendo una llamada para ensureIndex . En lugar de llamar (como estaba haciendo anteriormente)...

 collection.ensureIndex({ "location": "2dsphere" });

Utilice lo siguiente en su lugar...

 collection.ensureIndex({ "location.coordinates":"2d"});

Esto eliminó por completo el error en tiempo de ejecución y no se necesitó una refactorización masiva de datos.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!