Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-19328

$geoIntersects does not work as expected

    • Type: Icon: Question Question
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Geo
    • None

      Collection content:
      db.geotest.insert({
      "geometry" :

      { "type" : "Polygon", "coordinates" : [[[80,50],[90,50],[90,40],[80,40],[80,50]]] }

      })

      The following query does not return anything (the searched shape is totally within the polygon):
      db.geotest.find({
      "geometry":{"$geoIntersects":{"$geometry":{"type":"Polygon",
      "coordinates":[[[10,60],[160,60],[160,20],[10,20],[10,60]]]
      }}}});

      But when we shrink the polygon just a little (160->150, the shape is still inside), we get the expected result:
      db.geotest.find({
      "geometry":{"$geoIntersects":{"$geometry":{"type":"Polygon",
      "coordinates":[[[10,60],[150,60],[150,20],[10,20],[10,60]]]
      }}}});

      I chose the values to be round and nice, but this appeared many times for the others and I did not find any pattern. I tested it on 3 different mongodb versions: 3.0.4, 2.6.5 and 2.6.9. I tested also with changing points order and custom crs. This example works with setting crs to "urn:x-mongodb:crs:strictwinding:EPSG:4326", but I can find also other examples that failed.

      My case is filtering the polygons of countries borders by the visible area and on large polygons (but much smaller than half of the sphere) couple of countries was always missing in the result.

      I have no idea if I do sth wrong or this is a bug.

        1. plot-server-19328.png
          1.26 MB
          Sam Kleinman

            Assignee:
            sam.kleinman Sam Kleinman (Inactive)
            Reporter:
            mjaworsk Mateusz Jaworski
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: