diff options
author | Daniel Friesel <derf@finalrewind.org> | 2021-10-23 09:57:49 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2021-10-23 09:58:39 +0200 |
commit | d748b0c877d5b65b35740824af8f46fc786a487e (patch) | |
tree | ce0f17b276e9acc2cb2dd692b9b7a401663b8461 | |
parent | f4d2b548ce39521d098c5c766283bb27fc81456b (diff) |
Use GIS::Distance for non-debian builds
-rw-r--r-- | cpanfile | 3 | ||||
-rw-r--r-- | lib/Travel/Status/DE/IRIS/Stations.pm.PL | 39 | ||||
-rwxr-xr-x | scripts/makedeb-docker-helper | 1 |
3 files changed, 34 insertions, 9 deletions
@@ -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 |