aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/osm/osm.village.nat_ref.makefile
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/osm/osm.village.nat_ref.makefile')
-rw-r--r--[-rwxr-xr-x]scripts/osm/osm.village.nat_ref.makefile28
1 files changed, 14 insertions, 14 deletions
diff --git a/scripts/osm/osm.village.nat_ref.makefile b/scripts/osm/osm.village.nat_ref.makefile
index f763c19..ffadcf4 100755..100644
--- a/scripts/osm/osm.village.nat_ref.makefile
+++ b/scripts/osm/osm.village.nat_ref.makefile
@@ -1,3 +1,5 @@
1SHELL := /bin/bash
2
1data/taiwan-latest.osm.pbf: 3data/taiwan-latest.osm.pbf:
2 mkdir -p data 4 mkdir -p data
3 curl -o $@ http://download.geofabrik.de/asia/taiwan-latest.osm.pbf 5 curl -o $@ http://download.geofabrik.de/asia/taiwan-latest.osm.pbf
@@ -23,7 +25,13 @@ village.no_nat_ref.csv: village.csv
23village.with_nat_ref.csv: village.csv 25village.with_nat_ref.csv: village.csv
24 (head -1 $<; grep nat_ref $<) |\ 26 (head -1 $<; grep nat_ref $<) |\
25 sed -r "s/\"\"\".*nat_ref\"\"=>\"\"([^\"]+).*\"\"\"/\1/g" |\ 27 sed -r "s/\"\"\".*nat_ref\"\"=>\"\"([^\"]+).*\"\"\"/\1/g" |\
26 sed '1s/other_tags/nat_ref/'> $@ 28 sed '1s/other_tags/nat_ref/;s/"//g' |\
29 (sed -u 1q; sort -t',' -k5)> $@
30
31village.gov.csv: data/VILLAGE_MOI_1081007.shp
32 ogr2ogr -f CSV /vsistdout/ $< |\
33 (sed -u 1q; sort -t',' -k1) |\
34 sed 's/"//g'> $@
27 35
28matched.csv: data/VILLAGE_MOI_1081007.shp village.no_nat_ref.csv 36matched.csv: data/VILLAGE_MOI_1081007.shp village.no_nat_ref.csv
29 ogr2ogr $@ $(word 2,$^) \ 37 ogr2ogr $@ $(word 2,$^) \
@@ -33,18 +41,12 @@ matched.csv: data/VILLAGE_MOI_1081007.shp village.no_nat_ref.csv
33 FROM 'village.no_nat_ref' osm, '$<'.VILLAGE_MOI_1081007 gov \ 41 FROM 'village.no_nat_ref' osm, '$<'.VILLAGE_MOI_1081007 gov \
34 WHERE osm.name = gov.VILLNAME AND Intersects(gov.geometry, osm.geometry)" 42 WHERE osm.name = gov.VILLNAME AND Intersects(gov.geometry, osm.geometry)"
35 43
36village.gov.csv: data/VILLAGE_MOI_1081007.shp 44matched.by_nat_ref.list: village.with_nat_ref.csv village.gov.csv
37 ogr2ogr $@ $< 45 join -t',' -1 5 -2 1 <(sed 1d $<) <(sed 1d $(word 2,$^)) > $@
38 46
39matched.by_ref.csv: village.gov.csv village.with_nat_ref.csv 47change.county_town_en.list: matched.by_nat_ref.list
40 ogr2ogr $@ $(word 2,$^) \ 48 awk -F',' -v q=\" '{print $$4, "is_in:county", q$$6q, "is_in:town", q$$7q, "name:en", q$$9q }' $< |\
41 -dialect sqlite \ 49 sed 's/^/relation /' > $@
42 -sql "SELECT osm.osm_id, gov.* \
43 FROM 'village.with_nat_ref' osm, '$<'.'village.gov' gov \
44 WHERE osm.nat_ref = gov.VILLCODE"
45
46diff: matched.by_ref.csv
47 awk -F',' -v q='"' '{print (, "is_in:county", q{q, "is_in:town", q{})}" q, "name:en", q$6q }' $<
48 50
49confilct.list: matched.csv 51confilct.list: matched.csv
50 cat $< | cut -d',' -f2 | sort | uniq -d | xargs -I {} grep {} $< 52 cat $< | cut -d',' -f2 | sort | uniq -d | xargs -I {} grep {} $<
@@ -60,5 +62,3 @@ change.list: matched.csv
60 cat $< |\ 62 cat $< |\
61 sed 1d |\ 63 sed 1d |\
62 awk -F',' '{print "relation", $$1, "nat_ref", $$2}' > $@ 64 awk -F',' '{print "relation", $$1, "nat_ref", $$2}' > $@
63
64# sed -i -r 's/([0-9]+ +)(.+)$/\1"name:en" "\2"/' diff.eng