From 6b73a1166e0b9805d034329f88303180183e5038 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 9 Jun 2024 18:14:26 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- osm_fieldwork/basemapper.py | 7 +++---- osm_fieldwork/boundary_handler_factory.py | 6 ++++-- osm_fieldwork/boundary_handlers.py | 9 +++++++-- tests/test_basemap.py | 4 ++-- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/osm_fieldwork/basemapper.py b/osm_fieldwork/basemapper.py index 44ab7aa2..b712a000 100755 --- a/osm_fieldwork/basemapper.py +++ b/osm_fieldwork/basemapper.py @@ -21,16 +21,15 @@ import argparse import concurrent.futures -from io import BytesIO import logging import queue import re import sys import threading +from io import BytesIO from pathlib import Path from typing import Union -import geojson import mercantile from cpuinfo import get_cpu_info from pmtiles.tile import ( @@ -44,8 +43,7 @@ ) from pmtiles.writer import Writer as PMTileWriter from pySmartDL import SmartDL -from shapely.geometry import shape -from shapely.ops import unary_union + from osm_fieldwork.boundary_handler_factory import BoundaryHandlerFactory from osm_fieldwork.sqlite import DataFile, MapTile from osm_fieldwork.xlsforms import xlsforms_path @@ -273,6 +271,7 @@ def tileExists( log.debug("%s doesn't exists" % filespec) return False + def tileid_from_xyz_dir_path(filepath: Union[Path, str], is_xy: bool = False) -> int: """Helper function to get the tile id from a tile in xyz directory structure. diff --git a/osm_fieldwork/boundary_handler_factory.py b/osm_fieldwork/boundary_handler_factory.py index 3b38e5a9..77a80ba2 100644 --- a/osm_fieldwork/boundary_handler_factory.py +++ b/osm_fieldwork/boundary_handler_factory.py @@ -1,5 +1,6 @@ -from typing import Union from io import BytesIO +from typing import Union + from .boundary_handlers import BoundingBox, BytesIOBoundaryHandler, StringBoundaryHandler """ @@ -10,6 +11,7 @@ - BoundaryHandlerFactory: Factory class for creating boundary handlers. """ + class BoundaryHandlerFactory: def __init__(self, boundary: Union[str, BytesIO]): if isinstance(boundary, BytesIO): @@ -22,4 +24,4 @@ def __init__(self, boundary: Union[str, BytesIO]): self.boundary_box = self.handler.make_bbox() def get_bounding_box(self) -> BoundingBox: - return self.boundary_box \ No newline at end of file + return self.boundary_box diff --git a/osm_fieldwork/boundary_handlers.py b/osm_fieldwork/boundary_handlers.py index 071a5964..5de5d685 100644 --- a/osm_fieldwork/boundary_handlers.py +++ b/osm_fieldwork/boundary_handlers.py @@ -1,6 +1,7 @@ -from typing import Union, Tuple import logging from io import BytesIO +from typing import Tuple + import geojson from shapely.geometry import shape from shapely.ops import unary_union @@ -17,10 +18,13 @@ - BytesIOBoundaryHandler: Extracts BBOX from GeoJSON data stored in a BytesIO object. - StringBoundaryHandler: Extracts BBOX from string representation. """ + + class BoundaryHandler: def make_bbox(self) -> BoundingBox: pass + class BytesIOBoundaryHandler(BoundaryHandler): def __init__(self, boundary: BytesIO): self.boundary = boundary @@ -54,6 +58,7 @@ def make_bbox(self) -> BoundingBox: # minX, minY, maxX, maxY return bbox + class StringBoundaryHandler(BoundaryHandler): def __init__(self, boundary: str): self.boundary = boundary @@ -76,4 +81,4 @@ def make_bbox(self) -> BoundingBox: log.error(e) msg = f"Failed to parse BBOX string: {self.boundary}" log.error(msg) - raise ValueError(msg) from None \ No newline at end of file + raise ValueError(msg) from None diff --git a/tests/test_basemap.py b/tests/test_basemap.py index 673722b3..390be7a9 100755 --- a/tests/test_basemap.py +++ b/tests/test_basemap.py @@ -19,13 +19,13 @@ # """Test functionalty of basemapper.py.""" -from io import BytesIO import logging import os import shutil -import pytest +from io import BytesIO from pathlib import Path +import pytest from pmtiles.reader import MemorySource from pmtiles.reader import Reader as PMTileReader