Add schema validation in IDE for route map definition files

This commit is contained in:
2026-03-01 20:05:55 +00:00
parent bda2e8a0be
commit e70b55a5f0
4 changed files with 618 additions and 10 deletions

8
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,8 @@
{
"yaml.schemas": {
"./static/mapFiles/yaml/mapFiles.schema.json": "static/mapFiles/yaml/*.yaml"
},
"yaml.format.enable": true,
"yaml.validate": true,
"yaml.schemaStore.enable": false
}

View File

@@ -1,6 +1,6 @@
routeStart: Reading routeStart: Reading
routeEnd: Bristol TM routeEnd: Bristol TM
routeId: 0002 routeId: "0002"
updated: 2026-02-04 updated: 2026-02-04
checked: checked:
signallerStart: TVSC Reading WS signallerStart: TVSC Reading WS

View File

@@ -1,8 +1,9 @@
# yaml-language-server: $schema=./mapFiles.schema.json
routeStart: Gloucester routeStart: Gloucester
routeEnd: Severn Tunnel Jn routeEnd: Severn Tunnel Jn
routeId: 2421 routeId: "2421"
updated: 2026-02-28 updated: 2026-02-28
checked: checked: 2026-03-01
signallerStart: Gloucester PSB signallerStart: Gloucester PSB
signallerEnd: SWCC Severn Tunnel WS signallerEnd: SWCC Severn Tunnel WS
elecStart: elecStart:
@@ -51,6 +52,7 @@ routeDetail:
- type: minorBridge - type: minorBridge
name: St. Catherines Meadow Viaduct name: St. Catherines Meadow Viaduct
category: minorRoad
position: under position: under
miles: 115 miles: 115
chains: 2 chains: 2
@@ -64,6 +66,7 @@ routeDetail:
- type: minorBridge - type: minorBridge
name: Ham Meadow Viaduct name: Ham Meadow Viaduct
category: minorRoad
position: under position: under
miles: 115 miles: 115
chains: 20 chains: 20
@@ -77,6 +80,7 @@ routeDetail:
chains: 32 chains: 32
- type: minorBridge - type: minorBridge
category: minorRoad
position: under position: under
miles: 115 miles: 115
chains: 37 chains: 37
@@ -106,6 +110,7 @@ routeDetail:
chains: 48 chains: 48
- type: minorBridge - type: minorBridge
category: minorRoad
position: under position: under
miles: 116 miles: 116
chains: 40 chains: 40
@@ -117,6 +122,7 @@ routeDetail:
chains: 46 chains: 46
- type: minorBridge - type: minorBridge
category: minorRoad
position: under position: under
miles: 116 miles: 116
chains: 64 chains: 64
@@ -148,6 +154,7 @@ routeDetail:
chains: 48 chains: 48
- type: minorBridge - type: minorBridge
category: minorRoad
name: Farm Bridge name: Farm Bridge
position: over position: over
miles: 118 miles: 118
@@ -185,7 +192,7 @@ routeDetail:
chains: 1 chains: 1
- type: crossing - type: crossing
kind: cctv kind: CCTV
name: Ley Level Crossing name: Ley Level Crossing
description: CCTV by Gloucester description: CCTV by Gloucester
miles: 120 miles: 120
@@ -198,13 +205,14 @@ routeDetail:
chains: 49 chains: 49
- type: crossing - type: crossing
kind: R/G kind: r/g
name: Broken Cross Farm Level Crossing name: Broken Cross Farm Level Crossing
miles: 120 miles: 120
chains: 66 chains: 66
- type: minorBridge - type: minorBridge
position: over position: over
category: minorRoad
name: Grange Court Road name: Grange Court Road
miles: 121 miles: 121
chains: 50 chains: 50
@@ -244,18 +252,20 @@ routeDetail:
- type: minorBridge - type: minorBridge
name: Farm Bridge name: Farm Bridge
category: minorRoad
position: under position: under
miles: 123 miles: 123
chains: 33 chains: 33
- type: minorBridge - type: minorBridge
name: Cattle Creep name: Cattle Creep
category: minorRoad
position: under position: under
miles: 123 miles: 123
chains: 53 chains: 53
- type: crossing - type: crossing
kind: OMSL kind: omsl
name: Broadoak Crossing name: Broadoak Crossing
miles: 123 miles: 123
chains: 76 chains: 76
@@ -270,6 +280,7 @@ routeDetail:
- type: minorBridge - type: minorBridge
name: Cattle Creep name: Cattle Creep
category: minorRoad
position: under position: under
miles: 124 miles: 124
chains: 25 chains: 25
@@ -283,6 +294,7 @@ routeDetail:
- type: minorBridge - type: minorBridge
name: Cattle Creep name: Cattle Creep
category: minorRoad
position: under position: under
miles: 124 miles: 124
chains: 45 chains: 45
@@ -297,6 +309,8 @@ routeDetail:
- type: signallerChange - type: signallerChange
from: Gloucester PSB (G) from: Gloucester PSB (G)
to: SWCC Severn Tunnel Workstation (NT) to: SWCC Severn Tunnel Workstation (NT)
miles: 125
chains: 10
- type: tunnel - type: tunnel
tunnelType: whole tunnelType: whole
@@ -307,6 +321,7 @@ routeDetail:
- type: minorBridge - type: minorBridge
name: Farm Bridge name: Farm Bridge
category: minorRoad
position: over position: over
miles: 125 miles: 125
chains: 26 chains: 26
@@ -340,12 +355,14 @@ routeDetail:
- type: minorBridge - type: minorBridge
name: Farm Bridge name: Farm Bridge
category: minorRoad
position: over position: over
miles: 126 miles: 126
chains: 74 chains: 74
- type: minorBridge - type: minorBridge
name: Awre Road Cockshoot Bridge name: Awre Road Cockshoot Bridge
category: minorRoad
position: over position: over
miles: 127 miles: 127
chains: 34 chains: 34
@@ -396,6 +413,7 @@ routeDetail:
- type: minorBridge - type: minorBridge
name: Cliff Farm Bridge name: Cliff Farm Bridge
category: minorRoad
position: over position: over
miles: 131 miles: 131
chains: 79 chains: 79
@@ -458,6 +476,7 @@ routeDetail:
- type: minorBridge - type: minorBridge
name: Garlands Bridge name: Garlands Bridge
category: minorRoad
position: under position: under
miles: 134 miles: 134
chains: 26 chains: 26
@@ -505,13 +524,14 @@ routeDetail:
chains: 77 chains: 77
- type: crossing - type: crossing
kind: R/G kind: r/g
name: Woolaston Level Crossing name: Woolaston Level Crossing
miles: 136 miles: 136
chains: 14 chains: 14
- type: minorBridge - type: minorBridge
name: Farm Bridge name: Farm Bridge
category: minorRoad
position: over position: over
miles: 136 miles: 136
chains: 27 chains: 27
@@ -531,6 +551,7 @@ routeDetail:
- type: minorBridge - type: minorBridge
name: Farm Bridge name: Farm Bridge
category: minorRoad
position: under position: under
miles: 139 miles: 139
chains: 56 chains: 56
@@ -599,7 +620,7 @@ routeDetail:
chains: 15 chains: 15
- type: crossing - type: crossing
kind: OMSL kind: omsl
name: Three Gates Crossing name: Three Gates Crossing
miles: 143 miles: 143
chains: 35 chains: 35
@@ -612,12 +633,13 @@ routeDetail:
- type: minorBridge - type: minorBridge
name: Redcliffe Bridge name: Redcliffe Bridge
category: minorRoad
position: over position: over
miles: 144 miles: 144
chains: 40 chains: 40
- type: crossing - type: crossing
kind: OMSL kind: omsl
name: Mathern 21 Foot Crossing name: Mathern 21 Foot Crossing
miles: 144 miles: 144
chains: 68 chains: 68
@@ -643,13 +665,14 @@ routeDetail:
- type: minorBridge - type: minorBridge
name: Portskewett Road name: Portskewett Road
category: minorRoad
position: over position: over
miles: 146 miles: 146
chains: 32 chains: 32
- type: crossing - type: crossing
name: Caldicot Level Crossing name: Caldicot Level Crossing
kind: cctv kind: CCTV
description: CCTV by SWCC description: CCTV by SWCC
miles: 147 miles: 147
chains: 4 chains: 4
@@ -689,6 +712,7 @@ routeDetail:
- type: minorBridge - type: minorBridge
name: Ifton Tramway Underbridge name: Ifton Tramway Underbridge
category: minorRoad
position: under position: under
miles: 148 miles: 148
chains: 50 chains: 50

