From 9b9555983fe7fab1db7b54dfa33607db04a7d3e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Wed, 19 May 2021 22:57:49 +0300 Subject: [PATCH] labeled code listings --- Makefile | 6 ++++-- aggregate-rivers.sql | 16 +++++++++++++--- mj-msc.tex | 4 ++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 149919f..374de69 100644 --- a/Makefile +++ b/Makefile @@ -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 ARCHIVABLES = $(filter-out $(NON_ARCHIVABLES),$(shell git ls-files .)) +LISTINGS = aggregate-rivers.sql wm.sql extract-and-generate + FIGURES = \ test-figures \ fig8-definition-of-a-bend \ @@ -66,8 +68,8 @@ slides: $(SLIDES) # The report, quick version ########################### -mj-msc.pdf: mj-msc.tex version.inc.tex vars.inc.tex extract-and-generate bib.bib \ - $(addsuffix .pdf,$(FIGURES)) $(addsuffix .pdf,$(RIVERS)) +mj-msc.pdf: mj-msc.tex version.inc.tex vars.inc.tex bib.bib \ + $(LISTINGS) $(addsuffix .pdf,$(FIGURES)) $(addsuffix .pdf,$(RIVERS)) latexmk -shell-escape -g -pdf $< ############################ diff --git a/aggregate-rivers.sql b/aggregate-rivers.sql index 22d7924..7fd1ec0 100644 --- a/aggregate-rivers.sql +++ b/aggregate-rivers.sql @@ -1,6 +1,10 @@ /* Aggregates rivers by name and proximity. */ 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 c record; cc record; @@ -12,7 +16,11 @@ begin changed = true; while changed loop 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)); delete from wm_rivers_tmp a where a.osm_id = cc.osm_id; changed = true; @@ -36,5 +44,7 @@ insert into wm_rivers_tmp where waterway in ('river', 'stream', 'canal') and :where; 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; diff --git a/mj-msc.tex b/mj-msc.tex index 337eb35..039cedd 100644 --- a/mj-msc.tex +++ b/mj-msc.tex @@ -854,10 +854,10 @@ Like explained in section~\ref{sec:reproducing-the-paper}, illustrations in \inputcode{bash}{extract-and-generate} -\subsection{\texttt{ST\_SimplifyWV}} +\subsection{Function \texttt{ST\_SimplifyWV}} \inputcode{postgresql}{wm.sql} -\subsection{\texttt{aggregate\_rivers}} +\subsection{Function \texttt{aggregate\_rivers}} \inputcode{postgresql}{aggregate-rivers.sql} \end{appendices}