DS=-dsco NAME="Hualien Shoufeng street numbering and house addressing idea" \ -dsco DESCRIPTION="See $(subst $(HOME)/,https://www.,$(PWD))" ## Author: Dan Jacobson https://www.jidanni.org/ ## Copyright: https://www.gnu.org/licenses/gpl.html ## Created: 2026-07-07T22:11:08+0000 ## Last-Updated: 2026-08-06T00:18:37+0000 ## Update #: 545 D=$(HOME)/Downloads BI=--citeproc --bibliography=dan.bib --metadata link-citations=true #--csl dan6.csl pand=--from=markdown+east_asian_line_breaks --output=$@ --standalone \ --metadata document-css=false --metadata=lang:zh-hant \ --fail-if-warnings=true --verbose --strip-comments=true $(BI) \ --include-in-header=dan43.html --number-sections=true gol=$< gol=$$(wwwize -c $(PWD)/$<\#goal) %.browse:%.html; $${BROWSER?} $(gol); sleep 33 shoufeng.browse: slid:slides.html; $$BROWSER $< slides.md:slides.html; pandoc --to markdown $< FIL='' #production, else for transport to google docs for preview: docxbrowse_no_images:FIL='s/^!/\\/;' docxbrowse docxbrowse_no_images:shoufeng.docx; mv $< $D && echo Now open it in WORD roundtrip.%:shoufeng.docx; pandoc $< --to=$* --standalone --output=$@ roundtrip.markdown: roundtrip.html: shoufeng.html:shoufeng.txt shoufeng.panache dan.bib dan43.html; pandoc $(pand) $< shoufeng.docx:shoufeng.txt shoufeng.panache dan.bib dan43.html perl -pwle $(FIL) $< | pandoc $(pand) %.panache:%.txt; panache lint --message-format short --flavor pandoc $< S1=.title, .author, .abstract-title {text-align: center;} .abstract-title {font-weight: bold;}\ table, th, td { border: 1px solid black; } dan43.html:; echo '' > $@ char_count:shoufeng.html; w3m -dump $< | wc --chars dd=$D/d/data/shoufeng %.view:%.kml; viking $D/hua_dong.vik $^ & sleep 1d N=$(notdir $(basename $<)) KML1=$R $S 'SELECT name || "" AS name, geom FROM "$N"' -f LIBKML -dim XY #Avoid LIBKML "simple data" XAR= %.kml:%.gpkg; $(KML1) $(XAR) GCP=\ 23.877758 121.540624 8000 500\ 23.879406 121.545506 8200 600\ 23.838215 121.519542 5700 700\ 23.842867 121.515594 5800 500\ 23.870080 121.542264 7700 700\ 23.877856 121.544276 8100 600\ 23.876299 121.543155 8000 600\ 23.871586 121.539759 7700 600 gcps.txt:; echo $(GCP)|xargs -n 4|perl -anwle 'push @F, "-gcp"; @G=reverse @F; print qq{@G};'>$@ gz=SELECT geometry AS geom, FORMAT('%d/%d', field_2, field_3) AS name FROM $N gcps.gpkg:gcps.txt $R -if CSV -nlt POINT -oo X_POSSIBLE_NAMES=field_4 -oo Y_POSSIBLE_NAMES=field_5 $S "$(gz)" gcps.view: klip.csv:klip=\ 675 8375 775 8300 850 5750 575 5700 500 5800 400 6000 200 6875 325 7900 375 8050 675 8375 klip.csv: echo $(klip)|xargs --max-args 2 > /tmp/$@ ogr2ogr $@ /tmp/$@ -lco GEOMETRY=AS_WKT -dialect SQLite -sql \ 'SELECT "." as Name,'\ 'MakePolygon(MakeLine(MakePoint(field_1+0, field_2+0))) AS WKT FROM $(basename $@)' klip.gpkg:klip.csv; $R $S 'SELECT Name,WKT FROM $N' klip.kml: klip.csv ; ogr2ogr -f LIBKML $@ $< -sql 'SELECT Name FROM $N' $(GO) include ../../../utilities/integer_graticule.makefile _i=100 GO=--optfile gcps.txt -tps graticule_k_00.gpkg: _x = x0=100 xi=$(_i) x1=900 graticule_k_00.gpkg: _y = y0=5500 yi=$(_i) y1=8400 graticule_k_00.kml : gcps.txt klip.kml graticule_k_00.kml : XAR= $(GO) -clipdst klip.kml view:shoufeng.kmz; viking $^ & sleep 1111m shoufeng.kmz:graticule_k_00.kml B_ho.kml ogrmerge -overwrite_ds -o $@ $^ -f LIBKML $(DS) --config LIBKML_EXTRUDE_FIELD= ad=$(dd)/addr.geojson #all these in here have addr:TW:dataset too in fact, so are standard: h03.gpkg:$(ad); $R -clipsrc 121.534920 23.874202 122 24 h06.csv:h03.gpkg; $R $S "SELECT ST_X(geom), ST_Y(geom), \"addr:full\" FROM $N" h09.csv:h06.csv gcps.txt grep '^[0-9]' $< | grep 21弄 | tr , \ | gdaltransform -E -i -output_xy $(GO) > $@ h14.csv:aih h09.csv; bad=700 ./$^ > $@ #there is no road 700 in our study area A_ho.view B_ho.view: A_ho.gpkg:$(ad); $R $S "SELECT \"addr:housenumber\" AS name, geometry AS geom FROM $N "\ "WHERE \"addr:street\" LIKE '_600巷21弄'" B_ho.gpkg:h14.csv; $R -a_srs EPSG:4326 $S \ "SELECT FORMAT('%4d路%c%4d號', field_1+0, CHAR(10), field_2+0) AS name,"\ "ST_Point(0+field_3,0+field_4) AS geom FROM $N" h17.csv:h14.csv; perl -anwle 's/.*鄰//; print "$$_ $$F[0]路$$F[1]號"' $< > $@ h18.csv:h17.csv; perl -nwle '$$I=$$_; s/ .*//; s/\d+/sprintf "%05d", $$&/ge; $$z{$$_}=$$I;'\ 'END{for(sort keys %z){print $$z{$$_};}}' $< > $@ p1=next unless /21弄/; printf qq[- %s (原%s)\n], reverse (@F); pp=next unless /21弄/; s/(63之1|684)號/$$&\[^$$&\]/;tr! !|!; print; duizhao.csv:h18.csv; perl -anwle '$(p1)' $< > $@ #duizhao_pipe.csv:h18.csv; perl -anwle 'BEGIN{print "|xxx|xxx|";print"|-|-|";}$(pp)' $< > $@ duizhao_pipe.csv:h18.csv; perl -nwle 'BEGIN{print "|xxx|xxx|";print"|-|-|";}$(pp)' $< > $@ duizhao_05.csv:h18.csv; grep 21弄 $< > $@ duizhao_10.csv:h18.csv; perl -anwle 'printf "%s%s\n", @F;' $< # Overpass-Turbo query: # [out:json][timeout:25]; # {{geocodeArea:Gonghe Village, Shoufeng}}->.searchArea; # node["addr:housenumber"](area.searchArea);out geom; gz=SELECT geometry AS geom, FORMAT('%d/%d', field_2, field_3) AS name FROM $N S=-dialect SQLite -sql R=ogr2ogr $@ $< -nln $(basename $@) MAKEFLAGS+=--warn-undefined-variables --no-builtin-variables clean: rm -vf *.csv gcps.txt *.gpkg *.kml \ *.linted *.url dan.bib shoufeng.html \ shoufeng.docx dan43.html roundtrip.* .DELETE_ON_ERROR: .SECONDARY: dan.bib:; perl -wle '$$_=q%$(DB)%; s/\s*!/\n/g; print;' > $@ dan.bib:DB=@online{2026dj,\ ! author = {積, 丹尼},\ ! title = {路號門牌弧形網},\ ! date = {2026},\ ! month = jul,\ ! url = {https://www.jidanni.org/geo/house_numbering/grids/tw/taichung/dajia/youshi/youshi.html},\ ! organization = {台灣地理資訊學會},\ ! eventtitle = {2026 台灣地理資訊學會年會暨學術研討會},\ !}\ !@online{jzkhl,\ ! xxauthor = {{今周刊}},\ ! title = {\ 今周刊:「門牌錯亂」釀花蓮壽豐4死火警?縣議員轟30年未整編,縣府駁「勿將悲劇作政治操作籌碼」},\ ! date = {2025},\ ! month = jul,\ ! url = {https://www.businesstoday.com.tw/article/category/183027/post/202507210024/},\ !}\ !@online{hlxzfcq,\ ! xxauthor = {{花蓮縣政府}},\ ! title = {針對網路流傳「壽豐鄉門牌30年未整編,導致消防隊誤判位置、釀成火警4人死亡」等訊息,花蓮縣政府嚴正澄清},\ ! date = {2025},\ ! month = jul,\ ! url = {https://www.hl.gov.tw/News_Content.aspx?n=34650&s=183504},\ !}\ !@online{laws1,\ ! title = {花蓮縣道路命名暨門牌編釘自治條例},\ ! date = {2008},\ !}\ !@online{laws2,\ ! title = {花蓮縣道路命名暨門牌編釘作業注意事項},\ ! date = {2009},\ !} to_j:slides.html shoufeng.kmz #shoufeng.html shoufeng.txt Makefile aih scp -p $^ jidanni.org:$(PWD) #give abj google translate link to paper.