On 3/18/2014 8:32 PM, S. Dale Morrey wrote:
I have a resource constrained system that contains a map and a list of
points on the map given as longitude and latitude.
Each point is it's own seperate object.
I also have a point on the map that corresponds to the user's current
location.

What I want to do is search all of the points in the map and return the one
closest to the user.
The long and lat are both signed doubles (language is Java but the
principles should basically be the same).

What would be the optimal search given that the list of points is contained
in a Vector (array).
I'm thinking something like a loop that goes through each item and compares
the long and lat differences for the smallest differences.  But that seems
to me like a suboptimal solution.
I have access to background threads and I do wonder about maybe 2 threads
doing this, but one counting from the front of the array and another
counting from the back.  At present there are only a couple of hundred
points, but it's possible in the future that the list might balloon to
thousands.

Anyways just hoping someone knows of a better search method.

Fix your data formats? At least if you're going to do this search a lot or need it to be quicker.

-Tod Hansmann

/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to