DS =\ -dsco NAME="UP Diliman, Philippines simulated house address grid" \ -dsco DESCRIPTION="See $(subst $(HOME)/,https://www.,$(PWD))" ## Author: Dan Jacobson https://www.jidanni.org/ ## Copyright: https://www.gnu.org/licenses/gpl.html ## Created: 2025-03-30T03:46:49+0000 ## Last-Updated: 2025-04-04T23:52:34+0000 ## Update #: 45 P=up_diliman B=$P.boundary v=viking $P.vik: # Ground control points. "X","Y",lat,lon: G:=$G 2500 7500 14.654897 121.064883 #Oblation Statue t=3177 #to get the same 125 meter spacing G:=$G $t 7600 14.656164 121.072742 #F. Ma. Guerrero Street/OsmeƱa Avenue G:=$G $t 7400 14.653915 121.072777 #A. Maria Regidor Street/M. Roxas Avenue see_gcps:$P.kml; $v $< %.csv:%.optfile; perl -anwle 'printf "%s,%s,%s/%s\n", @F[3,4,1,2];' $< > $@ $P.kml:$P.csv; ogr2ogr -f LIBKML $@ $< -oo X_POSSIBLE_NAMES=field_1 \ -oo Y_POSSIBLE_NAMES=field_2 -sql 'SELECT field_3 AS Name FROM "$(basename $<)"' $P.optfile:Makefile; echo $G|xargs --max-args 4|perl -anwle 'print qq(-gcp @F[0,1,3,2])' > $@ # Drape contours over the wedge. Our own version of "gdal_create -outsize 2 2". # (Makes four points per line, we actually only want the middle two, but will get clipped anyway): K=gdal_contour -q -a Name $< $@ -lco GEOMETRY=AS_WKT %.csv:%.xyz; $K -i 100 %.single_axis.csv:%.xyz; $K -fl 5000 clean:; rm *.xyz *.kml *.csv *.optfile W=1500 E=5000 S=$E N=8500 $P.%.xyz: Makefile; perl -wle "for([$W,$N],[$E,$N],[$W,$S],[$E,$S]){print qq(@\$$_ @\$$_[$*])}" > $@ $P.%.kml:$P.%.csv $B.csv $P.optfile ogr2ogr -f LIBKML $@ $< --optfile $P.optfile -clipdst $B.csv -sql \ 'SELECT Name FROM "$(basename $<)"' $P.%.single_axis.kml:$P.%.single_axis.csv $P.optfile ogr2ogr -f LIBKML $@ $< --optfile $P.optfile -sql \ 'SELECT Name FROM "$(basename $<)"' -clipsrc $W $S $E $N sak=$P.0.single_axis.kml $P.1.single_axis.kml sa:$(sak); $v $^ guts=$B.kml $(sak) #$P.kml %.kmz: $(guts) %.0.kml %.1.kml; ogrmerge -f LIBKML -overwrite_ds -o $@ $^ $(DS) .SECONDARY: .PRECIOUS: %.kmz # Clipping boundary: p0= 14.656338 121.076779 #MWSS [NE], now go south C:=$(p0) #now going down the east side: C:=$C 14.649591 121.076199 #Pansol Av. C:=$C 14.646872 121.059892 #SW C:=$C 14.654076 121.057692 #Commission on Higher Education C:=$C 14.655010 121.054913 #University Av. Station C:=$C 14.663272 121.067445 #Tandang Sora Station [N] C:=$C $(p0) $B.csv:Makefile echo $C|xargs --max-args 2 > /tmp/$@ #I'm not sure this is the best way, but it works: ogr2ogr $@ /tmp/$@ -lco GEOMETRY=AS_WKT -dialect SQLite -sql \ 'SELECT "." as Name, $(\ )MakePolygon(MakeLine(MakePoint(field_2+0, field_1+0))) AS WKT FROM "$B"' $B.kml:$B.csv; ogr2ogr -f LIBKML $@ $< -sql 'SELECT Name FROM "$(basename $<)"' %.vik:%.kmz cd /tmp && nohup sh -c \ "if pidof -q $v; then killall --wait `: --signal SIGHUP` $v; fi; \ $v `: --zoom 17` -e $(PWD)/$< & sleep 17" sleep 4