From 24a55903ddceb8107c527d637f57f7c1d135ef8e Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 28 Nov 2011 12:39:31 +0100 Subject: Fix extra info display --- lib/Travel/Routing/DE/VRR.pm | 16 +++++++++++++--- lib/Travel/Routing/DE/VRR/Route.pm | 4 ++-- 2 files changed, 15 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/Travel/Routing/DE/VRR.pm b/lib/Travel/Routing/DE/VRR.pm index d55ac98..7a0abef 100644 --- a/lib/Travel/Routing/DE/VRR.pm +++ b/lib/Travel/Routing/DE/VRR.pm @@ -430,7 +430,9 @@ sub itdtime_str { } sub parse_part { - my ($self, $tree) = @_; + my ($self, $route) = @_; + + my $info; my $xp_route = XML::LibXML::XPathExpression->new('./itdPartialRouteList/itdPartialRoute'); my $xp_dep = XML::LibXML::XPathExpression->new('./itdPoint[@usage="departure"]'); @@ -440,10 +442,15 @@ sub parse_part { # my $xp_tdate = XML::LibXML::XPathExpression->new('./itdDateTimeTarget/itdDate'); # my $xp_ttime = XML::LibXML::XPathExpression->new('./itdDateTimeTarget/itdTime'); my $xp_mot = XML::LibXML::XPathExpression->new('./itdMeansOfTransport'); + my $xp_info = XML::LibXML::XPathExpression->new('./itdInfoTextList/infoTextListElem'); + my @route_parts; - for my $e ( $tree->findnodes($xp_route) ) { + $info->{vehicle_time} = $route->getAttribute('vehicleTime'); + $info->{duration} = $route->getAttribute('publicDuration'); + + for my $e ( $route->findnodes($xp_route) ) { my $e_dep = ( $e->findnodes($xp_dep) )[0]; my $e_arr = ( $e->findnodes($xp_arr) )[0]; @@ -452,6 +459,7 @@ sub parse_part { my $e_adate = ( $e_arr->findnodes($xp_date) )[0]; my $e_atime = ( $e_arr->findnodes($xp_time) )[0]; my $e_mot = ( $e->findnodes($xp_mot) )[0]; + my @e_info = $e->findnodes($xp_info); my $hash = { departure_time => $self->itdtime_str($e_dtime), @@ -470,10 +478,12 @@ sub parse_part { $hash->{$key} = decode('UTF-8', $hash->{$key} ); } + $hash->{extra} = [ map { decode('UTF-8', $_->textContent) } @e_info ]; + push(@route_parts, $hash); } - push(@{$self->{routes}}, Travel::Routing::DE::VRR::Route->new(@route_parts)); + push(@{$self->{routes}}, Travel::Routing::DE::VRR::Route->new($info, @route_parts)); return; } diff --git a/lib/Travel/Routing/DE/VRR/Route.pm b/lib/Travel/Routing/DE/VRR/Route.pm index e5ffa05..73bda07 100644 --- a/lib/Travel/Routing/DE/VRR/Route.pm +++ b/lib/Travel/Routing/DE/VRR/Route.pm @@ -9,9 +9,9 @@ use Travel::Routing::DE::VRR::Route::Part; our $VERSION = '1.06'; sub new { - my ( $obj, @parts ) = @_; + my ( $obj, $info, @parts ) = @_; - my $ref = {}; + my $ref = $info; for my $part (@parts) { push( -- cgit v1.2.3