summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpanfile3
-rw-r--r--lib/Travel/Status/DE/IRIS/Stations.pm.PL39
-rwxr-xr-xscripts/makedeb-docker-helper1
3 files changed, 34 insertions, 9 deletions
diff --git a/cpanfile b/cpanfile
index 0f3a187..9d414f0 100644
--- a/cpanfile
+++ b/cpanfile
@@ -4,7 +4,8 @@ requires 'Class::Accessor';
requires 'DateTime';
requires 'DateTime::Format::Strptime';
requires 'Encode';
-requires 'Geo::Distance' => '!= 0.21';
+requires 'GIS::Distance';
+requires 'GIS::Distance::Fast';
requires 'Getopt::Long';
requires 'List::Compare' => '0.29',
requires 'List::MoreUtils';
diff --git a/lib/Travel/Status/DE/IRIS/Stations.pm.PL b/lib/Travel/Status/DE/IRIS/Stations.pm.PL
index d4f0726..2b47802 100644
--- a/lib/Travel/Status/DE/IRIS/Stations.pm.PL
+++ b/lib/Travel/Status/DE/IRIS/Stations.pm.PL
@@ -23,16 +23,21 @@ use warnings;
use 5.014;
use utf8;
-use Geo::Distance;
+EOF
+
+if ($ENV{DB_IRIS_DEB_BUILD}) {
+ $buf .= "use Geo::Distance;\n"
+}
+else {
+ $buf .= "use GIS::Distance;\n";
+}
+
+$buf .= <<'EOF';
use List::Util qw(min);
use List::UtilsBy qw(uniq_by);
use List::MoreUtils qw(firstval pairwise);
use Text::LevenshteinXS qw(distance);
-# TODO Geo::Distance is kinda deprecated, it is recommended to use GIS::Distance
-# instead. However, since GIS::Distance is not packaged for Debian, I'll stick
-# with Geo::Distance for now (which works fine enough here)
-
# TODO switch to Text::Levenshtein::XS once AUR/Debian packages become available
our $VERSION = '1.60';
@@ -104,7 +109,16 @@ sub get_station_by_location {
$num_matches //= 10;
- my $geo = Geo::Distance->new();
+EOF
+
+if ($ENV{DB_IRIS_DEB_BUILD}) {
+ $buf .= "\tmy \$dist = Geo::Distance->new();\n";
+}
+else {
+ $buf .= "\tmy \$dist = GIS::Distance->new();\n";
+}
+
+$buf .= <<'EOF';
# we only use geolocations inside germany.
# For these, this fast preprocessing step will let through all
@@ -116,7 +130,16 @@ sub get_station_by_location {
< 1
} @stations;
my @distances
- = map { $geo->distance( 'kilometer', $lon, $lat, $_->[3], $_->[4] ) }
+EOF
+
+if ($ENV{DB_IRIS_DEB_BUILD}) {
+ $buf .= '= map { $dist->distance( \'kilometer\', $lon, $lat, $_->[3], $_->[4] ) }';
+}
+else {
+ $buf .= '= map { $dist->distance_metal( $lat, $lon, $_->[4], $_->[3] ) }';
+}
+
+$buf .= <<'EOF';
@candidates;
my @station_map = pairwise { [ $a, $b ] } @candidates, @distances;
@@ -272,7 +295,7 @@ None.
=over
-=item * Geo::Distance(3pm)
+=item * GIS::Distance(3pm)
=item * List::MoreUtils(3pm)
diff --git a/scripts/makedeb-docker-helper b/scripts/makedeb-docker-helper
index a0b8ac3..d265124 100755
--- a/scripts/makedeb-docker-helper
+++ b/scripts/makedeb-docker-helper
@@ -25,6 +25,7 @@ cp -a /orig/bin /orig/examples /orig/lib /orig/share /orig/t /src/app
cd /src/app
sed -i 's/sign *=> *1/sign => 0/' Build.PL
+export DB_IRIS_DEB_BUILD=1
perl Build.PL
perl Build
perl Build manifest