Skip to content

Commit

Permalink
osrd_schema+editoast: renamed panel to sign and lpv to psl
Browse files Browse the repository at this point in the history
LPV (Limite Permanente de Vitesse) -> PSL (Permanent Speed Limit)
  • Loading branch information
Bubullzz authored and clarani committed Oct 4, 2023
1 parent 343166e commit 7e60fdd
Show file tree
Hide file tree
Showing 22 changed files with 125 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class RJSInfra {
.build()
.adapter(RJSInfra.class);

public static final transient String CURRENT_VERSION = "3.4.1";
public static final transient String CURRENT_VERSION = "3.4.2";

/** The version of the infra format used */
public String version;
Expand Down
14 changes: 7 additions & 7 deletions editoast/map_layers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ layers:
joins:
- inner join infra_object_speed_section speed_section on speed_section.obj_id = layer.obj_id and speed_section.infra_id = layer.infra_id
where:
- not (speed_section.data @? '$.extensions.lpv_sncf.z')
- not (speed_section.data @? '$.extensions.psl_sncf.z')
sch:
on_field: schematic
cache_duration: 3600
data_expr: speed_section.data
joins:
- inner join infra_object_speed_section speed_section on speed_section.obj_id = layer.obj_id and speed_section.infra_id = layer.infra_id
where:
- not (speed_section.data @? '$.extensions.lpv_sncf.z')
- not (speed_section.data @? '$.extensions.psl_sncf.z')

lpv:
psl:
table_name: infra_layer_speed_section
id_field: id
views:
Expand All @@ -67,15 +67,15 @@ layers:
joins:
- inner join infra_object_speed_section speed_section on speed_section.obj_id = layer.obj_id and speed_section.infra_id = layer.infra_id
where:
- speed_section.data @? '$.extensions.lpv_sncf.z'
- speed_section.data @? '$.extensions.psl_sncf.z'
sch:
on_field: schematic
cache_duration: 3600
data_expr: speed_section.data
joins:
- inner join infra_object_speed_section speed_section on speed_section.obj_id = layer.obj_id and speed_section.infra_id = layer.infra_id
where:
- speed_section.data @? '$.extensions.lpv_sncf.z'
- speed_section.data @? '$.extensions.psl_sncf.z'

track_section_links:
table_name: infra_layer_track_section_link
Expand Down Expand Up @@ -179,8 +179,8 @@ layers:
joins:
- inner join infra_object_catenary catenary on catenary.obj_id = layer.obj_id and catenary.infra_id = layer.infra_id

lpv_panels:
table_name: infra_layer_lpv_panel
psl_signs:
table_name: infra_layer_psl_sign
id_field: id
views:
geo:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
alter table infra alter column railjson_version set default '3.4.1';

update infra set railjson_version = '3.4.1';

alter table infra_layer_psl_sign rename to infra_layer_lpv_panel;

update infra_object_speed_section set data['extensions']['lpv_sncf'] = data['extensions']['psl_sncf'];

update infra_object_speed_section set data['extensions'] = data['extensions'] - 'psl_sncf';
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
alter table infra alter column railjson_version set default '3.4.2';

update infra set railjson_version = '3.4.2';

alter table infra_layer_lpv_panel rename to infra_layer_psl_sign;

update infra_object_speed_section set data['extensions']['psl_sncf'] = data['extensions']['lpv_sncf'];

update infra_object_speed_section set data['extensions'] = data['extensions'] - 'lpv_sncf';
4 changes: 2 additions & 2 deletions editoast/src/generated_data/error/speed_sections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ pub fn check_overlapping(infra_cache: &InfraCache, _: &Graph) -> Vec<InfraError>
// Iterate over all the speed sections insure we don't report duplicated errors
for speed_section in infra_cache.speed_sections().values() {
let speed_section = speed_section.unwrap_speed_section();
// Ignore LPV (they can overlap)
if speed_section.extensions.lpv_sncf.is_some() {
// Ignore PSL (they can overlap)
if speed_section.extensions.psl_sncf.is_some() {
continue;
}
for track_range in speed_section.track_ranges.iter() {
Expand Down
10 changes: 5 additions & 5 deletions editoast/src/generated_data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ mod buffer_stop;
mod catenary;
mod detector;
mod error;
mod lpv_panel;
mod neutral_section;
mod operational_point;
mod psl_sign;
mod signal;
mod speed_section;
mod switch;
Expand All @@ -18,9 +18,9 @@ use buffer_stop::BufferStopLayer;
use catenary::CatenaryLayer;
use detector::DetectorLayer;
use error::ErrorLayer;
use lpv_panel::LPVPanelLayer;
use neutral_section::NeutralSectionLayer;
use operational_point::OperationalPointLayer;
use psl_sign::PSLSignLayer;
use signal::SignalLayer;
use speed_section::SpeedSectionLayer;
use switch::SwitchLayer;
Expand Down Expand Up @@ -100,7 +100,7 @@ pub async fn refresh_all(
DetectorLayer::refresh_pool(db_pool.clone(), infra, infra_cache),
OperationalPointLayer::refresh_pool(db_pool.clone(), infra, infra_cache),
TrackSectionLinkLayer::refresh_pool(db_pool.clone(), infra, infra_cache),
LPVPanelLayer::refresh_pool(db_pool.clone(), infra, infra_cache),
PSLSignLayer::refresh_pool(db_pool.clone(), infra, infra_cache),
NeutralSectionLayer::refresh_pool(db_pool.clone(), infra, infra_cache),
)?;
log::debug!("⚙️ Infra {infra}: object layers is generated");
Expand All @@ -121,7 +121,7 @@ pub async fn clear_all(conn: &mut PgConnection, infra: i64) -> Result<()> {
DetectorLayer::clear(conn, infra).await?;
OperationalPointLayer::clear(conn, infra).await?;
TrackSectionLinkLayer::clear(conn, infra).await?;
LPVPanelLayer::clear(conn, infra).await?;
PSLSignLayer::clear(conn, infra).await?;
ErrorLayer::clear(conn, infra).await?;
NeutralSectionLayer::clear(conn, infra).await?;
Ok(())
Expand All @@ -143,7 +143,7 @@ pub async fn update_all(
DetectorLayer::update(conn, infra, operations, infra_cache).await?;
OperationalPointLayer::update(conn, infra, operations, infra_cache).await?;
TrackSectionLinkLayer::update(conn, infra, operations, infra_cache).await?;
LPVPanelLayer::update(conn, infra, operations, infra_cache).await?;
PSLSignLayer::update(conn, infra, operations, infra_cache).await?;
ErrorLayer::update(conn, infra, operations, infra_cache).await?;
NeutralSectionLayer::update(conn, infra, operations, infra_cache).await?;
Ok(())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ use crate::diesel::ExpressionMethods;
use crate::error::Result;
use crate::infra_cache::InfraCache;
use crate::schema::ObjectType;
use crate::tables::infra_layer_lpv_panel::dsl;
use crate::tables::infra_layer_psl_sign::dsl;

pub struct LPVPanelLayer;
pub struct PSLSignLayer;

#[async_trait]
impl GeneratedData for LPVPanelLayer {
impl GeneratedData for PSLSignLayer {
fn table_name() -> &'static str {
"infra_layer_lpv_panel"
"infra_layer_psl_sign"
}

async fn generate(conn: &mut PgConnection, infra: i64, _cache: &InfraCache) -> Result<()> {
sql_query(include_str!("sql/generate_lpv_panel_layer.sql"))
sql_query(include_str!("sql/generate_psl_sign_layer.sql"))
.bind::<BigInt, _>(infra)
.execute(conn)
.await?;
Expand All @@ -47,7 +47,7 @@ impl GeneratedData for LPVPanelLayer {
.iter()
.chain(involved_objects.updated.iter());
delete(
dsl::infra_layer_lpv_panel
dsl::infra_layer_psl_sign
.filter(dsl::infra_id.eq(infra))
.filter(dsl::obj_id.eq_any(objs)),
)
Expand All @@ -57,7 +57,7 @@ impl GeneratedData for LPVPanelLayer {

// Insert involved elements
if !involved_objects.updated.is_empty() {
sql_query(include_str!("sql/insert_lpv_panel_layer.sql"))
sql_query(include_str!("sql/insert_psl_sign_layer.sql"))
.bind::<BigInt, _>(infra)
.bind::<Array<Text>, _>(involved_objects.updated.into_iter().collect::<Vec<_>>())
.execute(conn)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
WITH panels AS (
WITH signs AS (
SELECT obj_id AS sc_id,
(
jsonb_array_elements(data->'extensions'->'lpv_sncf'->'announcement')->'position'
jsonb_array_elements(data->'extensions'->'psl_sncf'->'announcement')->'position'
)::float AS position,
jsonb_array_elements(data->'extensions'->'lpv_sncf'->'announcement')->>'track' AS track_id,
jsonb_array_elements(data->'extensions'->'lpv_sncf'->'announcement') AS data
jsonb_array_elements(data->'extensions'->'psl_sncf'->'announcement')->>'track' AS track_id,
jsonb_array_elements(data->'extensions'->'psl_sncf'->'announcement') AS data
FROM infra_object_speed_section
WHERE infra_id = $1
AND infra_object_speed_section.data @? '$.extensions.lpv_sncf.z'
AND infra_object_speed_section.data @? '$.extensions.psl_sncf.z'
UNION
SELECT obj_id AS sc_id,
(
jsonb_array_elements(data->'extensions'->'lpv_sncf'->'r')->'position'
jsonb_array_elements(data->'extensions'->'psl_sncf'->'r')->'position'
)::float AS position,
jsonb_array_elements(data->'extensions'->'lpv_sncf'->'r')->>'track' AS track_id,
jsonb_array_elements(data->'extensions'->'lpv_sncf'->'r') AS data
jsonb_array_elements(data->'extensions'->'psl_sncf'->'r')->>'track' AS track_id,
jsonb_array_elements(data->'extensions'->'psl_sncf'->'r') AS data
FROM infra_object_speed_section
WHERE infra_id = $1
AND infra_object_speed_section.data @? '$.extensions.lpv_sncf.z'
AND infra_object_speed_section.data @? '$.extensions.psl_sncf.z'
UNION
SELECT obj_id AS sc_id,
(data->'extensions'->'lpv_sncf'->'z'->'position')::float AS position,
data->'extensions'->'lpv_sncf'->'z'->>'track' AS track_id,
data->'extensions'->'lpv_sncf'->'z' AS data
(data->'extensions'->'psl_sncf'->'z'->'position')::float AS position,
data->'extensions'->'psl_sncf'->'z'->>'track' AS track_id,
data->'extensions'->'psl_sncf'->'z' AS data
FROM infra_object_speed_section
WHERE infra_id = $1
AND infra_object_speed_section.data @? '$.extensions.lpv_sncf.z'
AND infra_object_speed_section.data @? '$.extensions.psl_sncf.z'
),
collect AS (
SELECT panels.sc_id,
panels.data,
SELECT signs.sc_id,
signs.data,
ST_LineInterpolatePoint(
tracks_layer.geographic,
LEAST(
GREATEST(
panels.position / (tracks.data->'length')::float,
signs.position / (tracks.data->'length')::float,
0.
),
1.
Expand All @@ -44,19 +44,19 @@ collect AS (
tracks_layer.schematic,
LEAST(
GREATEST(
panels.position / (tracks.data->'length')::float,
signs.position / (tracks.data->'length')::float,
0.
),
1.
)
) AS sch
FROM panels
INNER JOIN infra_object_track_section AS tracks ON tracks.obj_id = panels.track_id
FROM signs
INNER JOIN infra_object_track_section AS tracks ON tracks.obj_id = signs.track_id
AND tracks.infra_id = $1
INNER JOIN infra_layer_track_section AS tracks_layer ON tracks.obj_id = tracks_layer.obj_id
AND tracks.infra_id = tracks_layer.infra_id
)
INSERT INTO infra_layer_lpv_panel (obj_id, infra_id, geographic, schematic, data)
INSERT INTO infra_layer_psl_sign (obj_id, infra_id, geographic, schematic, data)
SELECT sc_id,
$1,
geo,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
WITH panels AS (
WITH signs AS (
SELECT obj_id AS sc_id,
(
jsonb_array_elements(data->'extensions'->'lpv_sncf'->'announcement')->'position'
jsonb_array_elements(data->'extensions'->'psl_sncf'->'announcement')->'position'
)::float AS position,
jsonb_array_elements(data->'extensions'->'lpv_sncf'->'announcement')->>'track' AS track_id,
jsonb_array_elements(data->'extensions'->'lpv_sncf'->'announcement') AS data
jsonb_array_elements(data->'extensions'->'psl_sncf'->'announcement')->>'track' AS track_id,
jsonb_array_elements(data->'extensions'->'psl_sncf'->'announcement') AS data
FROM infra_object_speed_section
WHERE infra_id = $1
AND obj_id = ANY($2)
AND infra_object_speed_section.data @? '$.extensions.lpv_sncf.z'
AND infra_object_speed_section.data @? '$.extensions.psl_sncf.z'
UNION
SELECT obj_id AS sc_id,
(
jsonb_array_elements(data->'extensions'->'lpv_sncf'->'r')->'position'
jsonb_array_elements(data->'extensions'->'psl_sncf'->'r')->'position'
)::float AS position,
jsonb_array_elements(data->'extensions'->'lpv_sncf'->'r')->>'track' AS track_id,
jsonb_array_elements(data->'extensions'->'lpv_sncf'->'r') AS data
jsonb_array_elements(data->'extensions'->'psl_sncf'->'r')->>'track' AS track_id,
jsonb_array_elements(data->'extensions'->'psl_sncf'->'r') AS data
FROM infra_object_speed_section
WHERE infra_id = $1
AND obj_id = ANY($2)
AND infra_object_speed_section.data @? '$.extensions.lpv_sncf.z'
AND infra_object_speed_section.data @? '$.extensions.psl_sncf.z'
UNION
SELECT obj_id AS sc_id,
(data->'extensions'->'lpv_sncf'->'z'->'position')::float AS position,
data->'extensions'->'lpv_sncf'->'z'->>'track' AS track_id,
data->'extensions'->'lpv_sncf'->'z' AS data
(data->'extensions'->'psl_sncf'->'z'->'position')::float AS position,
data->'extensions'->'psl_sncf'->'z'->>'track' AS track_id,
data->'extensions'->'psl_sncf'->'z' AS data
FROM infra_object_speed_section
WHERE infra_id = $1
AND obj_id = ANY($2)
AND infra_object_speed_section.data @? '$.extensions.lpv_sncf.z'
AND infra_object_speed_section.data @? '$.extensions.psl_sncf.z'
),
collect AS (
SELECT panels.sc_id,
panels.data,
SELECT signs.sc_id,
signs.data,
ST_LineInterpolatePoint(
tracks_layer.geographic,
LEAST(
GREATEST(
panels.position / (tracks.data->'length')::float,
signs.position / (tracks.data->'length')::float,
0.
),
1.
Expand All @@ -47,19 +47,19 @@ collect AS (
tracks_layer.schematic,
LEAST(
GREATEST(
panels.position / (tracks.data->'length')::float,
signs.position / (tracks.data->'length')::float,
0.
),
1.
)
) AS sch
FROM panels
INNER JOIN infra_object_track_section AS tracks ON tracks.obj_id = panels.track_id
FROM signs
INNER JOIN infra_object_track_section AS tracks ON tracks.obj_id = signs.track_id
AND tracks.infra_id = $1
INNER JOIN infra_layer_track_section AS tracks_layer ON tracks.obj_id = tracks_layer.obj_id
AND tracks.infra_id = tracks_layer.infra_id
)
INSERT INTO infra_layer_lpv_panel (obj_id, infra_id, geographic, schematic, data)
INSERT INTO infra_layer_psl_sign (obj_id, infra_id, geographic, schematic, data)
SELECT sc_id,
$1,
geo,
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/models/infra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use log::{debug, error};
use serde::{Deserialize, Serialize};
use uuid::Uuid;

pub const RAILJSON_VERSION: &str = "3.4.1";
pub const RAILJSON_VERSION: &str = "3.4.2";
pub const INFRA_VERSION: &str = "0";

#[derive(
Expand Down
4 changes: 2 additions & 2 deletions editoast/src/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,15 +331,15 @@ pub enum Side {
#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq)]
#[derivative(Default)]
#[serde(deny_unknown_fields)]
pub struct Panel {
pub struct Sign {
#[derivative(Default(value = r#""InvalidRef".into()"#))]
pub track: Identifier,
pub position: f64,
pub angle_geo: f64,
pub angle_sch: f64,
pub side: Side,
#[serde(rename = "type")]
pub panel_type: NonBlankString,
pub sign_type: NonBlankString,
pub value: Option<NonBlankString>,
}

Expand Down
Loading

0 comments on commit 7e60fdd

Please sign in to comment.