0

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

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}]
4

1 回答 1

0

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

于 2013-02-21T19:07:31.537 回答