### Makefile --- Glencoe IL address grid, contour version ## Author: Dan Jacobson https://www.jidanni.org/ ## Copyright: https://www.gnu.org/licenses/gpl.html ## Created: 2024-06-09T08:00:48+0000 ## Last-Updated: 2024-06-09T09:42:05+0000 ## Update #: 14 # I think the KMZ looks great, and it was so simple to make. # Project name: fs = glencoe_il DO = -dsco NAME="Glencoe IL USA address grid" #-dsco DESCRIPTION="Quirk: ...." # What are the four edges of the rectangle of grids you want? # And remember, e.g., 500S and 500W are written -500. N=1300 E=0 S=0 W=-800 NPG=100 # How many numbers per grid (block, cell) # Let's note some street values: Park=700 Sunset=943 #At Vernon Bluff=-500 Vernon=-350 # Now noting the coordinates of their intersections GCPs=\ -gcp $(Vernon) $(Sunset) -87.76453 42.13984\ -gcp $(Vernon) $(Park) -87.75973 42.13412\ -gcp $(Bluff) $(Park) -87.76428 42.13198 # The following is just internal stuff. Ho hum. No need to read it. # Never mind this special Dan J. junk: #Hardwired... FIX IT dd=$(HOME)/jidanni.org/geo/house_numbering/grids/us/il/cook/glencoe H=ssh $(remote) viking $(dd)/$< remote=n3 target=all.vik f: clean if pidof -q viking; then killall --wait --signal SIGHUP viking; fi case `uname --nodename` in dan1) false;; esac ssh dan1 make -C $$PWD $(target) %.vik:%.kmz cd /tmp && nohup ssh $(remote) viking --map 13 -e $(dd)/$? & sleep 11 # End of special Dan J. junk. # Here are the order of operations, backwards, in fact: publish:all.kmz; mv $< $(fs).kmz #yes, when you're satisfied, run "make publish" all.kmz: $(addsuffix .kml, $(addsuffix .lines,0 1) $(addsuffix .labels,0 1)) #$D/$(fs).kml ogrmerge -f LIBKML -overwrite_ds -o $@ $^ $(DO) #Yes, get warnings as of 2024. %.labels.kml:%.labels.csv ogr2ogr -order 1 -f LIBKML $@ $< \ -oo X_POSSIBLE_NAMES=field_1 \ -oo Y_POSSIBLE_NAMES=field_2 \ -sql 'SELECT Name FROM "$(basename $<)"' %.labels.csv:%.lines.kml # We use the nodes that the contour operation gave us as convenient places for labels: ogr2ogr -explodecollections -dialect SQLITE -lco GEOMETRY=AS_WKT -sql \ 'SELECT Name AS Name, ST_DissolvePoints(GEOMETRY) AS WKT FROM "$*"' $@ $< %.lines.kml:%.csv #Apply the Ground Control Points!: ogr2ogr -f LIBKML $@ $< $(GCPs) -sql 'SELECT Name FROM "$*"' %.csv:%.H.csv # Glencoe uses only one quadrant perl -pwle 's/-?\d+$$/abs $$&/e' $< > $@ %.H.csv:%.A.csv #Here we hack the hell out of the lines the contour operation made. # Indeed our Makefile is one big hack. Real sorry about that. sed \$$d $<|perl -F'\(|\)' -anwle \ 'if($$#F){@M=split /,/, $$F[1]; $$N=join "," ,$(\ )@M[1..$$#M-1]; print "$$F[0]($$N)$$F[2]";}else{print}' > $@ %.A.csv:%.f2.xyz #drape contours over the wedge gdal_contour -i $(NPG) -q -a Name $< $@ -lco GEOMETRY=AS_WKT %.f2.xyz:f2.xy #It's our very own version of "gdal_create -outsize 2 2"!: #Here's where we fork, making one "wedge" for each axis perl -anwle '$$F[2]=$$F[$*]; print "@F"' $< > $@ f2.xy:; echo $W $N, $E $N, $W $S, $E $S | tr , \\n > $@ clean: find -maxdepth 1 \( \ -name \*.xy -o \ -name \*.xyz -o \ -name \*.kml -o \ -name \*.csv -o \ -name all.kmz \ \) -delete .SECONDARY: