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

geo query the area range coordinates, the result set has coordinates that are not within the area

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.4.10
    • Component/s: None
    • Labels:
      None
    • Environment:
      centos7

      mongodb version: rhel70-3.4.10。I have a polygon.

      "loc:2dsphere".
      [[[ 151.53203354373443 , 58.49758352997918 ] ,
      [ 151.53203354373443 , 58.60891434369525] ,
      [ 157.98703167431324 , 58.60891434369525 ] ,
      [ 157.98703167431324 , 58.49758352997918 ],
      [151.53203354373443 , 58.49758352997918]]]
      

      Here's the query:

      db.places.find({
        loc: {
          $geoWithin: {
            $geometry: {
              type: "Polygon",
              coordinates: [
                [
                  [151.53203354373443, 58.49758352997918],
                  [151.53203354373443, 58.60891434369525],
                  [157.98703167431324, 58.60891434369525],
                  [157.98703167431324, 58.49758352997918],
                  [151.53203354373443, 58.49758352997918]
                ]
              ]
            }
          }
        }
      })
      

      There exists coordinates that are beyond the highest latitude, 58.60891434369525. For example:
      [156.1194,58.638217],[156.1194,58.61],[156.51067,58.610183],[155.858483,58.618367],[155.858483,58.618367],[155.859767,58.618867],[153.55,58,616667]. They are not in the query area.


      mongodb版本rhel70-3.4.10。我现在有一个多边形,"loc:2dsphere".
      [[[ 151.53203354373443 , 58.49758352997918 ] ,
      [ 151.53203354373443 , 58.60891434369525] ,
      [ 157.98703167431324 , 58.60891434369525 ] ,
      [ 157.98703167431324 , 58.49758352997918 ],
      [151.53203354373443 , 58.49758352997918]]]
      查询命令如下:

      {{db.places.find( { loc :
      { $geoWithin :
      { $geometry :

      { type : "Polygon", coordinates : [ [ [ 151.53203354373443 , 58.49758352997918 ] , [ 151.53203354373443 , 58.60891434369525] , [ 157.98703167431324 , 58.60891434369525 ] , [ 157.98703167431324 , 58.49758352997918 ], [151.53203354373443 , 58.49758352997918] ] ] }

      } } } )}}

      {{}}

      查询结果中发现有不少坐标点纬度超过了该区域的最大纬度,58.60891434369525。例如:[156.1194,58.638217],[156.1194,58.61],[156.51067,58.610183],[155.858483,58.618367],[155.858483,58.618367],[155.859767,58.618867],[153.55,58,616667]等坐标点不在该区域范围内。{{}}

      {{}}

      {{}}

      {{}}

      {{}}

      {{}}

      {{}}

      {{}}

      {{}}

      {{}}

            Assignee:
            nick.brewer Nick Brewer
            Reporter:
            doe wang wangdejian
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: