| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
import sys |
| 25 |
import csv |
| 26 |
|
| 27 |
MAP_FEATURES = 'map-features.csv' |
| 28 |
|
| 29 |
if len(sys.argv) > 1: |
| 30 |
MAP_FEATURES = sys.argv[1] |
| 31 |
|
| 32 |
points = [] |
| 33 |
lines = [] |
| 34 |
polygons = [] |
| 35 |
|
| 36 |
features = { |
| 37 |
'polyline': lines, |
| 38 |
'polygon': polygons, |
| 39 |
'point': points, |
| 40 |
} |
| 41 |
file_names = { |
| 42 |
'polyline': 'lines', |
| 43 |
'polygon': 'polygons', |
| 44 |
'point': 'points', |
| 45 |
} |
| 46 |
|
| 47 |
def main(): |
| 48 |
|
| 49 |
|
| 50 |
f = open(MAP_FEATURES) |
| 51 |
r = csv.reader(f, delimiter='|') |
| 52 |
for line in r: |
| 53 |
kind = line[0] |
| 54 |
if kind[0] == '#': continue |
| 55 |
key = line[1] + '=' + line[2] |
| 56 |
value = makeval(line[3], line[4]) |
| 57 |
res = int(line[5]) |
| 58 |
|
| 59 |
line = "%s [%s resolution %d]" % (key, value, res) |
| 60 |
ft = features[kind] |
| 61 |
ft.append(line) |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
for name in features.keys(): |
| 66 |
f = open(file_names[name], 'w') |
| 67 |
ft = features[name] |
| 68 |
for line in ft: |
| 69 |
f.write(line) |
| 70 |
f.write("\n") |
| 71 |
|
| 72 |
def makeval(a, b): |
| 73 |
if not b: return a |
| 74 |
return a + b[2:] |
| 75 |
|
| 76 |
if __name__ == '__main__': |
| 77 |
main() |