From d895076b6d1959cf8ad4396279dda800d4b606d7 Mon Sep 17 00:00:00 2001 From: typebrook Date: Fri, 15 Nov 2019 22:55:32 +0800 Subject: update --- utils/osm.village.nat_ref.makefile | 44 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 utils/osm.village.nat_ref.makefile (limited to 'utils') diff --git a/utils/osm.village.nat_ref.makefile b/utils/osm.village.nat_ref.makefile new file mode 100644 index 0000000..5f59c02 --- /dev/null +++ b/utils/osm.village.nat_ref.makefile @@ -0,0 +1,44 @@ +data/taiwan-latest.osm.pbf: + mkdir -p data + curl -o $@ http://download.geofabrik.de/asia/taiwan-latest.osm.pbf + +data/village.zip: + mkdir -p data + curl -o $@ -L http://data.moi.gov.tw/MoiOD/System/DownloadFile.aspx\?DATA\=B8AF344F-B5C6-4642-AF46-1832054399CE + +data/VILLAGE_MOI_1081007.shp: data/village.zip + @if [ ! -e $@ ]; then unzip $< -d data && rm data/*xml data/*xlsx; fi + +village.csv: data/taiwan-latest.osm.pbf + ogr2ogr $@ $< \ + -lco GEOMETRY=AS_XY \ + -dialect sqlite \ + -sql "SELECT osm_id, name, other_tags, ST_PointOnSurface(geometry) \ + FROM multipolygons \ + WHERE admin_level = '9'" + +village.no_nat_ref.csv: village.csv + grep -v nat_ref $< > $@ + +matched.csv: data/VILLAGE_MOI_1081007.shp village.no_nat_ref.csv + ogr2ogr $@ $(word 2,$^) \ + -oo X_POSSIBLE_NAMES=X -oo Y_POSSIBLE_NAMES=Y \ + -dialect sqlite \ + -sql "SELECT osm.osm_id, gov.* \ + FROM 'village.no_nat_ref' osm, '$<'.VILLAGE_MOI_1081007 gov \ + WHERE osm.name = gov.VILLNAME AND Intersects(gov.geometry, osm.geometry)" + +confilct.list: matched.csv + cat $< | cut -d',' -f2 | sort | uniq -d | xargs -I {} grep {} $< + +origin.osm: matched.csv data/taiwan-latest.osm.pbf + cat $< |\ + sed 1d |\ + cut -d'"' -f2 |\ + sed -nr 's/.*/r\0/p' |\ + osmium getid $(word 2,$^) --id-file - --output-format=osm > $@ + +change.list: matched.csv + cat $< |\ + sed 1d |\ + awk -F',' '{print "relation", $$1, "nat_ref", $$2}' > $@ -- cgit v1.2.3-70-g09d2