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

$geoIntersects query fails when a polygon around (0,0) is queried

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 3.2.9
    • Component/s: Geo
    • None
    • ALL
    • Hide

      Run a $geoIntersects query with a polygon circling around (0,0)

      Show
      Run a $geoIntersects query with a polygon circling around (0,0)

      Running the following query on a 2dsphere index:

      { "tags.name" : { "$exists" : true} , "loc" : { "$geoIntersects" : { "$geometry" : { "type" : "Polygon" , "coordinates" : [ [ [ 1.7834514204456963E-4 , 6.102440130139471E-7] , [ 1.7488909954756064E-4 , 3.570003235196329E-5] , [ 1.646537858315228E-4 , 6.944133980362683E-5] , [ 1.4803253826253338E-4 , 1.0053750684498035E-4] , [ 1.256641020633656E-4 , 1.27793525215556E-4] , [ 9.840808369278992E-5 , 1.5016196141472382E-4] , [ 6.73119166514364E-5 , 1.6678320898371325E-4] , [ 3.3570609199772854E-5 , 1.7701852269975108E-4] , [ -1.5191791391765005E-6 , 1.8047456519676007E-4] , [ -3.660896747812585E-5 , 1.7701852269975108E-4] , [ -7.03502749297894E-5 , 1.6678320898371325E-4] , [ -1.0144644197114289E-4 , 1.5016196141472385E-4] , [ -1.287024603417186E-4 , 1.2779352521555604E-4] , [ -1.510708965408864E-4 , 1.0053750684498035E-4] , [ -1.6769214410987583E-4 , 6.944133980362686E-5] , [ -1.7792745782591366E-4 , 3.570003235196336E-5] , [ -1.8138350032292265E-4 , 6.102440130139692E-7] , [ -1.7792745782591366E-4 , -3.447954432593542E-5] , [ -1.6769214410987585E-4 , -6.822085177759893E-5] , [ -1.5107089654088643E-4 , -9.931701881895242E-5] , [ -1.2870246034171862E-4 , -1.265730371895281E-4] , [ -1.0144644197114293E-4 , -1.489414733886959E-4] , [ -7.035027492978951E-5 , -1.655627209576853E-4] , [ -3.660896747812594E-5 , -1.7579803467372316E-4] , [ -1.5191791391765446E-6 , -1.7925407717073215E-4] , [ 3.357060919977285E-5 , -1.7579803467372316E-4] , [ 6.731191665143643E-5 , -1.655627209576853E-4] , [ 9.840808369278984E-5 , -1.4894147338869593E-4] , [ 1.2566410206336554E-4 , -1.2657303718952815E-4] , [ 1.4803253826253338E-4 , -9.931701881895246E-5] , [ 1.6465378583152275E-4 , -6.822085177759905E-5] , [ 1.7488909954756064E-4 , -3.447954432593549E-5] , [ 1.7834514204456963E-4 , 6.102440130139031E-7]]]}}} , "valid" : true}
      

      on a table with the index:

        {
                      "v" : 1,
                      "key" : {
                              "valid" : 1,
                              "loc" : "2dsphere"
                      },
                      "name" : "valid_1_loc_2dsphere",
                      "ns" : "osm.osm_ways",
                      "background" : true,
                      "2dsphereIndexVersion" : 3
              }
      

      Results in the following error:

      com.mongodb.MongoException: Can't canonicalize query: BadValue: Loop is not closed: [ [ 0.0001783451420445696, 6.102440130139471e-07 ], [ 0.0001748890995475606, 3.570003235196329e-05 ], [ 0.0001646537858315228, 6.944133980362683e-05 ], [ 0.0001480325382625334, 0.0001005375068449803 ], [ 0.0001256641020633656, 0.000127793525215556 ], [ 9.840808369278992e-05, 0.0001501619614147238 ], [ 6.73119166514364e-05, 0.0001667832089837132 ], [ 3.357060919977285e-05, 0.0001770185226997511 ], [ -1.519179139176501e-06, 0.0001804745651967601 ], [ -3.660896747812585e-05, 0.0001770185226997511 ], [ -7.03502749297894e-05, 0.0001667832089837132 ], [ -0.0001014464419711429, 0.0001501619614147238 ], [ -0.0001287024603417186, 0.000127793525215556 ], [ -0.0001510708965408864, 0.0001005375068449803 ], [ -0.0001676921441098758, 6.944133980362686e-05 ], [ -0.0001779274578259137, 3.570003235196336e-05 ], [ -0.0001813835003229227, 6.102440130139692e-07 ], [ -0.0001779274578259137, -3.447954432593542e-05 ], [ -0.0001676921441098759, -6.822085177759893e-05 ], [ -0.0001510708965408864, -9.931701881895242e-05 ], [ -0.0001287024603417186, -0.0001265730371895281 ], [ -0.0001014464419711429, -0.0001489414733886959 ], [ -7.035027492978951e-05, -0.0001655627209576853 ], [ -3.660896747812594e-05, -0.0001757980346737232 ], [ -1.519179139176545e-06, -0.0001792540771707322 ], [ 3.357060919977285e-05, -0.0001757980346737232 ], [ 6.731191665143643e-05, -0.0001655627209576853 ], [ 9.840808369278984e-05, -0.0001489414733886959 ], [ 0.0001256641020633655, -0.0001265730371895281 ], [ 0.0001480325382625334, -9.931701881895246e-05 ], [ 0.0001646537858315227, -6.822085177759905e-05 ], [ 0.0001748890995475606, -3.447954432593549e-05 ], [ 0.0001783451420445696, 6.102440130139031e-07 ] ]
      

      I have double checked, the polygon is closed, but what's special about it is that it's exactly around (0,0), so that both the latitude and longitude change signs. I'm guessing this is the cause for the bug.

            Assignee:
            kelsey.schubert@mongodb.com Kelsey Schubert
            Reporter:
            zoharby Zohar Bar-Yehuda
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: