Skip to content

Commit

Permalink
bump: version 0.8.2 → 0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Apr 22, 2024
1 parent 7d64844 commit a457e4e
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 12 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 0.9.0 (2024-04-23)

### Feat

- create new entities-based xlsforms for registration/buildings

### Refactor

- move existing xlsforms to archived dir (replace with entities)

## 0.8.2 (2024-04-19)

### Fix
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

PACKAGE := org.osm_fieldwork.py
NAME := osm-fieldwork
VERSION := 0.8.2
VERSION := 0.9.0

# All python source files
FILES := $(wildcard ./osm_fieldwork/*.py)
Expand Down
2 changes: 1 addition & 1 deletion osm_fieldwork/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.8.2"
__version__ = "0.9.0"
19 changes: 11 additions & 8 deletions osm_fieldwork/basemapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,17 +331,20 @@ def makeBbox(
return bbox


def tileid_from_y_tile(filepath: Union[Path | str]):
def tileid_from_tms_path(filepath: Union[Path, str]):
"""Helper function to get the tile id from a tile in z/x/y directory structure.
Args:
filepath (Union[Path, str]): The path to the y tile in /z/x/y.jpg structure.
"""
# Get final two dirs + tile filename
parts = list(Path(filepath).parts[-3:])
# strip extension from y tile filename
parts[-1] = str(Path(parts[-1]).stem)
z, x, y = map(int, parts)
# Extract the final 3 parts from the TMS file path
zxy_path = Path(filepath).parts[-3:]
# Extract filename without extension
y_tile_filename = Path(zxy_path[-1]).stem
# If filename contains a dot, take the part before the dot as 'y'
y = int(y_tile_filename.split(".")[0]) if "." in y_tile_filename else int(y_tile_filename)
# Extract z and x values
z, x = map(int, zxy_path[:-1])
return zxy_to_tileid(z, x, y)


Expand Down Expand Up @@ -379,7 +382,7 @@ def tile_dir_to_pmtiles(outfile: str, tile_dir: str, bbox: tuple, attribution: s

for tile_path in tile_dir.rglob("*"):
if tile_path.is_file():
tile_id = tileid_from_y_tile(tile_path)
tile_id = tileid_from_tms_path(tile_path)

with open(tile_path, "rb") as tile:
writer.write_tile(tile_id, tile.read())
Expand Down Expand Up @@ -415,7 +418,7 @@ def create_basemap_file(
zooms="12-17",
outdir=None,
source="esri",
):
) -> None:
"""Create a basemap with given parameters.
Args:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ asyncio_mode="auto"

[tool.commitizen]
name = "cz_conventional_commits"
version = "0.8.2"
version = "0.9.0"
version_files = [
"pyproject.toml:version",
"osm_fieldwork/__version__.py",
Expand Down
26 changes: 25 additions & 1 deletion tests/test_basemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@
import logging
import os
import shutil
from pathlib import Path

from osm_fieldwork.basemapper import BaseMapper
from pmtiles.reader import MemorySource
from pmtiles.reader import Reader as PMTileReader

from osm_fieldwork.basemapper import BaseMapper, create_basemap_file
from osm_fieldwork.sqlite import DataFile

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -66,5 +70,25 @@ def test_create():
assert hits == 2


def test_pmtiles():
"""Test PMTile creation via helper function."""
create_basemap_file(
boundary="-4.730494 41.650541 -4.725634 41.652874",
outfile=f"{rootdir}/../test.pmtiles",
zooms="12-14",
outdir=f"{rootdir}/../",
source="esri",
)
tiles = Path(f"{rootdir}/../test.pmtiles")
assert tiles.exists()
# Test reading
with open(tiles, "rb") as pmtile_file:
data = pmtile_file.read()
pmtile = PMTileReader(MemorySource(data))
data_length = pmtile.header().get("tile_data_length", 0)
assert data_length > 2000 and data_length < 80000
assert len(pmtile.metadata().keys()) == 1


if __name__ == "__main__":
test_create()

0 comments on commit a457e4e

Please sign in to comment.