Skip to content

Commit

Permalink
Show multiple types of signals on same node (#189)
Browse files Browse the repository at this point in the history
Part of #187

Part of #141

---

unsolved problems:
- ~UI should know which types of signals exist~
- ~hover for icons does not work with `text-field` with `format`
structure~
- ~if `text-field` is not used, stacking of signals somehow has to be
done manually (take width/height into account)~
- ~with `text-field`, either all text overlaps (because icons can
overlap), or labels have to be put into separate layer (text labels are
optional)~
- ~define ordering of importance of signals~

~Current state: main and distant signals combined~

---

Changes:
- Merge the all railway signal features into a single file
- Update the `signals_with_azimuth` table to contain a column per type
of feature
- The signal views get the responsibility of filtering signals and
ordering them in relative priority
- Show deactivated signals for speed and electrification layers


![image](https://github.com/user-attachments/assets/11f5a433-f6c1-4e64-b90f-33f78544d322)



At most 5 signals on one pole can be combined.



(Oberhausen, Germany,
http://localhost:8000/#view=16.77/51.474918/6.851609&style=signals)

![image](https://github.com/user-attachments/assets/77b187f2-794a-4015-a2ef-537527efce31)
  • Loading branch information
hiddewie authored Dec 29, 2024
1 parent afb1a55 commit bcdee55
Show file tree
Hide file tree
Showing 14 changed files with 2,301 additions and 2,218 deletions.
137 changes: 64 additions & 73 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,110 +14,101 @@ The file contains a list of train protection systems, each with a code, a legend

At the top of the file, add an entry for the legend, For example:
```yaml
signals_railway_line:
train_protections:
# ...
- { train_protection: 'new', legend: 'Description about this new train protection system', color: '#abc123' }
# ...
train_protections:
# ...
- { train_protection: 'new', legend: 'Description about this new train protection system', color: '#abc123' }
# ...
```

In the body of the file, add a new entry at a certain place in the list. The `rank` should match the ordering of the entries. The value of `train_protection` should match the value in the legend entries. For example:
```yaml
signals_railway_line:
features:
# ...
features:
# ...

- train_protection: new
tags:
- { tag: 'railway:new', value: 'yes' }
- train_protection: new
tags:
- { tag: 'railway:new', value: 'yes' }

# ...
# ...
```

Open a pull request where you provide details about the new train protection system. Ensure the pull request contains references to documentation and places on the map where the train protection system exists.

## I want to visualize a new railway signal

Railway signals are present on three layers. Find and edit the relevant file:
- Speed: [`features/speed_railway_signals.yaml`](https://github.com/hiddewie/OpenRailwayMap-vector/edit/master/features/speed_railway_signals.yaml)
- Train protection: [`features/signals_railway_signals.yaml`](https://github.com/hiddewie/OpenRailwayMap-vector/edit/master/features/signals_railway_signals.yaml)
- Electrification: [`features/electrification_signals.yaml`](https://github.com/hiddewie/OpenRailwayMap-vector/edit/master/features/electrification_signals.yaml)
Railway signals are present on three layers. The features are defined in a YAML file [`features/signals_railway_signals.yaml`](https://github.com/hiddewie/OpenRailwayMap-vector/edit/master/features/signals_railway_signals.yaml).

The file contains a list of train protection systems, each with a code, a legend and a color.

In the body of the file, add a new entry for the new railway signal. The signals are grouped by country. Every signal has a description, a set of tags and an icon. The icon can optionally have a `match` caluse to match tag values to render the feature differently based on the matched tag value.
In the body of the file, add a new entry for the new railway signal. The signals are grouped by country. Every signal has a description, a set of tags and an icon. The icon can optionally have a `match` clause to match tag values to render the feature differently based on the matched tag value.

For example, to match railway signals with tags `railway:signal:shunting=AT-V2:verschubhalttafel` and `railway:signal:shunting:form=sign` with icon `de/ra10`:
```yaml
signals_railway_signals:
features:
# ...

- description: Verschubhalttafel
country: AT
icon: { default: 'at/verschubhalttafel' }
tags:
- { tag: 'railway:signal:shunting', value: 'AT-V2:verschubhalttafel' }
- { tag: 'railway:signal:shunting:form', value: 'sign' }

# ...
features:
# ...

- description: Verschubhalttafel
country: AT
icon: { default: 'at/verschubhalttafel' }
tags:
- { tag: 'railway:signal:shunting', value: 'AT-V2:verschubhalttafel' }
- { tag: 'railway:signal:shunting:form', value: 'sign' }

# ...
```

A more complicated example where the different forms of features with tags `railway:signal:main=AT-V2:hauptsignal` and `railway:signal:main:form=semaphore` are rendered with different icons, based on the value of the `railway:signal:main:states` tag. Each of the cases will be matched as a [regular expression](https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-POSIX-REGEXP) against the tag value. These variants of the icon will also be shown in the legend, described by the `description` of each of the cases:
```yaml
signals_railway_signals:
features:
# ...

- description: Hauptsignal (semaphore)
country: AT
icon:
match: 'railway:signal:main:states'
cases:
- regex: '^(.*;)?AT-V2:frei_mit_(4|2)0(;.*)?$'
value: 'at/hp2-semaphore'
description: '20/40 km/h'
- regex: '^(.*;)?AT-V2:frei(;.*)?$'
value: 'at/hp1-semaphore'
description: 'clear'
default: 'de/hp0-semaphore'
tags:
- { tag: 'railway:signal:main', value: 'AT-V2:hauptsignal' }
- { tag: 'railway:signal:main:form', value: 'semaphore' }

# ...
features:
# ...

- description: Hauptsignal (semaphore)
country: AT
icon:
match: 'railway:signal:main:states'
cases:
- regex: '^(.*;)?AT-V2:frei_mit_(4|2)0(;.*)?$'
value: 'at/hp2-semaphore'
description: '20/40 km/h'
- regex: '^(.*;)?AT-V2:frei(;.*)?$'
value: 'at/hp1-semaphore'
description: 'clear'
default: 'de/hp0-semaphore'
tags:
- { tag: 'railway:signal:main', value: 'AT-V2:hauptsignal' }
- { tag: 'railway:signal:main:form', value: 'semaphore' }

# ...
```

A final example for speed signals which display an icon depending on the matched speed value. The `value` property contains `{}` as part of the icon, which is replaced automatically with the matched tag value. In particular an `example` must be given, which is used in the legend:

```yaml
speed_railway_signals:
features:
# ...

- description: Geschwindigkeitsvoranzeiger (sign)
country: AT
icon:
match: 'railway:signal:speed_limit_distant:speed'
cases:
- regex: '^(1[02]|[1-9])0$'
value: 'at/geschwindigkeitsvoranzeiger-{}-sign'
example: 'at/geschwindigkeitsvoranzeiger-80-sign'
default: 'at/geschwindigkeitsvoranzeiger-empty-sign'
tags:
- { tag: 'railway:signal:speed_limit_distant', value: 'AT-V2:geschwindigkeitsvoranzeiger' }
- { tag: 'railway:signal:speed_limit_distant:form', value: 'sign' }

# ...
features:
# ...

- description: Geschwindigkeitsvoranzeiger (sign)
country: AT
icon:
match: 'railway:signal:speed_limit_distant:speed'
cases:
- regex: '^(1[02]|[1-9])0$'
value: 'at/geschwindigkeitsvoranzeiger-{}-sign'
example: 'at/geschwindigkeitsvoranzeiger-80-sign'
default: 'at/geschwindigkeitsvoranzeiger-empty-sign'
tags:
- { tag: 'railway:signal:speed_limit_distant', value: 'AT-V2:geschwindigkeitsvoranzeiger' }
- { tag: 'railway:signal:speed_limit_distant:form', value: 'sign' }

# ...
```

If the railway signal uses tags that are not in the list at the top of the file, ensure the tag is added there. For example:
```yaml
signals_railway_signals:
tags:
# ...
- 'railway:signal:combined:form'
# ...
tags:
# ...
- 'railway:signal:combined:form'
# ...
```

Next, ensure the icon exists in the [symbols directory](https://github.com/hiddewie/OpenRailwayMap-vector/tree/master/symbols). The icon must be an SVG file, minified and of the correct dimensions (most icons are between 10 and 24 pixels wide / high).
Expand Down
Loading

0 comments on commit bcdee55

Please sign in to comment.