2021-03-17 11:32:12 +02:00
|
|
|
\i wm.sql
|
|
|
|
|
2021-04-18 09:58:43 +03:00
|
|
|
insert into wm_visuals(name, way) values('salcia-visincia',
|
|
|
|
st_closestpoint(
|
|
|
|
(select way from wm_rivers where name='Šalčia'),
|
|
|
|
(select way from wm_rivers where name='Visinčia')
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
insert into wm_visuals(name, way) values('nemunas-merkys',
|
|
|
|
st_closestpoint(
|
|
|
|
(select way from wm_rivers where name='Nemunas'),
|
|
|
|
(select way from wm_rivers where name='Merkys')
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2021-04-18 20:58:42 +03:00
|
|
|
|
|
|
|
-- wm_envelope clips a geometry by a bounding box around a given object,
|
|
|
|
-- matching dimensions of A-class paper (1 by sqrt(2).
|
2021-04-18 23:24:15 +03:00
|
|
|
drop function if exists wm_bbox;
|
|
|
|
create function wm_bbox(
|
2021-04-18 20:58:42 +03:00
|
|
|
center text,
|
|
|
|
projection_scale integer,
|
2021-04-18 23:24:15 +03:00
|
|
|
projection_width_cm float
|
2021-04-18 20:58:42 +03:00
|
|
|
) returns geometry as $$
|
|
|
|
declare
|
|
|
|
gcenter geometry;
|
|
|
|
halfX float;
|
|
|
|
halfY float;
|
|
|
|
begin
|
2021-04-18 23:24:15 +03:00
|
|
|
halfX = projection_scale * projection_width_cm / 2;
|
2021-04-18 20:58:42 +03:00
|
|
|
halfY = halfX * sqrt(2);
|
|
|
|
select way from wm_visuals where name=center into gcenter;
|
|
|
|
if gcenter is null then
|
|
|
|
raise 'center % not found', center;
|
|
|
|
end if;
|
|
|
|
|
2021-04-18 23:24:15 +03:00
|
|
|
return st_envelope(
|
|
|
|
st_union(
|
|
|
|
st_translate(gcenter, halfX, halfY),
|
|
|
|
st_translate(gcenter, -halfX, -halfY)
|
|
|
|
)
|
2021-04-18 20:58:42 +03:00
|
|
|
);
|
|
|
|
end
|
|
|
|
$$ language plpgsql;
|
|
|
|
|
2021-04-16 08:00:08 +03:00
|
|
|
do $$
|
|
|
|
declare
|
|
|
|
npoints bigint;
|
|
|
|
secs bigint;
|
|
|
|
begin
|
2021-04-17 16:16:27 +03:00
|
|
|
select * from ST_SimplifyWM_Estimate((select st_union(way) from wm_rivers)) into npoints, secs;
|
2021-04-16 08:00:08 +03:00
|
|
|
raise notice 'Total points: %', npoints;
|
2021-04-16 08:05:17 +03:00
|
|
|
raise notice 'Expected duration: %s (+-%s)', ceil(secs), floor(secs*.5);
|
2021-04-16 08:00:08 +03:00
|
|
|
end $$ language plpgsql;
|
|
|
|
|
2021-04-17 17:36:32 +03:00
|
|
|
delete from wm_debug where name in (select distinct name from wm_rivers);
|
2021-04-17 17:23:48 +03:00
|
|
|
delete from wm_demo where name in (select distinct name from wm_rivers);
|
2021-04-17 16:16:27 +03:00
|
|
|
insert into wm_demo (name, way) select name, ST_SimplifyWM(way, name) from wm_rivers;
|