summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-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();
}