separate visuals from integration tests
This commit is contained in:
parent
406981050f
commit
6d77c5e334
23
IV/Makefile
23
IV/Makefile
@ -1,6 +1,5 @@
|
|||||||
OSM ?= lithuania-latest.osm.pbf
|
OSM ?= lithuania-latest.osm.pbf
|
||||||
#WHERE ?= name='Visinčia' OR name='Šalčia' OR name='Nemunas' OR name='Merkys'
|
WHERE ?= name='Visinčia' OR name='Šalčia' OR name='Nemunas' OR name='Merkys'
|
||||||
WHERE ?= name='Šalčia' OR name='Visinčia'
|
|
||||||
#WHERE ?= name like '%'
|
#WHERE ?= name like '%'
|
||||||
SLIDES = slides-2021-03-29.pdf
|
SLIDES = slides-2021-03-29.pdf
|
||||||
|
|
||||||
@ -88,7 +87,7 @@ $(1).pdf: layer2img.py Makefile $(2)
|
|||||||
)
|
)
|
||||||
endef
|
endef
|
||||||
$(foreach fig,$(FIGURES),$(eval $(call FIG_template,$(fig),.faux_test)))
|
$(foreach fig,$(FIGURES),$(eval $(call FIG_template,$(fig),.faux_test)))
|
||||||
$(foreach fig,$(RIVERS), $(eval $(call FIG_template,$(fig),.faux_test-rivers)))
|
$(foreach fig,$(RIVERS), $(eval $(call FIG_template,$(fig),.faux_visuals)))
|
||||||
|
|
||||||
test-figures_1SELECT = wm_figures
|
test-figures_1SELECT = wm_figures
|
||||||
|
|
||||||
@ -160,17 +159,21 @@ salvis-overlaid-visvalingam-64-chaikin-50k_WIDTHDIV = 2
|
|||||||
salvis-overlaid-visvalingam-64-chaikin-50k_QUADRANT = 1
|
salvis-overlaid-visvalingam-64-chaikin-50k_QUADRANT = 1
|
||||||
|
|
||||||
|
|
||||||
.faux_test-rivers: test-rivers.sql wm.sql Makefile .faux_db
|
.faux_db: db init.sql rivers.sql
|
||||||
bash db -v scaledwidth=$(SCALEDWIDTH) -f $<
|
bash db start
|
||||||
|
bash db -f init.sql -f rivers.sql
|
||||||
touch $@
|
touch $@
|
||||||
|
|
||||||
.faux_test: test.sql wm.sql .faux_db
|
.faux_test: test.sql wm.sql .faux_db
|
||||||
bash db -f $<
|
bash db -f $<
|
||||||
touch $@
|
touch $@
|
||||||
|
|
||||||
.faux_db: db init.sql
|
.faux_visuals: visuals.sql wm.sql Makefile .faux_db
|
||||||
bash db start
|
bash db -v scaledwidth=$(SCALEDWIDTH) -f $<
|
||||||
bash db -f init.sql -f rivers.sql
|
touch $@
|
||||||
|
|
||||||
|
.faux_test-rivers: test-rivers.sql wm.sql Makefile .faux_db
|
||||||
|
bash db -f $<
|
||||||
touch $@
|
touch $@
|
||||||
|
|
||||||
################################
|
################################
|
||||||
@ -219,8 +222,8 @@ mj-msc-gray.pdf: mj-msc.pdf
|
|||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean: ## Clean the current working directory
|
clean: ## Clean the current working directory
|
||||||
-bash db stop
|
-bash db stop
|
||||||
-rm -r .faux_test .faux_aggregate-rivers .faux_test-rivers .faux_db \
|
-rm -r .faux_test .faux_aggregate-rivers .faux_test-rivers .faux_visuals \
|
||||||
version.inc.tex vars.inc.tex version.aux version.fdb_latexmk \
|
.faux_db version.inc.tex vars.inc.tex version.aux version.fdb_latexmk \
|
||||||
_minted-mj-msc \
|
_minted-mj-msc \
|
||||||
$(shell git ls-files -o mj-msc*) \
|
$(shell git ls-files -o mj-msc*) \
|
||||||
$(addsuffix .pdf,$(FIGURES)) \
|
$(addsuffix .pdf,$(FIGURES)) \
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,100 +1,5 @@
|
|||||||
\i wm.sql
|
\set ON_ERROR_STOP on
|
||||||
|
SET plpgsql.extra_errors TO 'all';
|
||||||
-- wm_bbox clips a geometry by a bounding box around a given object,
|
|
||||||
-- matching dimensions of A-class paper (1 by sqrt(2).
|
|
||||||
drop function if exists wm_bbox;
|
|
||||||
create function wm_bbox(
|
|
||||||
center geometry,
|
|
||||||
scaledwidth float
|
|
||||||
) returns geometry as $$
|
|
||||||
declare
|
|
||||||
halfX float;
|
|
||||||
halfY float;
|
|
||||||
begin
|
|
||||||
halfX = scaledwidth / 2;
|
|
||||||
halfY = halfX * sqrt(2);
|
|
||||||
return st_envelope(
|
|
||||||
st_union(
|
|
||||||
st_translate(center, halfX, halfY),
|
|
||||||
st_translate(center, -halfX, -halfY)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
end $$ language plpgsql;
|
|
||||||
|
|
||||||
-- wm_quadrant divides the given geometry to 4 rectangles
|
|
||||||
-- and returns the requested quadrant following cartesian
|
|
||||||
-- convention:
|
|
||||||
-- +----------+
|
|
||||||
-- | II | I |
|
|
||||||
--- +----------+
|
|
||||||
-- | III | IV |
|
|
||||||
-- +-----+----+
|
|
||||||
-- matching dimensions of A-class paper (1 by sqrt(2).
|
|
||||||
drop function if exists wm_quadrant;
|
|
||||||
create function wm_quadrant(
|
|
||||||
geom geometry,
|
|
||||||
quadrant integer
|
|
||||||
) returns geometry as $$
|
|
||||||
declare
|
|
||||||
xmin float;
|
|
||||||
xmax float;
|
|
||||||
ymin float;
|
|
||||||
ymax float;
|
|
||||||
begin
|
|
||||||
xmin = st_xmin(geom);
|
|
||||||
xmax = st_xmax(geom);
|
|
||||||
ymin = st_ymin(geom);
|
|
||||||
ymax = st_ymax(geom);
|
|
||||||
|
|
||||||
if quadrant = 1 or quadrant = 2 then
|
|
||||||
ymin = (ymin + ymax)/2;
|
|
||||||
else
|
|
||||||
ymax = (ymin + ymax)/2;
|
|
||||||
end if;
|
|
||||||
|
|
||||||
if quadrant = 2 or quadrant = 3 then
|
|
||||||
xmax = (xmin + xmax)/2;
|
|
||||||
else
|
|
||||||
xmin = (xmin + xmax)/2;
|
|
||||||
end if;
|
|
||||||
|
|
||||||
return st_intersection(
|
|
||||||
geom,
|
|
||||||
st_makeenvelope(xmin, ymin, xmax, ymax, st_srid(geom))
|
|
||||||
);
|
|
||||||
end $$ language plpgsql;
|
|
||||||
|
|
||||||
|
|
||||||
delete from wm_visuals where name like 'salvis%';
|
|
||||||
insert into wm_visuals(name, way) values('salvis', (
|
|
||||||
select st_intersection(
|
|
||||||
(select st_union(way) from wm_rivers where name in ('Šalčia', 'Visinčia')),
|
|
||||||
wm_bbox(
|
|
||||||
st_closestpoint(
|
|
||||||
(select way from wm_rivers where name='Šalčia'),
|
|
||||||
(select way from wm_rivers where name='Visinčia')
|
|
||||||
),
|
|
||||||
:scaledwidth
|
|
||||||
)
|
|
||||||
)
|
|
||||||
));
|
|
||||||
|
|
||||||
do $$
|
|
||||||
declare
|
|
||||||
i integer;
|
|
||||||
geom1 geometry;
|
|
||||||
geom2 geometry;
|
|
||||||
begin
|
|
||||||
foreach i in array array[16, 64, 256] loop
|
|
||||||
geom1 = st_simplify((select way from wm_visuals where name='salvis'), i);
|
|
||||||
geom2 = st_simplifyvw((select way from wm_visuals where name='salvis'), i*i);
|
|
||||||
insert into wm_visuals(name, way) values
|
|
||||||
('salvis-douglas-' || i, geom1),
|
|
||||||
('salvis-douglas-' || i || '-chaikin', st_chaikinsmoothing(geom1, 5)),
|
|
||||||
('salvis-visvalingam-' || i, geom2),
|
|
||||||
('salvis-visvalingam-' || i || '-chaikin', st_chaikinsmoothing(geom2, 5));
|
|
||||||
end loop;
|
|
||||||
end $$ language plpgsql;
|
|
||||||
|
|
||||||
do $$
|
do $$
|
||||||
declare
|
declare
|
||||||
|
100
IV/visuals.sql
Normal file
100
IV/visuals.sql
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
\set ON_ERROR_STOP on
|
||||||
|
SET plpgsql.extra_errors TO 'all';
|
||||||
|
|
||||||
|
-- wm_bbox clips a geometry by a bounding box around a given object,
|
||||||
|
-- matching dimensions of A-class paper (1 by sqrt(2)).
|
||||||
|
drop function if exists wm_bbox;
|
||||||
|
create function wm_bbox(
|
||||||
|
center geometry,
|
||||||
|
scaledwidth float
|
||||||
|
) returns geometry as $$
|
||||||
|
declare
|
||||||
|
halfX float;
|
||||||
|
halfY float;
|
||||||
|
begin
|
||||||
|
halfX = scaledwidth / 2;
|
||||||
|
halfY = halfX * sqrt(2);
|
||||||
|
return st_envelope(
|
||||||
|
st_union(
|
||||||
|
st_translate(center, halfX, halfY),
|
||||||
|
st_translate(center, -halfX, -halfY)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
end $$ language plpgsql;
|
||||||
|
|
||||||
|
-- wm_quadrant divides the given geometry to 4 rectangles
|
||||||
|
-- and returns the requested quadrant following cartesian
|
||||||
|
-- convention:
|
||||||
|
-- +----------+
|
||||||
|
-- | II | I |
|
||||||
|
--- +----------+
|
||||||
|
-- | III | IV |
|
||||||
|
-- +-----+----+
|
||||||
|
-- matching dimensions of A-class paper (1 by sqrt(2).
|
||||||
|
drop function if exists wm_quadrant;
|
||||||
|
create function wm_quadrant(
|
||||||
|
geom geometry,
|
||||||
|
quadrant integer
|
||||||
|
) returns geometry as $$
|
||||||
|
declare
|
||||||
|
xmin float;
|
||||||
|
xmax float;
|
||||||
|
ymin float;
|
||||||
|
ymax float;
|
||||||
|
begin
|
||||||
|
xmin = st_xmin(geom);
|
||||||
|
xmax = st_xmax(geom);
|
||||||
|
ymin = st_ymin(geom);
|
||||||
|
ymax = st_ymax(geom);
|
||||||
|
|
||||||
|
if quadrant = 1 or quadrant = 2 then
|
||||||
|
ymin = (ymin + ymax)/2;
|
||||||
|
else
|
||||||
|
ymax = (ymin + ymax)/2;
|
||||||
|
end if;
|
||||||
|
|
||||||
|
if quadrant = 2 or quadrant = 3 then
|
||||||
|
xmax = (xmin + xmax)/2;
|
||||||
|
else
|
||||||
|
xmin = (xmin + xmax)/2;
|
||||||
|
end if;
|
||||||
|
|
||||||
|
return st_intersection(
|
||||||
|
geom,
|
||||||
|
st_makeenvelope(xmin, ymin, xmax, ymax, st_srid(geom))
|
||||||
|
);
|
||||||
|
end $$ language plpgsql;
|
||||||
|
|
||||||
|
|
||||||
|
delete from wm_visuals where name like 'salvis%';
|
||||||
|
insert into wm_visuals(name, way) values('salvis', (
|
||||||
|
select st_intersection(
|
||||||
|
(select st_union(way) from wm_rivers where name in ('Šalčia', 'Visinčia')),
|
||||||
|
wm_bbox(
|
||||||
|
st_closestpoint(
|
||||||
|
(select way from wm_rivers where name='Šalčia'),
|
||||||
|
(select way from wm_rivers where name='Visinčia')
|
||||||
|
),
|
||||||
|
:scaledwidth
|
||||||
|
)
|
||||||
|
)
|
||||||
|
));
|
||||||
|
|
||||||
|
do $$
|
||||||
|
declare
|
||||||
|
i integer;
|
||||||
|
geom1 geometry;
|
||||||
|
geom2 geometry;
|
||||||
|
begin
|
||||||
|
foreach i in array array[16, 64, 256] loop
|
||||||
|
geom1 = st_simplify((select way from wm_visuals where name='salvis'), i);
|
||||||
|
geom2 = st_simplifyvw((select way from wm_visuals where name='salvis'), i*i);
|
||||||
|
insert into wm_visuals(name, way) values
|
||||||
|
('salvis-douglas-' || i, geom1),
|
||||||
|
('salvis-douglas-' || i || '-chaikin', st_chaikinsmoothing(geom1, 5)),
|
||||||
|
('salvis-visvalingam-' || i, geom2),
|
||||||
|
('salvis-visvalingam-' || i || '-chaikin', st_chaikinsmoothing(geom2, 5));
|
||||||
|
end loop;
|
||||||
|
end $$ language plpgsql;
|
||||||
|
|
||||||
|
insert into wm_demo (name, way) select name, ST_SimplifyWM(way, 75, null, name) from wm_visuals where name='salvis';
|
Loading…
Reference in New Issue
Block a user