diff options
author | Daniel Friesel <derf@finalrewind.org> | 2022-01-28 23:00:23 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2022-01-28 23:00:23 +0100 |
commit | d0f6ffdbfee3b594adf58ce8a83d0564e2181639 (patch) | |
tree | e2d287505f0f4d74372f07b8abc3fc448910d7a0 /share | |
parent | 37c0aa5bb513da2cb6de7f673e97bc5192384e06 (diff) |
add "meta" dict (referenced / paired stations)
Diffstat (limited to 'share')
-rw-r--r-- | share/meta.json | 632 | ||||
-rwxr-xr-x | share/xml2meta | 45 |
2 files changed, 677 insertions, 0 deletions
diff --git a/share/meta.json b/share/meta.json new file mode 100644 index 0000000..f9002f9 --- /dev/null +++ b/share/meta.json @@ -0,0 +1,632 @@ +{ + "151011" : [ + 401003 + ], + "367072" : [ + 901013 + ], + "370051" : [ + 8079126 + ], + "371210" : [ + 720841 + ], + "373013" : [ + 721084 + ], + "377903" : [ + 501001, + 8079125 + ], + "378402" : [ + 8003185 + ], + "401003" : [ + 151011 + ], + "501001" : [ + 377903, + 8079125 + ], + "501004" : [ + 721358 + ], + "5500003" : [ + 5500008, + 5500728 + ], + "5500008" : [ + 5500003 + ], + "5500728" : [ + 5500003 + ], + "712896" : [ + 716122 + ], + "716122" : [ + 712896 + ], + "720841" : [ + 371210 + ], + "721084" : [ + 373013 + ], + "721245" : [ + 8001009 + ], + "721301" : [ + 8002116 + ], + "721358" : [ + 501004 + ], + "721401" : [ + 8003187 + ], + "721836" : [ + 8079144 + ], + "8000044" : [ + 8098044 + ], + "8000096" : [ + 8098096 + ], + "8000105" : [ + 8098105 + ], + "8000147" : [ + 8098147 + ], + "8000157" : [ + 8070171 + ], + "8000191" : [ + 8079041, + 8089390 + ], + "8000193" : [ + 8098193 + ], + "8000261" : [ + 8098261, + 8098262, + 8098263 + ], + "8000292" : [ + 8013434 + ], + "8000348" : [ + 8098349 + ], + "8000577" : [ + 8079075 + ], + "8000713" : [ + 8070073 + ], + "8001009" : [ + 721245 + ], + "8001091" : [ + 8070026 + ], + "8001138" : [ + 8001152 + ], + "8001152" : [ + 8001138 + ], + "8001903" : [ + 8001904 + ], + "8001904" : [ + 8001903 + ], + "8002059" : [ + 8071169 + ], + "8002116" : [ + 721301 + ], + "8002228" : [ + 8071001 + ], + "8002442" : [ + 8007078 + ], + "8002549" : [ + 8098549 + ], + "8002553" : [ + 8098553 + ], + "8002673" : [ + 8082673 + ], + "8002699" : [ + 8072722 + ], + "8002847" : [ + 8079088 + ], + "8003185" : [ + 378402 + ], + "8003187" : [ + 721401 + ], + "8003368" : [ + 8073368 + ], + "8003400" : [ + 8073400 + ], + "8003402" : [ + 8003403, + 8003434 + ], + "8003403" : [ + 8003402, + 8003434 + ], + "8003432" : [ + 8073432 + ], + "8003434" : [ + 8003402, + 8003403 + ], + "8004343" : [ + 8074343 + ], + "8005523" : [ + 8070859 + ], + "8005556" : [ + 8075556 + ], + "8006536" : [ + 8079212 + ], + "8007078" : [ + 8002442 + ], + "8010036" : [ + 8089182 + ], + "8010041" : [ + 8089168 + ], + "8010053" : [ + 8089186 + ], + "8010184" : [ + 8071738, + 8089295 + ], + "8010185" : [ + 8017475 + ], + "8010205" : [ + 8098205 + ], + "8010255" : [ + 8089185 + ], + "8010256" : [ + 8017020, + 8070777 + ], + "8010341" : [ + 8089187 + ], + "8010403" : [ + 8089165 + ], + "8010404" : [ + 8089083 + ], + "8010405" : [ + 8089190 + ], + "8010406" : [ + 8089046 + ], + "8011003" : [ + 8089188 + ], + "8011041" : [ + 8089113 + ], + "8011102" : [ + 8089015 + ], + "8011113" : [ + 8089073 + ], + "8011118" : [ + 8089032 + ], + "8011155" : [ + 8089001 + ], + "8011160" : [ + 8089021, + 8098160 + ], + "8011162" : [ + 8089028 + ], + "8011167" : [ + 8089100 + ], + "8011201" : [ + 8089201 + ], + "8011306" : [ + 8089066 + ], + "8011343" : [ + 8089072 + ], + "8011695" : [ + 8080530 + ], + "8011901" : [ + 8089117 + ], + "8012494" : [ + 8017017 + ], + "8012666" : [ + 8089184 + ], + "8013434" : [ + 8000292 + ], + "8013470" : [ + 8089205 + ], + "8013477" : [ + 8089181 + ], + "8013483" : [ + 8089207 + ], + "8013487" : [ + 8089197 + ], + "8017017" : [ + 8012494 + ], + "8017020" : [ + 8010256, + 8070777 + ], + "8017475" : [ + 8010185 + ], + "8070003" : [ + 8070004 + ], + "8070004" : [ + 8070003 + ], + "8070026" : [ + 8001091 + ], + "8070073" : [ + 8000713 + ], + "8070171" : [ + 8000157 + ], + "8070172" : [ + 8071172, + 8072172 + ], + "8070777" : [ + 8010256, + 8017020 + ], + "8070859" : [ + 8005523 + ], + "8071001" : [ + 8002228 + ], + "8071169" : [ + 8002059 + ], + "8071172" : [ + 8070172, + 8072172 + ], + "8071738" : [ + 8010184, + 8089295 + ], + "8072172" : [ + 8070172, + 8071172 + ], + "8072722" : [ + 8002699 + ], + "8073368" : [ + 8003368 + ], + "8073400" : [ + 8003400 + ], + "8073432" : [ + 8003432 + ], + "8074343" : [ + 8004343 + ], + "8075556" : [ + 8005556 + ], + "8079041" : [ + 8000191, + 8089390 + ], + "8079075" : [ + 8000577 + ], + "8079088" : [ + 8002847 + ], + "8079125" : [ + 377903, + 501001 + ], + "8079126" : [ + 370051 + ], + "8079144" : [ + 721836 + ], + "8079212" : [ + 8006536 + ], + "8080530" : [ + 8011695 + ], + "8082673" : [ + 8002673 + ], + "8089001" : [ + 8011155 + ], + "8089015" : [ + 8011102 + ], + "8089021" : [ + 8011160, + 8098160 + ], + "8089028" : [ + 8011162 + ], + "8089032" : [ + 8011118 + ], + "8089046" : [ + 8010406 + ], + "8089050" : [ + 8089051 + ], + "8089051" : [ + 8089050 + ], + "8089066" : [ + 8011306 + ], + "8089072" : [ + 8011343 + ], + "8089073" : [ + 8011113 + ], + "8089083" : [ + 8010404 + ], + "8089100" : [ + 8011167 + ], + "8089113" : [ + 8011041 + ], + "8089117" : [ + 8011901 + ], + "8089165" : [ + 8010403 + ], + "8089168" : [ + 8010041 + ], + "8089181" : [ + 8013477 + ], + "8089182" : [ + 8010036 + ], + "8089184" : [ + 8012666 + ], + "8089185" : [ + 8010255 + ], + "8089186" : [ + 8010053 + ], + "8089187" : [ + 8010341 + ], + "8089188" : [ + 8011003 + ], + "8089190" : [ + 8010405 + ], + "8089197" : [ + 8013487 + ], + "8089201" : [ + 8011201 + ], + "8089205" : [ + 8013470 + ], + "8089207" : [ + 8013483 + ], + "8089295" : [ + 8010184, + 8071738 + ], + "8089390" : [ + 8000191, + 8079041 + ], + "8098044" : [ + 8000044 + ], + "8098096" : [ + 8000096 + ], + "8098105" : [ + 8000105 + ], + "8098147" : [ + 8000147 + ], + "8098160" : [ + 8011160, + 8089021 + ], + "8098193" : [ + 8000193 + ], + "8098205" : [ + 8010205 + ], + "8098261" : [ + 8000261, + 8098262, + 8098263 + ], + "8098262" : [ + 8000261, + 8098261, + 8098263 + ], + "8098263" : [ + 8000261, + 8098261, + 8098262 + ], + "8098349" : [ + 8000348 + ], + "8098549" : [ + 8002549 + ], + "8098553" : [ + 8002553 + ], + "8100102" : [ + 8100545 + ], + "8100545" : [ + 8100102 + ], + "8503310" : [ + 8503340 + ], + "8503340" : [ + 8503310 + ], + "8503428" : [ + 8506152 + ], + "8506110" : [ + 8506308 + ], + "8506111" : [ + 8506307 + ], + "8506112" : [ + 8506121 + ], + "8506113" : [ + 8506306 + ], + "8506121" : [ + 8506112 + ], + "8506133" : [ + 8506162 + ], + "8506134" : [ + 8506160 + ], + "8506135" : [ + 8506159 + ], + "8506136" : [ + 8506157 + ], + "8506137" : [ + 8506155 + ], + "8506152" : [ + 8503428 + ], + "8506155" : [ + 8506137 + ], + "8506157" : [ + 8506136 + ], + "8506159" : [ + 8506135 + ], + "8506160" : [ + 8506134 + ], + "8506162" : [ + 8506133 + ], + "8506306" : [ + 8506113 + ], + "8506307" : [ + 8506111 + ], + "8506308" : [ + 8506110 + ], + "8700074" : [ + 8700464 + ], + "8700464" : [ + 8700074 + ], + "8800004" : [ + 8898004 + ], + "8898004" : [ + 8800004 + ], + "901013" : [ + 367072 + ] +} diff --git a/share/xml2meta b/share/xml2meta new file mode 100755 index 0000000..ff8bb63 --- /dev/null +++ b/share/xml2meta @@ -0,0 +1,45 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use 5.010; + +use File::Slurp qw(read_file write_file); +use JSON; +use List::Util qw(any); +use XML::LibXML; + +my $json_str = read_file('stations.json'); +my %known_eva; +for my $station ( @{ JSON->new->utf8->decode($json_str) } ) { + $known_eva{ $station->{eva} } = 1; +} + +# Norddeich and Norddeich Mole are illegaly coupled in the backend (they are +# different stations with different departure times). Ignore their EVA IDs. +delete $known_eva{8007768}; +delete $known_eva{8004449}; + +my $xml_str = read_file('stations.xml'); +my $tree = XML::LibXML->load_xml( string => $xml_str ); + +my %meta; + +for my $station ( $tree->findnodes('//station') ) { + my $eva = $station->getAttribute('eva'); + my $meta = $station->getAttribute('meta'); + + if ( $known_eva{$eva} and $meta ) { + for my $ref ( split( qr{[|]}, $meta ) ) { + if ( $known_eva{$ref} ) { + push( @{ $meta{$eva} }, 0 + $ref ); + } + else { + say "Note: Ignoring $eva -> $ref (unknown)"; + } + } + } +} + +my $json_out = JSON->new->utf8->canonical->pretty->encode( {%meta} ); +write_file( 'meta.json', $json_out ); |