首页 文章

DocumentDB的空间索引

提问于
浏览
1

我正在尝试对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坐标顺序 .

1 回答

  • 2

    GeoJSON多边形的正确规范在坐标周围有一个额外的数组,而不是您显示的空间和多边形的可能性 . 所以,它看起来像这样:

    {
      "type": "Polygon",
      "coordinates": [
        [
          [0, 0], [10, 10], [10, 0], [0, 0]
        ]
      ]
    }
    

相关问题