summaryrefslogtreecommitdiff
path: root/bin/efa-m
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2024-10-13 08:48:35 +0200
committerBirte Kristina Friesel <derf@finalrewind.org>2024-10-13 08:48:35 +0200
commitb8a15268fa0a14867c8056375843f54659d74aee (patch)
treeaa62049c4f5754011f4fdaac573c857fe3bb6d98 /bin/efa-m
parent98296b5aa191d5ddbd9c511f688d66c5a77c6596 (diff)
Add coord request mode
Diffstat (limited to 'bin/efa-m')
-rwxr-xr-xbin/efa-m32
1 files changed, 31 insertions, 1 deletions
diff --git a/bin/efa-m b/bin/efa-m
index 360ea2d..2dfca8d 100755
--- a/bin/efa-m
+++ b/bin/efa-m
@@ -95,7 +95,7 @@ if ($use_cache) {
@grep_mots = split( qr{,}, join( q{,}, @grep_mots ) );
@grep_platforms = split( qr{,}, join( q{,}, @grep_platforms ) );
-my ( $place, $input, $stopseq );
+my ( $place, $input, $coord, $stopseq, $stopfinder );
if ( @ARGV == 1 ) {
if ( $ARGV[0] =~ m{ ^ ([^@]*) @ ([^@]*) [(] ([^)]*) [)] (.*) $ }x ) {
@@ -106,6 +106,17 @@ if ( @ARGV == 1 ) {
key => $4
};
}
+ elsif ( $ARGV[0] =~ m{ ^ [?] (?<name> .*) $ }x ) {
+ $stopfinder = {
+ name => $+{name},
+ };
+ }
+ elsif ( $ARGV[0] =~ m{ ^ (?<lat> [0-9.]+ ) : (?<lon> [0-9].+ ) $ }x ) {
+ $coord = {
+ lat => $+{lat},
+ lon => $+{lon},
+ };
+ }
else {
$input = $ARGV[0];
}
@@ -160,6 +171,8 @@ sub new_efa {
full_routes => $full_routes,
place => $place,
name => $input,
+ coord => $coord,
+ stopfinder => $stopfinder,
stopseq => $stopseq,
time => $time,
type => $input_type,
@@ -301,6 +314,17 @@ sub display_result {
return;
}
+sub show_coord {
+ my $max_len = max map { length( $_->full_name ) } $efa->results;
+ for my $stop ( $efa->results ) {
+ printf(
+ "%5.1f km %-${max_len}s %s\n",
+ $stop->distance_m * 1e-3,
+ $stop->full_name, $stop->id
+ );
+ }
+}
+
sub show_stopseq {
my $trip = $efa->result;
@@ -540,6 +564,12 @@ if ($json_output) {
say JSON->new->convert_blessed->encode( [ $efa->results ] );
}
}
+elsif ($coord) {
+ show_coord();
+}
+elsif ($stopfinder) {
+ show_stopfinder();
+}
elsif ($stopseq) {
show_stopseq();
}