DocumentDB空间查询 - 奇怪的结果

时间:2016-05-12 13:47:06

标签: azure-cosmosdb

我是DocumentDB的新手,我有使用MongoDB的经验。

这是我的简单文件:

 {
"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) 

当我运行此查询时,它返回文档,但该点不在多边形内。有谁知道会发生什么?

由于

1 个答案:

答案 0 :(得分:0)

您以顺时针方式指定了多边形,其本地化被解释为此多边形之外的所有内容。如果将其改为逆时针(如下所示),您将获得预期的结果。

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