Reputation: 59
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
Upvotes: 0
Views: 127
Reputation: 9523
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"
}
Upvotes: 0