Geo-Distance-XS
view release on metacpan or search on metacpan
0.04 Wed Jul 15 07:49:07 UTC 2009
- Noted in pod that Geo::Distance now calls this module if installed.
- Moved author tests into separate directory.
- Updated ppport.h.
- Added link to repository.
0.03 Wed May 6 07:16:34 UTC 2009
- Added support for non-C99 compilers. (Taro Nishino)
0.02 Tue May 5 13:55:49 UTC 2009
- (Hopefully) fixed compilation under Solaris by making test for NaN more
portable.
0.01 Sat Apr 4 16:59:27 UTC 2009
- Initial distribution.
return d;
}
double
cosines (double lat1, double lon1, double lat2, double lon2) {
lat1 *= DEG_RADS; lon1 *= DEG_RADS;
lat2 *= DEG_RADS; lon2 *= DEG_RADS;
double a = sin(lat1) * sin(lat2);
double b = cos(lat1) * cos(lat2) * cos(lon2 - lon1);
double d = acos(a + b);
/* Antipodal coordinates result in NaN */
if (isnan(d))
return haversine(lat1, lon1, lat2, lon2);
return d;
}
double
polar (double lat1, double lon1, double lat2, double lon2) {
double a = M_PI_2 - lat1 * DEG_RADS;
double b = M_PI_2 - lat2 * DEG_RADS;
double dlon = (lon2 - lon1) * DEG_RADS;
t/03_methods.t view on Meta::CPAN
my @coords = (-118.243103, 34.159545, -73.987427, 40.853293);
my %expected = (
map({ $_ => 2443 } @formulas), polar => 2766, tv => 2448, alt => 2448,
);
my $d = $geo->distance(mile => @coords);
is int $d, $expected{$f}, "$f: distance from LA to NY";
@coords = (175, 12, -5, -12);
$d = $geo->distance(mile => @coords);
ok $d == $d, "$f with antipodal coordinates is not NaN";
}
done_testing;
( run in 0.457 second using v1.01-cache-2.11-cpan-fd5d4e115d8 )