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

$geoIntersects does not return polygon with shared edge

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: Geo
    • Labels:
      None
    • Operating System:
      ALL
    • Case:

      Description

      db.polygon.drop();
      db.polygon.insert([ { "_id" : "Poly1", "shape" : { "type" : "Polygon", "coordinates" : [ [ [0.0000, 0.000],[3.000,0.000],[3.000,3.000],[0.000,3.000], [0.0000, 0.000]]]}},
      ... { "_id" : "Poly2", "shape" : { "type" : "Polygon", "coordinates" : [ [ [3.00,0.00],[6.00,0.00],[6.00,3.00],[3.00,3.00],[3.00,0.00] ] ] } } ]);
      db.polygon.ensureIndex({shape:"2dsphere"});
      var box={"type" : "Polygon", "coordinates" : [ [ [ 0.000, 0.0000 ], [ 3.0000, 0.0000 ], [ 3.000, 3.000 ], [ 0.000, 3.000 ], [ 0.000, 0.0000 ] ] ] }
      db.polygon.find( {shape: {$geoIntersects: {$geometry: box}}}, {_id:1})
      { "_id" : "Poly1" }
      

      Poly2 and box share two adjacent points [ 3.0000, 0.0000 ] and [ 3.000, 3.000 ] so Poly2 should be returned, but it's not.

      Analogously, using box of points from Poly2 will only match Poly2 and not Poly1.

      Our docs say: A location intersects a GeoJSON object if the intersection is non-empty. This includes documents that have a shared edge.

      This happens in 2.4 (v1) and 2.6(v2). It happens with line/polygon and polygon/polygon intersections.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                4 Vote for this issue
                Watchers:
                14 Start watching this issue

                Dates

                • Created:
                  Updated: