Unverified Commit d748b0c8 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Use GIS::Distance for non-debian builds

parent f4d2b548
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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';
+31 −8
Original line number Diff line number Diff line
@@ -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)

+1 −0
Original line number Diff line number Diff line
@@ -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