Ruby / Geo - 找到距离给定中心最远的点

时间:2013-02-21 17:49:31

标签: ruby geolocation geometry

给定一个中心点和一组点,是否有一个宝石/函数,我可以看到哪些点离原点最远,彼此相距最小距离?

def find_furthest origin, set, min_distance 
    #
end

我如何计算距离,欢迎替代方案

http://www.esawdust.com/blog/gps/files/HaversineFormulaInRuby.html

来源

{"lat"=>43.643326, "lng"=>-79.3831843}

    [{"lat"=>43.64506, "lng"=>-79.384136},
     {"lat"=>43.642806, "lng"=>-79.380683},
     {"lat"=>43.645062, "lng"=>-79.384126},
     {"lat"=>43.644701, "lng"=>-79.384699},
     {"lat"=>43.644987, "lng"=>-79.383204},
     {"lat"=>43.64506, "lng"=>-79.384136},
     {"lat"=>43.644537, "lng"=>-79.385584},
     {"lat"=>43.643393, "lng"=>-79.380678},
     {"lat"=>43.642736, "lng"=>-79.381281},
     {"lat"=>43.642487, "lng"=>-79.382914},
     {"lat"=>43.642426, "lng"=>-79.383248},
     {"lat"=>43.642415, "lng"=>-79.383254},
     {"lat"=>43.645099, "lng"=>-79.383252},
     {"lat"=>43.642425, "lng"=>-79.383374},
     {"lat"=>43.64482, "lng"=>-79.385219},
     {"lat"=>43.64482, "lng"=>-79.385219},
     {"lat"=>43.645082, "lng"=>-79.38379},
     {"lat"=>43.64333, "lng"=>-79.380654},
     {"lat"=>43.644535, "lng"=>-79.385171},
     {"lat"=>43.64482, "lng"=>-79.385219}]

1 个答案:

答案 0 :(得分:0)

你正在寻找这样的宝石吗? https://rubygems.org/gems/geo-distance