Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jun 9, 2024
1 parent f01c4df commit 6b73a11
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
7 changes: 3 additions & 4 deletions osm_fieldwork/basemapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions osm_fieldwork/boundary_handler_factory.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Union
from io import BytesIO
from typing import Union

from .boundary_handlers import BoundingBox, BytesIOBoundaryHandler, StringBoundaryHandler

"""
Expand All @@ -10,6 +11,7 @@
- BoundaryHandlerFactory: Factory class for creating boundary handlers.
"""


class BoundaryHandlerFactory:
def __init__(self, boundary: Union[str, BytesIO]):
if isinstance(boundary, BytesIO):
Expand All @@ -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
return self.boundary_box
9 changes: 7 additions & 2 deletions osm_fieldwork/boundary_handlers.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
raise ValueError(msg) from None
4 changes: 2 additions & 2 deletions tests/test_basemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 6b73a11

Please sign in to comment.