summaryrefslogtreecommitdiff
path: root/lib/Travel/Routing
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-06-18 15:52:16 +0200
committerDaniel Friesel <derf@finalrewind.org>2015-06-18 15:52:16 +0200
commit920477d9a0a0b5d5178208fe3da342e5b925640f (patch)
tree6f620a093eb063e1c35d3049a78735e37ed49397 /lib/Travel/Routing
parentf0b539d7c6619eb3c05a57bdc1b0f7d06e8f0bd5 (diff)
parse most info and make it available properly
Diffstat (limited to 'lib/Travel/Routing')
-rw-r--r--lib/Travel/Routing/DE/EFA.pm38
-rw-r--r--lib/Travel/Routing/DE/EFA/Route/Part.pm21
2 files changed, 54 insertions, 5 deletions
diff --git a/lib/Travel/Routing/DE/EFA.pm b/lib/Travel/Routing/DE/EFA.pm
index ca5c051..f423cf8 100644
--- a/lib/Travel/Routing/DE/EFA.pm
+++ b/lib/Travel/Routing/DE/EFA.pm
@@ -497,6 +497,31 @@ sub itdtime_str {
$node->getAttribute('minute') );
}
+sub parse_cur_info {
+ my ( $self, $node ) = @_;
+
+ my $xp_text = XML::LibXML::XPathExpression->new('./infoLinkText');
+ my $xp_subject = XML::LibXML::XPathExpression->new('./infoText/subject');
+ my $xp_subtitle = XML::LibXML::XPathExpression->new('./infoText/subtitle');
+ my $xp_content = XML::LibXML::XPathExpression->new('./infoText/content');
+
+ my $e_text = ( $node->findnodes($xp_text) )[0];
+ my $e_subject = ( $node->findnodes($xp_subject) )[0];
+ my $e_subtitle = ( $node->findnodes($xp_subtitle) )[0];
+ my $e_content = ( $node->findnodes($xp_content) )[0];
+
+ my $ret = {
+ summary => $e_text->textContent,
+ subject => $e_subject->textContent,
+ subtitle => $e_subtitle->textContent,
+ content => $e_content->textContent,
+ };
+ for my $key ( keys %{$ret} ) {
+ $ret->{$key} = decode( 'UTF-8', $ret->{$key} );
+ }
+ return $ret;
+}
+
sub parse_xml_part {
my ( $self, $route ) = @_;
@@ -519,8 +544,10 @@ sub parse_xml_part {
my $xp_fp_e
= XML::LibXML::XPathExpression->new('./itdFootPathInfo/itdFootPathElem');
my $xp_delay = XML::LibXML::XPathExpression->new('./itdRBLControlled');
- my $xp_info
- = XML::LibXML::XPathExpression->new('./itdInfoTextList/infoTextListElem | ./infoLink/infoLinkText');
+
+ my $xp_sched_info
+ = XML::LibXML::XPathExpression->new('./itdInfoTextList/infoTextListElem');
+ my $xp_cur_info = XML::LibXML::XPathExpression->new('./infoLink');
my $xp_mapitem_rm = XML::LibXML::XPathExpression->new(
'./itdMapItemList/itdMapItem[@type="RM"]/itdImage');
@@ -561,7 +588,8 @@ sub parse_xml_part {
my $e_mot = ( $e->findnodes($xp_mot) )[0];
my $e_delay = ( $e->findnodes($xp_delay) )[0];
my $e_fp = ( $e->findnodes($xp_fp) )[0];
- my @e_info = $e->findnodes($xp_info);
+ my @e_sinfo = $e->findnodes($xp_sched_info);
+ my @e_cinfo = $e->findnodes($xp_cur_info);
my @e_dmap_rm = $e_dep->findnodes($xp_mapitem_rm);
my @e_dmap_sm = $e_dep->findnodes($xp_mapitem_sm);
my @e_amap_rm = $e_arr->findnodes($xp_mapitem_rm);
@@ -662,7 +690,9 @@ sub parse_xml_part {
);
}
- $hash->{extra} = [ map { decode( 'UTF-8', $_->textContent ) } @e_info ];
+ $hash->{sched_info}
+ = [ map { decode( 'UTF-8', $_->textContent ) } @e_sinfo ];
+ $hash->{current_info} = [ map { $self->parse_cur_info($_) } @e_cinfo ];
push( @route_parts, $hash );
}
diff --git a/lib/Travel/Routing/DE/EFA/Route/Part.pm b/lib/Travel/Routing/DE/EFA/Route/Part.pm
index cc52f80..3bf5d60 100644
--- a/lib/Travel/Routing/DE/EFA/Route/Part.pm
+++ b/lib/Travel/Routing/DE/EFA/Route/Part.pm
@@ -82,10 +82,29 @@ sub footpath_parts {
return;
}
+# DEPRECATED
sub extra {
my ($self) = @_;
- return @{ $self->{extra} // [] };
+ return @{ $self->{sched_info} // [] };
+}
+
+sub sched_info {
+ my ($self) = @_;
+
+ if ( $self->{sched_info} ) {
+ return @{ $self->{sched_info} };
+ }
+ return;
+}
+
+sub current_info {
+ my ($self) = @_;
+
+ if ( $self->{current_info} ) {
+ return @{ $self->{current_info} };
+ }
+ return;
}
sub via {