Skip to content

Commit 0e0d140

Browse files
committed
editoast: split op layer by part
1 parent c0a0b02 commit 0e0d140

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE infra_layer_operational_point DROP COLUMN kp;
2+
ALTER TABLE infra_layer_operational_point ADD CONSTRAINT infra_layer_operational_point_infra_id_obj_id_key UNIQUE (infra_id, obj_id);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE infra_layer_operational_point ADD COLUMN kp text;
2+
ALTER TABLE infra_layer_operational_point DROP CONSTRAINT infra_layer_operational_point_infra_id_obj_id_key;

editoast/src/generated_data/sql/generate_operational_point_layer.sql

+8-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ WITH ops AS (
33
(
44
jsonb_array_elements(data->'parts')->'position'
55
)::float AS position,
6-
jsonb_array_elements(data->'parts')->>'track' AS track_id
6+
jsonb_array_elements(data->'parts')->>'track' AS track_id,
7+
jsonb_array_elements(data->'parts')->'extensions'->'sncf'->>'kp' AS kp
78
FROM infra_object_operational_point
89
WHERE infra_id = $1
910
),
@@ -28,17 +29,18 @@ collect AS (
2829
),
2930
1.
3031
)
31-
) AS sch
32+
) AS sch,
33+
ops.kp AS kp
3234
FROM ops
3335
INNER JOIN infra_object_track_section AS tracks ON tracks.obj_id = ops.track_id
3436
AND tracks.infra_id = $1
3537
INNER JOIN infra_layer_track_section AS tracks_layer ON tracks.obj_id = tracks_layer.obj_id
3638
AND tracks.infra_id = tracks_layer.infra_id
3739
)
38-
INSERT INTO infra_layer_operational_point (obj_id, infra_id, geographic, schematic)
40+
INSERT INTO infra_layer_operational_point (obj_id, infra_id, geographic, schematic, kp)
3941
SELECT op_id,
4042
$1,
41-
St_Collect(geo),
42-
St_Collect(sch)
43+
geo,
44+
sch,
45+
kp
4346
FROM collect
44-
GROUP BY op_id

editoast/src/generated_data/sql/insert_operational_point_layer.sql

+8-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ WITH ops AS (
33
(
44
jsonb_array_elements(data->'parts')->'position'
55
)::float AS position,
6-
jsonb_array_elements(data->'parts')->>'track' AS track_id
6+
jsonb_array_elements(data->'parts')->>'track' AS track_id,
7+
jsonb_array_elements(data->'parts')->'extensions'->'sncf'->>'kp' AS kp
78
FROM infra_object_operational_point
89
WHERE infra_id = $1
910
AND obj_id = ANY($2)
@@ -29,17 +30,19 @@ collect AS (
2930
),
3031
1.
3132
)
32-
) AS sch
33+
) AS sch,
34+
ops.kp AS kp
3335
FROM ops
3436
INNER JOIN infra_object_track_section AS tracks ON tracks.obj_id = ops.track_id
3537
AND tracks.infra_id = $1
3638
INNER JOIN infra_layer_track_section AS tracks_layer ON tracks.obj_id = tracks_layer.obj_id
3739
AND tracks.infra_id = tracks_layer.infra_id
3840
)
39-
INSERT INTO infra_layer_operational_point (obj_id, infra_id, geographic, schematic)
41+
INSERT INTO infra_layer_operational_point (obj_id, infra_id, geographic, schematic, kp)
4042
SELECT op_id,
4143
$1,
42-
St_Collect(geo),
43-
St_Collect(sch)
44+
geo,
45+
sch,
46+
kp
4447
FROM collect
4548
GROUP BY op_id

editoast/src/tables.rs

+1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ diesel::table! {
125125
geographic -> Geometry,
126126
schematic -> Geometry,
127127
infra_id -> Int8,
128+
kp -> Nullable<Text>,
128129
}
129130
}
130131

0 commit comments

Comments
 (0)