Algorithm to find all Latitude Longitude locations within a certain distance from a given Lat Lng location

前端 未结 11 636
傲寒
傲寒 2020-12-02 04:32

Given a database of places with Latitude + Longitude locations, such as 40.8120390, -73.4889650, how would I find all locations within a given distance of a specific locatio

11条回答
  •  不思量自难忘°
    2020-12-02 04:56

    As biziclop mentioned, some sort of metric space tree would probably be your best option. I have experience using kd-trees and quad trees to do these sorts of range queries and they're amazingly fast; they're also not that hard to write. I'd suggest looking into one of these structures, as they also let you answer other interesting questions like "what's the closest point in my data set to this other point?"

提交回复
热议问题