forked from organicmaps/organicmaps
Review fixes
This commit is contained in:
parent
a265714d89
commit
545bad15ad
6 changed files with 22 additions and 16 deletions
|
@ -118,7 +118,10 @@ namespace stats
|
|||
os << prefix << ": size = " << info.m_size << "; count = " << info.m_count;
|
||||
|
||||
if (measurements)
|
||||
os << "; length = " << uint64_t(info.m_length) << " m; area = " << uint64_t(info.m_area) << " m²";
|
||||
{
|
||||
os << "; length = " << static_cast<uint64_t>(info.m_length)
|
||||
<< " m; area = " << static_cast<uint64_t>(info.m_area) << " m²";
|
||||
}
|
||||
|
||||
os << "; names = " << info.m_names << '\n';
|
||||
}
|
||||
|
|
|
@ -261,5 +261,4 @@ std::ofstream OfstreamWithExceptions(std::string const & name)
|
|||
f.open(name);
|
||||
return f;
|
||||
}
|
||||
|
||||
} // namespace generator
|
||||
|
|
|
@ -8,7 +8,7 @@ from pathlib import Path
|
|||
from typing import Any
|
||||
from typing import AnyStr
|
||||
|
||||
from maps_generator.utils.md5 import md5
|
||||
from maps_generator.utils.md5 import md5_ext
|
||||
from maps_generator.utils.system import total_virtual_memory
|
||||
|
||||
parser = argparse.ArgumentParser(add_help=False)
|
||||
|
@ -68,7 +68,7 @@ class CfgReader:
|
|||
|
||||
|
||||
DEFAULT_PLANET_URL = "https://planet.openstreetmap.org/pbf/planet-latest.osm.pbf"
|
||||
DEFAULT_PLANET_MD5_URL = md5(DEFAULT_PLANET_URL)
|
||||
DEFAULT_PLANET_MD5_URL = md5_ext(DEFAULT_PLANET_URL)
|
||||
|
||||
# Main section:
|
||||
# If DEBUG is True, a little special planet is downloaded.
|
||||
|
@ -136,7 +136,7 @@ PLANET_COASTS_RAWGEOM_URL = os.path.join(PLANET_COASTS_URL, "latest_coasts.rawge
|
|||
|
||||
if DEBUG:
|
||||
PLANET_URL = "http://osmz.ru/mwm/islands/islands.o5m"
|
||||
PLANET_MD5_URL = "https://cloud.mail.ru/public/5v2F/f7cSaEXBC"
|
||||
PLANET_MD5_URL = "https://cloclo10.cldmail.ru/2n5jWJm11RtdLYm5QFYM/G/QAsr/24zvN9Gf8"
|
||||
|
||||
# Common:
|
||||
THREADS_COUNT = multiprocessing.cpu_count()
|
||||
|
@ -280,4 +280,4 @@ def init(default_settings_path: AnyStr):
|
|||
|
||||
if DEBUG:
|
||||
PLANET_URL = "http://osmz.ru/mwm/islands/islands.o5m"
|
||||
PLANET_MD5_URL = "https://cloud.mail.ru/public/5v2F/f7cSaEXBC"
|
||||
PLANET_MD5_URL = "https://cloclo10.cldmail.ru/2n5jWJm11RtdLYm5QFYM/G/QAsr/24zvN9Gf8"
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
This file contains basic api for generator_tool and osm tools to generate maps.
|
||||
"""
|
||||
import functools
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import json
|
||||
from typing import AnyStr
|
||||
|
||||
from maps_generator.generator import settings
|
||||
|
@ -15,6 +15,7 @@ from maps_generator.generator.env import PathProvider
|
|||
from maps_generator.generator.env import WORLDS_NAMES
|
||||
from maps_generator.generator.env import WORLD_NAME
|
||||
from maps_generator.generator.env import get_all_countries_list
|
||||
from maps_generator.generator.exceptions import ValidationError
|
||||
from maps_generator.generator.gen_tool import run_gen_tool
|
||||
from maps_generator.generator.osmtools import osmconvert
|
||||
from maps_generator.generator.osmtools import osmupdate
|
||||
|
@ -22,7 +23,7 @@ from maps_generator.generator.statistics import make_stats
|
|||
from maps_generator.utils.file import download_files
|
||||
from maps_generator.utils.file import is_verified
|
||||
from maps_generator.utils.file import symlink_force
|
||||
from maps_generator.utils.md5 import md5
|
||||
from maps_generator.utils.md5 import md5_ext
|
||||
from maps_generator.utils.md5 import write_md5sum
|
||||
|
||||
logger = logging.getLogger("maps_generator")
|
||||
|
@ -46,7 +47,7 @@ def convert_planet(
|
|||
error=subprocess.DEVNULL,
|
||||
):
|
||||
osmconvert(tool, in_planet, out_planet, output=output, error=error)
|
||||
write_md5sum(out_planet, md5(out_planet))
|
||||
write_md5sum(out_planet, md5_ext(out_planet))
|
||||
|
||||
|
||||
def step_download_and_convert_planet(env: Env, force_download: bool, **kwargs):
|
||||
|
@ -54,11 +55,14 @@ def step_download_and_convert_planet(env: Env, force_download: bool, **kwargs):
|
|||
download_files(
|
||||
{
|
||||
settings.PLANET_URL: env.paths.planet_osm_pbf,
|
||||
settings.PLANET_MD5_URL: md5(env.paths.planet_osm_pbf),
|
||||
settings.PLANET_MD5_URL: md5_ext(env.paths.planet_osm_pbf),
|
||||
},
|
||||
env.force_download_files,
|
||||
)
|
||||
|
||||
if not is_verified(env.paths.planet_osm_pbf):
|
||||
raise ValidationError(f"Wrong md5 sum for {env.paths.planet_osm_pbf}.")
|
||||
|
||||
convert_planet(
|
||||
env[settings.OSM_TOOL_CONVERT],
|
||||
env.paths.planet_osm_pbf,
|
||||
|
@ -67,7 +71,7 @@ def step_download_and_convert_planet(env: Env, force_download: bool, **kwargs):
|
|||
error=env.get_subprocess_out(),
|
||||
)
|
||||
os.remove(env.paths.planet_osm_pbf)
|
||||
os.remove(md5(env.paths.planet_osm_pbf))
|
||||
os.remove(md5_ext(env.paths.planet_osm_pbf))
|
||||
|
||||
|
||||
def step_update_planet(env: Env, **kwargs):
|
||||
|
@ -82,7 +86,7 @@ def step_update_planet(env: Env, **kwargs):
|
|||
)
|
||||
os.remove(env.paths.planet_o5m)
|
||||
os.rename(tmp, env.paths.planet_o5m)
|
||||
write_md5sum(env.paths.planet_o5m, md5(env.paths.planet_o5m))
|
||||
write_md5sum(env.paths.planet_o5m, md5_ext(env.paths.planet_o5m))
|
||||
|
||||
|
||||
def step_preprocess(env: Env, **kwargs):
|
||||
|
|
|
@ -12,7 +12,7 @@ from typing import Dict
|
|||
from typing import Optional
|
||||
|
||||
from maps_generator.utils.md5 import check_md5
|
||||
from maps_generator.utils.md5 import md5
|
||||
from maps_generator.utils.md5 import md5_ext
|
||||
|
||||
logger = logging.getLogger("maps_generator")
|
||||
|
||||
|
@ -56,11 +56,11 @@ def download_files(url_to_path: Dict[AnyStr, AnyStr], download_if_exists: bool =
|
|||
|
||||
|
||||
def is_exists_file_and_md5(name: AnyStr) -> bool:
|
||||
return os.path.isfile(name) and os.path.isfile(md5(name))
|
||||
return os.path.isfile(name) and os.path.isfile(md5_ext(name))
|
||||
|
||||
|
||||
def is_verified(name: AnyStr) -> bool:
|
||||
return is_exists_file_and_md5(name) and check_md5(name, md5(name))
|
||||
return is_exists_file_and_md5(name) and check_md5(name, md5_ext(name))
|
||||
|
||||
|
||||
def copy_overwrite(from_path: AnyStr, to_path: AnyStr):
|
||||
|
|
|
@ -27,5 +27,5 @@ def check_md5(fname, name):
|
|||
return False
|
||||
|
||||
|
||||
def md5(name):
|
||||
def md5_ext(name):
|
||||
return f"{name}.md5"
|
||||
|
|
Loading…
Add table
Reference in a new issue