Hi,
I see there is now geopoint relationship, which is nice.
My question is, how can I do search in geopoints and received data associated? I need to retrieve data from tabled, but search by geopoint.
hope the question is clear.
Hi,
I see there is now geopoint relationship, which is nice.
My question is, how can I do search in geopoints and received data associated? I need to retrieve data from tabled, but search by geopoint.
hope the question is clear.
Hi Janis.
It is a very good question.
There are several samples for you:
curl -X GET -H 'application-id : <your app id>' -H 'secret-key : <your secret key>'
-X POST -v "http://api.backendless.com/v1/data/table" -d '{"relation":{"___class":"GeoPoint","latitude":38.53,"longitude":77.01}}'
curl -X GET -H 'application-id : <your app id>' -H 'secret-key : <your secret key>' https://api.backendless.com/v1/data/table?where=relation.categories='Default' OR relation.latitude='1'
Encoded query looks like this:
curl -X GET -H 'application-id : <your app id>' -H 'secret-key : <your secret key>' https://api.backendless.com/v1/data/table?where=relation.categories%3D'Default'%20OR%20relation.latitude%3D'1'
In “whereClause” you can run search by metadata, latitude, longitude, categories…
Regards,
Kate.
There are samples for search by radius:
-H application-id:application-id-value-from-console
-H secret-key:secret-key-value-from-console
-H Content-Type:"application/json"
-H application-type:REST
-X POST
-v "[url=http://api.backendless.com/v1/data/Person]http://api.backendless.com/v1/data/Person"[/url];
-d '{"name":"Bob", "age":33, "phoneNumber":"512-555-1212", "coordinates": {"___class":"GeoPoint","latitude":30.26715,"longitude":-97.74306,"categories":["Home"],"metadata":{"description":"Bob's home"}}}'
two:
-H application-id:application-id-value-from-console
-H secret-key:secret-key-value-from-console
-H Content-Type:"application/json"
-H application-type:REST
-X POST
-v "[url=http://api.backendless.com/v1/data/Person]http://api.backendless.com/v1/data/Person"[/url];
-d '{"name":"Jane", "age":28, "phoneNumber":"281-555-1212", "coordinates": {"___class":"GeoPoint","latitude":29.76328,"longitude":-95.36327,"categories":["Home"],"metadata":{"description":"Jane's home"}}}'
distance( 30.26715, -97.74306, coordinates.latitude, coordinates.longitude ) < mi(200)
The semantic of the “distance” function is:
distance(
center point latitude,
center point longitude,
columnname which contains geo point.latitude,
columnname which contains geo point.longitude ) “comparison operator” units-function(value)
where
The request returns all data objects for which the “coordinates” column contains a geo point within the distance identified by the “distance” function:
-H application-id:application-id-value-from-console
-H secret-key:secret-key-value-from-console
-H Content-Type:"application/json"
-H application-type:REST
-X GET
-v "[url=http://api.backendless.com/v1/data/Person?where=distance(%2030.26715%2C%20-97.74306%2C%20coordinates.latitude%2C%20coordinates.longitude%20)%20%3C%20mi(200)]http://api.backendless.com/v1/data/Person?where=distance(%2030.26715%2C%20-97.74306%2C%20coordinates.latitude%2C%20coordinates.longitude%20)%20%3C%20mi(200)"[/url];
thsnks will do this way