Skip to content

Commit 6e16d75

Browse files
committed
editoast: add tvm atlas and config
1 parent ed4023d commit 6e16d75

9 files changed

+68
-4
lines changed
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"REP TGV": {
3+
"height": 128,
4+
"pixelRatio": 1,
5+
"width": 128,
6+
"x": 0,
7+
"y": 0
8+
}
9+
}
531 Bytes
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"REP TGV": {
3+
"height": 256,
4+
"pixelRatio": 2,
5+
"width": 256,
6+
"x": 0,
7+
"y": 0
8+
}
9+
}
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"REP TGV": {
3+
"height": 384,
4+
"pixelRatio": 3,
5+
"width": 384,
6+
"x": 0,
7+
"y": 0
8+
}
9+
}
Loading

editoast/signal_sprites.yml

+2
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ BAPR:
1414
- conditions:
1515
distant: "true"
1616
sprite: "DISQUE VL"
17+
TVM:
18+
default: "REP TGV"

editoast/src/views/sprites.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ crate::routes! {
1515
}
1616

1717
#[derive(Debug, Error, EditoastError)]
18-
#[editoast_error(base_id = "scenario")]
18+
#[editoast_error(base_id = "sprites")]
1919
enum SpriteErrors {
2020
#[error("Unknown signaling system '{0}'")]
2121
#[editoast_error(status = 404)]
2222
UnknownSignalingSystem(String),
23+
#[error("File '{0}' not found")]
24+
#[editoast_error(status = 404)]
25+
FileNotFound(String),
2326
}
2427

2528
/// This endpoint returns the list of supported signaling systems
@@ -41,21 +44,23 @@ async fn signaling_systems() -> Result<Json<Vec<String>>> {
4144
tag = "sprites",
4245
params(
4346
("signaling_system" = String, Path, description = "Signaling system name"),
44-
("file_name" = String, Path, description = "Atlas file name (json or png) respecting map libre documentation"),
47+
("file_name" = String, Path, description = "File name (json, png or svg)"),
4548
),
4649
responses(
4750
(status = 200, description = "Atlas image of config"),
4851
(status = 404, description = "Signaling system not found"),
4952
),
5053
)]
51-
#[get("/{signaling_system}/{file_name:sprites(@[23]x)?\\.(json|png)}")]
54+
#[get("/{signaling_system}/{file_name:[-_ @0-9A-Za-z]+\\.(json|png|svg)}")]
5255
async fn sprites(path: Path<(String, String)>) -> Result<NamedFile> {
5356
let (signaling_system, file_name) = path.into_inner();
5457
let sprite_configs = SpriteConfig::load();
5558
if !sprite_configs.contains_key(&signaling_system) {
5659
return Err(SpriteErrors::UnknownSignalingSystem(signaling_system).into());
5760
}
5861
let path = get_assets_path().join(format!("signal_sprites/{signaling_system}/{file_name}"));
59-
assert!(path.is_file());
62+
if !path.is_file() {
63+
return Err(SpriteErrors::FileNotFound(file_name).into());
64+
}
6065
Ok(NamedFile::open(path).unwrap().use_last_modified(false))
6166
}

0 commit comments

Comments
 (0)