Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

299
Vistas
$geoIntersects returns no results

I am querying a polygon, to check if a point is inside of it or not, but no results are returned. I am in the mongo shell: (MongoDB shell version: 3.2.6)

db.restPolygons.find();
{
  "_id" : ObjectId("586e663175c32828be59e3a9"),
  "zoneCoordinates" : {
    "type" : "Polygon",
    "coordinates" : [
      [ 2, 0 ],
      [ 6, 0 ],
      [ 6, 2 ],
      [ 2, 2 ],
      [ 2, 0 ]
    ]
  }
}

db.restPolygons.find({
  "zoneCoordinates": {
    "$geoIntersects": {
      "$geometry": {
        "type": "Point",
        "coordinates": [3 ,1]
      }
    }
  }
}).count();
    0
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Your polygon is invalid, it's missing a level of enclosing array in the coordinates field. This one should work:

> db.geo.find()
{
    "_id": ObjectId("586e663175c32828be59e3a9"),
    "zoneCoordinates": {
        "type": "Polygon",
        "coordinates": [
            [
                [2, 0],
                [6, 0],
                [6, 2],
                [2, 2],
                [2, 0]
            ]
        ]
    }
}

> db.geo.find({
    "zoneCoordinates": {
      "$geoIntersects": {
        "$geometry": {
          "type": "Point",
          "coordinates": [3 ,1]
        }
      }
    }
  }).count()
1

You can check the validity of your GeoJSON object in GeoJSONList

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda