Matt Douhan
Matt Douhan

Reputation: 733

CosmosDB GeoSpatial Query not returning results

I have a document that has the following properties

"Latitude": 13.7461464,
"Longitude": 100.535355

Now my own coordinates where I am currently are

13.7604
100.5238

I would assume the following query would return the above document but it is not

SELECT c.id
FROM c
WHERE ST_DISTANCE({"type": "Point", "coordinates":[c.Latitude, c.Longitude]}, {"type": "Point", "coordinates":[13.7604, 100.5238]}) > 1

I get no error message just no matching results but for sure the distance is more than 1 meter so why am I not getting a result back?

Upvotes: 0

Views: 94

Answers (1)

NotFound
NotFound

Reputation: 6157

You are using the wrong format for the coordinates. It should be:

{"type": "Point", "coordinates": [lon, lat]}

As found in the RFC7946 specifications. Note the longitude appears before the latitude in the array.

Upvotes: 1

Related Questions