I have location data objects stored in Core Data, I would like to be able to retrieve and display only the closest point to the current location. I know that there are formulas that will calculate the distance from the current lat / long to the stored lat / long, but I am wondering how best to do this for a set of 1000+ points stored in Core Data. I know that I can just return the points from Core Data to an array, and then execute a loop that searches for the minimum value for the distance between the points, but I would suggest that there is a more efficient method, possibly using Core Data in some way.
Any insight would be appreciated.
EDIT: I don’t know how I missed this in my initial search, but this SO question suggests simply iterating through an array of Core Data objects, but limiting the size of the array with a bounding box based on the current location. Is this the best I can do?
source
share