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

Geo within query requires custom crs to specify the larger of the two areas

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Geo
    • None
    • ALL

      In our Mongo database we have a test polygon defined by the following coordinates:

      0.026856601145655,53.3536401702337 -0.018187415636542,53.3543968971421 -0.016935805565727,53.381347118852 -0.01651815359378,53.3903304943447 -
      0.001490628678547,53.390079813912 -0.001911439808241,53.3810965200027 0.028136611683245,53.3805896527841 0.026856601145655,53.3536401702337

      We then use a within query to see if this polygon lies within a particular area. This one returns the above polygon:

      {{ "PId" : ObjectId("5c1bccda3930321b784dbade"), "GeoPnt" : { "$within" : { "$geometry" :

      { "type" : "Polygon", "coordinates" : [[[-33.353119999999997, -50.140853], [-33.353119999999997, 76.184997999999993], [146.24300500000001, 76.184997999999993], [146.24300500000001, -50.140853], [-33.353119999999997, -50.140853]]] }

      } } }}

      and this one does not:

      {{ "PId" : ObjectId("5c1bccda3930321b784dbade"), "GeoPnt" : { "$within" : { "$geometry" :

      { "type" : "Polygon", "coordinates" : [[[-34.353119999999997, -50.140853], [-34.353119999999997, 76.184997999999993], [146.24300500000001, 76.184997999999993], [146.24300500000001, -50.140853], [-34.353119999999997, -50.140853]]] }

      } } }}

      As you can see the test polygon is well within the polygon defined in both cases.

      I have been reading up about "big polygons" but both of these areas do not cover more than half a hemisphere so I have no idea why both of these queries do not work.

      We are using Mongo 3.6.5 and version 2.4 of the C# driver using the legacy query methods.

        1. firstQuery.png
          firstQuery.png
          297 kB
        2. secondQuery.png
          secondQuery.png
          300 kB

            Assignee:
            kelsey.schubert@mongodb.com Kelsey Schubert
            Reporter:
            ihannah@meniscus.co.uk Ian Hannah
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: