From 1c82ee17d2fa06a79fe3b96883d603408b4fe74a Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sun, 19 Nov 2023 12:49:41 +0100 Subject: Replace built-in Location package with Travel::Status::DE::HAFAS::Location --- lib/Travel/Routing/DE/HAFAS.pm | 4 +- lib/Travel/Routing/DE/HAFAS/Connection.pm | 4 +- lib/Travel/Routing/DE/HAFAS/Connection/Section.pm | 4 +- lib/Travel/Routing/DE/HAFAS/Location.pm | 104 ---------------------- 4 files changed, 6 insertions(+), 110 deletions(-) delete mode 100644 lib/Travel/Routing/DE/HAFAS/Location.pm (limited to 'lib/Travel') diff --git a/lib/Travel/Routing/DE/HAFAS.pm b/lib/Travel/Routing/DE/HAFAS.pm index 32eb6f0..4890c3c 100644 --- a/lib/Travel/Routing/DE/HAFAS.pm +++ b/lib/Travel/Routing/DE/HAFAS.pm @@ -15,7 +15,7 @@ use Encode qw(decode encode); use JSON; use LWP::UserAgent; use Travel::Routing::DE::HAFAS::Connection; -use Travel::Routing::DE::HAFAS::Location; +use Travel::Status::DE::HAFAS::Location; use Travel::Status::DE::HAFAS::Message; our $VERSION = '0.01'; @@ -517,7 +517,7 @@ sub check_mgate { sub parse_trips { my ($self) = @_; - my @locL = map { Travel::Routing::DE::HAFAS::Location->new( loc => $_ ) } + my @locL = map { Travel::Status::DE::HAFAS::Location->new( loc => $_ ) } @{ $self->{raw_json}{svcResL}[0]{res}{common}{locL} // [] }; my @conL = @{ $self->{raw_json}{svcResL}[0]{res}{outConL} // [] }; diff --git a/lib/Travel/Routing/DE/HAFAS/Connection.pm b/lib/Travel/Routing/DE/HAFAS/Connection.pm index bc587fc..64583e9 100644 --- a/lib/Travel/Routing/DE/HAFAS/Connection.pm +++ b/lib/Travel/Routing/DE/HAFAS/Connection.pm @@ -208,7 +208,7 @@ if available, falls back to schedule data otherwise. =item $connection->arr_loc -Travel::Routing::DE::HAFAS::Location(3pm) object describing the arrival stop. +Travel::Status::DE::HAFAS::Location(3pm) object describing the arrival stop. =item $connection->arr_platform @@ -230,7 +230,7 @@ data if available, falls back to schedule data otherwise. =item $connection->dep_loc -Travel::Routing::DE::HAFAS::Location(3pm) object describing the departure stop. +Travel::Status::DE::HAFAS::Location(3pm) object describing the departure stop. =item $connection->dep_platform diff --git a/lib/Travel/Routing/DE/HAFAS/Connection/Section.pm b/lib/Travel/Routing/DE/HAFAS/Connection/Section.pm index 375398b..b298419 100644 --- a/lib/Travel/Routing/DE/HAFAS/Connection/Section.pm +++ b/lib/Travel/Routing/DE/HAFAS/Connection/Section.pm @@ -231,7 +231,7 @@ Arrival delay in minutes. Undef if unknown. =item $section->arr_loc -Travel::Routing::DE::HAFAS::Location(3pm) object describing the arrival stop. +Travel::Status::DE::HAFAS::Location(3pm) object describing the arrival stop. =item $section->arr_platform @@ -253,7 +253,7 @@ Departure dlay in minutes. Undef if unknown. =item $section->dep_loc -Travel::Routing::DE::HAFAS::Location(3pm) object describing the departure stop. +Travel::Status::DE::HAFAS::Location(3pm) object describing the departure stop. =item $section->dep_platform diff --git a/lib/Travel/Routing/DE/HAFAS/Location.pm b/lib/Travel/Routing/DE/HAFAS/Location.pm deleted file mode 100644 index a852a55..0000000 --- a/lib/Travel/Routing/DE/HAFAS/Location.pm +++ /dev/null @@ -1,104 +0,0 @@ -package Travel::Routing::DE::HAFAS::Location; - -use strict; -use warnings; -use 5.014; - -use parent 'Class::Accessor'; - -our $VERSION = '0.01'; - -Travel::Routing::DE::HAFAS::Location->mk_ro_accessors( - qw(lid type name eva state coordinate)); - -sub new { - my ( $obj, %opt ) = @_; - - my $loc = $opt{loc}; - - my $ref = { - lid => $loc->{lid}, - type => $loc->{type}, - name => $loc->{name}, - eva => 0 + $loc->{extId}, - state => $loc->{state}, - coordinate => $loc->{crd} - }; - - bless( $ref, $obj ); - - return $ref; -} - -sub TO_JSON { - my ($self) = @_; - - my $ret = { %{$self} }; - - return $ret; -} - -1; - -__END__ - -=head1 NAME - -Travel::Routing::DE::HAFAS::Location - A single public transit stop - -=head1 SYNOPSIS - - printf("Destination: %s (%8d)\n", $stop->name, $stop->eva); - -=head1 VERSION - -version 0.01 - -=head1 DESCRIPTION - -Travel::Routing::DE::HAFAS::Stop describes a HAFAS stop that is part of -a connection, connection section, or (partial) journey. - -=head1 METHODS - -=head2 ACCESSORS - -=over - -=item $stop->name - -Stop name, e.g. "Essen Hbf" or "Unter den Linden/B75, Tostedt". - -=item $stop->eva - -EVA ID, e.g. 8000080. - -=back - -=head1 DIAGNOSTICS - -None. - -=head1 DEPENDENCIES - -=over - -=item Class::Accessor(3pm) - -=back - -=head1 BUGS AND LIMITATIONS - -None known. - -=head1 SEE ALSO - -Travel::Routing::DE::HAFAS(3pm). - -=head1 AUTHOR - -Copyright (C) 2023 by Birte Kristina Friesel Ederf@finalrewind.orgE - -=head1 LICENSE - -This module is licensed under the same terms as Perl itself. -- cgit v1.2.3