diff --git a/test/upsert/ws/test_v_edit_link.sql b/test/upsert/ws/test_v_edit_link.sql index be807f65b..4635711ec 100644 --- a/test/upsert/ws/test_v_edit_link.sql +++ b/test/upsert/ws/test_v_edit_link.sql @@ -12,8 +12,8 @@ SET search_path = "SCHEMA_NAME", public, pg_catalog; SELECT plan(6); -INSERT INTO v_edit_link (link_id, feature_type, feature_id, exit_type, exit_id, state, expl_id, sector_id, sector_name, sector_type, macrosector_id, presszone_id, presszone_name, presszone_type, presszone_head, dma_id, dma_name, dma_type, macrodma_id, dqa_id, dqa_name, dqa_type, macrodqa_id, exit_topelev, exit_elev, fluid_type, gis_length, the_geom, muni_id, expl_id2, epa_type, is_operative, staticpressure, conneccat_id, workcat_id, workcat_id_end, builtdate, enddate, lastupdate, lastupdate_user, uncertain, minsector_id, macrominsector_id) -VALUES(-901, 'CONNEC', '3008', 'ARC', '2067', 1, 1, 3, 'sector1-1d', 'DISTRIBUTION', 1, '3', 'pzone1-1d', NULL, 71.75, 2, 'dma1-2d', NULL, NULL, 1, 'dqa1-1d', NULL, NULL, NULL, NULL, 'St. Fluid', 16.646, 'SRID=25831;LINESTRING (419084.18264611065 4576806.076099069, 419093.3076407612 4576819.998540623)'::public.geometry, 1, NULL, 'JUNCTION', true, 22.741, 'PVC25-PN16-DOM', NULL, NULL, '2002-04-21', NULL, NULL, NULL, false, 113854, NULL); +INSERT INTO v_edit_link (link_id, feature_type, feature_id, exit_type, exit_id, state, expl_id, sector_id, sector_name, sector_type, macrosector_id, presszone_id, presszone_name, presszone_type, presszone_head, dma_id, dma_name, dma_type, macrodma_id, dqa_id, dqa_name, dqa_type, macrodqa_id, exit_topelev, exit_elev, fluid_type, gis_length, the_geom, muni_id, expl_id2, epa_type, is_operative, staticpressure, conneccat_id, workcat_id, workcat_id_end, builtdate, enddate, lastupdate, lastupdate_user, uncertain, minsector_id, macrominsector_id, verified) +VALUES(-901, 'CONNEC', '3008', 'ARC', '2067', 1, 1, 3, 'sector1-1d', 'DISTRIBUTION', 1, '3', 'pzone1-1d', NULL, 71.75, 2, 'dma1-2d', NULL, NULL, 1, 'dqa1-1d', NULL, NULL, NULL, NULL, 'St. Fluid', 16.646, 'SRID=25831;LINESTRING (419084.18264611065 4576806.076099069, 419093.3076407612 4576819.998540623)'::public.geometry, 1, NULL, 'JUNCTION', true, 22.741, 'PVC25-PN16-DOM', NULL, NULL, '2002-04-21', NULL, NULL, NULL, false, 113854, NULL, 0); SELECT is((SELECT count(*)::integer FROM v_edit_link WHERE link_id = -901), 1, 'INSERT: v_edit_link -901 was inserted'); SELECT is((SELECT count(*)::integer FROM link WHERE link_id = -901), 1, 'INSERT: link -901 was inserted'); diff --git a/ud/ftrg/ud_gw_trg_edit_arc.sql b/ud/ftrg/ud_gw_trg_edit_arc.sql index 9101eaa95..c123e97f1 100644 --- a/ud/ftrg/ud_gw_trg_edit_arc.sql +++ b/ud/ftrg/ud_gw_trg_edit_arc.sql @@ -273,7 +273,7 @@ BEGIN -- Verified IF (NEW.verified IS NULL) THEN - NEW.verified := (SELECT "value" FROM config_param_user WHERE "parameter"='edit_verified_vdefault' AND "cur_user"="current_user"() LIMIT 1); + NEW.verified := (SELECT "value"::INTEGER FROM config_param_user WHERE "parameter"='edit_verified_vdefault' AND "cur_user"="current_user"() LIMIT 1); END IF; -- State @@ -532,30 +532,30 @@ BEGIN END IF; END LOOP; END IF; - - + + -- automatic connection of closest connecs to the arc - SELECT + SELECT ("value"::json->>'active')::boolean as v_active, ("value"::json->>'buffer')::numeric as v_buffer INTO rec_param_link - FROM config_param_user - WHERE "parameter" ilike 'edit_arc_automatic_link2netowrk' + FROM config_param_user + WHERE "parameter" ilike 'edit_arc_automatic_link2netowrk' AND cur_user = current_user; - + IF rec_param_link.v_active is true THEN - - SELECT string_agg(connec_id::text, ',') + + SELECT string_agg(connec_id::text, ',') INTO v_connecs - FROM v_edit_connec c - WHERE st_dwithin (new.the_geom, c.the_geom, rec_param_link.v_buffer) + FROM v_edit_connec c + WHERE st_dwithin (new.the_geom, c.the_geom, rec_param_link.v_buffer) AND c.connec_id not in (select feature_id from v_edit_link); - + execute 'SELECT ws_link2net.gw_fct_setlinktonetwork($${"client":{"device":4, "infoType":1,"lang":"ES"},"feature": {"id":"['||v_connecs||']"}, "data":{"feature_type":"CONNEC", "forcedArcs":["'||new.arc_id||'"]}}$$)'; - + END IF; - + RETURN NEW; diff --git a/ud/ftrg/ud_gw_trg_edit_connec.sql b/ud/ftrg/ud_gw_trg_edit_connec.sql index a453c1d15..4071b18ca 100644 --- a/ud/ftrg/ud_gw_trg_edit_connec.sql +++ b/ud/ftrg/ud_gw_trg_edit_connec.sql @@ -274,7 +274,7 @@ BEGIN -- Verified IF (NEW.verified IS NULL) THEN - NEW.verified := (SELECT "value" FROM config_param_user WHERE "parameter"='edit_verified_vdefault' AND "cur_user"="current_user"() LIMIT 1); + NEW.verified := (SELECT "value"::INTEGER FROM config_param_user WHERE "parameter"='edit_verified_vdefault' AND "cur_user"="current_user"() LIMIT 1); END IF; -- State @@ -490,7 +490,7 @@ BEGIN v_streetaxis2, v_streetaxis, NEW.postnumber, NEW.postnumber2, NEW.postcomplement, NEW.postcomplement2, NEW.descript, NEW.rotation, NEW.link, NEW.verified, NEW.the_geom, NEW.undelete, NEW.label_x, NEW.label_y, NEW.label_rotation, NEW.accessibility, NEW.diagonal, NEW.expl_id, NEW.publish, NEW.inventory, NEW.uncertain, NEW.num_value, NEW.private_conneccat_id, - NEW.lastupdate, NEW.lastupdate_user, NEW.asset_id, NEW.drainzone_id, NEW.expl_id2, NEW.adate, NEW.adescript, NEW.plot_code, NEW.placement_type, + NEW.lastupdate, NEW.lastupdate_user, NEW.asset_id, NEW.drainzone_id, NEW.expl_id2, NEW.adate, NEW.adescript, NEW.plot_code, NEW.placement_type, NEW.label_quadrant, NEW.access_type, NEW.streetname, NEW.streetname2); ELSE INSERT INTO connec (connec_id, code, customer_code, top_elev, y1, y2,conneccat_id, connec_type, sector_id, demand, "state", state_type, connec_depth, connec_length, arc_id, annotation, @@ -505,7 +505,7 @@ BEGIN v_streetaxis2, v_streetaxis, NEW.postnumber, NEW.postnumber2, NEW.postcomplement, NEW.postcomplement2, NEW.descript, NEW.rotation, NEW.link, NEW.verified, NEW.the_geom, NEW.undelete, NEW.label_x, NEW.label_y, NEW.label_rotation, NEW.accessibility, NEW.diagonal, NEW.expl_id, NEW.publish, NEW.inventory, NEW.uncertain, NEW.num_value, NEW.private_conneccat_id, NEW.matcat_id, - NEW.lastupdate, NEW.lastupdate_user, NEW.asset_id, NEW.drainzone_id, NEW.expl_id2, NEW.adate, NEW.adescript, NEW.plot_code, NEW.placement_type, + NEW.lastupdate, NEW.lastupdate_user, NEW.asset_id, NEW.drainzone_id, NEW.expl_id2, NEW.adate, NEW.adescript, NEW.plot_code, NEW.placement_type, NEW.label_quadrant, NEW.access_type, NEW.streetname, NEW.streetname2); END IF; diff --git a/ud/ftrg/ud_gw_trg_edit_gully.sql b/ud/ftrg/ud_gw_trg_edit_gully.sql index d81097e21..46a5dca3b 100644 --- a/ud/ftrg/ud_gw_trg_edit_gully.sql +++ b/ud/ftrg/ud_gw_trg_edit_gully.sql @@ -303,7 +303,7 @@ BEGIN -- Verified IF (NEW.verified IS NULL) THEN - NEW.verified := (SELECT "value" FROM config_param_user WHERE "parameter"='edit_verified_vdefault' AND "cur_user"="current_user"() LIMIT 1); + NEW.verified := (SELECT "value"::INTEGER FROM config_param_user WHERE "parameter"='edit_verified_vdefault' AND "cur_user"="current_user"() LIMIT 1); END IF; -- State @@ -613,7 +613,7 @@ BEGIN NEW.postnumber2, NEW.postcomplement2, NEW.descript, NEW.rotation, NEW.link, NEW.verified, NEW.the_geom, NEW.undelete, NEW.label_x, NEW.label_y, NEW.label_rotation, NEW.expl_id , NEW.publish, NEW.inventory, NEW.uncertain, NEW.num_value,NEW.lastupdate, NEW.lastupdate_user, NEW.asset_id, NEW.connec_matcat_id, NEW.gullycat2_id, - NEW.epa_type, NEW.units_placement, NEW.groove_height, NEW.groove_length, NEW.drainzone_id,NEW.expl_id2, NEW.adate, NEW.adescript, + NEW.epa_type, NEW.units_placement, NEW.groove_height, NEW.groove_length, NEW.drainzone_id,NEW.expl_id2, NEW.adate, NEW.adescript, NEW.siphon_type, NEW.odorflap, NEW.connec_y2, NEW.placement_type, NEW.label_quadrant, NEW.access_type, NEW.streetname, NEW.streetname2); END IF; diff --git a/ud/ftrg/ud_gw_trg_edit_node.sql b/ud/ftrg/ud_gw_trg_edit_node.sql index a1741e8b4..be9e718ef 100644 --- a/ud/ftrg/ud_gw_trg_edit_node.sql +++ b/ud/ftrg/ud_gw_trg_edit_node.sql @@ -406,7 +406,7 @@ BEGIN -- Verified IF (NEW.verified IS NULL) THEN - NEW.verified := (SELECT "value" FROM config_param_user WHERE "parameter"='edit_verified_vdefault' AND "cur_user"="current_user"() LIMIT 1); + NEW.verified := (SELECT "value"::INTEGER FROM config_param_user WHERE "parameter"='edit_verified_vdefault' AND "cur_user"="current_user"() LIMIT 1); END IF; -- State @@ -623,7 +623,7 @@ BEGIN NEW.muni_id, v_streetaxis, NEW.postcode, NEW.district_id, v_streetaxis2,NEW.postnumber,NEW.postnumber2, NEW.postcomplement, NEW.postcomplement2, NEW.descript, NEW.rotation,NEW.link, NEW.verified, NEW.undelete, NEW.label_x,NEW.label_y,NEW.label_rotation,NEW.the_geom, NEW.expl_id, NEW.publish, NEW.inventory, NEW.uncertain, NEW.xyz_date, NEW.unconnected, NEW.num_value, NEW.lastupdate, NEW.lastupdate_user,NEW.matcat_id, - NEW.asset_id, NEW.drainzone_id, NEW.parent_id, NEW.arc_id, NEW.expl_id2, NEW.adate, NEW.adescript, NEW.placement_type, + NEW.asset_id, NEW.drainzone_id, NEW.parent_id, NEW.arc_id, NEW.expl_id2, NEW.adate, NEW.adescript, NEW.placement_type, NEW.label_quadrant, NEW.access_type, NEW.brand_id, NEW.model_id, NEW.serial_number, NEW.streetname, NEW.streetname2); END IF; @@ -911,8 +911,8 @@ BEGIN streetaxis2_id=v_streetaxis2, postnumber=NEW.postnumber, postnumber2=NEW.postnumber2, descript=NEW.descript, link=NEW.link, verified=NEW.verified, undelete=NEW.undelete, label_x=NEW.label_x, label_y=NEW.label_y, label_rotation=NEW.label_rotation, publish=NEW.publish, inventory=NEW.inventory, rotation=NEW.rotation, uncertain=NEW.uncertain, xyz_date=NEW.xyz_date, unconnected=NEW.unconnected, expl_id=NEW.expl_id, num_value=NEW.num_value, lastupdate=now(), lastupdate_user=current_user, matcat_id = NEW.matcat_id, - asset_id=NEW.asset_id, drainzone_id=NEW.drainzone_id, parent_id=NEW.parent_id, arc_id = NEW.arc_id, expl_id2=NEW.expl_id2, adate=NEW.adate, adescript=NEW.adescript, - placement_type=NEW.placement_type, label_quadrant=NEW.label_quadrant, access_type=NEW.access_type, brand_id=NEW.brand_id, model_id=NEW.model_id, serial_number=NEW.serial_number, + asset_id=NEW.asset_id, drainzone_id=NEW.drainzone_id, parent_id=NEW.parent_id, arc_id = NEW.arc_id, expl_id2=NEW.expl_id2, adate=NEW.adate, adescript=NEW.adescript, + placement_type=NEW.placement_type, label_quadrant=NEW.label_quadrant, access_type=NEW.access_type, brand_id=NEW.brand_id, model_id=NEW.model_id, serial_number=NEW.serial_number, streetname = NEW.streetname, streetname2 = NEW.streetname2 WHERE node_id = OLD.node_id; END IF; @@ -1007,38 +1007,38 @@ BEGIN END IF; END LOOP; END IF; - + -- set label_quadrant, label_x and label_y according to cat_feature EXECUTE ' SELECT addparam->''labelPosition''->''dist''->>0 FROM cat_feature WHERE id = '||quote_literal(new.node_type)||' ' INTO v_dist_xlab; - + EXECUTE ' SELECT addparam->''labelPosition''->''dist''->>1 FROM cat_feature WHERE id = '||quote_literal(new.node_type)||' ' INTO v_dist_ylab; - - if v_dist_ylab is not null and v_dist_xlab is not null and - (SELECT value::boolean FROM config_param_user WHERE parameter='edit_noderotation_update_dsbl' AND cur_user=current_user) IS FALSE + + if v_dist_ylab is not null and v_dist_xlab is not null and + (SELECT value::boolean FROM config_param_user WHERE parameter='edit_noderotation_update_dsbl' AND cur_user=current_user) IS FALSE then -- only start the process with not-null values - - + + -- prev calc: intermediate rotations according to dist_x and dist_y from cat_feature if (v_dist_xlab > 0 and v_dist_ylab > 0) -- top right or (v_dist_xlab < 0 and v_dist_ylab < 0) -- bottom left - then - v_rot1 = 90+new.rotation; - v_rot2 = 0+new.rotation; - + then + v_rot1 = 90+new.rotation; + v_rot2 = 0+new.rotation; + elsif (v_dist_xlab > 0 and v_dist_ylab < 0) -- bottom right or (v_dist_xlab < 0 and v_dist_ylab > 0) -- top left - then + then v_rot1 = 0+new.rotation; - v_rot2 = 90+new.rotation; - + v_rot2 = 90+new.rotation; + end if; -- prev calc: label position according to cat_feature @@ -1049,8 +1049,8 @@ BEGIN SELECT ST_Project(ST_Transform(eee::geometry, 4326)::geography, '||v_dist_xlab||', radians('||v_rot2||')) as fff from mec) select st_transform(fff::geometry, '||v_srid||') as label_p from lab_point'; - - execute v_sql into v_label_point; + + execute v_sql into v_label_point; -- prev calc: diagonal distance between node and label position (Pitagoras) v_label_dist = sqrt(v_dist_xlab^2 + v_dist_ylab^2); @@ -1068,10 +1068,10 @@ BEGIN ) select degrees(ST_Azimuth(vertex_point, point1)) from mec'; - + execute v_sql into v_cur_rotation using v_label_point, new.node_id; - - + + -- prev calc: current label_quadrant according to cat_feature if v_dist_xlab > 0 and v_dist_ylab > 0 then -- top right v_cur_quadrant = 'TR'; @@ -1082,87 +1082,87 @@ BEGIN elsif v_dist_xlab < 0 and v_dist_ylab < 0 then -- bottom left v_cur_quadrant = 'BL'; end if; - - end if; - + + end if; + -- set label_x and label_y according to cat_feature update node set label_x = st_x(v_label_point) where node_id = new.node_id; update node set label_y = st_y(v_label_point) where node_id = new.node_id; - + update node set label_quadrant = v_cur_quadrant where node_id = new.node_id; -- CASE: if label_quadrant changes if new.label_quadrant != old.label_quadrant then - + if new.label_quadrant ilike 'B%' then - + v_dist_sign = -1; - + if new.label_quadrant ilike '%L' then - + v_rot1 = 45; - + elsif new.label_quadrant ilike '%R' then - + v_rot1 = -45; - + end if; - + end if; - - + + if new.label_quadrant ilike 'T%' then - + v_dist_sign = 1; - + if new.label_quadrant ilike '%L' then - + v_rot1 = -45; - + elsif new.label_quadrant ilike '%R' then - + v_rot1 = 45; - + end if; - + end if; - - + + -- calc new label position with mec as ( - select + select n.the_geom as geom_node, n.rotation as rot_node - from node n, arc a + from node n, arc a where n.node_id = new.node_id - and st_dwithin(a.the_geom, n.the_geom, 5) + and st_dwithin(a.the_geom, n.the_geom, 5) order by st_distance(a.the_geom, n.the_geom) limit 1 ) - select st_transform(st_project(st_transform(geom_node::geometry, 4326), v_dist_sign * v_label_dist, radians(v_rot1+rot_node))::geometry, v_srid) + select st_transform(st_project(st_transform(geom_node::geometry, 4326), v_dist_sign * v_label_dist, radians(v_rot1+rot_node))::geometry, v_srid) into v_new_lab_position from mec; - - + + -- update label position update node set label_x = st_x(v_new_lab_position) where node_id = new.node_id; update node set label_y = st_y(v_new_lab_position) where node_id = new.node_id; - + update node set label_quadrant = new.label_quadrant where node_id = new.node_id; end if; - - + + -- CASE: if rotation of the node changes if new.rotation != old.rotation then - + -- prev calc: current label position select st_setsrid(st_makepoint(label_x::numeric, label_y::numeric), v_srid) into v_label_point from node where node_id = new.node_id; - + -- prev calc: geom of the node execute 'select the_geom from node where node_id = '||quote_literal(new.node_id)||'' into v_geom; - + -- prev calc: current angle between node and its label v_sql = ' with mec as ( @@ -1175,25 +1175,25 @@ BEGIN ) select degrees(ST_Azimuth(vertex_point, point1)) from mec'; - + execute v_sql into v_cur_rotation using v_label_point, new.node_id; - - - -- prev calc: intermediate rotations according to dist_x and dist_y + + + -- prev calc: intermediate rotations according to dist_x and dist_y if (v_dist_xlab > 0 and v_dist_ylab > 0) -- top right or (v_dist_xlab < 0 and v_dist_ylab < 0) -- bottom left - then - v_rot1 = 90+new.rotation; - v_rot2 = 0+new.rotation; - + then + v_rot1 = 90+new.rotation; + v_rot2 = 0+new.rotation; + elsif (v_dist_xlab > 0 and v_dist_ylab < 0) -- bottom right or (v_dist_xlab < 0 and v_dist_ylab > 0) -- top left - then + then v_rot1 = 0+new.rotation; - v_rot2 = 90+new.rotation; - + v_rot2 = 90+new.rotation; + end if; - + -- label position v_sql = ' @@ -1203,17 +1203,17 @@ BEGIN SELECT ST_Project(ST_Transform(eee::geometry, 4326)::geography, '||v_dist_xlab||', radians('||v_rot2||')) as fff from mec) select st_transform(fff::geometry, '||v_srid||') as label_p from lab_point'; - + execute v_sql into v_label_point; update node set label_rotation = new.rotation where node_id = new.node_id; - + update node set label_x = st_x(v_label_point) where node_id = new.node_id; update node set label_y = st_y(v_label_point) where node_id = new.node_id; - - + + end if; - + -- man2inp_values PERFORM gw_fct_man2inp_values(v_input); diff --git a/updates/40/40000/ud/ddl.sql b/updates/40/40000/ud/ddl.sql index 1e3a493b2..e04f745cb 100644 --- a/updates/40/40000/ud/ddl.sql +++ b/updates/40/40000/ud/ddl.sql @@ -535,4 +535,7 @@ CREATE TABLE man_vflwreg ( ); -- 30/01/2025 +SELECT gw_fct_admin_manage_fields($${"data":{"action":"CHANGETYPE","table":"arc", "column":"verified", "dataType":"integer"}}$$); +SELECT gw_fct_admin_manage_fields($${"data":{"action":"CHANGETYPE","table":"node", "column":"verified", "dataType":"integer"}}$$); +SELECT gw_fct_admin_manage_fields($${"data":{"action":"CHANGETYPE","table":"connec", "column":"verified", "dataType":"integer"}}$$); SELECT gw_fct_admin_manage_fields($${"data":{"action":"CHANGETYPE","table":"gully", "column":"verified", "dataType":"integer"}}$$); \ No newline at end of file diff --git a/updates/40/40000/ud/ddlview.sql b/updates/40/40000/ud/ddlview.sql index 5ef568203..89b8f8044 100644 --- a/updates/40/40000/ud/ddlview.sql +++ b/updates/40/40000/ud/ddlview.sql @@ -318,7 +318,8 @@ AS SELECT DISTINCT ON (link_id) l.enddate, date_trunc('second'::text, l.lastupdate) AS lastupdate, l.lastupdate_user, - l.uncertain + l.uncertain, + l.verified FROM link l LEFT JOIN exploitation e USING (expl_id) LEFT JOIN sector s USING (sector_id) diff --git a/updates/40/40000/utils/ddl.sql b/updates/40/40000/utils/ddl.sql index ad9dc25df..15279ba6d 100644 --- a/updates/40/40000/utils/ddl.sql +++ b/updates/40/40000/utils/ddl.sql @@ -242,8 +242,3 @@ SELECT gw_fct_admin_manage_fields($${"data":{"action":"ADD", "table":"link", "co SELECT gw_fct_admin_manage_fields($${"data":{"action":"ADD", "table":"sys_fprocess", "column":"active", "dataType":"boolean", "isUtils":"False"}}$$); update sys_fprocess set active = true; - --- 30/01/2025 -SELECT gw_fct_admin_manage_fields($${"data":{"action":"CHANGETYPE","table":"arc", "column":"verified", "dataType":"integer"}}$$); -SELECT gw_fct_admin_manage_fields($${"data":{"action":"CHANGETYPE","table":"node", "column":"verified", "dataType":"integer"}}$$); -SELECT gw_fct_admin_manage_fields($${"data":{"action":"CHANGETYPE","table":"connec", "column":"verified", "dataType":"integer"}}$$); \ No newline at end of file diff --git a/updates/40/40000/utils/dml_issue_30.sql b/updates/40/40000/utils/dml_issue_30.sql index 1ad71a4f4..fdc226e13 100644 --- a/updates/40/40000/utils/dml_issue_30.sql +++ b/updates/40/40000/utils/dml_issue_30.sql @@ -57,12 +57,12 @@ UPDATE sys_fprocess SET fprocess_name='inlet_x_exploitation with null/wrong valu UPDATE sys_fprocess SET fprocess_name='dma-nodeparent acording with graphdelimiter', "source"='core', fprocess_type='Check graph-config', project_type='ws', except_level=2, except_msg='nodes with cat_feature_node.graph_delimiter=''DMA'' not configured on the dma table.', query_text='SELECT node_id, nodecat_id, the_geom, a.active, t_node.expl_id FROM t_node JOIN cat_node c ON id=nodecat_id JOIN cat_feature_node n ON n.id=c.node_type LEFT JOIN (SELECT node_id, a.active FROM t_node JOIN (SELECT (json_array_elements_text((graphconfig::json->>''use'')::json))::json->>''nodeParent'' as node_id, active FROM dma WHERE graphconfig IS NOT NULL )a USING (node_id)) a USING (node_id) WHERE graph_delimiter=''DMA'' AND (a.node_id IS NULL -OR node_id NOT IN (SELECT (json_array_elements_text((graphconfig::json->>''ignore'')::json))::text FROM dma WHERE active IS TRUE)) AND t_node.state > 0 and verified<>''2'' and a.active is false', info_msg='All nodes with cat_feature_node.graphdelimiter=''DMA'' are defined as nodeParent on dma.graphconfig', function_name='[gw_fct_graphanalytics_check_data, gw_fct_om_check_data, gw_fct_admin_check_data]' WHERE fid=180; -UPDATE sys_fprocess SET fprocess_name='dqa-nodeparent acording with graphdelimiter', "source"='core', fprocess_type='Check graph-data', project_type='ws', except_level=2, except_msg='nodes with cat_feature_node.graph_delimiter=''DQA'' not configured on the dqa table. nodes with cat_feature_node.graph_delimiter=''DQA'' configured for unactive mapzone.', query_text='SELECT node_id, nodecat_id, the_geom, v_prefix_node.expl_id FROM v_prefix_node JOIN cat_node c ON id=nodecat_id JOIN cat_feature_node n ON n.id=c.node_type LEFT JOIN (SELECT node_id FROM v_prefix_node JOIN (SELECT (json_array_elements_text((graphconfig::json->>''use'')::json))::json->>''nodeParent'' as node_id FROM v_prefix_dqa WHERE graphconfig IS NOT NULL ) a USING (node_id)) a USING (node_id) WHERE graph_delimiter=''DQA'' AND (a.node_id IS NULL OR node_id NOT IN (SELECT (json_array_elements_text((graphconfig::json->>''ignore'')::json))::text FROM v_prefix_dqa)) AND v_prefix_node.state > 0 and verified<>''2''', info_msg='All nodes with cat_feature_node.graphdelimiter=''DMA'' are defined as nodeParent on dma.graphconfig', function_name='[gw_fct_graphanalytics_check_data, gw_fct_admin_check_data]' WHERE fid=181; -UPDATE sys_fprocess SET fprocess_name='presszone-nodeparent acording with graphdelimiter', "source"='core', fprocess_type='Check graph-data', project_type='ws', except_level=2, except_msg='nodes with cat_feature_node.graph_delimiter=''PRESSZONE'' not configured on the presszone table. nodes with cat_feature_node.graph_delimiter=''PRESSZONE'' configured for unactive mapzone.', query_text='SELECT node_id, nodecat_id, the_geom, v_prefix_node.expl_id FROM v_prefix_node JOIN cat_node c ON id=nodecat_id JOIN cat_feature_node n ON n.id=c.node_type LEFT JOIN (SELECT node_id FROM v_prefix_node JOIN (SELECT (json_array_elements_text((graphconfig::json->>''use'')::json))::json->>''nodeParent'' as node_id FROM v_prefix_presszone WHERE graphconfig IS NOT NULL )a USING (node_id)) a USING (node_id) WHERE graph_delimiter=''PRESSZONE'' AND (a.node_id IS NULL OR node_id NOT IN (SELECT (json_array_elements_text((graphconfig::json->>''ignore'')::json))::text FROM v_prefix_presszone)) AND v_prefix_node.state > 0 and verified<>''2''', info_msg='All nodes with cat_feature_node.graphdelimiter=''PRESSZONE'' are defined as nodeParent on presszone.graphconfig', function_name='[gw_fct_graphanalytics_check_data, gw_fct_admin_check_data]' WHERE fid=182; -UPDATE sys_fprocess SET fprocess_name='Nodes with state_type is_operative false', "source"='core', fprocess_type='Check om-data', project_type='utils', except_level=2, except_msg='nodes with state > 0 and state_type.is_operative on FALSE. Please, check your data before continue', query_text='SELECT node_id, nodecat_id, the_geom, n.expl_id FROM node n JOIN value_state_type s ON id=state_type WHERE n.state > 0 AND s.is_operative IS FALSE AND verified <>''2''', info_msg='No nodes with state > 0 AND state_type.is_operative on FALSE found.', function_name='[gw_fct_om_check_data, gw_fct_pg2epa_check_data]' WHERE fid=187; +OR node_id NOT IN (SELECT (json_array_elements_text((graphconfig::json->>''ignore'')::json))::text FROM dma WHERE active IS TRUE)) AND t_node.state > 0 and verified <> 2 and a.active is false', info_msg='All nodes with cat_feature_node.graphdelimiter=''DMA'' are defined as nodeParent on dma.graphconfig', function_name='[gw_fct_graphanalytics_check_data, gw_fct_om_check_data, gw_fct_admin_check_data]' WHERE fid=180; +UPDATE sys_fprocess SET fprocess_name='dqa-nodeparent acording with graphdelimiter', "source"='core', fprocess_type='Check graph-data', project_type='ws', except_level=2, except_msg='nodes with cat_feature_node.graph_delimiter=''DQA'' not configured on the dqa table. nodes with cat_feature_node.graph_delimiter=''DQA'' configured for unactive mapzone.', query_text='SELECT node_id, nodecat_id, the_geom, v_prefix_node.expl_id FROM v_prefix_node JOIN cat_node c ON id=nodecat_id JOIN cat_feature_node n ON n.id=c.node_type LEFT JOIN (SELECT node_id FROM v_prefix_node JOIN (SELECT (json_array_elements_text((graphconfig::json->>''use'')::json))::json->>''nodeParent'' as node_id FROM v_prefix_dqa WHERE graphconfig IS NOT NULL ) a USING (node_id)) a USING (node_id) WHERE graph_delimiter=''DQA'' AND (a.node_id IS NULL OR node_id NOT IN (SELECT (json_array_elements_text((graphconfig::json->>''ignore'')::json))::text FROM v_prefix_dqa)) AND v_prefix_node.state > 0 and verified <> 2', info_msg='All nodes with cat_feature_node.graphdelimiter=''DMA'' are defined as nodeParent on dma.graphconfig', function_name='[gw_fct_graphanalytics_check_data, gw_fct_admin_check_data]' WHERE fid=181; +UPDATE sys_fprocess SET fprocess_name='presszone-nodeparent acording with graphdelimiter', "source"='core', fprocess_type='Check graph-data', project_type='ws', except_level=2, except_msg='nodes with cat_feature_node.graph_delimiter=''PRESSZONE'' not configured on the presszone table. nodes with cat_feature_node.graph_delimiter=''PRESSZONE'' configured for unactive mapzone.', query_text='SELECT node_id, nodecat_id, the_geom, v_prefix_node.expl_id FROM v_prefix_node JOIN cat_node c ON id=nodecat_id JOIN cat_feature_node n ON n.id=c.node_type LEFT JOIN (SELECT node_id FROM v_prefix_node JOIN (SELECT (json_array_elements_text((graphconfig::json->>''use'')::json))::json->>''nodeParent'' as node_id FROM v_prefix_presszone WHERE graphconfig IS NOT NULL )a USING (node_id)) a USING (node_id) WHERE graph_delimiter=''PRESSZONE'' AND (a.node_id IS NULL OR node_id NOT IN (SELECT (json_array_elements_text((graphconfig::json->>''ignore'')::json))::text FROM v_prefix_presszone)) AND v_prefix_node.state > 0 and verified <> 2', info_msg='All nodes with cat_feature_node.graphdelimiter=''PRESSZONE'' are defined as nodeParent on presszone.graphconfig', function_name='[gw_fct_graphanalytics_check_data, gw_fct_admin_check_data]' WHERE fid=182; +UPDATE sys_fprocess SET fprocess_name='Nodes with state_type is_operative false', "source"='core', fprocess_type='Check om-data', project_type='utils', except_level=2, except_msg='nodes with state > 0 and state_type.is_operative on FALSE. Please, check your data before continue', query_text='SELECT node_id, nodecat_id, the_geom, n.expl_id FROM node n JOIN value_state_type s ON id=state_type WHERE n.state > 0 AND s.is_operative IS FALSE AND verified <> 2', info_msg='No nodes with state > 0 AND state_type.is_operative on FALSE found.', function_name='[gw_fct_om_check_data, gw_fct_pg2epa_check_data]' WHERE fid=187; UPDATE sys_fprocess SET fprocess_name='Arcs with state_type is_operative false', "source"='core', fprocess_type='Check om-data', project_type='utils', except_level=2, except_msg='arcs with state > 0 and state_type.is_operative on FALSE. Please, check your data before continue', query_text='SELECT arc_id, arccat_id, the_geom, a.expl_id FROM v_prefix_arc a JOIN value_state_type s ON id=state_type -WHERE a.state > 0 AND s.is_operative IS FALSE AND verified <>''2''', info_msg='No arcs with state > 0 AND state_type.is_operative on FALSE found.', function_name='[gw_fct_om_check_data, gw_fct_pg2epa_check_data]' WHERE fid=188; +WHERE a.state > 0 AND s.is_operative IS FALSE AND verified <> 2', info_msg='No arcs with state > 0 AND state_type.is_operative on FALSE found.', function_name='[gw_fct_om_check_data, gw_fct_pg2epa_check_data]' WHERE fid=188; UPDATE sys_fprocess SET fprocess_name='Arcs with state=1 using nodes on state=0', "source"='core', fprocess_type='Check om-topology', project_type='utils', except_level=3, except_msg='arcs with state=1 using extremals nodes with state = 0. Please, check your data before continue', query_text='SELECT a.arc_id, arccat_id, a.the_geom, a.expl_id FROM v_prefix_arc a JOIN v_prefix_node n ON node_1=node_id WHERE a.state =1 AND n.state=0 UNION SELECT a.arc_id, arccat_id, a.the_geom, a.expl_id FROM v_prefix_arc a @@ -1088,7 +1088,7 @@ insert into sys_fprocess values (632, 'Orifice present in more than one enabled insert into sys_fprocess values (633, 'Pump present in more than one enabled scenario','ud'); insert into sys_fprocess values (634, 'Weir present in more than one enabled scenario','ud'); insert into sys_fprocess values (635, 'Junction present in more than one enabled scenario','ud'); -INSERT INTO sys_fprocess (fid, fprocess_name, project_type, parameters, "source", isaudit, fprocess_type, addparam, except_level, except_msg, except_table, except_table_msg, query_text, info_msg, function_name, active) VALUES(636, 'dma-nodeparent acording with graphdelimiter (unactive dma)', 'ws', NULL, 'core', true, 'Check graph-config', NULL, 2, 'nodes with cat_feature_node.graph_delimiter=''DMA'' configured for unactive mapzone.', NULL, NULL, 'SELECT node_id, nodecat_id, the_geom, t_node.expl_id FROM t_node JOIN cat_node c ON id=nodecat_id JOIN cat_feature_node n ON n.id=c.node_type LEFT JOIN (SELECT node_id FROM t_node JOIN (SELECT (json_array_elements_text((graphconfig::json->>''use'')::json))::json->>''nodeParent'' as node_id FROM t_dma WHERE graphconfig IS NOT NULL )a USING (node_id)) a USING (node_id) WHERE graph_delimiter=''DMA'' AND (a.node_id IS NULL OR node_id NOT IN (SELECT (json_array_elements_text((graphconfig::json->>''ignore'')::json))::text FROM t_dma)) AND t_node.state > 0 and verified<>''2''', 'All nodes with cat_feature_node.graphdelimiter=''DMA'' are defined as nodeParent on dma.graphconfig', '[gw_fct_graphanalytics_check_data, gw_fct_om_check_data, gw_fct_admin_check_data]', true) ON CONFLICT (fid) DO NOTHING; +INSERT INTO sys_fprocess (fid, fprocess_name, project_type, parameters, "source", isaudit, fprocess_type, addparam, except_level, except_msg, except_table, except_table_msg, query_text, info_msg, function_name, active) VALUES(636, 'dma-nodeparent acording with graphdelimiter (unactive dma)', 'ws', NULL, 'core', true, 'Check graph-config', NULL, 2, 'nodes with cat_feature_node.graph_delimiter=''DMA'' configured for unactive mapzone.', NULL, NULL, 'SELECT node_id, nodecat_id, the_geom, t_node.expl_id FROM t_node JOIN cat_node c ON id=nodecat_id JOIN cat_feature_node n ON n.id=c.node_type LEFT JOIN (SELECT node_id FROM t_node JOIN (SELECT (json_array_elements_text((graphconfig::json->>''use'')::json))::json->>''nodeParent'' as node_id FROM t_dma WHERE graphconfig IS NOT NULL )a USING (node_id)) a USING (node_id) WHERE graph_delimiter=''DMA'' AND (a.node_id IS NULL OR node_id NOT IN (SELECT (json_array_elements_text((graphconfig::json->>''ignore'')::json))::text FROM t_dma)) AND t_node.state > 0 and verified <> 2', 'All nodes with cat_feature_node.graphdelimiter=''DMA'' are defined as nodeParent on dma.graphconfig', '[gw_fct_graphanalytics_check_data, gw_fct_om_check_data, gw_fct_admin_check_data]', true) ON CONFLICT (fid) DO NOTHING; UPDATE sys_fprocess SET except_table='anl_arc' WHERE fid=103; UPDATE sys_fprocess SET except_table='anl_node' WHERE fid=106; diff --git a/updates/40/40000/ws/ddl.sql b/updates/40/40000/ws/ddl.sql index 88bacc74b..0bd8f4f5c 100644 --- a/updates/40/40000/ws/ddl.sql +++ b/updates/40/40000/ws/ddl.sql @@ -656,4 +656,9 @@ ALTER TABLE supplyzone ADD CONSTRAINT node_supplyzone_id_fkey FOREIGN KEY (suppl SELECT gw_fct_admin_manage_fields($${"data":{"action":"ADD","table":"connec", "column":"supplyzone_id", "dataType":"int4"}}$$); ALTER TABLE supplyzone ADD CONSTRAINT connec_supplyzone_id_fkey FOREIGN KEY (supplyzone_id) REFERENCES supplyzone(supplyzone_id) ON DELETE RESTRICT ON UPDATE CASCADE; SELECT gw_fct_admin_manage_fields($${"data":{"action":"ADD","table":"link", "column":"supplyzone_id", "dataType":"int4"}}$$); -ALTER TABLE supplyzone ADD CONSTRAINT link_supplyzone_id_fkey FOREIGN KEY (supplyzone_id) REFERENCES supplyzone(supplyzone_id) ON DELETE RESTRICT ON UPDATE CASCADE; \ No newline at end of file +ALTER TABLE supplyzone ADD CONSTRAINT link_supplyzone_id_fkey FOREIGN KEY (supplyzone_id) REFERENCES supplyzone(supplyzone_id) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- 30/01/2025 +SELECT gw_fct_admin_manage_fields($${"data":{"action":"CHANGETYPE","table":"arc", "column":"verified", "dataType":"integer"}}$$); +SELECT gw_fct_admin_manage_fields($${"data":{"action":"CHANGETYPE","table":"node", "column":"verified", "dataType":"integer"}}$$); +SELECT gw_fct_admin_manage_fields($${"data":{"action":"CHANGETYPE","table":"connec", "column":"verified", "dataType":"integer"}}$$); \ No newline at end of file diff --git a/updates/40/40000/ws/ddlview.sql b/updates/40/40000/ws/ddlview.sql index 195f8f501..6fb4112f3 100644 --- a/updates/40/40000/ws/ddlview.sql +++ b/updates/40/40000/ws/ddlview.sql @@ -432,6 +432,7 @@ CREATE OR REPLACE VIEW vu_link AS date_trunc('second'::text, l.lastupdate) AS lastupdate, l.lastupdate_user, l.uncertain, + l.verified, l.minsector_id, l.macrominsector_id, CASE @@ -4664,7 +4665,7 @@ AS SELECT d.dqa_id, WHERE d.dqa_id > 0 ORDER BY d.dqa_id; - + CREATE OR REPLACE VIEW v_ui_sector AS SELECT s.sector_id, diff --git a/utils/fct/gw_fct_manage_temp_tables.sql b/utils/fct/gw_fct_manage_temp_tables.sql index 0ab1dec66..ff18e1617 100644 --- a/utils/fct/gw_fct_manage_temp_tables.sql +++ b/utils/fct/gw_fct_manage_temp_tables.sql @@ -130,9 +130,9 @@ BEGIN -- LOGIC FOR THE DIFFERENT ACTIONS IF v_action = 'CREATE' THEN IF v_verifiedExceptions THEN - v_filter = ' WHERE (verified is null or verified::INTEGER IN (0,1))'; + v_filter = ' WHERE (verified IS NULL OR verified IN (0,1))'; ELSE - v_filter = ' WHERE state is not null '; + v_filter = ' WHERE state IS NOT NULL '; END IF; diff --git a/utils/ftrg/gw_trg_edit_element.sql b/utils/ftrg/gw_trg_edit_element.sql index 4326d8a53..6500e311e 100644 --- a/utils/ftrg/gw_trg_edit_element.sql +++ b/utils/ftrg/gw_trg_edit_element.sql @@ -90,7 +90,7 @@ BEGIN -- Verified IF (NEW.verified IS NULL) THEN - NEW.verified := (SELECT "value" FROM config_param_user WHERE "parameter"='edit_verified_vdefault' AND "cur_user"="current_user"() LIMIT 1); + NEW.verified := (SELECT "value"::INTEGER FROM config_param_user WHERE "parameter"='edit_verified_vdefault' AND "cur_user"="current_user"() LIMIT 1); END IF; -- State @@ -111,7 +111,7 @@ BEGIN IF (NEW.expl_id IS NULL) THEN EXECUTE 'SELECT gw_fct_getmessage($${"client":{"device":4, "infoType":1, "lang":"ES"},"feature":{}, "data":{"message":"2012", "function":"1114","parameters":{"feature_id":"'||NEW.element_id||'"}}}$$);'; - END IF; + END IF; END IF; END IF; diff --git a/utils/ftrg/gw_trg_edit_link.sql b/utils/ftrg/gw_trg_edit_link.sql index 8ceead7f1..09b032bd6 100644 --- a/utils/ftrg/gw_trg_edit_link.sql +++ b/utils/ftrg/gw_trg_edit_link.sql @@ -540,6 +540,11 @@ BEGIN END IF; END IF; + -- Verified + IF (NEW.verified IS NULL) THEN + NEW.verified := (SELECT "value"::INTEGER FROM config_param_user WHERE "parameter"='edit_verified_vdefault' AND "cur_user"="current_user"() LIMIT 1); + END IF; + -- upsert process IF TG_OP ='INSERT' THEN @@ -552,17 +557,18 @@ BEGIN IF v_projectype = 'WS' THEN INSERT INTO link (link_id, feature_type, feature_id, expl_id, exit_id, exit_type, userdefined_geom, state, the_geom, sector_id, - fluid_type, dma_id, dqa_id, presszone_id, minsector_id, conneccat_id, workcat_id, workcat_id_end, builtdate, enddate, exit_elev, exit_topelev, uncertain, muni_id) + fluid_type, dma_id, dqa_id, presszone_id, minsector_id, conneccat_id, workcat_id, workcat_id_end, builtdate, enddate, exit_elev, exit_topelev, + uncertain, muni_id, verified) VALUES (NEW.link_id, NEW.feature_type, NEW.feature_id, v_expl, NEW.exit_id, NEW.exit_type, TRUE, NEW.state, NEW.the_geom, v_sector, v_fluidtype, v_dma, v_dqa, v_presszone, v_minsector, NEW.conneccat_id, NEW.workcat_id, NEW.workcat_id_end, NEW.builtdate, NEW.enddate, - NEW.exit_elev, NEW.exit_topelev, NEW.uncertain, NEW.muni_id); + NEW.exit_elev, NEW.exit_topelev, NEW.uncertain, NEW.muni_id, NEW.verified); ELSIF v_projectype = 'UD' THEN INSERT INTO link (link_id, feature_type, feature_id, expl_id, exit_id, exit_type, userdefined_geom, state, the_geom, sector_id, fluid_type, dma_id, - conneccat_id, workcat_id, workcat_id_end, builtdate, enddate, exit_elev, exit_topelev, uncertain, muni_id) + conneccat_id, workcat_id, workcat_id_end, builtdate, enddate, exit_elev, exit_topelev, uncertain, muni_id, verified) VALUES (NEW.link_id, NEW.feature_type, NEW.feature_id, v_expl, NEW.exit_id, NEW.exit_type, TRUE, NEW.state, NEW.the_geom, v_sector, v_fluidtype, v_dma, - NEW.conneccat_id, NEW.workcat_id, NEW.workcat_id_end, NEW.builtdate, NEW.enddate, NEW.exit_elev, NEW.exit_topelev, NEW.uncertain, NEW.muni_id); + NEW.conneccat_id, NEW.workcat_id, NEW.workcat_id_end, NEW.builtdate, NEW.enddate, NEW.exit_elev, NEW.exit_topelev, NEW.uncertain, NEW.muni_id, NEW.verified); END IF; -- update feature @@ -694,7 +700,8 @@ BEGIN -- update link parameters UPDATE link SET state = NEW.state, the_geom = NEW.the_geom, workcat_id = NEW.workcat_id, workcat_id_end = NEW.workcat_id_end, builtdate = NEW.builtdate, - enddate = NEW.enddate, exit_elev = NEW.exit_elev, exit_topelev = NEW.exit_topelev, uncertain = NEW.uncertain, muni_id = NEW.muni_id, sector_id=v_sector + enddate = NEW.enddate, exit_elev = NEW.exit_elev, exit_topelev = NEW.exit_topelev, uncertain = NEW.uncertain, muni_id = NEW.muni_id, sector_id=v_sector, + verified = NEW.verified WHERE link_id=NEW.link_id; -- Update state_type if edit_connect_update_statetype is TRUE diff --git a/ws/ftrg/ws_gw_trg_edit_arc.sql b/ws/ftrg/ws_gw_trg_edit_arc.sql index f0e47c915..8eaa8314e 100644 --- a/ws/ftrg/ws_gw_trg_edit_arc.sql +++ b/ws/ftrg/ws_gw_trg_edit_arc.sql @@ -368,7 +368,7 @@ BEGIN -- Verified IF (NEW.verified IS NULL) THEN - NEW.verified := (SELECT "value" FROM config_param_user WHERE "parameter"='edit_verified_vdefault' AND "cur_user"="current_user"() LIMIT 1); + NEW.verified := (SELECT "value"::INTEGER FROM config_param_user WHERE "parameter"='edit_verified_vdefault' AND "cur_user"="current_user"() LIMIT 1); END IF; -- LINK @@ -428,7 +428,7 @@ BEGIN NEW.soilcat_id, NEW.function_type, NEW.category_type, NEW.fluid_type, NEW.location_type, NEW.workcat_id, NEW.workcat_id_end, NEW.workcat_id_plan, NEW.buildercat_id, NEW.builtdate,NEW.enddate, NEW.ownercat_id, NEW.muni_id, NEW.postcode, NEW.district_id,v_streetaxis,NEW.postnumber, NEW.postcomplement, v_streetaxis2, NEW.postnumber2, NEW.postcomplement2, NEW.descript,NEW.link, NEW.verified, NEW.the_geom,NEW.undelete,NEW.label_x,NEW.label_y,NEW.label_rotation, NEW.publish, NEW.inventory, NEW.expl_id, NEW.num_value, - NEW.adate, NEW.adescript, NEW.lastupdate, NEW.lastupdate_user, NEW.asset_id, NEW.pavcat_id, NEW.om_state, NEW.conserv_state, + NEW.adate, NEW.adescript, NEW.lastupdate, NEW.lastupdate_user, NEW.asset_id, NEW.pavcat_id, NEW.om_state, NEW.conserv_state, NEW.parent_id, NEW.expl_id2, NEW.brand_id, NEW.model_id, NEW.serial_number, NEW.label_quadrant, NEW.streetname, NEW.streetname2); -- this overwrites triger topocontrol arc values (triggered before insertion) just in that moment: In order to make more profilactic this issue only will be overwrited in case of NEW.node_* not nulls @@ -507,30 +507,30 @@ BEGIN "state":"'||NEW.state::text||'","stateType":"'||NEW.state_type::text||'", "arcId":"'||NEW.arc_id||'" }}$$);'; END IF; END IF; - - + + -- automatic connection of closest connecs to the arc - SELECT + SELECT ("value"::json->>'active')::boolean as v_active, ("value"::json->>'buffer')::numeric as v_buffer INTO rec_param_link - FROM config_param_user - WHERE "parameter" ilike 'edit_arc_automatic_link2netowrk' + FROM config_param_user + WHERE "parameter" ilike 'edit_arc_automatic_link2netowrk' AND cur_user = current_user; - + IF rec_param_link.v_active is true THEN - - SELECT string_agg(connec_id::text, ',') + + SELECT string_agg(connec_id::text, ',') INTO v_connecs - FROM v_edit_connec c - WHERE st_dwithin (new.the_geom, c.the_geom, rec_param_link.v_buffer) + FROM v_edit_connec c + WHERE st_dwithin (new.the_geom, c.the_geom, rec_param_link.v_buffer) AND c.connec_id not in (select feature_id from v_edit_link); - + execute 'SELECT ws_link2net.gw_fct_setlinktonetwork($${"client":{"device":4, "infoType":1,"lang":"ES"},"feature": {"id":"['||v_connecs||']"}, "data":{"feature_type":"CONNEC", "forcedArcs":["'||new.arc_id||'"]}}$$)'; - + END IF; - + RETURN NEW; diff --git a/ws/ftrg/ws_gw_trg_edit_connec.sql b/ws/ftrg/ws_gw_trg_edit_connec.sql index 646e618c5..2e835d2aa 100644 --- a/ws/ftrg/ws_gw_trg_edit_connec.sql +++ b/ws/ftrg/ws_gw_trg_edit_connec.sql @@ -418,7 +418,7 @@ BEGIN -- Verified IF (NEW.verified IS NULL) THEN - NEW.verified := (SELECT "value" FROM config_param_user WHERE "parameter"='edit_verified_vdefault' AND "cur_user"="current_user"() LIMIT 1); + NEW.verified := (SELECT "value"::INTEGER FROM config_param_user WHERE "parameter"='edit_verified_vdefault' AND "cur_user"="current_user"() LIMIT 1); END IF; -- Code @@ -543,7 +543,7 @@ BEGIN NEW.postcomplement2, NEW.descript, NEW.link, NEW.verified, NEW.rotation, NEW.the_geom,NEW.undelete,NEW.label_x, NEW.label_y,NEW.label_rotation, NEW.expl_id, NEW.publish, NEW.inventory, NEW.num_value, NEW.connec_length, NEW.arc_id, NEW.minsector_id, NEW.dqa_id, NEW.pjoint_id, NEW.pjoint_type, NEW.adate, NEW.adescript, NEW.accessibility, NEW.lastupdate, NEW.lastupdate_user, NEW.asset_id, NEW.epa_type, NEW.om_state, NEW.conserv_state, NEW.priority, - NEW.valve_location, NEW.valve_type, NEW.shutoff_valve, NEW.access_type, NEW.placement_type, NEW.crmzone_id, NEW.expl_id2, NEW.plot_code, NEW.brand_id, NEW.model_id, NEW.serial_number, + NEW.valve_location, NEW.valve_type, NEW.shutoff_valve, NEW.access_type, NEW.placement_type, NEW.crmzone_id, NEW.expl_id2, NEW.plot_code, NEW.brand_id, NEW.model_id, NEW.serial_number, NEW.cat_valve, NEW.label_quadrant, NEW.streetname, NEW.streetname2); SELECT feature_class, cat_feature.id INTO v_feature_class, v_featurecat_id FROM cat_feature diff --git a/ws/ftrg/ws_gw_trg_edit_node.sql b/ws/ftrg/ws_gw_trg_edit_node.sql index 8782a6f6d..85a98ea74 100644 --- a/ws/ftrg/ws_gw_trg_edit_node.sql +++ b/ws/ftrg/ws_gw_trg_edit_node.sql @@ -461,7 +461,7 @@ BEGIN -- Verified IF (NEW.verified IS NULL) THEN - NEW.verified := (SELECT "value" FROM config_param_user WHERE "parameter"='edit_verified_vdefault' AND "cur_user"="current_user"() LIMIT 1); + NEW.verified := (SELECT "value"::INTEGER FROM config_param_user WHERE "parameter"='edit_verified_vdefault' AND "cur_user"="current_user"() LIMIT 1); END IF; -- Parent id @@ -1094,38 +1094,38 @@ BEGIN UPDATE arc SET nodetype_2 = v_new_node_type, elevation2=NEW.elevation, depth2=NEW.depth, staticpress2 = NEW.staticpressure WHERE node_2 = NEW.node_id; - + -- set label_quadrant, label_x and label_y according to cat_feature EXECUTE ' SELECT addparam->''labelPosition''->''dist''->>0 FROM cat_feature WHERE id = '||quote_literal(new.node_type)||' ' INTO v_dist_xlab; - + EXECUTE ' SELECT addparam->''labelPosition''->''dist''->>1 FROM cat_feature WHERE id = '||quote_literal(new.node_type)||' ' INTO v_dist_ylab; - - if v_dist_ylab is not null and v_dist_xlab is not null and - (SELECT value::boolean FROM config_param_user WHERE parameter='edit_noderotation_update_dsbl' AND cur_user=current_user) IS FALSE + + if v_dist_ylab is not null and v_dist_xlab is not null and + (SELECT value::boolean FROM config_param_user WHERE parameter='edit_noderotation_update_dsbl' AND cur_user=current_user) IS FALSE then -- only start the process with not-null values - - + + -- prev calc: intermediate rotations according to dist_x and dist_y from cat_feature if (v_dist_xlab > 0 and v_dist_ylab > 0) -- top right or (v_dist_xlab < 0 and v_dist_ylab < 0) -- bottom left - then - v_rot1 = 90+new.rotation; - v_rot2 = 0+new.rotation; - + then + v_rot1 = 90+new.rotation; + v_rot2 = 0+new.rotation; + elsif (v_dist_xlab > 0 and v_dist_ylab < 0) -- bottom right or (v_dist_xlab < 0 and v_dist_ylab > 0) -- top left - then + then v_rot1 = 0+new.rotation; - v_rot2 = 90+new.rotation; - + v_rot2 = 90+new.rotation; + end if; -- prev calc: label position according to cat_feature @@ -1136,8 +1136,8 @@ BEGIN SELECT ST_Project(ST_Transform(eee::geometry, 4326)::geography, '||v_dist_xlab||', radians('||v_rot2||')) as fff from mec) select st_transform(fff::geometry, '||v_srid||') as label_p from lab_point'; - - execute v_sql into v_label_point; + + execute v_sql into v_label_point; -- prev calc: diagonal distance between node and label position (Pitagoras) v_label_dist = sqrt(v_dist_xlab^2 + v_dist_ylab^2); @@ -1155,10 +1155,10 @@ BEGIN ) select degrees(ST_Azimuth(vertex_point, point1)) from mec'; - + execute v_sql into v_cur_rotation using v_label_point, new.node_id; - - + + -- prev calc: current label_quadrant according to cat_feature if v_dist_xlab > 0 and v_dist_ylab > 0 then -- top right v_cur_quadrant = 'TR'; @@ -1169,87 +1169,87 @@ BEGIN elsif v_dist_xlab < 0 and v_dist_ylab < 0 then -- bottom left v_cur_quadrant = 'BL'; end if; - - end if; - + + end if; + -- set label_x and label_y according to cat_feature update node set label_x = st_x(v_label_point) where node_id = new.node_id; update node set label_y = st_y(v_label_point) where node_id = new.node_id; - + update node set label_quadrant = v_cur_quadrant where node_id = new.node_id; -- CASE: if label_quadrant changes if new.label_quadrant != old.label_quadrant then - + if new.label_quadrant ilike 'B%' then - + v_dist_sign = -1; - + if new.label_quadrant ilike '%L' then - + v_rot1 = 45; - + elsif new.label_quadrant ilike '%R' then - + v_rot1 = -45; - + end if; - + end if; - - + + if new.label_quadrant ilike 'T%' then - + v_dist_sign = 1; - + if new.label_quadrant ilike '%L' then - + v_rot1 = -45; - + elsif new.label_quadrant ilike '%R' then - + v_rot1 = 45; - + end if; - + end if; - - + + -- calc new label position with mec as ( - select + select n.the_geom as geom_node, n.rotation as rot_node - from node n, arc a + from node n, arc a where n.node_id = new.node_id - and st_dwithin(a.the_geom, n.the_geom, 5) + and st_dwithin(a.the_geom, n.the_geom, 5) order by st_distance(a.the_geom, n.the_geom) limit 1 ) - select st_transform(st_project(st_transform(geom_node::geometry, 4326), v_dist_sign * v_label_dist, radians(v_rot1+rot_node))::geometry, v_srid) + select st_transform(st_project(st_transform(geom_node::geometry, 4326), v_dist_sign * v_label_dist, radians(v_rot1+rot_node))::geometry, v_srid) into v_new_lab_position from mec; - - + + -- update label position update node set label_x = st_x(v_new_lab_position) where node_id = new.node_id; update node set label_y = st_y(v_new_lab_position) where node_id = new.node_id; - + update node set label_quadrant = new.label_quadrant where node_id = new.node_id; end if; - - + + -- CASE: only change the rotation of the node if new.rotation != old.rotation then - + -- prev calc: current label position select st_setsrid(st_makepoint(label_x::numeric, label_y::numeric), v_srid) into v_label_point from node where node_id = new.node_id; - + -- prev calc: geom of the node execute 'select the_geom from node where node_id = '||quote_literal(new.node_id)||'' into v_geom; - + -- prev calc: current angle between node and its label v_sql = ' with mec as ( @@ -1262,25 +1262,25 @@ BEGIN ) select degrees(ST_Azimuth(vertex_point, point1)) from mec'; - + execute v_sql into v_cur_rotation using v_label_point, new.node_id; - - - -- prev calc: intermediate rotations according to dist_x and dist_y + + + -- prev calc: intermediate rotations according to dist_x and dist_y if (v_dist_xlab > 0 and v_dist_ylab > 0) -- top right or (v_dist_xlab < 0 and v_dist_ylab < 0) -- bottom left - then - v_rot1 = 90+new.rotation; - v_rot2 = 0+new.rotation; - + then + v_rot1 = 90+new.rotation; + v_rot2 = 0+new.rotation; + elsif (v_dist_xlab > 0 and v_dist_ylab < 0) -- bottom right or (v_dist_xlab < 0 and v_dist_ylab > 0) -- top left - then + then v_rot1 = 0+new.rotation; - v_rot2 = 90+new.rotation; - + v_rot2 = 90+new.rotation; + end if; - + -- label position v_sql = ' @@ -1290,18 +1290,18 @@ BEGIN SELECT ST_Project(ST_Transform(eee::geometry, 4326)::geography, '||v_dist_xlab||', radians('||v_rot2||')) as fff from mec) select st_transform(fff::geometry, '||v_srid||') as label_p from lab_point'; - + execute v_sql into v_label_point; update node set label_rotation = new.rotation where node_id = new.node_id; - + update node set label_x = st_x(v_label_point) where node_id = new.node_id; update node set label_y = st_y(v_label_point) where node_id = new.node_id; - - + + end if; - - + + -- man2inp_values PERFORM gw_fct_man2inp_values(v_input);