问题描述
我试图做对DocumentDB空间查询,看起来像这样:
SELECT * FROM根r其中\r
ST_WITHIN({'类型':'点','协调':[ - 122.02625,37.4718]},r.boundingBox)
\r
匹配文件看起来像这样的集合:
{\r
用户id:747941cfb829\r
ID:747941cfb829_1453640096710\r
boundingBox的:{\r
类型:多边形,\r
坐标:[\r
[-122.0263,37.9718]\r
[-122.0262,37.9718]\r
[-122.0262,36.9718]\r
[-122.0263,36.9718]\r
[-122.0263,37.9718]\r
]\r
},\r
距离:0,\r
持续时间:1\r
}
\r
我打开空间索引ALA 但我没有从DocumentDB得到一个比赛了。
任何想法?
请注意:更正以GeoJSON坐标顺序
。一个以GeoJSON多边形的正确规格有绕坐标其它阵列比你展示允许孔和multipolygons的可能性。因此,它应该是这样的:
{
类型:多边形,
坐标:[
[
[0,0],[10,10],[10,0],[0,0]
]
]
}
I’m trying to do a spatial query against DocumentDB that looks like this:
SELECT * FROM root r WHERE
ST_WITHIN({'type':'Point','coordinates':[-122.02625, 37.4718]}, r.boundingBox)
to match a document that looks like this in the collection:
{
"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
}
I’ve turned on spatial indexes ala https://azure.microsoft.com/en-us/documentation/articles/documentdb-geospatial/ but I’m not getting a match back from DocumentDB.
Any ideas?
NOTE: Corrected GeoJson coordinate order.
The correct specification of a GeoJSON polygon has an additional array around the coordinates than you show to allow for the possibility of holes and multipolygons. So, it would look like this:
{
"type": "Polygon",
"coordinates": [
[
[0, 0], [10, 10], [10, 0], [0, 0]
]
]
}
这篇关于空间索引与DocumentDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!