0
votes

I am trying to get a valid result from the following DocumentDB spatial query.

In both LINQ or SQL -

SELECT * FROM root 
WHERE (ST_Distance(root["Address"]["Location"]["Queryable"], 
{"type": "Point", "coordinates": [-36.******, 174.******]}) < 10000) 

...and/or:

FeedOptions queryOptions = new FeedOptions { MaxItemCount = -1, EnableScanInQuery = true };
IQueryable<Store> documentQuery = client.CreateDocumentQuery<Store>(
UriFactory.CreateDocumentCollectionUri(this.databaseName, this.collection), queryOptions)
.Where(s => s.Address.Location.Queryable.Distance(store.Address.Location.Queryable) < 10000);

...both approaches give me the same result - empty set.

But there are two "Store" documents in the database that should be resolved by this query.

My DB instance is in Australia East - that should be fine apparently.

What am I doing wrong here? My Collection does not have a spatial index on it - is it required?

1
What does root["Address"]["Location"]["Queryable"] look like? - Larry Maccherone
Queryable : {type : Point, coordinates : [ -36.908, 174.123 ] } - Bernard

1 Answers

0
votes

In GeoJSON, points are specified with [longitude, latitude] to make it match with our normal expectations of x being east-west, and y being north-south. Unfortunately, this is the opposite of the traditional way of showing GEO coordinates.

174.xxx is not a valid value for latitude. The range for latitude is -90 to +90. Longitude is specified -180 to +180.

Swap the coordinates and it should work as expected.