Permalink
Browse files

use Geo::Distance::XS if available

  • Loading branch information...
1 parent 4f43a17 commit 0124585e7afa78a3959cc73939d192b72b4fd161 @gray gray committed Jul 15, 2009
Showing with 19 additions and 0 deletions.
  1. +3 −0 Changes
  2. +2 −0 Makefile.PL
  3. +10 −0 lib/Geo/Distance.pm
  4. +4 −0 t/00.t
View
@@ -1,5 +1,8 @@
Revision history for Perl extension Geo::Distance.
+0.13
+ - Use Geo::Distance::XS if available. (gray <gray@cpan.org>)
+
0.12
- Noted GIS::Distance in POD.
- Some cleanups to install process.
View
@@ -9,5 +9,7 @@ all_from 'lib/Geo/Distance.pm';
build_requires 'Test::More' => 0.62;
+recommends 'Geo::Distance::XS';
+
WriteAll;
View
@@ -444,6 +444,10 @@ sub closest {
}
#-------------------------------------------------------------------------------
+INIT {
+ eval "use Geo::Distance::XS" unless $ENV{GEO_DISTANCE_PP};
+}
+
1;
__END__
@@ -519,6 +523,12 @@ Math::Trig states that the formula that it uses is:
lat1 = 90 degrees - phi1
d = R * arccos(cos(lat0) * cos(lat1) * cos(lon1 - lon01) + sin(lat0) * sin(lat1))
+=head1 NOTES
+
+If L<Geo::Distance::XS> is installed, this module will use it. You can
+stick with the pure Perl version by setting the GEO_DISTANCE_PP environment
+variable before using this module.
+
=head1 TODO
=over 4
View
@@ -4,9 +4,13 @@ BEGIN{
eval( 'use DBI' );
plan( skip_all => 'DBI required for these tests' ) if $@;
plan( 'no_plan' );
+
+ BEGIN { $ENV{GEO_DISTANCE_PP} = 1; }
use_ok( 'Geo::Distance' );
}
+ok(! defined &distance_hsin, 'prevent XS from loading; use pure Perl');
+
my $geo = eval{ return Geo::Distance->new() };
ok(!$@,'create a Geo::Distance object');

0 comments on commit 0124585

Please sign in to comment.