Updated path schema to 2022.05
parent
a752987b34
commit
f10d20b0b1
57
src/types.jl
57
src/types.jl
|
@ -110,6 +110,7 @@ end #struct Settings
|
|||
|
||||
Path is a datastruture for calculation context.
|
||||
The function Path() will create a running path for the train.
|
||||
Supported formats are: railtoolkit/schema (2022.05)
|
||||
|
||||
# Example
|
||||
```jldoctest
|
||||
|
@ -141,11 +142,37 @@ struct Path
|
|||
## load from file
|
||||
if type == :YAML
|
||||
|
||||
path = YAML.load(open(file))["path"]
|
||||
data = YAML.load(open(file))
|
||||
if data["schema"] != "https://railtoolkit.org/schema/running-path.json"
|
||||
error("Could not load path file '$file'.\n
|
||||
YAML format is not recognized.
|
||||
Currently supported: railtoolkit/schema/running-path (2022.05)")
|
||||
end
|
||||
if data["schema_schema"] != "2022.05"
|
||||
error("Could not load path file '$file'.\n
|
||||
YAML format is not recognized.
|
||||
Currently supported: railtoolkit/schema/running-path (2022.05)")
|
||||
end
|
||||
|
||||
## JSON schema for YAML-file validation
|
||||
railtoolkit_schema = Schema("""{
|
||||
"required": [ "schema", "schema_version", "paths" ],
|
||||
"properties": {
|
||||
"schema": {
|
||||
"description": "Identifier of the schema",
|
||||
"enum": [ "https://railtoolkit.org/schema/running-path.json" ]
|
||||
},
|
||||
"schema_version": {
|
||||
"description": "Version of the schema",
|
||||
"type": "string",
|
||||
"pattern": "[2-9][0-9][0-9][0-9].[0-1][0-9]"
|
||||
},
|
||||
"paths": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"required": [ "name", "id", "characteristic_sections" ],
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"characteristic_sections": {
|
||||
"description": "",
|
||||
|
@ -158,9 +185,19 @@ struct Path
|
|||
"maxItems": 3,
|
||||
"description": "",
|
||||
"prefixItems": [
|
||||
{ "type": "number" },
|
||||
{ "type": "number" },
|
||||
{ "type": "number" }
|
||||
{
|
||||
"description": "milage in meter",
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"description": "speed in kilometers per hour",
|
||||
"type": "number",
|
||||
"exclusiveMinimum": 0
|
||||
},
|
||||
{
|
||||
"description": "resistance in permil",
|
||||
"type": "number"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@ -194,15 +231,23 @@ struct Path
|
|||
"format": "uuid"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}""")
|
||||
|
||||
paths = data["paths"]
|
||||
try
|
||||
validate(railtoolkit_schema, path)
|
||||
validate(railtoolkit_schema, paths)
|
||||
catch err
|
||||
error("Could not load path file '$file'.\n
|
||||
YAML format is not recognized.
|
||||
Currently supported: railtoolkit/schema (2022.04)")
|
||||
Currently supported: railtoolkit/schema/running-path (2022.05)")
|
||||
end
|
||||
if length(paths) > 1
|
||||
println("WARNING: the loaded file contains more than one path. Using only the first!")
|
||||
end
|
||||
path = paths[1]
|
||||
|
||||
## set the variables if they exist in "settings"
|
||||
# required
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
%YAML 1.2
|
||||
---
|
||||
path:
|
||||
name: "10 km, no gradient, 160 km/h"
|
||||
schema: https://railtoolkit.org/schema/running-path.json
|
||||
schema_version: "2022.05"
|
||||
paths:
|
||||
- name: "10 km, no gradient, 160 km/h"
|
||||
id: const
|
||||
UUID: 23ff336e-9b9a-4535-bdb6-9db488b10945
|
||||
points_of_interest:
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
%YAML 1.2
|
||||
---
|
||||
path:
|
||||
name: "'infra_Ostsachsen': track id='tr_80.6212_2' name='DG-DN' -> spp_5"
|
||||
schema: https://railtoolkit.org/schema/running-path.json
|
||||
schema_version: "2022.05"
|
||||
paths:
|
||||
- name: "'infra_Ostsachsen': track id='tr_80.6212_2' name='DG-DN' -> spp_5"
|
||||
id: realworld
|
||||
UUID: 2b31a0c5-85bc-4721-b7e0-66f9df95f7b6
|
||||
# source: https://www.railml.org/en/user/exampledata.html
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
%YAML 1.2
|
||||
---
|
||||
path:
|
||||
name: "10 km, different gradient, 160 km/h"
|
||||
schema: https://railtoolkit.org/schema/running-path.json
|
||||
schema_version: "2022.05"
|
||||
paths:
|
||||
- name: "10 km, different gradient, 160 km/h"
|
||||
id: slope
|
||||
UUID: ffd243a9-0223-4210-8c7d-e6c90fde70d3
|
||||
points_of_interest:
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
%YAML 1.2
|
||||
---
|
||||
path:
|
||||
name: "10 km, no gradient, different speed limits"
|
||||
schema: https://railtoolkit.org/schema/running-path.json
|
||||
schema_version: "2022.05"
|
||||
paths:
|
||||
- name: "10 km, no gradient, different speed limits"
|
||||
id: speed
|
||||
UUID: 401b8ce7-fa75-4576-8a4a-43be2eb55e50
|
||||
points_of_interest:
|
||||
|
|
Loading…
Reference in New Issue