Commit 87d2c64b authored by Alice Salsé's avatar Alice Salsé
Browse files

👌 améliorations

parent 31e22a80
\encoding UTF8
set search_path to utils, public;
CREATE OR REPLACE FUNCTION fnc_remove_spikes(
CREATE OR REPLACE FUNCTION fnc_remove_spike(
IN i_geom geometry,
OUT o_geom geometry
)
......@@ -14,8 +14,8 @@ with dump_pipe as (
)
, intsct as (
SELECT *
,ST_DWithin(LEAD(vtx,1) OVER (ORDER by no_vtx), segmt_lag, config.get_tolerance('topo')) intsct_lag
,ST_DWithin(LAG(vtx,1) OVER (ORDER by no_vtx), segmt_lead, config.get_tolerance('topo')) intsct_lead
,ST_DWithin(LEAD(vtx,1) OVER (ORDER by no_vtx), segmt_lag, config.get_tolerance('spike')) intsct_lag
,ST_DWithin(LAG(vtx,1) OVER (ORDER by no_vtx), segmt_lead, config.get_tolerance('spike')) intsct_lead
FROM dump_pipe
)
select st_makeline(array_agg(vtx)) o_geom
......
......@@ -8,8 +8,11 @@ CREATE TABLE IF NOT EXISTS config.tolerance (
type varchar(15) PRIMARY KEY,
distance float
);
INSERT INTO config.tolerance VALUES('topo', 0.01)
ON CONFLICT DO NOTHING;
INSERT INTO config.tolerance VALUES('spike', 0.05)
ON CONFLICT DO NOTHING;
CREATE OR REPLACE FUNCTION config.get_tolerance(i_type varchar(15))
RETURNS double precision AS
......
......@@ -102,7 +102,7 @@ begin
END ugeom
FROM %1$I.%2$I p
LEFT OUTER JOIN %1$I.lpipe lp ON lp.end_node=p.id
,utils.fnc_get_closest_pipe(coalesce(lp.geom, p.geom), p.level,''%1$I.pipe'') tp
,utils.fnc_get_closest_pipe(p.geom, p.level,''%1$I.pipe'') tp
WHERE p.pipe_id = %4$s
)
UPDATE %1$I.%2$I p
......
......@@ -23,7 +23,7 @@ begin
-- >>> Tolerance for snapping <<<
select config.get_tolerance('topo') into _distance;
new.geom:=ST_RemoveRepeatedPoints(new.geom, _distance);
new.geom:=utils.fnc_remove_spikes(new.geom);
new.geom:=utils.fnc_remove_spike(new.geom);
-- >>> Find start & end nodes <<<
for _node_table_name in select unnest(_node_tables) LOOP
if _start_node is null or _end_node is null THEN
......
......@@ -35,7 +35,7 @@ begin
,TG_TABLE_SCHEMA, _nw_table, new.geom, _level, _distance)
INTO _geom_id;
-- >>> New row to jsonb <<<
_new:=jsonb_strip_nulls(row_to_json(new.*)::jsonb);
_new := row_to_json(new.*)::jsonb;
_new := _new -'id' || jsonb_build_object('level', _level);
-- >>> Insert geom if not exist <<<
IF _geom_id is null then
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment