What is an effective way to calculate the nearest point?

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?

+3
source share
3 answers

From what I can assemble, it seems that the best approach in this case is to return an array of points using the bounding box around the current location.

, , . , .

+2

Core Data, , Quadtree

+2

, , , , . , , , , :)

NNS , " ". , , O (Nd)

(LSH) "" .

+1

Source: https://habr.com/ru/post/1736451/


All Articles