diff options
| author | typebrook <typebrook@gmail.com> | 2020-02-04 11:05:37 +0800 |
|---|---|---|
| committer | typebrook <typebrook@gmail.com> | 2020-02-04 11:05:37 +0800 |
| commit | 58f0e0aebf7f63372caadb6ece27a1faa22828e8 (patch) | |
| tree | 4865a3002a21ecee619a78af869288e2ef7c3d2d /scripts/osm | |
| parent | 1ffcf709066caf4acd13062e4ee520c537688e17 (diff) | |
update
Diffstat (limited to 'scripts/osm')
| -rw-r--r-- | scripts/osm/osm.village.nat_ref.makefile | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/scripts/osm/osm.village.nat_ref.makefile b/scripts/osm/osm.village.nat_ref.makefile deleted file mode 100644 index a051ee4..0000000 --- a/scripts/osm/osm.village.nat_ref.makefile +++ /dev/null | |||
| @@ -1,71 +0,0 @@ | |||
| 1 | SHELL := /bin/bash | ||
| 2 | |||
| 3 | data/taiwan-latest.osm.pbf: | ||
| 4 | mkdir -p data | ||
| 5 | curl -o $@ http://download.geofabrik.de/asia/taiwan-latest.osm.pbf | ||
| 6 | |||
| 7 | data/village.zip: | ||
| 8 | mkdir -p data | ||
| 9 | curl -o $@ -L http://data.moi.gov.tw/MoiOD/System/DownloadFile.aspx\?DATA\=B8AF344F-B5C6-4642-AF46-1832054399CE | ||
| 10 | |||
| 11 | data/VILLAGE_MOI_1081007.shp: data/village.zip | ||
| 12 | @if [ ! -e $@ ]; then unzip $< -d data && rm data/*xml data/*xlsx; fi | ||
| 13 | |||
| 14 | village.csv: data/taiwan-latest.osm.pbf | ||
| 15 | ogr2ogr $@ $< \ | ||
| 16 | -lco GEOMETRY=AS_XY \ | ||
| 17 | -dialect sqlite \ | ||
| 18 | -sql "SELECT osm_id, name, other_tags, ST_PointOnSurface(geometry) \ | ||
| 19 | FROM multipolygons \ | ||
| 20 | WHERE admin_level = '9'" | ||
| 21 | |||
| 22 | town.csv: data/taiwan-latest.osm.pbf | ||
| 23 | ogr2ogr $@ $< \ | ||
| 24 | -dialect sqlite \ | ||
| 25 | -sql "SELECT osm_id, name, other_tags \ | ||
| 26 | FROM multipolygons \ | ||
| 27 | WHERE admin_level = '5' OR admin_level = '7' OR admin_level = '8'" | ||
| 28 | |||
| 29 | village.no_nat_ref.csv: village.csv | ||
| 30 | grep -v nat_ref $< > $@ | ||
| 31 | |||
| 32 | village.with_nat_ref.csv: village.csv | ||
| 33 | (head -1 $<; grep nat_ref $<) |\ | ||
| 34 | sed -r "s/\"\"\".*nat_ref\"\"=>\"\"([^\"]+).*\"\"\"/\1/g" |\ | ||
| 35 | sed '1s/other_tags/nat_ref/;s/"//g' |\ | ||
| 36 | (sed -u 1q; sort -t',' -k5)> $@ | ||
| 37 | |||
| 38 | village.gov.csv: data/VILLAGE_MOI_1081007.shp | ||
| 39 | ogr2ogr -f CSV /vsistdout/ $< |\ | ||
| 40 | (sed -u 1q; sort -t',' -k1) |\ | ||
| 41 | sed 's/"//g'> $@ | ||
| 42 | |||
| 43 | matched.csv: data/VILLAGE_MOI_1081007.shp village.no_nat_ref.csv | ||
| 44 | ogr2ogr $@ $(word 2,$^) \ | ||
| 45 | -oo X_POSSIBLE_NAMES=X -oo Y_POSSIBLE_NAMES=Y \ | ||
| 46 | -dialect sqlite \ | ||
| 47 | -sql "SELECT osm.osm_id, osm.name, gov.* \ | ||
| 48 | FROM 'village.no_nat_ref' osm, '$<'.VILLAGE_MOI_1081007 gov \ | ||
| 49 | WHERE Intersects(gov.geometry, osm.geometry)" | ||
| 50 | |||
| 51 | matched.by_nat_ref.list: village.with_nat_ref.csv village.gov.csv | ||
| 52 | join -t',' -1 5 -2 1 <(sed 1d $<) <(sed 1d $(word 2,$^)) > $@ | ||
| 53 | |||
| 54 | change.county_town_en.list: matched.by_nat_ref.list | ||
| 55 | awk -F',' -v q=\" '{print $$4, "is_in:county", q$$6q, "is_in:town", q$$7q, "name:en", q$$9q }' $< |\ | ||
| 56 | sed 's/^/relation /' > $@ | ||
| 57 | |||
| 58 | confilct.list: matched.csv | ||
| 59 | cat $< | cut -d',' -f2 | sort | uniq -d | xargs -I {} grep {} $< | ||
| 60 | |||
| 61 | origin.osm: matched.csv data/taiwan-latest.osm.pbf | ||
| 62 | cat $< |\ | ||
| 63 | sed 1d |\ | ||
| 64 | cut -d'"' -f2 |\ | ||
| 65 | sed -nr 's/.*/r\0/p' |\ | ||
| 66 | osmium getid $(word 2,$^) --id-file - --output-format=osm > $@ | ||
| 67 | |||
| 68 | change.list: matched.csv | ||
| 69 | cat $< |\ | ||
| 70 | sed 1d |\ | ||
| 71 | awk -F',' '{print "relation", $$1, "nat_ref", $$2}' > $@ | ||