Question 1:
I am using Google Datastore (Java Client Libraries) with App Engine Flex and I am storing location data. I would like to query for a list of locations within a rectangular region.
My location entity looks like this:
Location
- lat (eg. -56.1)
- long (eg. 45.6)
Google Datastore has limitations for querying with multiple inequalities on different properties so I can't query using GQL like this:
SELECT * FROM Location WHERE lat <= @maxLat AND lat >= @minLat AND long <= @maxLong AND long >= @minLong
Where maxLat, minLat, maxLong, and minLong represent the bounding rectangle to search for Locations.
Currently I am querying using just one filter:
SELECT * FROM Location WHERE lat <= @maxLat AND lat >= @minLat
And from the returned results, I filter out the ones within the longitude bounds as well. Is there a better way to do this without resorting to this strategy ?
Question 2:
If I store the latitude/longitude combination as a Geopoint in Google Datastore, how can I check the latitude and longitude ?
For example if the location is stored like this:
Location
- location (Geopoint)
I cannot filter on the lat/long within the Geopoint using the Java Client Libraries.
SELECT * FROM Location WHERE location.long <= @maxLong
Is there a workaround for the Datastore Geopoint property ?