View File

@@ -0,0 +1,576 @@
{
"$schema": "https://json-schema.org/draft-07/schema#",
"type": "object",
"required": [
"routeStart",
"routeEnd",
"routeId",
"updated",
"signallerStart",
"signallerEnd",
"elecStart",
"elecEnd",
"routeDetail"
],
"additionalProperties": false,
"properties": {
"routeStart": {
"type": "string",
"description": "The route start point"
},
"routeEnd": {
"type": "string",
"description": "The route end point"
},
"routeId": {
"type": "string",
"description": "The routes ID Code",
"pattern": "^[0-9]{4}$"
},
"updated": {
"type": "string",
"format": "date",
"description": "Date the route was last updated"
},
"checked": {
"type": "string",
"format": "date",
"description": "Date the route was last checked for accuracy"
},
"signallerStart": {
"type": "string",
"description": "The signaller at the start of the route"
},
"signallerEnd": {
"type": "string",
"description": "The signalller at the end of the route"
},
"elecStart": {
"$ref": "#/definitions/elecInfo",
"description": "Electrification details at the route start"
},
"elecEnd": {
"$ref": "#/definitions/elecInfo",
"description": "Electrification info at the end of the route"
},
"routeDetail": {
"type": "array",
"additionalItems": false,
"items": {
"anyOf": [
{
"$ref": "#/definitions/bridge"
},
{
"$ref": "#/definitions/crossing"
},
{
"$ref": "#/definitions/crossover"
},
{
"$ref": "#/definitions/electrificationChange"
},
{
"$ref": "#/definitions/junction"
},
{
"$ref": "#/definitions/loop"
},
{
"$ref": "#/definitions/routeContinuation"
},
{
"$ref": "#/definitions/siteof"
},
{
"$ref": "#/definitions/station"
},
{
"$ref": "#/definitions/tunnel"
},
{
"$ref": "#/definitions/signallerChange"
}
]
}
}
},
"definitions": {
"elecInfo": {
"type": "object",
"properties": {
"elec": {
"type": "string",
"enum": [
"25kvac",
"750vdc",
"650vdc",
"1500vdc",
"none"
]
},
"eco": {
"type": "string"
}
},
"required": [
"elec"
]
},
"bridge": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"bridge",
"minorBridge"
]
},
"roadName": {
"type": "string"
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"position": {
"type": "string",
"enum": [
"over",
"under"
]
},
"category": {
"type": "string",
"enum": [
"road",
"aroad",
"motorway",
"foot",
"waterway",
"stream",
"rail",
"minorRoad",
"pipeline"
]
},
"miles": {
"type": "number"
},
"chains": {
"type": "number"
}
},
"required": [
"type",
"position",
"category",
"miles",
"chains"
],
"additionalProperties": false
},
"crossing": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "crossing"
},
"kind": {
"type": "string",
"enum": [
"CCTV",
"AHB",
"uwc",
"foot",
"omsl",
"r/g",
"msl",
"mcb",
"mg",
"mcg",
"aocl"
]
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"miles": {
"type": "number"
},
"chains": {
"type": "number"
}
},
"required": [
"type",
"kind",
"name",
"miles",
"chains"
],
"additionalProperties": false
},
"crossover": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "crossovers"
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"miles": {
"type": "number"
},
"chains": {
"type": "number"
}
},
"required": [
"type",
"name",
"miles",
"chains"
],
"additionalProperties": false
},
"electrificationChange": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "electrificationChange"
},
"miles": {
"type": "number"
},
"chains": {
"type": "number"
},
"from": {
"type": "object",
"properties": {
"elec": {
"type": "string",
"enum": [
"25kvac",
"750vdc",
"650vdc",
"1500vdc",
"none"
]
},
"eco": {
"type": "string"
}
},
"required": [
"elec"
],
"additionalProperties": false
},
"to": {
"type": "object",
"properties": {
"elec": {
"type": "string",
"enum": [
"25kvac",
"750vdc",
"650vdc",
"1500vdc",
"none"
]
},
"eco": {
"type": "string"
}
},
"required": [
"elec"
],
"additionalProperties": false
}
},
"required": [
"miles",
"chains"
],
"additionalProperties": false
},
"junction": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "junction"
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"diverges": {
"type": "string",
"enum": [
"left",
"right",
"both"
]
},
"direction": {
"type": "string",
"enum": [
"up",
"down",
"both"
]
},
"miles": {
"type": "number"
},
"chains": {
"type": "number"
},
"elecBranch": {
"type": "string",
"enum": [
"25kvac",
"750vdc",
"650vdc",
"1500vdc",
"none"
]
},
"goto": {
"type": "string"
},
"entryPoint": {
"type": "string"
}
},
"required": [
"name",
"diverges",
"direction",
"miles",
"chains",
"type"
],
"additionalProperties": false
},
"loop": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "loop"
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"position": {
"type": "string",
"enum": [
"left",
"right",
"both"
]
},
"miles": {
"type": "number"
},
"chains": {
"type": "number"
},
"loopElec": {
"type": "string",
"enum": [
"25kvac",
"750vdc",
"650vdc",
"1500vdc",
"none"
]
}
},
"required": [
"type",
"name",
"position",
"miles",
"chains"
],
"additionalProperties": false
},
"routeContinuation": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "continues"
},
"routeName": {
"type": "string",
"description": "Name to display"
},
"routeId": {
"type": "string",
"description": "Id of route"
},
"entryPoint": {
"type": "string",
"description": "Entrypoint of other route (lowercase, replacing whitespace with -, junction always referred to as jn"
}
},
"required": [
"type",
"routeName",
"routeId",
"entryPoint"
],
"additionalProperties": false
},
"siteof": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "siteof"
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"miles": {
"type": "number"
},
"chains": {
"type": "number"
}
},
"required": [
"type",
"name",
"miles",
"chains"
],
"additionalProperties": false
},
"station": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "station"
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"miles": {
"type": "number"
},
"chains": {
"type": "number"
}
},
"required": [
"type",
"name",
"miles",
"chains"
]
},
"tunnel": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "tunnel"
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"tunnelType": {
"type": "string",
"enum": [
"start",
"end",
"mid",
"whole"
]
},
"length": {
"type": "string",
"pattern": ""
},
"miles": {
"type": "number"
},
"chains": {
"type": "number"
}
},
"required": [
"type",
"name",
"tunnelType",
"miles",
"chains"
],
"additionalProperties": false
},
"signallerChange": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "signallerChange"
},
"from": {
"type": "string"
},
"to": {
"type": "string"
},
"miles": {
"type": "number"
},
"chains": {
"type": "number"
}
},
"required": [
"from",
"to",
"miles",
"chains"
],
"additionalProperties": false
}
}
}