緯度経度から距離を算出
緯度経度から距離を算出方法のメモ
use strict;
use warnings;
my $latlng1 = [26.237108, 127.7086];
my $latlng2 = [26.264773, 127.771866];
my $lat = ($latlng1->[0] - $latlng2->[0]) * 69.1;
my $lng = ($latlng1->[1] - $latlng2->[1]) * 53.0;
my $distance = sqrt(($lat ** 2 + $lng ** 2));
print $distance;
ヒュベニ式の場合
use strict;
use warnings;
use Math::Complex;
my $x1 = 26.237108;
my $y1 = 127.7086;
my $x2 = 26.264773;
my $y2 = 127.771866;
my $x3 = $x1 * pi() / 180;
my $y3 = $y1 * pi() / 180;
my $x4 = $x2 * pi() / 180;
my $y4 = $y2 * pi() / 180;
my $e = 6368137;
my $x = $e * ($x4 - $x3) * cos($y3);
my $y = $e * ($y4 - $y3);
my $l = (sqrt($x ** 2 + $y ** 2) / 1000) / 2;
print $l;