-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
editoast: add new track_section field in operational point layer
Signed-off-by: Youness CHRIFI ALAOUI <youness.chrifi@gmail.com>
- Loading branch information
1 parent
5ec5bf4
commit 8078784
Showing
6 changed files
with
54 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
editoast/migrations/2024-11-27-095410_add_track_section_operational_point_layer/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE infra_layer_operational_point DROP COLUMN track_section; |
40 changes: 40 additions & 0 deletions
40
editoast/migrations/2024-11-27-095410_add_track_section_operational_point_layer/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
DELETE FROM infra_layer_operational_point; | ||
ALTER TABLE infra_layer_operational_point ADD COLUMN track_section text NOT NULL; | ||
|
||
WITH ops AS ( | ||
SELECT obj_id AS op_id, | ||
infra_id, | ||
( | ||
jsonb_array_elements(data->'parts')->'position' | ||
)::float AS position, | ||
jsonb_array_elements(data->'parts')->>'track' AS track_id, | ||
jsonb_array_elements(data->'parts')->'extensions'->'sncf'->>'kp' AS kp | ||
FROM infra_object_operational_point | ||
), | ||
collect AS ( | ||
SELECT ops.op_id, | ||
ST_LineInterpolatePoint( | ||
tracks_layer.geographic, | ||
LEAST( | ||
GREATEST( | ||
ops.position / (tracks.data->'length')::float, | ||
0. | ||
), | ||
1. | ||
) | ||
) AS geo, | ||
ops.kp AS kp, | ||
ops.infra_id AS infra_id, | ||
ops.track_id AS track_section | ||
FROM ops | ||
INNER JOIN infra_object_track_section AS tracks ON tracks.obj_id = ops.track_id AND tracks.infra_id = ops.infra_id | ||
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_operational_point (obj_id, infra_id, geographic, kp, track_section) | ||
SELECT op_id, | ||
infra_id, | ||
geo, | ||
kp, | ||
track_section | ||
FROM collect; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters