Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

editoast: better sql query to split a track section #10030

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
SELECT object_table.obj_id as obj_id,
object_table.data as railjson,
ST_AsGeoJSON(
ST_Transform(
ST_LineSubstring(
layer_table.geographic,
0,
$3
SELECT
obj_id,
railjson,
ST_AsGeoJSON( ST_Transform(ST_GeometryN( splitted, 1 ), 4326) )::jsonb as left_geo,
ST_AsGeoJSON( ST_Transform(ST_GeometryN( splitted, 2 ), 4326) )::jsonb as right_geo
FROM (
SELECT
obj_id,
railjson,
ST_SPLIT(
ST_Snap(
geometry::geometry,
geo_split_point::geometry,
ST_Distance(geometry::geometry, geo_split_point::geometry)*1.01
),
4326
geo_split_point::geometry
) as splitted
FROM
(SELECT
object_table.obj_id as obj_id,
object_table.data as railjson,
ST_Transform(layer_table.geographic, 4326)::geography as geometry,
ST_LineInterpolatePoint(
ST_Transform(layer_table.geographic, 4326),
$3::float,
True
) as geo_split_point
FROM infra_object_track_section AS object_table
LEFT JOIN infra_layer_track_section AS layer_table ON layer_table.infra_id = object_table.infra_id
AND object_table.obj_id = layer_table.obj_id
WHERE object_table.infra_id = $1
AND object_table.obj_id = $2
)
)::jsonb as left_geo,
ST_AsGeoJSON(
ST_Transform(
ST_LineSubstring(
layer_table.geographic,
$3,
1
),
4326
)
)::jsonb as right_geo
FROM infra_object_track_section AS object_table
LEFT JOIN infra_layer_track_section AS layer_table ON layer_table.infra_id = object_table.infra_id
AND object_table.obj_id = layer_table.obj_id
WHERE object_table.infra_id = $1
AND object_table.obj_id = $2
);
Loading