From 6a31711c2b93117d182dfc87208c215322dc14aa Mon Sep 17 00:00:00 2001 From: SJiB Date: Wed, 7 Aug 2024 17:15:28 +0200 Subject: [PATCH 1/2] new version from urs https://github.com/teksi/wastewater/issues/59 --- datamodel/app/view/vw_change_points.sql | 32 +++++++++++++------------ 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/datamodel/app/view/vw_change_points.sql b/datamodel/app/view/vw_change_points.sql index 81b4048e1..c62dcdb10 100644 --- a/datamodel/app/view/vw_change_points.sql +++ b/datamodel/app/view/vw_change_points.sql @@ -1,16 +1,18 @@ -CREATE VIEW tww_app.vw_change_points AS -SELECT - rp_to.obj_id, - rp_to.situation3d_geometry::geometry(POINTZ, {SRID}) AS geom, - re.material <> re_next.material AS change_in_material, - re.clear_height <> re_next.clear_height AS change_in_clear_height, - (rp_from.level - rp_to.level) / re.length_effective - (rp_next_from.level - rp_next_to.level) / re_next.length_effective AS change_in_slope +CREATE OR REPLACE VIEW tww_app.vw_change_points +AS +SELECT ne_node.obj_id, +node.situation3d_geometry AS geom, +re.material <> re_next.material AS change_in_material, +re.clear_height <> re_next.clear_height AS change_in_clear_height, +(rp_from.level - rp_to.level) / re.length_effective - (rp_next_from.level - rp_next_to.level) / re_next.length_effective AS change_in_slope FROM tww_od.reach re -LEFT JOIN tww_od.reach_point rp_to ON rp_to.obj_id = re.fk_reach_point_to -LEFT JOIN tww_od.reach_point rp_from ON rp_from.obj_id = re.fk_reach_point_from -LEFT JOIN tww_od.reach re_next ON rp_to.fk_wastewater_networkelement = re_next.obj_id -LEFT JOIN tww_od.reach_point rp_next_to ON rp_next_to.obj_id = re_next.fk_reach_point_to -LEFT JOIN tww_od.reach_point rp_next_from ON rp_next_from.obj_id = re_next.fk_reach_point_from -LEFT JOIN tww_od.wastewater_networkelement ne ON re.obj_id = ne.obj_id -LEFT JOIN tww_od.wastewater_networkelement ne_next ON re_next.obj_id = ne_next.obj_id -WHERE ne_next.fk_wastewater_structure = ne.fk_wastewater_structure +LEFT JOIN tww_od.reach_point rp_to ON rp_to.obj_id::text = re.fk_reach_point_to::text +LEFT JOIN tww_od.reach_point rp_from ON rp_from.obj_id::text = re.fk_reach_point_from::text +LEFT JOIN tww_od.wastewater_networkelement ne_node ON ne_node.obj_id::text = rp_to.fk_wastewater_networkelement::text +LEFT JOIN tww_od.wastewater_node node ON node.obj_id::text = ne_node.obj_id::text +LEFT JOIN tww_od.reach_point rp_next_from ON rp_next_from.fk_wastewater_networkelement::text = ne_node.obj_id::text +LEFT JOIN tww_od.reach re_next ON rp_next_from.obj_id::text = re_next.fk_reach_point_from::text +LEFT JOIN tww_od.reach_point rp_next_to ON rp_next_to.obj_id::text = re_next.fk_reach_point_to::text +LEFT JOIN tww_od.wastewater_networkelement ne ON re.obj_id::text = ne.obj_id::text +LEFT JOIN tww_od.wastewater_networkelement ne_next ON re_next.obj_id::text = ne_next.obj_id::text +WHERE ne_next.fk_wastewater_structure::text = ne.fk_wastewater_structure::text; From d52a8e3db8dfb0e508da93907fe7689ef33a08d9 Mon Sep 17 00:00:00 2001 From: SJiB Date: Thu, 8 Aug 2024 16:21:44 +0200 Subject: [PATCH 2/2] change alias node to wn --- datamodel/app/view/vw_change_points.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/datamodel/app/view/vw_change_points.sql b/datamodel/app/view/vw_change_points.sql index c62dcdb10..6029a860c 100644 --- a/datamodel/app/view/vw_change_points.sql +++ b/datamodel/app/view/vw_change_points.sql @@ -1,7 +1,7 @@ CREATE OR REPLACE VIEW tww_app.vw_change_points AS SELECT ne_node.obj_id, -node.situation3d_geometry AS geom, +wn.situation3d_geometry AS geom, re.material <> re_next.material AS change_in_material, re.clear_height <> re_next.clear_height AS change_in_clear_height, (rp_from.level - rp_to.level) / re.length_effective - (rp_next_from.level - rp_next_to.level) / re_next.length_effective AS change_in_slope @@ -9,7 +9,7 @@ FROM tww_od.reach re LEFT JOIN tww_od.reach_point rp_to ON rp_to.obj_id::text = re.fk_reach_point_to::text LEFT JOIN tww_od.reach_point rp_from ON rp_from.obj_id::text = re.fk_reach_point_from::text LEFT JOIN tww_od.wastewater_networkelement ne_node ON ne_node.obj_id::text = rp_to.fk_wastewater_networkelement::text -LEFT JOIN tww_od.wastewater_node node ON node.obj_id::text = ne_node.obj_id::text +LEFT JOIN tww_od.wastewater_node wn ON wn.obj_id::text = ne_node.obj_id::text LEFT JOIN tww_od.reach_point rp_next_from ON rp_next_from.fk_wastewater_networkelement::text = ne_node.obj_id::text LEFT JOIN tww_od.reach re_next ON rp_next_from.obj_id::text = re_next.fk_reach_point_from::text LEFT JOIN tww_od.reach_point rp_next_to ON rp_next_to.obj_id::text = re_next.fk_reach_point_to::text