# shicheng/Makefile -- 石城門牌號碼規劃 Shicheng house addressing project # Project URL : http://jidanni.org/geo/house_numbering/shicheng/ # Author : Dan Jacobson http://jidanni.org/ # Copyright : http://www.fsf.org/copyleft/gpl.html # Created On : Dec 2004 # Last Modified On: Wed May 10 01:31:15 2006 # Update Count : 884 # We use GRASS to place house numbers along curvy roads. # (We use touch(1) to simulate the times stamps of the maps in the database.) #2006 WARNING: this makefile not big5 anymore... so should adjust labels... #1/05: now one shot disposable oriented, waiting for a better day to #do it right. #My goodness, I actually got this to work. What a teetering steaming #pile of code. Wonder if I will understand what I wrote next week. #To operate: after manually converting data to 5.7: # make largeView; create largeEndPoints by hand, one pair per line # Can be empty files too. #Same for medium and small. Then "make display_all_maps". 0:;false #[safety stopper] #In file dmax place the maximum meters between address sample points. num_per_meter=2/5#house numbers per meter REGION=w=224000 e=229000 s=2686500 n=2689000#TWD67 datum #Don't change REGION before %Clip, or must recalculate EndPoints that #we selected by eye in %View. 5.0: #with old GRASS 5.0: wget http://www.moiland.gov.tw/land/map/25k_file/95211SW.EXE unzip 95211SW.EXE find *3.dxf -exec v.in.dxf dxf={} \; g.list type=vect|xargs -n1|grep 95211sw|sed 's/^/v.support map=/'|sh -e convert50-57:#all the rest with GRASS 5.7 #each road size, touch our time stamp simulation n=large; v.convert input=95211sw04.94213 output=$$n && touch $$n n=medium; v.convert input=95211sw04.94216_A output=$$n &&touch $$n n=small; v.convert input=95211sw04.94216 output=$$n && touch $$n n=hwy3; v.convert input=95211sw04.94212 output=$$n && touch $$n MAPS=large medium small #In GRASS 5.7 we can't use "." in file names due to database conflicts #hmm, my capitals are not database significant... .PRECIOUS: %Clip %Cat %Positions %.png cutter:#to use to clip g.region $(REGION) v.in.region output=$@ touch $@ %Clip:% cutter#clip to just our area of interest v.overlay ainput=$< atype=line binput=cutter operator=and output=$@ touch $@ %Cat:%Clip#give category numbers to (all nodes, including) road terminals v.net input=$? output=$@ v.category input=$@ output=$@ touch $@ %View:%Cat#View category numbers in order to note down start and end point #numbers for each street we want to number from the display g.region $(REGION) d.erase # d.redraw set -eu magenta green aqua grey orange brown; for m in $(MAPS);\ do d.vect map=$${m}Clip color=$$1; shift; done d.vect map=hwy3 color=red d.vect map=$*Clip d.vect map=$? display=cat,shape type=point #lsize=16 # d.zoom #etc. # [yes, no touch(1) here] all_view: #VIEW: bad name actually d.erase set -xeu "xref=left yref=top lcolor=magenta color=magenta" \ "xref=right yref=top lcolor=brown color=brown" \ "xref=left yref=bottom lcolor=aqua color=aqua";\ for m in $(MAPS);\ do d.vect map=$${m}Clip $$1;\ d.vect map=$${m}Cat display=cat,shape type=point $$1; shift; done d.vect map=hwy3 color=red #(Hope there are no shortcuts to fool v.net.path ! [then try v.net.salesman] #What if we want to continue numbering onto a different map without #resetting to 0?: *** We probably should combine all into one map early *** %Positions:%Cat %EndPoints dmax #add house number intervals between given endpoints if test -s $*EndPoints; then \ set -eu; DMAX=`cat dmax` I=tmp1 O=tmp2;\ grep -v ^# $*EndPoints|while read line; do echo $$line|\ v.net.path nfield=1 input=$< output=$$I;\ v.to.points input=$$I output=$$O dmax=$$DMAX;\ g.remove vect=$$I;\ for c in x y; do echo ALTER TABLE $$O ADD COLUMN $$c double\;;\ done|db.execute;\ v.to.db map=$$O option=coor col1=x col2=y;\ echo SELECT along,x,y FROM $$O|db.select -c|\ perl -aF\\\| -nwe 'use strict;my $$distance+=$$F[0];\ printf "%d|%f|%f\n",$$distance*$(num_per_meter),\ $$F[1],$$F[2] if $$distance'>>$@.tmp; g.remove vect=$$O; done;\ v.in.ascii out=$@ xcol=2 ycol=3 catcol=1 < $@.tmp; rm $@.tmp; fi touch $@ #Or put the points where you want... and e.g., note odd for left #branches, even for right. But that's more complicated... #0 looks bad as a house number so not printing! %DisplayOne:%Positions#Display one map and all its numbered streets d.vect map=$*Clip if test -s $*EndPoints;\ then d.vect display=cat map=$? xref=center\ bgcolor=white lcolor=black lsize=7; fi #(we target monochrome printers) # [no touch(1)] #A start and ends (endpoint) list, which we must type in, looks like #$ cat largeEndPoints #2 28 #33 55 display_all_maps:clear make ornaments largeDisplayOne mediumDisplayOne smallDisplayOne d.vect map=hwy3 ornaments: d.barscale at=17,17 shicheng.view: g.region $(REGION) d.erase;d.redraw grep -x 200 dmax > /dev/null || echo 200 > dmax make largeDisplayOne mediumDisplayOne smallDisplayOne echo Shicheng house number planning|d.text color=black at=20,7 d.text.freetype color=black charset=big5 \ east_north=225585,2686300 path=$(BK) text=石城門牌號碼規劃 d.barscale at=17,17 clear: g.region $(REGION) d.erase d.redraw %.gif:%.png pngtopnm $?|ppmtogif>$@ zhendong.view: g.region n=2687677 s=2687509 w=226642 e=226880 d.erase;d.redraw grep -x 9 dmax > /dev/null || echo 9 > dmax make largeDisplayOne mediumDisplayOne smallDisplayOne echo 14\&15 ALY 69 LN 324 ZHENDONG ST|d.text color=black at=27,10 d.text.freetype color=black charset=big5 \ east_north=226700,2687536 path=$(BK) size=6 \ text=珍東街324巷69弄14及15號 d.text.freetype color=black charset=big5 \ east_north=226680,2687589 path=$(BK) size=4 \ text=LN\ 326巷 rotation=77 d.text.freetype color=black charset=big5 \ east_north=226727,2687553 path=$(BK) size=4 \ text=LN\ 324巷 rotation=46 d.barscale at=10,12 echo -e move \ 226810 2687630\\n text 15\\nmove \ 226843 2687630\\n text 14|d.mapgraph #interesting... 0,1 ... 14,15... but don't use 0... tradition %.png: d.mon PNG make $*.view d.mon stop=PNG -d.mon select=x1 pngtopnm map.png|pnmcrop|pnmtopng>$@ #Just for maintainer jidanni: k: pcp Makefile :/儲存卡/shi_mk.txt web: #shicheng.png shicheng.gif zhendong.gif zhendong.png # cp -upv $^ ~/jidanni.org/geo/house_numbering/shicheng/images cp -upv Makefile \ ~/jidanni.org/geo/house_numbering/shicheng/programs/makefile # http://www.ris.gov.tw/gateway/village/street_no.cgi # http://grass.itc.it/grass57/manuals/html57_user/sql.html # http://grass.itc.it/grass51/tutorial/network.html # /usr/share/doc/python-pygresql/tutorial/basics.py floppy:/mnt/usb/floppy cd ~/jidanni.org/geo && rsync -av house_numbering $? rsync -av floppy.html $?/index.html BS=/usr/share/fonts/truetype/arphic/bsmi00lp.ttf#straight BK=/usr/share/fonts/truetype/arphic/bkai00mp.ttf#slant fonttest: d.erase e=226; n=2689;set -x;for i in $(BS) $(BK);\ do d.text.freetype text=石城`basename $$i` \ east_north=$$((e--*1000)),$$((n--*1000)) \ path=$$i charset=big5 color=black;done #[color=string] [size=integer] [align=string] [rotation=float] aline: echo -e move 228000 2688000\\n draw 228000 2688333|d.mapgraph n w s se: g.region $(REGION) # pnmgamma 9 < $@.pnm > T$@.pnm #lighten cp $@.pnm T$@.pnm r.in.gdal -o input=T$@.pnm output=$@ #good rm -f T$@.pnm i.group group=$@ input=$@ i.target -c group=$@ # d.vect largeCat # v.to.db -p map=largeCat option=coor|tr \| ' ' # i.points #by hand one by one # g.region $(REGION) i.rectify -c input=$@ group=$@ extension=1 order=1 #one day try vpoints wall: g.region $(REGION) d.erase d.redraw for i in n w s se; do d.rast -o $${i}1; done d.vect map=large d.vect map=hwy3 walladd: # g.region n=2688352 s=2686632 e=228500 w=226742 d.mon PNG d.erase d.redraw for i in n w s se; do d.rast -o $${i}1; done # d.barscale at=17,17 make largeDisplayOne mediumDisplayOne smallDisplayOne d.vect map=hwy3 d.mon stop=PNG pngtopnm map.png|pnmcrop|pnmtopng >$@.png # convert map.png map.pgm # pnmcrop < map.pgm|pnmtopng >$@.png #pnmtojpeg --quality=14 --grayscale>$@.jpg shicheng_photomaps: #Make all of Shicheng st. photos n=0;while test $$n -lt 4; do g.region n=2686990 s=2686810 \ e=$$((228456-$$n*450)) w=$$((227991-$$n*450));\ test $$n -eq 3 && g.region s=2686730;\ make walladd||exit; mv walladd.png s$$n.png; let n++; done shike: # d.zoom # v.digit -n map=shike bgcmd="d.rast map=w1" # v.digit map=shike bgcmd="d.rast map=n1" # v.build.polylines input=shike output=sk # make skView #then filled in skEndpoints d.erase d.rast w1 d.rast -o n1 make skDisplayOne PH=500 PK=($(PH)-80) skphotos: # v.to.points input=sk output=$@ dmax=$(PH) v.to.db -p map=$@ option=coor|awk -F\| \ '/^[0-9]/{printf "g.region w=%d e=%d s=%d n=%d;\ FILENAME=k$$((e++)) make oneskphoto\n",\ $$2-$(PK)/2, $$2+$(PK)/2, $$3-$(PK)/2, $$3+$(PK)/2}'|tac|sh -ex oneskphoto: d.mon PNG d.erase d.redraw d.rast w1 d.rast -o n1 make skDisplayOne d.mon stop=PNG pngtopnm map.png|pnmcrop|pnmtopng > map1.png pngcrush map1.png $${FILENAME?}.png 9767: awk '{print $$1-825,$$2+202}' slope: #proof Shike Ln. slope hardly influences so can be ignored perl -wle 'print 2/5*sqrt 2000**2+(400-280)**2' #so no need to factor in elevations from DEM map perl -wle 'print 2/5*1600," ",2/5*sqrt 1600**2+(400-789)**2'#Ruanbi