forked from organicmaps/organicmaps
[python][generator] Changed planet paths.
This commit is contained in:
parent
8a2b18565a
commit
2efa86d605
6 changed files with 23 additions and 29 deletions
|
@ -33,7 +33,7 @@ def make_coastline(env: Env):
|
|||
coastline_o5m = os.path.join(env.paths.coastline_path, "coastline.o5m")
|
||||
filter_coastline(
|
||||
env[settings.OSM_TOOL_FILTER],
|
||||
settings.PLANET_O5M,
|
||||
env.paths.planet_o5m,
|
||||
coastline_o5m,
|
||||
output=env.get_subprocess_out(),
|
||||
error=env.get_subprocess_out(),
|
||||
|
|
|
@ -211,6 +211,14 @@ class PathProvider:
|
|||
def transit_path(self) -> AnyStr:
|
||||
return self.intermediate_data_path
|
||||
|
||||
@property
|
||||
def planet_osm_pbf(self) -> AnyStr:
|
||||
return os.path.join(self.build_path, f"{settings.PLANET}.osm.pbf")
|
||||
|
||||
@property
|
||||
def planet_o5m(self) -> AnyStr:
|
||||
return os.path.join(self.build_path, f"{settings.PLANET}.o5m")
|
||||
|
||||
@property
|
||||
def main_status_path(self) -> AnyStr:
|
||||
return os.path.join(self.status_path, "stages.status")
|
||||
|
@ -312,7 +320,6 @@ class PathProvider:
|
|||
@staticmethod
|
||||
def srtm_path() -> AnyStr:
|
||||
return settings.SRTM_PATH
|
||||
|
||||
|
||||
@staticmethod
|
||||
def isolines_path() -> AnyStr:
|
||||
|
|
|
@ -66,17 +66,11 @@ class Generation:
|
|||
if from_stage is not None:
|
||||
self.reset_to_stage(from_stage)
|
||||
|
||||
planet_lock = filelock.FileLock(f"{settings.PLANET_O5M}.lock", timeout=1)
|
||||
build_lock = filelock.FileLock(
|
||||
f"{os.path.join(self.env.paths.build_path, 'lock')}.lock"
|
||||
)
|
||||
try:
|
||||
for stage in self.runnable_stages:
|
||||
if stage.need_planet_lock:
|
||||
planet_lock.acquire()
|
||||
else:
|
||||
planet_lock.release()
|
||||
|
||||
if stage.need_build_lock:
|
||||
build_lock.acquire()
|
||||
else:
|
||||
|
@ -84,7 +78,6 @@ class Generation:
|
|||
|
||||
stage(self.env)
|
||||
finally:
|
||||
planet_lock.release()
|
||||
build_lock.release()
|
||||
|
||||
def reset_to_stage(self, stage_name: AnyStr):
|
||||
|
|
|
@ -131,8 +131,6 @@ OSM_TOOLS_CC_FLAGS = [
|
|||
]
|
||||
|
||||
# Planet and coasts:
|
||||
PLANET_O5M = os.path.join(MAIN_OUT_PATH, PLANET + ".o5m")
|
||||
PLANET_PBF = os.path.join(MAIN_OUT_PATH, PLANET + ".osm.pbf")
|
||||
PLANET_COASTS_GEOM_URL = os.path.join(PLANET_COASTS_URL, "latest_coasts.geom")
|
||||
PLANET_COASTS_RAWGEOM_URL = os.path.join(PLANET_COASTS_URL, "latest_coasts.rawgeom")
|
||||
|
||||
|
@ -275,12 +273,8 @@ def init(default_settings_path: AnyStr):
|
|||
THREADS_COUNT = threads_count
|
||||
|
||||
# Planet and costs:
|
||||
global PLANET_O5M
|
||||
global PLANET_PBF
|
||||
global PLANET_COASTS_GEOM_URL
|
||||
global PLANET_COASTS_RAWGEOM_URL
|
||||
PLANET_O5M = os.path.join(MAIN_OUT_PATH, PLANET + ".o5m")
|
||||
PLANET_PBF = os.path.join(MAIN_OUT_PATH, PLANET + ".osm.pbf")
|
||||
PLANET_COASTS_GEOM_URL = os.path.join(PLANET_COASTS_URL, "latest_coasts.geom")
|
||||
PLANET_COASTS_RAWGEOM_URL = os.path.join(PLANET_COASTS_URL, "latest_coasts.rawgeom")
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ class StageDownloadProductionExternal(Stage):
|
|||
@planet_lock
|
||||
class StageDownloadAndConvertPlanet(Stage):
|
||||
def apply(self, env: Env, force_download: bool = True, **kwargs):
|
||||
if force_download or not is_verified(settings.PLANET_O5M):
|
||||
if force_download or not is_verified(env.paths.planet_o5m):
|
||||
steps.step_download_and_convert_planet(
|
||||
env, force_download=force_download, **kwargs
|
||||
)
|
||||
|
|
|
@ -53,33 +53,33 @@ def convert_planet(
|
|||
|
||||
|
||||
def step_download_and_convert_planet(env: Env, force_download: bool, **kwargs):
|
||||
if force_download or not is_verified(settings.PLANET_PBF):
|
||||
download_planet(settings.PLANET_PBF)
|
||||
if force_download or not is_verified(env.paths.planet_osm_pbf):
|
||||
download_planet(env.paths.planet_osm_pbf)
|
||||
|
||||
convert_planet(
|
||||
env[settings.OSM_TOOL_CONVERT],
|
||||
settings.PLANET_PBF,
|
||||
settings.PLANET_O5M,
|
||||
env.paths.planet_osm_pbf,
|
||||
env.paths.planet_o5m,
|
||||
output=env.get_subprocess_out(),
|
||||
error=env.get_subprocess_out(),
|
||||
)
|
||||
os.remove(settings.PLANET_PBF)
|
||||
os.remove(md5(settings.PLANET_PBF))
|
||||
os.remove(env.paths.planet_osm_pbf)
|
||||
os.remove(md5(env.paths.planet_osm_pbf))
|
||||
|
||||
|
||||
def step_update_planet(env: Env, **kwargs):
|
||||
tmp = settings.PLANET_O5M + ".tmp"
|
||||
tmp = f"{env.paths.planet_o5m}.tmp"
|
||||
osmupdate(
|
||||
env[settings.OSM_TOOL_UPDATE],
|
||||
settings.PLANET_O5M,
|
||||
env.paths.planet_o5m,
|
||||
tmp,
|
||||
output=env.get_subprocess_out(),
|
||||
error=env.get_subprocess_out(),
|
||||
**kwargs,
|
||||
)
|
||||
os.remove(settings.PLANET_O5M)
|
||||
os.rename(tmp, settings.PLANET_O5M)
|
||||
write_md5sum(settings.PLANET_O5M, md5(settings.PLANET_O5M))
|
||||
os.remove(env.paths.planet_o5m)
|
||||
os.rename(tmp, env.paths.planet_o5m)
|
||||
write_md5sum(env.paths.planet_o5m, md5(env.paths.planet_o5m))
|
||||
|
||||
|
||||
def step_preprocess(env: Env, **kwargs):
|
||||
|
@ -89,7 +89,7 @@ def step_preprocess(env: Env, **kwargs):
|
|||
err=env.get_subprocess_out(),
|
||||
intermediate_data_path=env.paths.intermediate_data_path,
|
||||
osm_file_type="o5m",
|
||||
osm_file_name=settings.PLANET_O5M,
|
||||
osm_file_name=env.paths.planet_o5m,
|
||||
node_storage=env.node_storage,
|
||||
user_resource_path=env.paths.user_resource_path,
|
||||
preprocess=True,
|
||||
|
@ -114,7 +114,7 @@ def step_features(env: Env, **kwargs):
|
|||
data_path=env.paths.data_path,
|
||||
intermediate_data_path=env.paths.intermediate_data_path,
|
||||
osm_file_type="o5m",
|
||||
osm_file_name=settings.PLANET_O5M,
|
||||
osm_file_name=env.paths.planet_o5m,
|
||||
node_storage=env.node_storage,
|
||||
user_resource_path=env.paths.user_resource_path,
|
||||
dump_cities_boundaries=True,
|
||||
|
|
Loading…
Add table
Reference in a new issue