blob bce7f00a (8103B) - Raw
1 OSM ?= lithuania-latest.osm.pbf 2 WHERE ?= name='Visinčia' OR name='Šalčia' OR name='Nemunas' OR name='Merkys' 3 #WHERE ?= name like '%' 4 SLIDES = slides-2021-03-29.pdf 5 6 # Max figure size (in meters) is when it's width is TEXTWIDTH_CM on scale 1:25k 7 SCALEDWIDTH = $(shell awk '/^TEXTWIDTH_CM/{print 25000/100*$$3}' layer2img.py) 8 9 ############################################################################## 10 # These variables have to come before first use due to how macros are expanded 11 ############################################################################## 12 13 NON_ARCHIVABLES = notes.txt referatui.txt slides-2021-03-29.txt 14 ARCHIVABLES = $(filter-out $(NON_ARCHIVABLES),$(shell git ls-files .)) 15 16 FIGURES = \ 17 test-figures \ 18 fig8-definition-of-a-bend \ 19 fig5-gentle-inflection-before \ 20 fig5-gentle-inflection-after \ 21 inflection-1-gentle-inflection-before \ 22 inflection-1-gentle-inflection-after \ 23 fig6-selfcrossing-before \ 24 fig6-selfcrossing-after \ 25 selfcrossing-1-before \ 26 selfcrossing-1-after 27 28 RIVERS = \ 29 salvis-25k \ 30 salvis-50k \ 31 salvis-250k 32 33 ################################# 34 # The thesis, publishable version 35 ################################# 36 37 mj-msc-full.pdf: mj-msc.pdf version.inc.tex $(ARCHIVABLES) ## Thesis for publishing 38 cp $< .tmp-$@ 39 for f in $^; do \ 40 if [ "$$f" = "$<" ]; then continue; fi; \ 41 pdfattach .tmp-$@ $$f .tmp2-$@; \ 42 mv .tmp2-$@ .tmp-$@; \ 43 done 44 mv .tmp-$@ $@ 45 46 ############################### 47 # Auxiliary targets for humans 48 ############################### 49 50 .PHONY: test 51 test: .faux_test ## Unit tests (fast) 52 53 .PHONY: test-rivers 54 test-rivers: .faux_test-rivers ## Rivers tests (slow) 55 56 .PHONY: slides 57 slides: $(SLIDES) 58 59 ########################### 60 # The report, quick version 61 ########################### 62 63 mj-msc.pdf: mj-msc.tex version.inc.tex vars.inc.tex extract-and-generate bib.bib \ 64 $(addsuffix .pdf,$(FIGURES)) $(addsuffix .pdf,$(RIVERS)) 65 latexmk -shell-escape -g -pdf $< 66 67 ############################ 68 # Report's test dependencies 69 ############################ 70 71 define FIG_template 72 $(1).pdf: layer2img.py Makefile $(2) 73 python ./layer2img.py --outfile=$(1).pdf \ 74 $$(if $$($(1)_WIDTHDIV),--widthdiv=$$($(1)_WIDTHDIV)) \ 75 $$(foreach i,1 2 3, \ 76 $$(if $$($(1)_$$(i)CMAP),--group$$(i)-cmap="$$($(1)_$$(i)CMAP)") \ 77 $$(if $$($(1)_$$(i)SELECT),--group$$(i)-select="$$($(1)_$$(i)SELECT)") \ 78 $$(if $$($(1)_$$(i)LINESTYLE),--group$$(i)-linestyle="$$($(1)_$$(i)LINESTYLE)") \ 79 ) 80 endef 81 $(foreach fig,$(FIGURES),$(eval $(call FIG_template,$(fig),.faux_test))) 82 $(foreach fig,$(RIVERS), $(eval $(call FIG_template,$(fig),.faux_test-rivers))) 83 84 test-figures_1SELECT = wm_figures 85 86 fig8-definition-of-a-bend_1SELECT = wm_debug where name='fig8' AND stage='bbends' AND gen=1 87 fig8-definition-of-a-bend_2CMAP = 1 88 fig8-definition-of-a-bend_2SELECT = wm_debug where name='fig8' AND stage='bbends-polygon' AND gen=1 89 90 fig5-gentle-inflection-before_WITHDIV = 2 91 fig5-gentle-inflection-before_1SELECT = wm_debug where name='fig5' AND stage='bbends' AND gen=1 92 fig5-gentle-inflection-before_2CMAP = 1 93 fig5-gentle-inflection-before_2SELECT = wm_debug where name='fig5' AND stage='bbends-polygon' AND gen=1 94 fig5-gentle-inflection-after_WITHDIV = 2 95 fig5-gentle-inflection-after_1SELECT = wm_debug where name='fig5' AND stage='cinflections' AND gen=1 96 fig5-gentle-inflection-after_2SELECT = wm_debug where name='fig5' AND stage='cinflections-polygon' AND gen=1 97 fig5-gentle-inflection-after_2CMAP = 1 98 99 inflection-1-gentle-inflection-before_WIDTHDIV = 2 100 inflection-1-gentle-inflection-before_1SELECT = wm_debug where name='inflection-1' AND stage='bbends' AND gen=1 101 inflection-1-gentle-inflection-before_2SELECT = wm_debug where name='inflection-1' AND stage='bbends-polygon' AND gen=1 102 inflection-1-gentle-inflection-before_2CMAP = 1 103 inflection-1-gentle-inflection-after_WIDTHDIV = 2 104 inflection-1-gentle-inflection-after_1SELECT = wm_debug where name='inflection-1' AND stage='cinflections' AND gen=1 105 inflection-1-gentle-inflection-after_2SELECT = wm_debug where name='inflection-1' AND stage='cinflections-polygon' AND gen=1 106 inflection-1-gentle-inflection-after_2CMAP = 1 107 108 fig6-selfcrossing-before_WIDTHDIV = 2 109 fig6-selfcrossing-before_1SELECT = wm_debug where name='fig6' AND stage='bbends' AND gen=1 110 fig6-selfcrossing-before_2SELECT = wm_visuals where name='fig6-baseline' 111 fig6-selfcrossing-before_2LINESTYLE = dotted 112 fig6-selfcrossing-before_3SELECT = wm_visuals where name='fig6-newline' 113 fig6-selfcrossing-after_WIDTHDIV = 2 114 fig6-selfcrossing-after_1SELECT = wm_debug where name='fig6' AND stage='dcrossings' AND gen=1 115 116 selfcrossing-1-before_WIDTHDIV = 2 117 selfcrossing-1-before_1SELECT = wm_debug where name='selfcrossing-1' AND stage='bbends' AND gen=1 118 selfcrossing-1-before_2SELECT = wm_visuals where name='selfcrossing-1-baseline' 119 selfcrossing-1-before_2LINESTYLE = dotted 120 selfcrossing-1-before_3SELECT = wm_visuals where name='selfcrossing-1-newline' 121 selfcrossing-1-after_WIDTHDIV = 2 122 selfcrossing-1-after_1SELECT = wm_debug where name='selfcrossing-1' AND stage='dcrossings' AND gen=1 123 selfcrossing-1-after_2SELECT = wm_debug where name='selfcrossing-1' AND stage='bbends' AND gen=1 124 selfcrossing-1-after_2LINESTYLE = invisible 125 126 salvis-25k_1SELECT = wm_rivers where name='Šalčia' OR name='Visinčia' 127 salvis-25k_WIDTHDIV = 1 128 129 salvis-50k_1SELECT = wm_rivers where name='Šalčia' OR name='Visinčia' 130 salvis-50k_WIDTHDIV = 2 131 132 salvis-250k_1SELECT = wm_rivers where name='Šalčia' OR name='Visinčia' 133 salvis-250k_WIDTHDIV = 10 134 135 .faux_test-rivers: tests-rivers.sql wm.sql Makefile .faux_db 136 bash db -v scaledwidth=$(SCALEDWIDTH) -f $< 137 touch $@ 138 139 .faux_test: tests.sql wm.sql .faux_db 140 bash db -f $< 141 touch $@ 142 143 .faux_db: db init.sql 144 bash db start 145 bash db -f init.sql -f rivers.sql 146 touch $@ 147 148 ################################ 149 # Report's non-test dependencies 150 ################################ 151 152 REF = $(shell git describe --abbrev=12 --always --dirty) 153 version.inc.tex: Makefile $(shell git rev-parse --git-dir 2>/dev/null) 154 TZ=UTC date '+\gdef\VCDescribe{%F ($(REF))}%' > $@ 155 156 vars.inc.tex: vars.awk wm.sql Makefile 157 awk -f $< wm.sql 158 159 ############### 160 # Misc commands 161 ############### 162 163 slides-2021-03-29.pdf: slides-2021-03-29.txt 164 pandoc -t beamer -i $< -o $@ 165 166 dump-debug_wm.sql.xz: 167 docker exec -ti wm-mj pg_dump -Uosm osm -t wm_devug | xz -v > $@ 168 169 release.zip: mj-msc.tex version.inc.tex vars.inc.tex \ 170 $(addsuffix .pdf,$(FIGURES)) $(addsuffix .pdf,$(RIVERS)) \ 171 $(shell git ls-files .) 172 -rm $@ 173 zip $@ $^ 174 175 176 mj-msc-gray.pdf: mj-msc.pdf 177 gs \ 178 -sOutputFile=$@ \ 179 -sDEVICE=pdfwrite \ 180 -sColorConversionStrategy=Gray \ 181 -dProcessColorModel=/DeviceGray \ 182 -dCompatibilityLevel=1.4 \ 183 -dNOPAUSE \ 184 -dBATCH \ 185 $< 186 187 .PHONY: clean 188 clean: ## Clean the current working directory 189 -bash db stop 190 -rm -r .faux_test .faux_aggregate-rivers .faux_test-rivers .faux_db \ 191 version.inc.tex vars.inc.tex version.aux version.fdb_latexmk \ 192 _minted-mj-msc \ 193 $(shell git ls-files -o mj-msc*) \ 194 $(addsuffix .pdf,$(FIGURES)) \ 195 $(addsuffix .pdf,$(RIVERS)) \ 196 $(SLIDES) 197 198 .PHONY: clean-tables 199 clean-tables: ## Remove tables created during unit or rivers tests 200 bash db -c '\dt wm_*' | awk '/_/{print "drop table "$$3";"}' | bash db -f - 201 -rm .faux_db 202 203 .PHONY: help 204 help: ## Print this help message 205 @awk -F':.*?## ' '/^[a-z0-9.-]*: *.*## */{printf "%-18s %s\n",$$1,$$2}' $(MAKEFILE_LIST) 206 207 .PHONY: wc 208 wc: mj-msc.pdf ## Character and page count 209 @pdftotext $< - | \ 210 awk '/\yReferences\y/{exit}; {print}' | \ 211 tr -d '[:space:]' | wc -c | \ 212 awk '{printf("Chars: %d, pages: %.1f\n", $$1, $$1/1500)}' 213 214 $(OSM): 215 wget http://download.geofabrik.de/europe/$@ 216 217 .PHONY: refresh-rivers 218 refresh-rivers: aggregate-rivers.sql $(OSM) .faux_db ## Refresh rivers.sql from Open Street Maps 219 PGPASSWORD=osm osm2pgsql -c --multi-geometry -H 127.0.0.1 -d osm -U osm $(OSM) 220 bash db -v where="$(WHERE)" -f $< 221 (\ 222 echo '-- Generated at $(shell TZ=UTC date +"%FT%TZ") on $(shell whoami)@$(shell hostname -f)'; \ 223 echo '-- Select: $(WHERE)'; \ 224 docker exec wm-mj pg_dump --clean -Uosm osm -t wm_rivers | tr -d '\r' \ 225 ) > rivers.sql.tmp 226 mv rivers.sql.tmp rivers.sql