I have a table called "pois", I want to run sql query which will show all locations nearest to the phone gps location in 500 m, I copied the mysql code somewhere and used it for sqlite and it does not work, maybe anyone can help me to translate the red highlighted query to sqlite query version ?
Thank you
the code is as follows :
Sub GPS_LocationChanged (Location1 As Location)
Loc1 = Location1.Latitude
Loc2 = Location1.Longitude
Dim Cursor As Cursor
Qry = "Select place_id,place_name,lat,lon,poi_catid, ( 6371 * acos( cos( radians( " & Loc1 & " ) ) * cos( radians( lat ) ) * cos( radians( lon ) - radians( " & Loc2 & ") ) + sin( radians( " & Loc1 & " ) ) * sin( radians( lat ) ) ) ) as distance FROM pois HAVING distance < 0.5 ORDER BY distance"
Cursor = SQL1.ExecQuery(Qry)
For i = 0 To 15
Cursor.Position = i
ToastMessageShow(Cursor.GetString("place_name"),True)
Next
Cursor.Close
End Sub
=======================================
Error message says :
android.database.sqlite.SQLiteException: no such function: acos (code 1):
Thank you
the code is as follows :
Sub GPS_LocationChanged (Location1 As Location)
Loc1 = Location1.Latitude
Loc2 = Location1.Longitude
Dim Cursor As Cursor
Qry = "Select place_id,place_name,lat,lon,poi_catid, ( 6371 * acos( cos( radians( " & Loc1 & " ) ) * cos( radians( lat ) ) * cos( radians( lon ) - radians( " & Loc2 & ") ) + sin( radians( " & Loc1 & " ) ) * sin( radians( lat ) ) ) ) as distance FROM pois HAVING distance < 0.5 ORDER BY distance"
Cursor = SQL1.ExecQuery(Qry)
For i = 0 To 15
Cursor.Position = i
ToastMessageShow(Cursor.GetString("place_name"),True)
Next
Cursor.Close
End Sub
=======================================
Error message says :
android.database.sqlite.SQLiteException: no such function: acos (code 1):