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

$geoIntersects does not return polygon with shared edge

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Geo
    • Query Integration
    • ALL

      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.

            Assignee:
            backlog-query-integration [DO NOT USE] Backlog - Query Integration
            Reporter:
            asya.kamsky@mongodb.com Asya Kamsky
            Votes:
            3 Vote for this issue
            Watchers:
            15 Start watching this issue

              Created:
              Updated: