2016-05-12 2 views
0

我對DocumentDB相當新,我有MongoDB的經驗。DocumentDB空間查詢 - 奇數結果

這是我簡單的文檔:

{ 
"id": "747941cfb829_1453640096710", 
"geometry": { 
    "type": "Polygon", 
    "coordinates": [ 
    [ 
     [ 
     0, 
     0 
     ], 
     [ 
     10, 
     10 
     ], 
     [ 
     10, 
     0 
     ], 
     [ 
     0, 
     0 
     ] 
    ] 
    ] 
}, 
"name": "name", 
"_rid": "Px12AM4QPgBsAAAAAAAAAA==", 
"_self": "dbs/Px12AA==/colls/Px12AM4QPgA=/docs/Px12AM4QPgBsAAAAAAAAAA==/", 
"_etag": "\"07006019-0000-0000-0000-573395f50000\"", 
"_attachments": "attachments/", 
"_ts": 1462998499} 

這是我的查詢:

SELECT * FROM root r WHERE ST_WITHIN({'type':'Point','coordinates':[-122.02625, 37.4718]}, r.geometry) 

當我運行此查詢,它返回文檔,但問題是沒有多邊形內。有誰知道會發生什麼事?

感謝

回答

0

您指定的多邊形中,局部的,被解釋爲這一切多邊形的外順時針的方式。如果您將其改爲逆時針(如下所示),您將獲得預期結果。

{ 
    "id": "747941cfb829_1453640096710", 
    "geometry": { 
    "type": "Polygon", 
    "coordinates": [ 
     [ 
     [ 
      0, 
      0 
     ], 
     [ 
      10, 
      0 
     ], 
     [ 
      10, 
      10 
     ], 
     [ 
      0, 
      0 
     ] 
     ] 
    ] 
    }, 
    "name": "name" 
} 
+0

這確實奏效,謝謝! –