2017-03-13 12 views
1

mongoDBクエリを実行すると「経度/緯度が範囲外です」というエラーが表示されます。ここでmongodbエラー: '経度/緯度が範囲外です

は私のクエリが作成されている。ここで

DBObject query = new BasicDBObject("loc", 
      new BasicDBObject("$geoWithin", 
        new BasicDBObject("$geometry", 
          new BasicDBObject("type","Polygon").append("coordinates", polygon)))); 

は私のMongoDBのクエリです:

db.collection_name.find(
    { "loc" : 
     { "$geoWithin" : 
      { "$geometry" : 
       { "type" : "Polygon" , "coordinates" : [ [ [ 44.67047 , 136.01075] , [ 77.05318 , 33.59619] , [ 13.04135 , -22.31323]]] 

       } 
      } 
     } 
    } 
) 

私は、このエラー出力を得る:

{ 
"code" : { 
    "_bsontype" : "Int32", 
    "value" : 2 
}, 
"codeName" : "BadValue", 
"errmsg" : "longitude/latitude is out of bounds, lng: 44.6705 lat: 136.011", 
"message" : "longitude/latitude is out of bounds, lng: 44.6705 lat: 136.011", 
"name" : "MongoError", 
"ok" : { 
    "_bsontype" : "Double", 
    "value" : 0 
}, 

どのように私はこの問題を解決することができます?あなたの答えをありがとう。

+0

これらは無効な座標です。エラーが示唆している正しい座標を使用してください。私は緯度を長く混ぜないことを願っています。緯度と経度の値を切り替えてみてください。 – Veeram

+0

@Veeram私が好きなときには、同じエラーが出ます。 – hisoka

+0

'db.collection_name.find( {" loc ": {" $ geoWithin ": {" $ geometry ": {" type ":" coordinates ":" coordinate "を使用すると同じエラーが発生します: [136.01075、44.67047]、[77.05318、33.59619]、[13.04135、-22.31323]]] }}} }) '? – Veeram

答えて

1

"longitude/latitude is out of bounds, lng: 44.6705 lat: 136.011"

緯度から緯度の順に指定する必要があります。緯度の有効範囲は、-90+90です。緯度の値が136.011の範囲外です。

"Loop is not closed"

あなたは、多角形の形状を作成するためにGeoJSON Polygonループを閉じる必要があり$geometryのための地理空間クエリを指定します。例えば

:最初と最後の座標をポリゴンの形状を閉じるために、一致していることを

{ 
    type: "Polygon", 
    coordinates: [ [ [ 0 , 0 ] , [ 3 , 6 ] , [ 6 , 1 ] , [ 0 , 0 ] ] ] 
} 

注意。

上記はあなたがGeoJSON polygons with a single ringを参照していることを前提としています。

関連する問題