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
87d2c64b
Commit
87d2c64b
authored
Nov 17, 2020
by
Alice Salsé
Browse files
👌
améliorations
parent
31e22a80
Changes
5
Hide whitespace changes
Inline
Side-by-side
sql/all/function_remove_spike
s
.sql
→
sql/all/function_remove_spike.sql
View file @
87d2c64b
\
encoding
UTF8
set
search_path
to
utils
,
public
;
CREATE
OR
REPLACE
FUNCTION
fnc_remove_spike
s
(
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
...
...
sql/network/create_table.sql
View file @
87d2c64b
...
...
@@ -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
...
...
sql/network/function_trigger_pipe_after.sql
View file @
87d2c64b
...
...
@@ -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
...
...
sql/network/function_trigger_pipe_before.sql
View file @
87d2c64b
...
...
@@ -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_spike
s
(
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
...
...
sql/network/function_trigger_vw_insert_nw.sql
View file @
87d2c64b
...
...
@@ -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
...
...
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