### Makefile --- Oak Park IL address grid ## Author: Dan Jacobson https://www.jidanni.org/ ## Copyright: https://www.gnu.org/licenses/gpl.html ## Permalink: https://www.jidanni.org/geo/house_numbering/grids/us/il/cook/oak_park/Makefile ## Created: 2024-05-29T21:45:05+0000 ## Last-Updated: 2024-06-12T09:57:06+0000 ## Update #: 505 # Welcome to the address grid project. I will be your guide today. # My name is Nerdsome. # Today we will see how, by "simply" entering a few parameters into # this Makefile, we'll have your grid on the screen in "no time". # Grid? See # https://www.jidanni.org/geo/house_numbering/grids/define.html , # where we "define" the "problem". # Actually for places like this we would usually use a PLSS based # setup. But this is a demo for a future user interface where the user clicks # on the map, and the interface fills out this Makefile, and the runs it. # OK, let's get started. # What project name file stem should we use? fs=oak_park_il # What shall we use for these KML/KMZ tags? They'll be embedded in the # file you'll show your grandkids. DO = -dsco NAME="Oak Park IL USA address grid (north sector), by \ Dan Jacobson" -dsco DESCRIPTION="Quirk: 100S\ is across the street from 100N. I.e., two tiers of city blocks\ swallowed up by a black hole. We will just map the part of town\ north of the hole today.\ \ One would think we could just make a translator algorithm but then\ there also is this long 1100 S block...\ \ One might think Oh, we'll just use Chicago's system and translate from\ that. But hey, Chicago also has a long 0-1200S mile that should have\ been 0-800S.\ " # That's correct. Just for "spite" today we chose a town where they # folded out those two "00 blocks". Gone into a black hole. So we must # deal with it. I bet those "village mothers and fathers" thought they # were "real smart" back a hundred years ago. # We will try to squeeze it out, with fancy math. No we will absolutely # not. We will instead make two sectors. I.e., two projects here # instead of one. And in fact do just one sector today. # What are the four edges of the rectangle of grids you want? # And remember, e.g., 500S and 500W are written -500. N=1400 E=100 S=0 W=-1300 # (By the way, don't "freak out" that on boundary streets, Oak Park uses # the system on the other side, instead of their own.) # And how many numbers per grid (block, cell)? NPG=100 # And where, may I ask, are your Ground Control Points? GCPs=\ -gcp -1200 1300 -87.80576 41.90887\ -gcp -800 100 -87.79448 41.88709\ -gcp 0 1300 -87.77559 41.90925 # Here's the southern corners of the Village #-gcp -1200 -1200 -87.80422 41.86502 #-gcp 0 -1200 -87.77416 41.86549 #usable on day after we figure out how we want to deal with quirks. # that's X and Y of an address point, followed by Longitude, Latitude. # Need at least three. Maybe just two next year with new GDAL. # The final ones fave fake negative Y values... # Oh yeah. Forgot to tell you to be sure you have installed the # gdal-bin (and viking) packages, then do "make all.kmz". Then do # "viking all.kmz", or use your own favorite KML/KMZ viewer, like # Google Earth (Pro). # The following is just internal stuff. Ho hum. No need to read it. # Never mind this special Dan J. junk: dd=$(HOME)/jidanni.org/geo/house_numbering/grids/us/il/cook/oak_park H=ssh $(remote) viking $(dd)/$< remote=n3 target=all.vik f: clean rm all.kmz||: 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, naturally: 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)) 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:%.raw.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}'|\ perl -F, -apwle '$(nwse)' > $@ # In Oak Park there is no E / W differentiation: perl -pwle 's/W$$//' $@ > $@.tmp && mv $@.tmp $@ %.raw.csv:%.f2.xyz #drape contours over the wedge gdal_contour -i $(NPG) -q -a Name $< $@ -lco GEOMETRY=AS_WKT %.f2.xyz:f2.xy #Here's where we fork, making one "wedge" for each axis perl -anwle '$$F[2]=$$F[$*]; print "@F"' $< > $@ f2.xy: #It's our very own version of "gdal_create -outsize 2 2"!: echo $W $N,$E $N,$W $S,$E $S | tr , \\n > $@ clean:; for i in xy xyz csv kml; do find -maxdepth 1 -name \*.$$i -delete; done # A function to make e.g., -500 into 500W or 500S: nwse=\ next if /WKT/;\ $$F[-1] =\ abs( $$F[-1] ) . ( $* ? ( ( $$F[-1] < 0 ) ? "S" : "N" ) : ( ( $$F[-1] < 0 ) ? "W" : "E" ) );\ $$_ = join ",", @F; .SECONDARY: # Discussion: So what have we done? We have discovered that we can # model addressing grids _one axis at a time_, as the slope on a # wedge, and drape contour lines on it! # Yes, we will still have to determine why it's not perfect here in # our implementation for Oak Park. # First of course we note the streets themselves aren't too regularly # spaced. Can't blame us for that one. # Then what about geographic datums, etc.? Seems like we haven't # figured them in yet. # Then of course note we have PLSS-based solutions for this are that # we will also try soon.