DocumentDB Spatial Query - Odd Result

最后都变了- 提交于 2019-12-13 07:26:08

问题


I am fairly new to DocumentDB, I have experience with MongoDB.

This is my simple document:

 {
"id": "747941cfb829_1453640096710",
"geometry": {
  "type": "Polygon",
  "coordinates": [
    [
      [
        0,
        0
      ],
      [
        10,
        10
      ],
      [
        10,
        0
      ],
      [
        0,
        0
      ]
    ]
  ]
},
"name": "name",
"_rid": "Px12AM4QPgBsAAAAAAAAAA==",
"_self": "dbs/Px12AA==/colls/Px12AM4QPgA=/docs/Px12AM4QPgBsAAAAAAAAAA==/",
"_etag": "\"07006019-0000-0000-0000-573395f50000\"",
"_attachments": "attachments/",
"_ts": 1462998499}

And this is my query:

SELECT * FROM root r WHERE   ST_WITHIN({'type':'Point','coordinates':[-122.02625, 37.4718]}, r.geometry) 

When I run this query, it returns the document, but the point is not within the polygon. Does anyone know what could be going on?

Thanks


回答1:


You specified your polygon in a clockwise manner which, localized, is interpreted as everything outside of this polygon. If you alter it to be counter-clockwise (shown below), you'll get the expected results.

{
  "id": "747941cfb829_1453640096710",
  "geometry": {
  "type": "Polygon",
    "coordinates": [
      [
        [
          0, 
          0
        ],
        [
          10,
          0
        ],
        [
          10,
          10
        ],
        [
          0,
          0
        ]
      ]
    ]
  },
  "name": "name"
}


来源:https://stackoverflow.com/questions/37188876/documentdb-spatial-query-odd-result

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