-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsplitter.py
112 lines (83 loc) · 2.84 KB
/
splitter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import configparser
import shutil
WORK_DIR = os.path.expanduser('~') + "/map_build/"
def info(msg):
print("II: " + msg)
def warn(msg):
print("WW: " + msg)
def write_config():
with open('pygmap3.cfg', 'w') as configfile:
config.write(configfile)
config = configparser.ConfigParser()
# split raw-data
def split():
os.chdir(WORK_DIR)
config.read('pygmap3.cfg')
region = config['runtime']['region']
splitter = config['splitter']['rev'] + "/splitter.jar "
# Java HEAP, RAM oder Mode
if config['java']['agh'] == "1":
heap = " -XX:+AggressiveHeap "
else:
heap = (config['java']['xmx'] + ' ' + config['java']['xms'])
java_opts = "java -ea " + heap + " -jar " + WORK_DIR + splitter
log_opts = " > splitter.log "
# splitter-options
BUILD_O5M = WORK_DIR + "o5m/" + region + ".o5m"
sea = " "
if config.has_option('runtime', 'no_sea'):
pass
elif config.has_option('precomp', 'sea'):
sea_zip = WORK_DIR + "precomp/" + config['precomp']['sea']
if os.path.exists(sea_zip):
sea = " --precomp-sea=" + sea_zip
cities15000 = WORK_DIR + "cities15000.zip"
if os.path.exists(cities15000):
geonames = " --geonames-file=" + cities15000
else:
geonames = " "
splitter_opts = (geonames +
" --mapid=" + config[region]['mapid'] + "0001 "
+ " --output=o5m "
+ sea
+ " --write-kml=" + region + ".kml "
+ " --keep-complete "
+ " --overlap=0 ")
# maxnodes
if config.has_option('maxnodes', region):
maxnodes = config['maxnodes'][region]
else:
maxnodes = config['maxnodes']['default']
# splitter.jar command_line
command_line = (java_opts
+ log_opts
+ splitter_opts
+ " --max-nodes=" + maxnodes + " "
+ BUILD_O5M)
if config.has_option('runtime', 'verbose'):
print()
info(command_line)
print()
os.chdir("tiles")
os.system(command_line)
if config.has_option('runtime', 'logging'):
log_dir = WORK_DIR + "log/splitter/" + region
if os.path.exists(log_dir):
path = log_dir
for file in os.listdir(path):
if os.path.isfile(os.path.join(path, file)):
os.remove(os.path.join(path, file))
else:
os.makedirs(log_dir)
for i in ['densities-out.txt',
'template.args',
'areas.poly',
'splitter.log',
'areas.list']:
if os.path.exists(i):
shutil.copy2(i, log_dir)
file = open(region + "_split.ready", "w")
file.close()