isolated bends

main
Motiejus Jakštys 2021-05-19 22:57:47 +03:00 committed by Motiejus Jakštys
parent 6062ce9389
commit 0b349d8681
3 changed files with 16 additions and 17 deletions

View File

@ -1,6 +1,6 @@
SOURCE ?= lithuania-latest.osm.pbf
#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='Visinčia' OR name='Šalčia' OR name='Nemunas' OR name='Žeimena' OR name='Lakaja'
#WHERE ?= name='Žeimena' OR name='Lakaja'
SLIDES = slides-2021-03-29.pdf
NON_ARCHIVABLES = notes.txt referatui.txt slides-2021-03-29.txt

View File

@ -22,7 +22,7 @@ end
$$ language plpgsql;
-- 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;
create table wm_debug(stage text, name text, gen bigint, nbend bigint, way geometry, props jsonb);

27
wm.sql
View File

@ -330,31 +330,30 @@ $$ language plpgsql;
create function isolated_bends(INOUT bendattrs t_bend_attrs[], dbgname text default null) as $$
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;
skip_next bool;
res t_bend_attrs;
prev_i int4;
i int4;
begin
i = 2;
while i < array_length(bendattrs, 1)-1 loop
this = bendattrs[i].curvature * isolation_threshold;
prev_i = i;
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;
for i in 2..array_length(bendattrs, 1)-1 loop
res = bendattrs[i];
if skip_next then
skip_next = false;
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;
if dbgname is not null then
insert into wm_debug (stage, name, nbend, way, props) values(
'fisolated_bends',
dbgname,
prev_i,
i,
res.bend,
jsonb_build_object(
'isolated', res.isolated