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

$geoWithin with $centerSphere does not find GeoJSON documents other than Points

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.6.0-rc0
    • Affects Version/s: 3.4.0
    • Component/s: Geo, Querying
    • None
    • Fully Compatible
    • ALL
    • v3.4
    • Query 2017-11-13

      Compare:

      > db.poiConcat.find( { ty: 1, l: { $geoWithin: { $centerSphere: [ [ -80.1745962, 26.148911 ], 50000000 ] } } } ).limit(1);
      { "_id" : "n99364450", "ty" : NumberLong(1), "l" : { "type" : "Point", "coordinates" : [ -80.3810378, 25.5883277 ] }, "ts" : [ "amenity=parking" ], "m" : { "v" : NumberLong(4), "cs" : NumberLong(18737061), "uid" : NumberLong(1795637), "ts" : NumberLong(1383685090) } }
      
      > db.poiConcat.find( { ty: 2, l: { $geoWithin: { $centerSphere: [ [ -80.1745962, 26.148911 ], 500000 ] } } } ).limit(1);
      

      With a distance of 500km, it should certainly find documents. The range below (1 degree) is much less (about 100km):

      > > db.poiConcat.find( { ty: 2, l: { $geoWithin: { $geometry : { type: 'Polygon', coordinates : [ [ [ -80.1745962, 26.148911 ], [ -79, 26 ], [ -79, 25 ], [ -80, 25 ], [ -80.1745962, 26.148911 ] ] ] } } } } ).limit(1);
      
      { "_id" : "w414476448", "ty" : NumberLong(2), "l" : { "type" : "Polygon", "coordinates" : [ [ [ -80.1091137, 26.0908518 ], [ -80.1090739, 26.0907767 ], [ -80.1092148, 26.0907164 ], [ -80.1092547, 26.0907915 ], [ -80.1091137, 26.0908518 ] ] ] }, "ts" : [ "name=Jetty Pavilion", "amenity=shelter", "building=yes" ], "m" : { "v" : NumberLong(1), "cs" : NumberLong(38985825), "uid" : NumberLong(684651), "ts" : NumberLong(1461953735) } }
      

            Assignee:
            wan.bachtiar@mongodb.com Wan Bachtiar
            Reporter:
            derick Derick Rethans
            Votes:
            2 Vote for this issue
            Watchers:
            16 Start watching this issue

              Created:
              Updated:
              Resolved: