Source code for openworld_radio_twin.config
from functools import lru_cache
from pathlib import Path
from pydantic import SecretStr
from pydantic_settings import BaseSettings, SettingsConfigDict
from openworld_radio_twin import __version__
# Sources whose publishers let anyone use, adapt and share the data for any purpose; the
# others are selected by identifier (docs/guide/extending/building_sources.md).
DEFAULT_AUTOMATIC_BUILDING_SOURCES = ("3dbag", "berlin")
DEFAULT_AUTOMATIC_ANTENNA_SOURCES = ("anfr", "antennebureau", "uke", "opencellid")
[docs]
class Settings(BaseSettings):
model_config = SettingsConfigDict(env_prefix="OWRT_", env_file=".env", extra="ignore")
host: str = "127.0.0.1"
port: int = 8765
location_provider: str = "osm_nominatim"
cache_ttl_seconds: int = 900
max_buildings: int = 5000
max_view_buildings: int = 7500
automatic_building_sources: tuple[str, ...] = DEFAULT_AUTOMATIC_BUILDING_SOURCES
boston_source_catalog: Path | None = None
automatic_antenna_sources: tuple[str, ...] = DEFAULT_AUTOMATIC_ANTENNA_SOURCES
# Downloaded antenna-source snapshots; default .cache/sources under the checkout, like scenes.
source_cache_root: Path | None = None
opencellid_token: SecretStr | None = None
local_antennas: Path | None = None
max_surface_features_per_theme: int = 20_000
http_request_timeout_seconds: int = 60
overture_connect_timeout_seconds: int = 15
overture_request_timeout_seconds: int = 60
user_agent: str = (
f"OpenWorldRadioTwin/{__version__} (+https://github.com/zhiheng-yang/openworld-radio-twin)"
)
overpass_url: str = "https://overpass-api.de/api/interpreter"
nominatim_url: str = "https://nominatim.openstreetmap.org/search"
dataset_root: Path = Path("data/generated")
scene_cache_root: Path | None = None
overture_index_root: Path | None = None
engine_spec_directory: Path | None = None
@property
def package_root(self) -> Path:
return Path(__file__).resolve().parent
@property
def project_root(self) -> Path:
"""Checkout root when the package runs from source, else the working directory."""
for parent in self.package_root.parents:
if (parent / "pyproject.toml").is_file():
return parent
return Path.cwd()
@property
def cache_root(self) -> Path:
"""Directory holding every cache the project writes."""
return self.project_root / ".cache"
@property
def web_root(self) -> Path:
return self.package_root / "web"
[docs]
@lru_cache
def get_settings() -> Settings:
return Settings()