Skip to content

Commit

Permalink
support of 'colour:text' in route_master and route relations
Browse files Browse the repository at this point in the history
  • Loading branch information
osm-ToniE committed Jan 29, 2025
1 parent 4e81158 commit 9688618
Show file tree
Hide file tree
Showing 23 changed files with 439 additions and 175 deletions.
58 changes: 33 additions & 25 deletions bin/ptna-routes.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,7 @@
'operator' => $relation_ptr->{'tag'}->{'operator'}, # take 'operator' value from first relation, undef outside this for-loop
'pt_type' => $entryref->{'route'},
'colour' => $relation_ptr->{'tag'}->{'colour'}, # take 'colour' value from first relation, undef outside this for-loop
'colour:text' => $relation_ptr->{'tag'}->{'colour:text'}, # take 'colour:text' value from first relation, undef outside this for-loop
'CSV-Comment' => $entryref->{'comment'},
'CSV-From' => $entryref->{'from'},
'CSV-From-List' => $entryref->{'from-list'},
Expand Down Expand Up @@ -1804,7 +1805,7 @@ sub SearchMatchingRelations {
$RelFrom = $RELATIONS{$rel_id}->{'tag'}->{'from'} || '';
$RelTo = $RELATIONS{$rel_id}->{'tag'}->{'to'} || '';
$RelVia = $RELATIONS{$rel_id}->{'tag'}->{'via'} || '';
$RelColour = $RELATIONS{$rel_id}->{'tag'}->{'to'} || '';
$RelColour = $RELATIONS{$rel_id}->{'tag'}->{'colour'} || '';

printf STDERR "%s Checking %s relation %s, 'ref' %s and 'operator' %s \n", get_time(), $type, $rel_id, $ExpRefPart, $RelOperator if ( $debug );

Expand Down Expand Up @@ -2331,19 +2332,21 @@ sub analyze_route_environment {
push( @{$relation_ptr->{'__issues__'}}, sprintf( $issues_string, handle_foreign($relation_ptr->{'tag'}->{'operator'}), handle_foreign($RELATIONS{$route_master_rel_id}->{'tag'}->{'operator'}), printRelationTemplate($route_master_rel_id)) );
}
}
if ( $relation_ptr->{'tag'}->{'colour'} ) {
if ( $RELATIONS{$route_master_rel_id}->{'tag'}->{'colour'} ) {
if ( uc($relation_ptr->{'tag'}->{'colour'}) ne uc($RELATIONS{$route_master_rel_id}->{'tag'}->{'colour'}) ) {
$issues_string = gettext( "'%s' = '%s' of Route does not fit to '%s' = '%s' of Route-Master: %s" );
push( @{$relation_ptr->{'__issues__'}}, sprintf( $issues_string, 'colour', $relation_ptr->{'tag'}->{'colour'}, 'colour', $RELATIONS{$route_master_rel_id}->{'tag'}->{'colour'}, printRelationTemplate($route_master_rel_id)) );
foreach my $colour_tag ( 'colour', 'colour:text' ) {
if ( $relation_ptr->{'tag'}->{$colour_tag} ) {
if ( $RELATIONS{$route_master_rel_id}->{'tag'}->{$colour_tag} ) {
if ( uc($relation_ptr->{'tag'}->{$colour_tag}) ne uc($RELATIONS{$route_master_rel_id}->{'tag'}->{$colour_tag}) ) {
$issues_string = gettext( "'%s' = '%s' of Route does not fit to '%s' = '%s' of Route-Master: %s" );
push( @{$relation_ptr->{'__issues__'}}, sprintf( $issues_string, $colour_tag, $relation_ptr->{'tag'}->{$colour_tag}, $colour_tag, $RELATIONS{$route_master_rel_id}->{'tag'}->{$colour_tag}, printRelationTemplate($route_master_rel_id)) );
}
} else {
$issues_string = gettext( "'%s' = '%s' of Route is set but '%s' of Route-Master is not set: %s" );
push( @{$relation_ptr->{'__issues__'}}, sprintf( $issues_string, , $colour_tag, handle_foreign($relation_ptr->{'tag'}->{$colour_tag}), $colour_tag, printRelationTemplate($route_master_rel_id)) );
}
} else {
$issues_string = gettext( "'%s' = '%s' of Route is set but '%s' of Route-Master is not set: %s" );
push( @{$relation_ptr->{'__issues__'}}, sprintf( $issues_string, , 'colour', $relation_ptr->{'tag'}->{'colour'}, 'colour', printRelationTemplate($route_master_rel_id)) );
} elsif ( $RELATIONS{$route_master_rel_id}->{'tag'}->{$colour_tag} ) {
$issues_string = gettext( "'%s' of Route is not set but '%s' = '%s' of Route-Master is set: %s" );
push( @{$relation_ptr->{'__issues__'}}, sprintf( $issues_string, $colour_tag, $colour_tag, $RELATIONS{$route_master_rel_id}->{'tag'}->{$colour_tag}, printRelationTemplate($route_master_rel_id)) );
}
} elsif ( $RELATIONS{$route_master_rel_id}->{'tag'}->{'colour'} ) {
$issues_string = gettext( "'%s' of Route is not set but '%s' = '%s' of Route-Master is set: %s" );
push( @{$relation_ptr->{'__issues__'}}, sprintf( $issues_string, 'colour', 'colour', $RELATIONS{$route_master_rel_id}->{'tag'}->{'colour'}, printRelationTemplate($route_master_rel_id)) );
}

#
Expand Down Expand Up @@ -2671,15 +2674,17 @@ sub analyze_relation {
push( @{$relation_ptr->{'__issues__'}}, $issues_string );
}

if ( $relation_ptr->{'tag'}->{'colour'} ) {
my $colour = GetColourFromString( $relation_ptr->{'tag'}->{'colour'} );
unless ( $colour ) {
if ( $relation_ptr->{'tag'}->{'colour'} =~ m/^[0-9A-Fa-f]{3,6}$/ ) {
$issues_string = gettext( "'colour' has unknown value '%s'. Add '#' as first character." );
push( @{$relation_ptr->{'__issues__'}}, sprintf( $issues_string, html_escape($relation_ptr->{'tag'}->{'colour'}) ) );
} else {
$issues_string = gettext( "'colour' has unknown value '%s'. Choose one of the 140 well defined HTML/CSS colour names or the HTML Hex colour codes '#...' or '#......'." );
push( @{$relation_ptr->{'__issues__'}}, sprintf( $issues_string, handle_foreign($relation_ptr->{'tag'}->{'colour'}) ) );
foreach my $colour_tag ( 'colour', 'colour:text' ) {
if ( $relation_ptr->{'tag'}->{$colour_tag} ) {
my $colour = GetColourFromString( $relation_ptr->{'tag'}->{$colour_tag} );
unless ( $colour ) {
if ( $relation_ptr->{'tag'}->{$colour_tag} =~ m/^[0-9A-Fa-f]{3,6}$/ ) {
$issues_string = gettext( "'%s' has unknown value '%s'. Add '#' as first character." );
push( @{$relation_ptr->{'__issues__'}}, $colour_tag, sprintf( $issues_string, html_escape($relation_ptr->{'tag'}->{$colour_tag}) ) );
} else {
$issues_string = gettext( "'%s' has unknown value '%s'. Choose one of the 140 well defined HTML/CSS colour names or the HTML Hex colour codes '#...' or '#......'." );
push( @{$relation_ptr->{'__issues__'}}, sprintf( $issues_string, $colour_tag, handle_foreign($relation_ptr->{'tag'}->{$colour_tag}) ) );
}
}
}
}
Expand Down Expand Up @@ -6794,6 +6799,7 @@ sub printTableSubHeader {
my $operator = $hash{'operator'} || '';
my $pt_type = $hash{'pt_type'} || '';
my $colour = $hash{'colour'} || '';
my $text_colour = $hash{'colour:text'} || '';
my $ref_text = undef;
my $csv_text = ''; # some information comming from the CSV input file
my $info = '';
Expand All @@ -6811,7 +6817,7 @@ sub printTableSubHeader {
}

if ( scalar @ref_or_array ) {
$ref_text = join(' ', map { printSketchLineTemplate( $_, $network, $operator, $pt_type, $colour ) } @ref_or_array );
$ref_text = join(' ', map { printSketchLineTemplate( $_, $network, $operator, $pt_type, $colour, $text_colour ) } @ref_or_array );
}

if ( scalar @ref_or_array && $pt_type ) {
Expand All @@ -6826,7 +6832,7 @@ sub printTableSubHeader {
$nav_label = $id_label;
}
$id_string = sprintf( "id=\"%s\" ", $nav_label );
printAddIdLabelToLocalNavigation( $nav_label, join(' ',@ref_or_array), $colour );
printAddIdLabelToLocalNavigation( $nav_label, join(' ',@ref_or_array), $colour, $text_colour );
}

if ( $hash{'CSV-Comment'} ) {
Expand Down Expand Up @@ -7121,6 +7127,7 @@ sub printSketchLineTemplate {
my $operator = shift || '';
my $pt_type = shift || '';
my $colour = shift || '';
my $text_colour = shift || '';
my $text = undef;
my $colour_string = '';
my $pt_string = '';
Expand All @@ -7131,7 +7138,7 @@ sub printSketchLineTemplate {
my $outer_span_end = '';
my $inner_span_end = '';
my $bg_colour = GetColourFromString( $colour );
my $fg_colour = GetForeGroundFromBackGround( $bg_colour );
my $fg_colour = ($text_colour ne '') ? GetColourFromString($text_colour) : GetForeGroundFromBackGround($bg_colour);

if ( $bg_colour && $fg_colour && $coloured_sketchline ) {
$colour_string = "&bg=" . uri_escape($bg_colour) . "&fg=". uri_escape($fg_colour);
Expand Down Expand Up @@ -7159,11 +7166,12 @@ sub printAddIdLabelToLocalNavigation {
my $id_label = shift;
my $visible_string = shift;
my $colour = shift;
my $text_colour = shift || '';

if ( !$no_additional_navigation && $local_navigation_at_index && $id_label && $visible_string ne '' ) {

my $bg_colour = GetColourFromString( $colour );
my $fg_colour = GetForeGroundFromBackGround( $bg_colour );
my $fg_colour = ($text_colour ne '') ? GetColourFromString($text_colour) : GetForeGroundFromBackGround($bg_colour);
my $outer_span_begin = '';
my $inner_span_begin = '';
my $outer_span_end = '';
Expand Down
Binary file modified locale/ca/LC_MESSAGES/ptna.mo
Binary file not shown.
Binary file modified locale/de/LC_MESSAGES/ptna.mo
Binary file not shown.
Binary file modified locale/es/LC_MESSAGES/ptna.mo
Binary file not shown.
Binary file modified locale/fr/LC_MESSAGES/ptna.mo
Binary file not shown.
Binary file modified locale/hu/LC_MESSAGES/ptna.mo
Binary file not shown.
Binary file modified locale/it/LC_MESSAGES/ptna.mo
Binary file not shown.
Binary file modified locale/pl_PL/LC_MESSAGES/ptna.mo
Binary file not shown.
Binary file modified locale/pt_BR/LC_MESSAGES/ptna.mo
Binary file not shown.
Binary file modified locale/sr/LC_MESSAGES/ptna.mo
Binary file not shown.
8 changes: 4 additions & 4 deletions modules/PtnaStrings.pm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ sub InitMessageStrings {
$MessageHash{$MessageList[$i]->{'message'}} = $i;

$i++;
$MessageList[$i]->{'message'} = gettext( "'colour' has unknown value '%s'. Add '#' as first character." );
$MessageList[$i]->{'message'} = gettext( "'%s' has unknown value '%s'. Add '#' as first character." );
$MessageList[$i]->{'type'} = gettext( "Errors" );
$MessageList[$i]->{'option'} = "";
$MessageList[$i]->{'description'} = "";
Expand All @@ -52,7 +52,7 @@ sub InitMessageStrings {
$MessageHash{$MessageList[$i]->{'message'}} = $i;

$i++;
$MessageList[$i]->{'message'} = gettext( "'colour' has unknown value '%s'. Choose one of the 140 well defined HTML/CSS colour names or the HTML Hex colour codes '#...' or '#......'." );
$MessageList[$i]->{'message'} = gettext( "'%s' has unknown value '%s'. Choose one of the 140 well defined HTML/CSS colour names or the HTML Hex colour codes '#...' or '#......'." );
$MessageList[$i]->{'type'} = gettext( "Errors" );
$MessageList[$i]->{'option'} = "";
$MessageList[$i]->{'description'} = "";
Expand All @@ -61,7 +61,7 @@ sub InitMessageStrings {
$MessageHash{$MessageList[$i]->{'message'}} = $i;

$i++;
$MessageList[$i]->{'message'} = gettext( "'colour' of Route is not set but 'colour' of Route-Master is set: %s" );
$MessageList[$i]->{'message'} = gettext( "'%s' of Route is not set but '%s' of Route-Master is set: %s" );
$MessageList[$i]->{'type'} = gettext( "Errors" );
$MessageList[$i]->{'option'} = "";
$MessageList[$i]->{'description'} = "";
Expand All @@ -70,7 +70,7 @@ sub InitMessageStrings {
$MessageHash{$MessageList[$i]->{'message'}} = $i;

$i++;
$MessageList[$i]->{'message'} = gettext( "'colour' of Route is set but 'colour' of Route-Master is not set: %s" );
$MessageList[$i]->{'message'} = gettext( "'%s' of Route is set but '%s' of Route-Master is not set: %s" );
$MessageList[$i]->{'type'} = gettext( "Errors" );
$MessageList[$i]->{'option'} = "";
$MessageList[$i]->{'description'} = "";
Expand Down
26 changes: 12 additions & 14 deletions po/ca.po
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ptna 2.0.2\n"
"Report-Msgid-Bugs-To: osm-ToniE@web.de\n"
"POT-Creation-Date: 2025-01-05 14:34+0100\n"
"POT-Creation-Date: 2025-01-29 15:02+0100\n"
"PO-Revision-Date: 2019-04-05 14:25+0000\n"
"Last-Translator: Carlos Sánchez López <erielkhan@gmail.com>, 2024\n"
"Language-Team: Catalan (https://app.transifex.com/jungle-bus/teams/97874/ca/)\n"
Expand Down Expand Up @@ -428,18 +428,14 @@ msgid "'network' is not set"
msgstr "No s'ha definit 'network'"

#, perl-format
msgid "'colour' has unknown value '%s'. Add '#' as first character."
msgid "'%s' has unknown value '%s'. Add '#' as first character."
msgstr ""
"L'etiqueta 'colour' té un valor no reconegut '%s'. Afegeix '#' com a primer "
"caràcter."

#, perl-format
msgid ""
"'colour' has unknown value '%s'. Choose one of the 140 well defined HTML/CSS"
" colour names or the HTML Hex colour codes '#...' or '#......'."
"'%s' has unknown value '%s'. Choose one of the 140 well defined HTML/CSS "
"colour names or the HTML Hex colour codes '#...' or '#......'."
msgstr ""
"'colour' té un valor desconegut '%s'. Escull un dels 140 noms de color "
"definits HTML/CSS o el codi de color HTML Hex '#000' o '#000000'."

msgid "'network:long' is long form"
msgstr "'network:long' és la forma llarga"
Expand All @@ -463,6 +459,12 @@ msgstr ""
"L'etiqueta 'line' (='%s') està reservada per a etiquetatge relacionat amb "
"'power' = 'line'. Per a quan es fa ús de 'route_master' o 'route'."

#, perl-format
msgid ""
"The tag 'public_transport' (='%s') is not defined for 'route_master' and "
"'route' relations. Do you mean 'public_transport:version'='2'?"
msgstr ""

#, perl-format
msgid "The tag '%s' has an empty value."
msgstr "L'etiqueta '%s' té un valor buit."
Expand Down Expand Up @@ -1366,16 +1368,12 @@ msgid ""
msgstr "'%s' = '%s' inclou el separador ';' (punt i coma) amb espais en blanc"

#, perl-format
msgid "'colour' of Route is not set but 'colour' of Route-Master is set: %s"
msgid "'%s' of Route is not set but '%s' of Route-Master is set: %s"
msgstr ""
"L'etiqueta 'colour' de la Ruta no es troba definida però si el 'colour' de "
"la Ruta Mestra: %s"

#, perl-format
msgid "'colour' of Route is set but 'colour' of Route-Master is not set: %s"
msgid "'%s' of Route is set but '%s' of Route-Master is not set: %s"
msgstr ""
"'colour' de la Route es troba definit però 'colour' del Route-Master no es "
"troba definit: %s"

#, perl-format
msgid ""
Expand Down
22 changes: 10 additions & 12 deletions po/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ptna 2.0.2\n"
"Report-Msgid-Bugs-To: osm-ToniE@web.de\n"
"POT-Creation-Date: 2025-01-28 17:37+0100\n"
"POT-Creation-Date: 2025-01-29 15:02+0100\n"
"PO-Revision-Date: 2019-04-05 14:25+0000\n"
"Last-Translator: ToniE <osm-ToniE@web.de>, 2025\n"
"Language-Team: German (https://app.transifex.com/jungle-bus/teams/97874/de/)\n"
Expand Down Expand Up @@ -434,16 +434,16 @@ msgid "'network' is not set"
msgstr "'network' ist nicht gesetzt"

#, perl-format
msgid "'colour' has unknown value '%s'. Add '#' as first character."
msgid "'%s' has unknown value '%s'. Add '#' as first character."
msgstr ""
"'colour' hat einen unbekannten Wert '%s'. Füge '#' als erstes Zeichen hinzu."
"'%s' hat einen unbekannten Wert '%s'. Füge '#' als erstes Zeichen hinzu."

#, perl-format
msgid ""
"'colour' has unknown value '%s'. Choose one of the 140 well defined HTML/CSS"
" colour names or the HTML Hex colour codes '#...' or '#......'."
"'%s' has unknown value '%s'. Choose one of the 140 well defined HTML/CSS "
"colour names or the HTML Hex colour codes '#...' or '#......'."
msgstr ""
"'colour' hat einen unbekannten Wert '%s'. Wähle einen der 140 definierten "
"'%s' hat einen unbekannten Wert '%s'. Wähle einen der 140 definierten "
"HTML/CSS Farbnamen oder den HTML Hex Farben Code '#...' oder '#......'."

msgid "'network:long' is long form"
Expand Down Expand Up @@ -1412,16 +1412,14 @@ msgstr ""
"Leerzeichen"

#, perl-format
msgid "'colour' of Route is not set but 'colour' of Route-Master is set: %s"
msgid "'%s' of Route is not set but '%s' of Route-Master is set: %s"
msgstr ""
"'colour' der Route ist nicht gesetzt aber 'colour' des Route-Masters ist "
"gesetzt: %s"
"'%s' der Route ist nicht gesetzt aber '%s' des Route-Masters ist gesetzt: %s"

#, perl-format
msgid "'colour' of Route is set but 'colour' of Route-Master is not set: %s"
msgid "'%s' of Route is set but '%s' of Route-Master is not set: %s"
msgstr ""
"'colour' der Route ist gesetzt aber 'colour' des Route-Masters ist nicht "
"gesetzt: %s"
"'%s' der Route ist gesetzt aber '%s' des Route-Masters ist nicht gesetzt: %s"

#, perl-format
msgid ""
Expand Down
26 changes: 12 additions & 14 deletions po/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ptna 2.0.2\n"
"Report-Msgid-Bugs-To: osm-ToniE@web.de\n"
"POT-Creation-Date: 2025-01-05 14:34+0100\n"
"POT-Creation-Date: 2025-01-29 15:02+0100\n"
"PO-Revision-Date: 2019-04-05 14:25+0000\n"
"Last-Translator: ToniE <osm-ToniE@web.de>, 2023\n"
"Language-Team: Spanish (https://app.transifex.com/jungle-bus/teams/97874/es/)\n"
Expand Down Expand Up @@ -430,18 +430,14 @@ msgid "'network' is not set"
msgstr "'network' no está establecido"

#, perl-format
msgid "'colour' has unknown value '%s'. Add '#' as first character."
msgid "'%s' has unknown value '%s'. Add '#' as first character."
msgstr ""
"'colour' tiene el valor desconocido '%s'. Añade '#' como primer carácter."

#, perl-format
msgid ""
"'colour' has unknown value '%s'. Choose one of the 140 well defined HTML/CSS"
" colour names or the HTML Hex colour codes '#...' or '#......'."
"'%s' has unknown value '%s'. Choose one of the 140 well defined HTML/CSS "
"colour names or the HTML Hex colour codes '#...' or '#......'."
msgstr ""
"'colour' tiene el valor desconocido '%s'. Escoge uno de los 140 nombres de "
"color HTML/CSS bien definidos o los códigos hexadecimales de color '#...' o "
"'#......'"

msgid "'network:long' is long form"
msgstr "'network:long' es la forma larga"
Expand All @@ -465,6 +461,12 @@ msgstr ""
"La etiqueta 'line'(='%s') se reserva para etiquetado relacionado con "
"'power'='line'. Para transporte público, se usan 'route_master' y 'route'."

#, perl-format
msgid ""
"The tag 'public_transport' (='%s') is not defined for 'route_master' and "
"'route' relations. Do you mean 'public_transport:version'='2'?"
msgstr ""

#, perl-format
msgid "The tag '%s' has an empty value."
msgstr ""
Expand Down Expand Up @@ -1252,16 +1254,12 @@ msgstr ""
"lados"

#, perl-format
msgid "'colour' of Route is not set but 'colour' of Route-Master is set: %s"
msgid "'%s' of Route is not set but '%s' of Route-Master is set: %s"
msgstr ""
"No se ha establecido el 'colour' de la ruta, pero sí el 'colour' de la Ruta-"
"Maestra: %s "

#, perl-format
msgid "'colour' of Route is set but 'colour' of Route-Master is not set: %s"
msgid "'%s' of Route is set but '%s' of Route-Master is not set: %s"
msgstr ""
"Se ha establecido el 'colour' de la ruta, pero el 'colour' de la Ruta-"
"Maestra no: %s"

#, perl-format
msgid ""
Expand Down
Loading

0 comments on commit 9688618

Please sign in to comment.