Commit f7c6173d authored by Alice Salsé's avatar Alice Salsé
Browse files

remove spikes function

parent 4896d9d1
\encoding UTF8
set search_path to utils, public;
CREATE OR REPLACE FUNCTION fnc_remove_spikes(
IN i_geom geometry,
OUT o_geom geometry
)
RETURNS geometry AS $BODY$
with dump_pipe as (
SELECT d.path[1] no_vtx, d.geom vtx
, ST_MakeLine(LAG(d.geom,1) OVER (ORDER by d.path[1]),d.geom) segmt_lag
, ST_MakeLine(d.geom,LEAD(d.geom,1) OVER (ORDER by d.path[1])) segmt_lead
FROM ST_DumpPoints(i_geom) d
)
, 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
FROM dump_pipe
)
select st_makeline(array_agg(vtx)) o_geom
from intsct
where intsct_lag is not True
and intsct_lead is not True
;
$BODY$
LANGUAGE sql IMMUTABLE SECURITY DEFINER
COST 100;
......@@ -23,6 +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);
-- >>> 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
......
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