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!

I also having error “Incorrect arguments to st_distance_sphere”. Could you help please?

Hello @FMS_APP!

Could your please provide more details?

Regards,
Alexander

normally result is ok when we do search by below query with distance 4000 M
distanceOnSphere(FATGPS, ‘POINT(96.11611 21.97283)’) <= 4000
But now we are receiving this error if distance is 300 M
distanceOnSphere(FATGPS, ‘POINT(96.11611 21.97283)’) <= 300


It got such error rather than empty result

Thank you, could you please provide your App ID?

Regards,
Alexander

Yes. My App ID is 96A33344-0C65-AC14-FF0D-C71CD4DDCA00
I have two data table called FATDB and FATDBMDY
Issue is only happened in FATDBMDY .Kindly check.
Thanks

@FMS_APP, sorry for inconvenience.

I’ve created an internal ticket BKNDLSS-29212 to investigate this issue, we will let you know as soon as it is done.

Regards,
Alexander

One of the records in the FATDBMDY has wrong lon/lat. That is the cause of the problem.

Please, look e.g. on the point coordinates in FATGPS:
“objectId”: “D0AF570A-E145-464C-A02A-9295709434A2”

Thanks. After fixing this objectId, it works fine now.

Hi @oleg-vyalyh

im facing the same issue.
how can i identify the record with wrong lat/lng ? (i have thousands of records)