Optimum search with geospatial coordinates

Grant Shipley gshipley at gmail.com
Tue Mar 18 20:43:10 MDT 2014

Just to clarify my last statement as I don't know if you aware that
database have spatial capabilities by default.  In fact, I just finished
writing a chapter for an upcoming book that includes an example of pretty
much what you are trying to do using mongodb 2.4 by enabling a 2d spacial
index.  I can send you the relevant parts of the chapter if you want to
review the code that is written in Java EE you can check it out on github
at github.com/gshipley/mlbparks


On Tue, Mar 18, 2014 at 7:38 PM, Grant Shipley <gshipley at gmail.com> wrote:

> Why not put it in a database that supports this natively?
> --
> gs
> On Tue, Mar 18, 2014 at 7:32 PM, S. Dale Morrey <sdalemorrey at gmail.com>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.
>> /*
>> PLUG: http://plug.org, #utah on irc.freenode.net
>> Unsubscribe: http://plug.org/mailman/options/plug
>> Don't fear the penguin.
>> */

More information about the PLUG mailing list