DS =\ -dsco NAME="Pasay, Philippines street numbers" \ -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-02-12T04:37:04+0000 ## Last-Updated: 2025-02-12T09:44:04+0000 ## Update #: 56 ## Our eye spots a regularly named street grid! ## Too bad house numbers are not related to the street names here! P=pasay_nos $P.vik: # Ground control points. NW/SE(odd), NE/SW(even) G:=$G 2 17 14.525013 121.018778 G:=$G 14 19 14.529365 121.014584 G:=$G 2 3 14.522728 121.016632 G:=$G 14 7 14.527469 121.012794 double_check:$P.kml $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 $<)"' %.csv:%.optfile; perl -anwle 'printf "%s,%s,%s/%s\n", @F[3,4,1,2];' $< > $@ $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): %.csv:%.xyz; gdal_contour -i 2 -off $(subst $P.,,$*) -q -a Name $< $@ -lco GEOMETRY=AS_WKT clean:; rm *.xyz *.kml *.csv *.optfile $P.%.xyz: Makefile; N=31 E=31 S=0 W=0; perl -wle \ "for([$$W,$$N],[$$E,$$N],[$$W,$$S],[$$E,$$S]){print qq(@\$$_ @\$$_[$*])}" > $@ $P.%.kml:$P.%.csv $P.boundary.csv $P.optfile ogr2ogr -f LIBKML $@ $< --optfile $P.optfile -clipdst $P.boundary.csv -sql \ 'SELECT Name FROM "$(basename $<)"' %.kmz: %.0.kml %.1.kml #$P.kml $P.boundary.kml ogrmerge -f LIBKML -overwrite_ds -o $@ $^ $(DS) .INTERMEDIATE: %.kml $P.optfile $P.boundary.csv $P.boundary_raw.csv .PRECIOUS: %.kmz # Study area clipping boundary: (counterclockwise) N= 14.530225 121.013892 # ~21 / creek C:=$C $N C:=$C 14.530465 121.012839 # 17 / 16 #Nortwestmost point C:=$C 14.529621 121.012257 # ~13 / 16 C:=$C 14.526181 121.011557 # Trinidad / Manlunas #Westmost point C:=$C 14.521925 121.016002 # Newport / Resort #Southmost point C:=$C 14.524916 121.018856 # 2nd+ / 17 #Better eastmost point C:=$C 14.527498 121.016821 # ~21 / 8 C:=$C $N $P.boundary_raw.csv:; echo $C|xargs --max-args 2 > $@ %.boundary.csv:%.boundary_raw.csv #I'm not sure this is the best way, but it works: ogr2ogr $@ $< -lco GEOMETRY=AS_WKT -dialect SQLite -sql \ 'SELECT "bdy" as Name, $(\ )MakePolygon(MakeLine(MakePoint(field_2+0, field_1+0))) AS WKT FROM "$(basename $<)"' $P.boundary.kml:$P.boundary.csv; ogr2ogr -f LIBKML $@ $< -sql 'SELECT Name FROM "$(basename $<)"' v=viking %.vik:%.kmz cd /tmp && nohup sh -c \ "if pidof -q $v; then killall `: --wait` --signal SIGHUP $v; fi; \ $v --zoom 17 -e $(PWD)/$< & sleep 11"