Hi , I dont mean to present the exact solution but a trivial and (hopefully)possible one. Maintain 2 <latitude,longitude> vectors one sorted based on Latitude values and other sorted based on Longitude values. Given a coordinate say (x,y) , from the vector sorted based on latitudes identify the coordinates whose latitude is close to X and keep a track of them. Similarly from the other vector note down the coordinates whose longitudes are close to Y.
Now the nearest person to the given point x,y must be within the two subsets and find distance from each coordinates within the subset to the given point x,y. The tricky part is identifying which coordinates from the 2 vectors are close to the given point. Hope there must be a better solution than this. Given an element within the vector, we should be 2009/11/17 Tiago Reul <[email protected]> > Suppose that you have the position of each person in the world. > Position is the pair (latitude, longitude). > > How to represent the data so that I can find the nearest person > from a point (φ,λ) without comparing to every pair in the collection? > > -- > > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<algogeeks%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=. > > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=.
