空间索引与DocumentDB [英] Spatial Indexes with DocumentDB

查看:225
本文介绍了空间索引与DocumentDB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做对DocumentDB空间查询,看起来像这样:

\r
\r

SELECT * FROM根r其中\r
   ST_WITHIN({'类型':'点','协调':[ - 122.02625,37.4718]},r.boundingBox)

\r

\r
\r

匹配文件看起来像这样的集合:

\r
\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

\r
\r

我打开空间索引ALA https://开头蔚蓝.microsoft.com / EN-US /文档/文章/ documentdb地理空间/ 但我没有从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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