Changes between Version 18 and Version 19 of Rules/PublicTransportGtfs


Ignore:
Timestamp:
2020-07-28T15:08:20+02:00 (6 years ago)
Author:
skyper
Comment:

Rearranged some test for better performance

Legend:

Unmodified
Added
Removed
Modified
  • Rules/PublicTransportGtfs

    v18 v19  
    6464}
    6565
     66/* Not only relations as ferry can be a way */
    6667*[type=route][route =~ /^(bus|share_taxi|trolleybus|train|tram|light_rail|subway|monorail|ferry)$/] {
    6768  set PtRoute;
    6869}
    6970
    70 /* relation[type=route_master][gtfs:route_id] > relation { */
    71 relation[type=route_master][gtfs:route_id] > * {
     71relation[gtfs:route_id][type=route_master] > * {
    7272  set ChildMasterRoute_id;
    7373}
     
    148148
    149149/* stop_position, platform */
    150 *[public_transport][public_transport =~ /^(platform|stop_area|stop_position)$/][!ref:IFOPT][!gtfs:stop_id] {
    151   throwWarning: tr("`{0}` without `{1}*` or `{2}*`.", "{0.tag}", "{2.tag}", "{3.tag}");
     150*[public_transport =~ /^(platform|stop_area|stop_position)$/][!ref:IFOPT][!gtfs:stop_id][public_transport] {
     151  throwWarning: tr("`{0}` without `{1}*` or `{2}*`.", "{3.tag}", "{1.tag}", "{2.tag}");
    152152  group: tr("Public Transport GTFS: missing tag");
    153153  assertMatch:   "node public_transport=stop_position train=yes railway=halt";
     
    162162
    163163/* route_master and route relations, ToDo ferry on ways */
    164 relation[gtfs:route_id][!gtfs:feed][!network:guid][!operator:guid].PtRouteMaster,
    165 relation["public_transport:version"=2][!gtfs:shape_id][!gtfs:trip_id][!gtfs:trip_id:sample].PtRoute,
    166 relation[gtfs:route_id][!gtfs:feed][!network:guid][!operator:guid].PtRoute,
    167 relation[gtfs:shape_id][!gtfs:feed][!network:guid][!operator:guid].PtRoute,
    168 relation[gtfs:trip_id][!gtfs:feed][!network:guid][!operator:guid].PtRoute,
    169 relation[gtfs:trip_id:sample][!gtfs:feed][!network:guid][!operator:guid].PtRoute {
    170   throwWarning: tr("Public transport relation with `{0}` but none of `{1}*`, `{2}*` or `{3}*`.", "{0.tag}", "{1.tag}", "{2.tag}", "{3.tag}");
     164relation["public_transport:version"=2].PtRoute[!gtfs:shape_id][!gtfs:trip_id][!gtfs:trip_id:sample],
     165relation[gtfs:route_id].PtRouteMaster[!gtfs:feed][!network:guid][!operator:guid],
     166relation[gtfs:route_id      ].PtRoute[!gtfs:feed][!network:guid][!operator:guid],
     167relation[gtfs:shape_id      ].PtRoute[!gtfs:feed][!network:guid][!operator:guid],
     168relation[gtfs:trip_id       ].PtRoute[!gtfs:feed][!network:guid][!operator:guid],
     169relation[gtfs:trip_id:sample].PtRoute[!gtfs:feed][!network:guid][!operator:guid] {
     170  throwWarning: tr("Public transport relation with `{0}` but none of `{1}*`, `{2}*` or `{3}*`.", "{0.tag}", "{2.tag}", "{3.tag}", "{4.tag}");
    171171  group: tr("Public Transport GTFS: missing tag");
    172172  assertMatch:   "relation type=route_master route_master=train gtfs:route_id=0-7-242-19j-1";
     
    179179
    180180/* platform and stop_position */
     181/* ToDo: Check against parent relation vehicle type */
     182/* ToDo: Extend to check for parent relation value and offer fix */
    181183*[public_transport =~ /^(platform|stop_position)$/][highway!=bus_stop][public_transport].noPtVehicle {
    182184  throwWarning: tr("`{0}` without serving vehicle type specified.", "{2.tag}");
     
    200202
    201203/* platform */
    202 *[public_transport =~ /^(platform|stop_position)$/][highway=bus_stop][bus!=yes][share_taxi!=yes][trolleybus!=yes][public_transport] {
    203   throwWarning: tr("`{0}` with `{1}` but none of `{2}*`, `{3}*` or `{4}*`.", "{5.tag}", "{1.tag}", "{2.tag}", "{3.tag}", "{4.tag}");
     204*[highway=bus_stop][public_transport =~ /^(platform|stop_position)$/][bus!=yes][share_taxi!=yes][trolleybus!=yes][public_transport] {
     205  throwWarning: tr("`{0}` with `{1}` but none of `{2}*`, `{3}*` or `{4}*`.", "{5.tag}", "{0.tag}", "{2.tag}", "{3.tag}", "{4.tag}");
    204206  group: tr("Public Transport GTFS: missing tag");
    205207  assertMatch:   "node public_transport=platform highway=bus_stop";
     
    239241/* FIXME: Get proper syntax as regex displayed. */
    240242*[gtfs:feed    ][gtfs:feed     !~ /^(([A-Z]{2}-){2}[a-zA-Z]{2}.*|CH-Alle|DE-SPNV|DE-S-und-U-Bahnen|DK-Alle)$/],
    241 *[network:guid ][network:guid  !~  /^([A-Z]{2}-){2}[a-zA-Z]{2}.*$/], 
     243*[network:guid ][network:guid  !~  /^([A-Z]{2}-){2}[a-zA-Z]{2}.*$/],
    242244*[operator:guid][operator:guid !~  /^([A-Z]{2}-){2}[a-zA-Z]{2}.*$/],
    243 *[gtfs:source_date][gtfs:source_date !~ /^20(1[7-9]|20)-(0[1-9]|1[0-2])-(3[01]|[12][0-9]|0[1-9])$/] { 
     245*[gtfs:source_date][gtfs:source_date !~ /^20(1[7-9]|20)-(0[1-9]|1[0-2])-(3[01]|[12][0-9]|0[1-9])$/] {
    244246  throwError: tr("Value `{0}` for `{1}=*` does not match value syntax.", "{0.value}", "{0.key}");
    245247/*  throwError: tr("Value `{0}` for `{1}=*` does not match value syntax `{2}`.", "{0.value}", "{0.key}", "{1.value}"); */
     
    298300
    299301/* short ref:IFOPT */
    300 node!.ErrorSyntaxIFOPT[ref:IFOPT        !~ /^.+(:.+){4}$/][ref:IFOPT   ][public_transport=stop_position],
    301 node!.ErrorSyntaxIFOPT[gtfs:stop_id     !~ /^.+(:.+){4}$/][gtfs:stop_id][public_transport=platform],
    302 node!.ErrorSyntaxIFOPT[ref:IFOPT        !~ /^.+(:.+){4}$/][ref:IFOPT   ][public_transport=platform],
    303 node!.ErrorSyntaxIFOPT[gtfs:stop_id     !~ /^.+(:.+){4}$/][gtfs:stop_id][public_transport=platform],
    304 way!.ErrorSyntaxIFOPT[ref:IFOPT         !~ /^.+(:.+){3}$/][ref:IFOPT   ][public_transport=platform],
    305 way!.ErrorSyntaxIFOPT[gtfs:stop_id      !~ /^.+(:.+){3}$/][gtfs:stop_id][public_transport=platform],
    306 relation!.ErrorSyntaxIFOPT[ref:IFOPT    !~ /^.+(:.+){3}$/][ref:IFOPT   ][public_transport][public_transport =~ /^(platform|stop_area)$/],
    307 relation!.ErrorSyntaxIFOPT[gtfs:stop_id !~ /^.+(:.+){3}$/][gtfs:stop_id][public_transport][public_transport =~ /^(platform|stop_area)$/] {
    308   throwWarning: tr("Incomplete `{0}` on `{1}`.", "{2.tag}", "{3.tag}");
     302node[public_transport=stop_position][ref:IFOPT   ]!.ErrorSyntaxIFOPT[ref:IFOPT        !~ /^.+(:.+){4}$/],
     303node[public_transport=platform     ][gtfs:stop_id]!.ErrorSyntaxIFOPT[gtfs:stop_id     !~ /^.+(:.+){4}$/],
     304node[public_transport=platform     ][ref:IFOPT   ]!.ErrorSyntaxIFOPT[ref:IFOPT        !~ /^.+(:.+){4}$/],
     305node[public_transport=platform     ][gtfs:stop_id]!.ErrorSyntaxIFOPT[gtfs:stop_id     !~ /^.+(:.+){4}$/],
     306way[public_transport=platform      ][ref:IFOPT   ]!.ErrorSyntaxIFOPT[ref:IFOPT         !~ /^.+(:.+){3}$/],
     307way[public_transport=platform      ][gtfs:stop_id]!.ErrorSyntaxIFOPT[gtfs:stop_id      !~ /^.+(:.+){3}$/],
     308relation[public_transport          ][ref:IFOPT   ]!.ErrorSyntaxIFOPT[ref:IFOPT    !~ /^.+(:.+){3}$/][public_transport =~ /^(platform|stop_area)$/],
     309relation[public_transport          ][gtfs:stop_id]!.ErrorSyntaxIFOPT[gtfs:stop_id !~ /^.+(:.+){3}$/][public_transport =~ /^(platform|stop_area)$/] {
     310  throwWarning: tr("Incomplete `{0}` on `{1}`.", "{1.tag}", "{0.tag}");
    309311  group: tr("Public Transport GTFS: value syntax");
    310312  assertMatch:   "node public_transport=platform ref:IFOPT=de:09162:1179:31";
     
    342344  assertNoMatch: "relation gtfs:trip_id:sample=1108.T2.11-4-I-j20-1.10.H gtfs:trip_id=1108.T2.11-4-I-j20-1.10.H";
    343345}
    344 *[gtfs:route_id]!.MultipleID!.GtfsIdSyntax[gtfs:shape_id      ][!(tag("gtfs:route_id") == get(regexp_match("^(.+)\\.[1-9][0-9]?\\.[HR]$", tag("gtfs:shape_id")), 1))],
    345 *[gtfs:route_id]!.MultipleID!.GtfsIdSyntax[gtfs:trip_id       ][!(tag("gtfs:route_id") == get(regexp_match("^[1-9][0-9]{0,3}\\.T[023A]\\.(.+)\\.[1-9][0-9]?\\.[HR]$", tag("gtfs:trip_id")), 1))],
    346 *[gtfs:route_id]!.MultipleID!.GtfsIdSyntax[gtfs:trip_id:sample][!(tag("gtfs:route_id") == get(regexp_match("^[1-9][0-9]{0,3}\\.T[023A]\\.(.+)\\.[1-9][0-9]?\\.[HR]$", tag("gtfs:trip_id:sample")), 3))],
    347 *[gtfs:shape_id]!.MultipleID!.GtfsIdSyntax[gtfs:trip_id       ][!(tag("gtfs:shape_id") == get(regexp_match("^[1-9][0-9]{0,3}\\.T[023A]\\.(.+)$", tag("gtfs:trip_id")), 1))],
    348 *[gtfs:shape_id]!.MultipleID!.GtfsIdSyntax[gtfs:trip_id:sample][!(tag("gtfs:shape_id") == get(regexp_match("^[1-9][0-9]{0,3}\\.T[023A]\\.(.+)$", tag("gtfs:trip_id:sample")), 1))] {
     346*[gtfs:route_id][gtfs:shape_id      ]!.MultipleID!.GtfsIdSyntax[!(tag("gtfs:route_id") == get(regexp_match("^(.+)\\.[1-9][0-9]?\\.[HR]$", tag("gtfs:shape_id")), 1))],
     347*[gtfs:route_id][gtfs:trip_id       ]!.MultipleID!.GtfsIdSyntax[!(tag("gtfs:route_id") == get(regexp_match("^[1-9][0-9]{0,3}\\.T[023A]\\.(.+)\\.[1-9][0-9]?\\.[HR]$", tag("gtfs:trip_id")), 1))],
     348*[gtfs:route_id][gtfs:trip_id:sample]!.MultipleID!.GtfsIdSyntax[!(tag("gtfs:route_id") == get(regexp_match("^[1-9][0-9]{0,3}\\.T[023A]\\.(.+)\\.[1-9][0-9]?\\.[HR]$", tag("gtfs:trip_id:sample")), 3))],
     349*[gtfs:shape_id][gtfs:trip_id       ]!.MultipleID!.GtfsIdSyntax[!(tag("gtfs:shape_id") == get(regexp_match("^[1-9][0-9]{0,3}\\.T[023A]\\.(.+)$", tag("gtfs:trip_id")), 1))],
     350*[gtfs:shape_id][gtfs:trip_id:sample]!.MultipleID!.GtfsIdSyntax[!(tag("gtfs:shape_id") == get(regexp_match("^[1-9][0-9]{0,3}\\.T[023A]\\.(.+)$", tag("gtfs:trip_id:sample")), 1))] {
    349351  throwError: tr("`{1}` is not a substring of `{0}`.", "{0.tag}", "{1.tag}");
    350352  group: tr("Public Transport GTFS: conflicting tags");
     
    359361/* FIXME: How to ckeck with multiple values? */
    360362/* FIXME: How to display the key-value of the parent? */
    361 relation[gtfs:route_id      ][parent_tag("gtfs:route_id")]!.MultipleID[count(split(";", parent_tag("gtfs:route_id"))) == 1][!(parent_tag("gtfs:route_id") == tag("gtfs:route_id"))].ChildMasterRoute_id,
    362 relation[gtfs:shape_id      ][parent_tag("gtfs:route_id")]!.MultipleID[count(split(";", parent_tag("gtfs:route_id"))) == 1][!gtfs:route_id][!(parent_tag("gtfs:route_id") == get(regexp_match("(.+)\\.\\d+\\.[HR]$", tag("gtfs:shape_id")), 1))].ChildMasterRoute_id,
    363 relation[gtfs:trip_id       ][parent_tag("gtfs:route_id")]!.MultipleID[count(split(";", parent_tag("gtfs:route_id"))) == 1][!gtfs:route_id][!gtfs:shape_id][!(parent_tag("gtfs:route_id") == get(regexp_match("^\\d+\\.T[023A]\\.(.+)\\.\\d+\\.[HR]$", tag("gtfs:trip_id")), 1))].ChildMasterRoute_id,
    364 relation[gtfs:trip_id:sample][parent_tag("gtfs:route_id")]!.MultipleID[count(split(";", parent_tag("gtfs:route_id"))) == 1][!gtfs:route_id][!gtfs:shape_id][!(parent_tag("gtfs:route_id") == get(regexp_match("^\\d+\\.T[023A]\\.(.+)\\.\\d+\\.[HR]$", tag("gtfs:trip_id:sample")), 1))].ChildMasterRoute_id {
     363relation!.MultipleID[count(split(";", parent_tag("gtfs:route_id"))) == 1].ChildMasterRoute_id {
     364  set ChildNoMultiID;
     365}
     366relation[gtfs:route_id      ][!(parent_tag("gtfs:route_id") == tag("gtfs:route_id"))],
     367relation[gtfs:shape_id      ][!gtfs:route_id][!(parent_tag("gtfs:route_id") == get(regexp_match("(.+)\\.\\d+\\.[HR]$", tag("gtfs:shape_id")), 1))],
     368relation[gtfs:trip_id       ][!gtfs:route_id][!gtfs:shape_id][!(parent_tag("gtfs:route_id") == get(regexp_match("^\\d+\\.T[023A]\\.(.+)\\.\\d+\\.[HR]$", tag("gtfs:trip_id")), 1))],
     369relation[gtfs:trip_id:sample][!gtfs:route_id][!gtfs:shape_id][!(parent_tag("gtfs:route_id") == get(regexp_match("^\\d+\\.T[023A]\\.(.+)\\.\\d+\\.[HR]$", tag("gtfs:trip_id:sample")), 1))]{
    365370  throwWarning:  tr("`{0}` conflicts with `gtfs:route_id=*` of the `route_master` relation.", "{0.tag}");
    366371/*  throwWarning:  tr("`{0}` differs to `route_id={1}` of the `route_master` relation.", "{0.tag}", "{1.value}"); */