I’m working on an app, where I need to determine which sqlite rows are closest to me given my current lat/long. I have a table with lat and long columns, I’m just having a bit of trouble working out how to get ones that are closest based on my devices current location. Any help would be appreciated.
Share
In this kind of situations you can use the Manhatten Distance. Let’s suppose your current position is:
And, that you have an array with the all the coordinates (
all_stops[]). You just have to go over all items inall_stops[]and calculate the distance tomyPosition, and save the minimum distance this way:Here
the_Latandthe_Longcontain the latitude and longitud you are calculating with.