isolated bends
This commit is contained in:
parent
6062ce9389
commit
0b349d8681
4
Makefile
4
Makefile
@ -1,6 +1,6 @@
|
|||||||
SOURCE ?= lithuania-latest.osm.pbf
|
SOURCE ?= lithuania-latest.osm.pbf
|
||||||
#WHERE ?= name='Visinčia' OR name='Šalčia' OR name='Nemunas' OR name='Žeimena' OR name='Lakaja'
|
WHERE ?= name='Visinčia' OR name='Šalčia' OR name='Nemunas' OR name='Žeimena' OR name='Lakaja'
|
||||||
WHERE ?= name='Žeimena' OR name='Lakaja'
|
#WHERE ?= name='Žeimena' OR name='Lakaja'
|
||||||
SLIDES = slides-2021-03-29.pdf
|
SLIDES = slides-2021-03-29.pdf
|
||||||
|
|
||||||
NON_ARCHIVABLES = notes.txt referatui.txt slides-2021-03-29.txt
|
NON_ARCHIVABLES = notes.txt referatui.txt slides-2021-03-29.txt
|
||||||
|
@ -22,7 +22,7 @@ end
|
|||||||
$$ language plpgsql;
|
$$ language plpgsql;
|
||||||
|
|
||||||
-- to preview this somewhat conveniently in QGIS:
|
-- to preview this somewhat conveniently in QGIS:
|
||||||
-- stage || '_' || name || ' gen:' || coalesce(gen, 'Ø') || ' nbend:' || lpad(nbend, 2, '0')
|
-- stage || '_' || name || ' gen:' || coalesce(gen, 'Ø') || ' nbend:' || lpad(nbend, 4, '0')
|
||||||
drop table if exists wm_debug;
|
drop table if exists wm_debug;
|
||||||
create table wm_debug(stage text, name text, gen bigint, nbend bigint, way geometry, props jsonb);
|
create table wm_debug(stage text, name text, gen bigint, nbend bigint, way geometry, props jsonb);
|
||||||
|
|
||||||
|
27
wm.sql
27
wm.sql
@ -330,31 +330,30 @@ $$ language plpgsql;
|
|||||||
|
|
||||||
create function isolated_bends(INOUT bendattrs t_bend_attrs[], dbgname text default null) as $$
|
create function isolated_bends(INOUT bendattrs t_bend_attrs[], dbgname text default null) as $$
|
||||||
declare
|
declare
|
||||||
isolation_threshold constant real default 0.2; -- if neighbor's curvatures are within, it's isolated
|
isolation_threshold constant real default 0.33; -- if neighbor's curvatures are within, it's isolated
|
||||||
this real;
|
this real;
|
||||||
|
skip_next bool;
|
||||||
res t_bend_attrs;
|
res t_bend_attrs;
|
||||||
prev_i int4;
|
|
||||||
i int4;
|
i int4;
|
||||||
begin
|
begin
|
||||||
i = 2;
|
for i in 2..array_length(bendattrs, 1)-1 loop
|
||||||
while i < array_length(bendattrs, 1)-1 loop
|
res = bendattrs[i];
|
||||||
this = bendattrs[i].curvature * isolation_threshold;
|
if skip_next then
|
||||||
prev_i = i;
|
skip_next = false;
|
||||||
if bendattrs[i-1].curvature < this and bendattrs[i+1].curvature < this then
|
|
||||||
raise notice '% %`th bend is isolated', dbgname, i;
|
|
||||||
res = bendattrs[i];
|
|
||||||
res.isolated = true;
|
|
||||||
bendattrs[i] = res;
|
|
||||||
i = i + 2;
|
|
||||||
else
|
else
|
||||||
i = i + 1;
|
this = bendattrs[i].curvature * isolation_threshold;
|
||||||
|
if bendattrs[i-1].curvature < this and bendattrs[i+1].curvature < this then
|
||||||
|
res.isolated = true;
|
||||||
|
bendattrs[i] = res;
|
||||||
|
skip_next = true;
|
||||||
|
end if;
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
if dbgname is not null then
|
if dbgname is not null then
|
||||||
insert into wm_debug (stage, name, nbend, way, props) values(
|
insert into wm_debug (stage, name, nbend, way, props) values(
|
||||||
'fisolated_bends',
|
'fisolated_bends',
|
||||||
dbgname,
|
dbgname,
|
||||||
prev_i,
|
i,
|
||||||
res.bend,
|
res.bend,
|
||||||
jsonb_build_object(
|
jsonb_build_object(
|
||||||
'isolated', res.isolated
|
'isolated', res.isolated
|
||||||
|
Loading…
Reference in New Issue
Block a user