Spatial Indexes with DocumentDB

北城以北 提交于 2020-01-25 01:49:20

问题


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.


回答1:


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]
    ]
  ]
}


来源:https://stackoverflow.com/questions/36511736/spatial-indexes-with-documentdb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!