我正在尝试对DocumentDB进行空间查询,如下所示:
SELECT * FROM root r WHERE
ST_WITHIN({'type':'Point','coordinates':[-122.02625, 37.4718]}, r.boundingBox)
匹配集合中看起来像这样的文档:
{
"userId": "747941cfb829",
"id": "747941cfb829_1453640096710",
"boundingBox": {
"type": "Polygon",
"coordinates": [
[-122.0263, 37.9718],
[-122.0262, 37.9718],
[-122.0262, 36.9718],
[-122.0263, 36.9718],
[-122.0263, 37.9718]
]
},
"distance": 0,
"duration": 1
}
我已打开空间索引ala https://azure.microsoft.com/en-us/documentation/articles/documentdb-geospatial/,但我没有从DocumentDB获得匹配。
有什么想法吗?
注意:更正了GeoJson坐标顺序。
答案 0 :(得分:2)
GeoJSON多边形的正确规范在坐标周围有一个额外的数组,而不是你所显示的,以便有可能出现空洞和多边形。所以,它看起来像这样:
{
"type": "Polygon",
"coordinates": [
[
[0, 0], [10, 10], [10, 0], [0, 0]
]
]
}