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

geoWithin: Data not being returned for points in bounds

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • ALL
    • Hide

      Create sample data

      db.geo_json_test.insertMany([{name: "001A", location: {type: "Point", coordinates: [-58.4473758, -34.5763659],{name: "001B", location: {type: "Point", coordinates: [-58.4473606, -34.5763057]}},{name: "001C", location: {type: "Point", coordinates: [-58.4473746, -34.5763513]}},{name: "001D", location: {type: "Point", coordinates: [-58.4474213, -34.5763618]}}])}}

       

      Query returning all points

      db.geo_json_test.find({'$and': [{'location': {'$geoWithin': {'$geometry': {'type': 'Polygon', 'coordinates': [[[23,0],[-133,0],[-133,-36],[23,-36],[23,0]]]}}]})}}

       

      Query not returning any point

      db.geo_json_test.find({'$and': [{'location': {'$geoWithin': {'$geometry': {'type': 'Polygon', 'coordinates': [[[26,-12],[-126,-12],[-126,-42],[26,-42],[26,-12]]]}}]})}}

      Show
      Create sample data db.geo_json_test.insertMany([{name: "001A", location: {type: "Point", coordinates: [-58.4473758, -34.5763659] ,{name: "001B", location: {type: "Point", coordinates: [-58.4473606, -34.5763057] }},{name: "001C", location: {type: "Point", coordinates: [-58.4473746, -34.5763513] }},{name: "001D", location: {type: "Point", coordinates: [-58.4474213, -34.5763618] }}])}}   Query returning all points db.geo_json_test.find({'$and': [{'location': {'$geoWithin': {'$geometry': {'type': 'Polygon', 'coordinates': [[ [23,0] , [-133,0] , [-133,-36] , [23,-36] , [23,0] ]] }}]})}}   Query not returning any point db.geo_json_test.find({'$and': [{'location': {'$geoWithin': {'$geometry': {'type': 'Polygon', 'coordinates': [[ [26,-12] , [-126,-12] , [-126,-42] , [26,-42] , [26,-12] ]] }}]})}}

      I have the data attached in this ticket. Corresponding queries are also attached in Steps to reproduce.  

      geoWithin query doesn't return data even when the bounds seem to enclose the data. Can you please help. This is being used in an application where the map bounds are being used to get data from MongoDB. However, the behavior is not deterministic.

      Server version: 6.0.8 Community

       

            Assignee:
            Unassigned Unassigned
            Reporter:
            khalidbashirbajwa@gmail.com Khalid Bashir Bajwa
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: