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

300
Views
$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 answers
Answer question

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 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!