mirror of
https://github.com/hyperknot/openfreemap.git
synced 2026-05-21 14:02:15 +00:00
download_natural_earth
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,6 +12,7 @@ rclone.conf
|
|||||||
node_modules
|
node_modules
|
||||||
tmp
|
tmp
|
||||||
temp
|
temp
|
||||||
|
_temp
|
||||||
|
|
||||||
/.idea
|
/.idea
|
||||||
venv
|
venv
|
||||||
|
|||||||
@@ -135,8 +135,7 @@ def install_benchmark(c):
|
|||||||
|
|
||||||
|
|
||||||
def debug_tmp(c):
|
def debug_tmp(c):
|
||||||
install_benchmark(c)
|
upload_https_host_files(c)
|
||||||
# upload_https_host_files(c)
|
|
||||||
# put(c, SCRIPTS_DIR / 'http_host' / 'cron.d' / 'ofm_http_host', '/etc/cron.d/')
|
# put(c, SCRIPTS_DIR / 'http_host' / 'cron.d' / 'ofm_http_host', '/etc/cron.d/')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from pathlib import Path
|
|||||||
import click
|
import click
|
||||||
import requests
|
import requests
|
||||||
from http_host_lib import DEFAULT_ASSETS_DIR, DEFAULT_RUNS_DIR, MNT_DIR
|
from http_host_lib import DEFAULT_ASSETS_DIR, DEFAULT_RUNS_DIR, MNT_DIR
|
||||||
from http_host_lib.download_fonts import download_fonts
|
from http_host_lib.download_assets import download_fonts, download_natural_earth
|
||||||
from http_host_lib.download_tileset import download_and_extract_tileset
|
from http_host_lib.download_tileset import download_and_extract_tileset
|
||||||
from http_host_lib.mount import clean_up_mounts, create_fstab
|
from http_host_lib.mount import clean_up_mounts, create_fstab
|
||||||
from http_host_lib.nginx import write_nginx_config
|
from http_host_lib.nginx import write_nginx_config
|
||||||
@@ -94,6 +94,7 @@ def download_assets(assets_dir: Path):
|
|||||||
sys.exit("asset dir's parent doesn't exist")
|
sys.exit("asset dir's parent doesn't exist")
|
||||||
|
|
||||||
download_fonts(assets_dir)
|
download_fonts(assets_dir)
|
||||||
|
download_natural_earth(assets_dir)
|
||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ def download_fonts(assets_dir: Path):
|
|||||||
|
|
||||||
fonts_temp = assets_dir / 'fonts_temp'
|
fonts_temp = assets_dir / 'fonts_temp'
|
||||||
|
|
||||||
for font in ['ml', 'omt', 'pm']:
|
for font in ['ofm']:
|
||||||
url = f'https://assets.openfreemap.com/fonts/{font}.tgz'
|
url = f'https://assets.openfreemap.com/fonts/{font}.tar.gz'
|
||||||
local_file = fonts_dir / f'{font}.tgz'
|
local_file = fonts_dir / f'{font}.tgz'
|
||||||
if not download_if_size_differs(url, local_file):
|
if not download_if_size_differs(url, local_file):
|
||||||
continue
|
continue
|
||||||
@@ -41,3 +41,26 @@ def download_fonts(assets_dir: Path):
|
|||||||
shutil.rmtree(target_dir_renamed, ignore_errors=True)
|
shutil.rmtree(target_dir_renamed, ignore_errors=True)
|
||||||
|
|
||||||
shutil.rmtree(fonts_temp, ignore_errors=True)
|
shutil.rmtree(fonts_temp, ignore_errors=True)
|
||||||
|
|
||||||
|
|
||||||
|
def download_natural_earth(assets_dir: Path):
|
||||||
|
ne_dir = assets_dir / 'natural_earth'
|
||||||
|
|
||||||
|
if (ne_dir / 'tiles' / 'natural_earth_2_shaded_relief.raster' / '0' / '0' / '0.png').exists():
|
||||||
|
return
|
||||||
|
|
||||||
|
ne_dir.mkdir(exist_ok=True, parents=True)
|
||||||
|
|
||||||
|
subprocess.run(
|
||||||
|
[
|
||||||
|
'git',
|
||||||
|
'clone',
|
||||||
|
'--depth=1',
|
||||||
|
'-b',
|
||||||
|
'gh-pages',
|
||||||
|
'https://github.com/lukasmartinelli/naturalearthtiles.git',
|
||||||
|
ne_dir,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
shutil.rmtree(ne_dir / '.git')
|
||||||
@@ -40,6 +40,7 @@ def get_remote_file_size(url: str) -> int | None:
|
|||||||
|
|
||||||
def download_file_aria2(url: str, local_file: Path):
|
def download_file_aria2(url: str, local_file: Path):
|
||||||
print(f' downloading: {url} into {local_file}')
|
print(f' downloading: {url} into {local_file}')
|
||||||
|
local_file.unlink(missing_ok=True)
|
||||||
|
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
[
|
[
|
||||||
|
|||||||
Reference in New Issue
Block a user