labeled code listings

This commit is contained in:
Motiejus Jakštys 2021-05-19 22:57:49 +03:00 committed by Motiejus Jakštys
parent e28bf03945
commit 9b9555983f
3 changed files with 19 additions and 7 deletions

View File

@ -13,6 +13,8 @@ SCALEDWIDTH = $(shell awk '/^TEXTWIDTH_CM/{print 25000/100*$$3}' layer2img.py)
NON_ARCHIVABLES = notes.txt referatui.txt slides-2021-03-29.txt NON_ARCHIVABLES = notes.txt referatui.txt slides-2021-03-29.txt
ARCHIVABLES = $(filter-out $(NON_ARCHIVABLES),$(shell git ls-files .)) ARCHIVABLES = $(filter-out $(NON_ARCHIVABLES),$(shell git ls-files .))
LISTINGS = aggregate-rivers.sql wm.sql extract-and-generate
FIGURES = \ FIGURES = \
test-figures \ test-figures \
fig8-definition-of-a-bend \ fig8-definition-of-a-bend \
@ -66,8 +68,8 @@ slides: $(SLIDES)
# The report, quick version # The report, quick version
########################### ###########################
mj-msc.pdf: mj-msc.tex version.inc.tex vars.inc.tex extract-and-generate bib.bib \ mj-msc.pdf: mj-msc.tex version.inc.tex vars.inc.tex bib.bib \
$(addsuffix .pdf,$(FIGURES)) $(addsuffix .pdf,$(RIVERS)) $(LISTINGS) $(addsuffix .pdf,$(FIGURES)) $(addsuffix .pdf,$(RIVERS))
latexmk -shell-escape -g -pdf $< latexmk -shell-escape -g -pdf $<
############################ ############################

View File

@ -1,6 +1,10 @@
/* Aggregates rivers by name and proximity. */ /* Aggregates rivers by name and proximity. */
drop function if exists aggregate_rivers; drop function if exists aggregate_rivers;
create function aggregate_rivers() returns table(osm_id bigint, name text, way geometry) as $$ create function aggregate_rivers() returns table(
osm_id bigint,
name text,
way geometry
) as $$
declare declare
c record; c record;
cc record; cc record;
@ -12,7 +16,11 @@ begin
changed = true; changed = true;
while changed loop while changed loop
changed = false; changed = false;
for cc in (select * from wm_rivers_tmp a where a.name = c.name and st_dwithin(a.way, c.way, 500)) loop for cc in (
select * from wm_rivers_tmp a where
a.name = c.name and
st_dwithin(a.way, c.way, 500)
) loop
c.way = st_linemerge(st_union(c.way, cc.way)); c.way = st_linemerge(st_union(c.way, cc.way));
delete from wm_rivers_tmp a where a.osm_id = cc.osm_id; delete from wm_rivers_tmp a where a.osm_id = cc.osm_id;
changed = true; changed = true;
@ -36,5 +44,7 @@ insert into wm_rivers_tmp
where waterway in ('river', 'stream', 'canal') and :where; where waterway in ('river', 'stream', 'canal') and :where;
drop table if exists wm_rivers; drop table if exists wm_rivers;
create table wm_rivers as (select * from aggregate_rivers() where st_length(way) >= 50000); create table wm_rivers as (
select * from aggregate_rivers() where st_length(way) >= 50000
);
drop table wm_rivers_tmp; drop table wm_rivers_tmp;

View File

@ -854,10 +854,10 @@ Like explained in section~\ref{sec:reproducing-the-paper}, illustrations in
\inputcode{bash}{extract-and-generate} \inputcode{bash}{extract-and-generate}
\subsection{\texttt{ST\_SimplifyWV}} \subsection{Function \texttt{ST\_SimplifyWV}}
\inputcode{postgresql}{wm.sql} \inputcode{postgresql}{wm.sql}
\subsection{\texttt{aggregate\_rivers}} \subsection{Function \texttt{aggregate\_rivers}}
\inputcode{postgresql}{aggregate-rivers.sql} \inputcode{postgresql}{aggregate-rivers.sql}
\end{appendices} \end{appendices}