Format python
This commit is contained in:
parent
85f5770e09
commit
4c258018c3
17 changed files with 348 additions and 248 deletions
|
|
@ -8,16 +8,12 @@ import osmium
|
|||
import polars as pl
|
||||
from tqdm import tqdm
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
BATCH_SIZE = 50_000
|
||||
|
||||
MIN_OCCURENCE_COUNT = 20
|
||||
|
||||
GEOFABRIK_GB_URL = (
|
||||
"https://download.geofabrik.de/europe/great-britain-latest.osm.pbf"
|
||||
)
|
||||
GEOFABRIK_GB_URL = "https://download.geofabrik.de/europe/great-britain-latest.osm.pbf"
|
||||
|
||||
UK_BBOX_WEST = -7.57
|
||||
UK_BBOX_SOUTH = 49.96
|
||||
|
|
@ -38,7 +34,6 @@ POI_TAG_KEYS: list[str] = [
|
|||
]
|
||||
|
||||
|
||||
|
||||
def download_pbf(pbf_file: Path) -> None:
|
||||
pbf_file.parent.mkdir(parents=True, exist_ok=True)
|
||||
tmp = pbf_file.with_suffix(".pbf.tmp")
|
||||
|
|
@ -91,7 +86,12 @@ class POIHandler(osmium.SimpleHandler):
|
|||
self._batch.clear()
|
||||
|
||||
def _add_poi(
|
||||
self, osm_id: str, tags: osmium.osm.TagList, category: str, lat: float, lng: float
|
||||
self,
|
||||
osm_id: str,
|
||||
tags: osmium.osm.TagList,
|
||||
category: str,
|
||||
lat: float,
|
||||
lng: float,
|
||||
) -> None:
|
||||
self._batch.append(
|
||||
{
|
||||
|
|
@ -123,8 +123,12 @@ class POIHandler(osmium.SimpleHandler):
|
|||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description="Download and extract POIs from OpenStreetMap")
|
||||
parser.add_argument("--output", type=Path, required=True, help="Output parquet file path")
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Download and extract POIs from OpenStreetMap"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--output", type=Path, required=True, help="Output parquet file path"
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
with tempfile.TemporaryDirectory() as cache_dir:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue