summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-12-21 14:49:06 +0100
committerDaniel Friesel <derf@finalrewind.org>2020-12-21 14:49:06 +0100
commit8285eeaf7d46a2b50e169df2690ae2e990e2c517 (patch)
tree4ff1a3007ae6e3b6c1053f0bb02dccfdb8df6d12
parent6a7fd1692a9a94e6209b0a34b9a6552ee4d22b4e (diff)
use objects in wagon list
-rw-r--r--README.md50
-rwxr-xr-xbin/db-zugbildung-to-json7
2 files changed, 31 insertions, 26 deletions
diff --git a/README.md b/README.md
index 5b7a57e..d7e142f 100644
--- a/README.md
+++ b/README.md
@@ -27,7 +27,8 @@ Graphical cycle maps are available on
This README documents **version 0** of the format. It is not stable yet; data
layout or semantic changes may not be reflected in the version number.
-Starting with v1, schema and semantics will be stable.
+Starting with v1, schema and semantics will be stable. See also the
+[OpenAPI spec](https://lib.finalrewind.org/dbdb/db_zugbildung_v0.yml).
```js
{
@@ -248,30 +249,29 @@ expressions and may miss rarely used wagon types.
```js
{
"wagons": [
- [
- "DBpbzfa",
- "1"
- ],
- [
- "DBpza",
- "2"
- ],
- [
- "DBpza",
- "3"
- ],
- [
- "DBpza",
- "4"
- ],
- [
- "DApza",
- "5"
- ],
- [
- "147.5",
- null
- ]
+ {
+ "type": "DBpbzfa",
+ "number": 1
+ },
+ {
+ "type": "DBpza",
+ "number": 2
+ },
+ {
+ "type": "DBpza",
+ "number": 3
+ },
+ {
+ "type": "DBpza",
+ "number": 4
+ },
+ {
+ "type": "DApza",
+ "number": 5
+ },
+ {
+ type: "147.5",
+ }
]
}
```
diff --git a/bin/db-zugbildung-to-json b/bin/db-zugbildung-to-json
index f5439d1..849d685 100755
--- a/bin/db-zugbildung-to-json
+++ b/bin/db-zugbildung-to-json
@@ -574,7 +574,12 @@ for my $train_number ( keys %map ) {
for my $wagon ( @{ $wagon_map{$train_number} // [] } ) {
my ( $wagon_type, $wagon_number ) = @{$wagon};
- push( @{ $map{$train_number}{wagons} }, $wagon );
+ my $json_wagon = { type => $wagon_type };
+ if ($wagon_number) {
+ $json_wagon->{number} = 0 + $wagon_number;
+ }
+
+ push( @{ $map{$train_number}{wagons} }, $json_wagon );
if ( $wagon_type =~ m{ 40[1-9] | 14[67] }x ) {
next;