Support Topics Documentation Slack YouTube Blog

Very simple distance query doesn't work

Backendless Version (3.x / 5.x, Online / Managed / Pro )

Managed

Client SDK (REST / Android / Objective-C / Swift / JS )

REST

Application ID

1D7F04AC-FD45-0ED7-FF19-2CFC91948C00

Expected Behavior

  1. Create a table names ‘Post’ and add a Non-nullable POINT type column ‘location’
  2. Add a data with a value for the column location POINT (35.7847337 129.4718646).
  3. In the ‘REST Console’ tab, click ‘GET’ button with following where clause ‘distance(35.7723197,129.4849648,location.latitude,location.longitude) < km(2)’
  4. get the only data in Post table.

Actual Behavior

1.~3. same
4. Get JSON Object
{
“code”: 1054,
“message”: “Column ‘latitude’ does not exist in table ‘Post’”
}

Hi, @Hyungil_Kang

Please, take a look at these docs:
https://backendless.com/docs/rest/data_spatial_retrieval_api.html

Your request should look like this one:
distanceOnSphere('POINT(129.47186459999998 35.78473370000001)', point) < km(2)

Regards,
Marina

Thank you for the answer but it returns following JSON Object
{
“code”: 1210,
“message”: “Incorrect arguments to st_distance_sphere”
}
Could you help me about this more?

You have incorrect data. Longitude should be entered first and then Latitude.
Your object should be: POINT (129.4718646 35.7847337) which as I see is in a South Korea.
Ger request should be like:
distanceOnSphere('POINT(129.4718646 35.7847337)', location) < km(2)

I recommend going through Backendless Missions to get the knowledge of Backendless APIs and database functionality first. Have you looked into it yet?

Regards,
Marina

OMG yeah I missed it so blindly. Thank you so much! But could you tell me why I can’t apply the method in ‘search by distance’ section?

Hi Hyungil,

What “search by distance” section are you referring to?

Regards,
Mark

Search by distance - Backendless REST API Documentation I was talking about this.

That functionality is deprecated. We will remove it from the docs.

Yeah that’s why it didn’t work at all. Thank you very much!