diff options
author | typebrook <typebrook@gmail.com> | 2019-11-19 21:34:34 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2019-11-19 21:34:34 +0800 |
commit | b2470324e3927c5e505ff206aa6d6fe63f42a191 (patch) | |
tree | cb15f921f8e20e3531d30525f1260b4c15e46d5d /scripts | |
parent | 56c24f398714b9594085eb85be38e90d24b5b49d (diff) |
update
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/osm/osm.osc.by_member | 31 | ||||
-rwxr-xr-x | scripts/osm/osm.osm.by_tag (renamed from scripts/osm/osm.osc.create) | 0 | ||||
-rw-r--r-- | scripts/osm/osm.village.nat_ref.makefile | 7 |
3 files changed, 38 insertions, 0 deletions
diff --git a/scripts/osm/osm.osc.by_member b/scripts/osm/osm.osc.by_member new file mode 100755 index 0000000..5f9d9be --- /dev/null +++ b/scripts/osm/osm.osc.by_member | |||
@@ -0,0 +1,31 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | while read -r line | ||
4 | do | ||
5 | |||
6 | TYPE=$(echo $line | cut -d ' ' -f1) # field1 is type | ||
7 | ID=$(echo $line | cut -d ' ' -f2) # field2 is ID | ||
8 | |||
9 | NEW_MEMBERS=$(echo $line |\ | ||
10 | cut -d' ' -f3- |\ | ||
11 | sed -r 's/([0-9]+)/<member type=\"relation\" ref=\"\1\" role=\"subarea\"\/>/g') | ||
12 | |||
13 | echo $NEW_MEMBERS | ||
14 | |||
15 | # print matched element with new tags to .osc file | ||
16 | cat $1 |\ | ||
17 | sed -nr "/<$TYPE id=\"$ID\"/,/<\/$TYPE/ { | ||
18 | /<$TYPE id=\"$ID\"/ { | ||
19 | s/(version=\"[0-9]+\")(.*)/\1>/ | ||
20 | a \ \ \ \ $NEW_MEMBERS | ||
21 | } | ||
22 | p | ||
23 | /<\/$TYPE/ q | ||
24 | }" >> $1.osc | ||
25 | done | ||
26 | |||
27 | # Add .osc structure for output | ||
28 | sed -ir '1 i <osmChange version="0.6" generator="bash script"> | ||
29 | 1 i <modify> | ||
30 | $ a </modify> | ||
31 | $ a </osmChange>' $1.osc | ||
diff --git a/scripts/osm/osm.osc.create b/scripts/osm/osm.osm.by_tag index cc92c1d..cc92c1d 100755 --- a/scripts/osm/osm.osc.create +++ b/scripts/osm/osm.osm.by_tag | |||
diff --git a/scripts/osm/osm.village.nat_ref.makefile b/scripts/osm/osm.village.nat_ref.makefile index cfaf92a..a051ee4 100644 --- a/scripts/osm/osm.village.nat_ref.makefile +++ b/scripts/osm/osm.village.nat_ref.makefile | |||
@@ -19,6 +19,13 @@ village.csv: data/taiwan-latest.osm.pbf | |||
19 | FROM multipolygons \ | 19 | FROM multipolygons \ |
20 | WHERE admin_level = '9'" | 20 | WHERE admin_level = '9'" |
21 | 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 | |||
22 | village.no_nat_ref.csv: village.csv | 29 | village.no_nat_ref.csv: village.csv |
23 | grep -v nat_ref $< > $@ | 30 | grep -v nat_ref $< > $@ |
24 | 31 | ||