Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
BMG PUBLIC RESOURCES
SIG-TOPO-BMG
Commits
f7c6173d
Commit
f7c6173d
authored
Oct 23, 2020
by
Alice Salsé
Browse files
✨
remove spikes function
parent
4896d9d1
Changes
2
Hide whitespace changes
Inline
Side-by-side
sql/all/function_remove_spikes.sql
0 → 100644
View file @
f7c6173d
\
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
;
sql/network/function_trigger_pipe_before.sql
View file @
f7c6173d
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment