Skip to content

Commit

Permalink
fix: pmtile basemap generation and remove temp workarounds (#1535)
Browse files Browse the repository at this point in the history
* build: update osm-fieldwork --> 0.10.0 for pmtile fix

* build: remove go-pmtiles binary from docker image

* fix: simplify basemap creation code to remove pmtile workaround
  • Loading branch information
spwoodcock authored May 24, 2024
1 parent b5c5d9c commit 441dc9b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 36 deletions.
4 changes: 0 additions & 4 deletions src/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
ARG PYTHON_IMG_TAG=3.10
ARG MINIO_TAG=${MINIO_TAG:-RELEASE.2024-01-01T16-36-33Z}
FROM docker.io/minio/minio:${MINIO_TAG} as minio
FROM docker.io/protomaps/go-pmtiles:v1.19.0 as go-pmtiles


# Includes all labels and timezone info to extend from
Expand Down Expand Up @@ -121,9 +120,6 @@ RUN set -ex \
&& rm -rf /var/lib/apt/lists/*
# Copy minio mc client
COPY --from=minio /usr/bin/mc /usr/local/bin/
# Copy go-pmtiles until for mbtiles-->pmtiles conversion
# FIXME osm-fieldwork should do this, but is currently broken
COPY --from=go-pmtiles /go-pmtiles /usr/local/bin/pmtiles
COPY *-entrypoint.sh /
ENTRYPOINT ["/app-entrypoint.sh"]
# Copy Python deps from build to runtime
Expand Down
36 changes: 9 additions & 27 deletions src/backend/app/projects/project_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"""Logic for FMTM project routes."""

import json
import subprocess
import uuid
from asyncio import gather
from io import BytesIO
Expand Down Expand Up @@ -1484,32 +1483,15 @@ def get_project_tiles(
f"tms={tms}"
)

# TODO replace this temp workaround with osm-fieldwork code
# TODO to generate pmtiles directly instead of with go-pmtiles
if output_format == "pmtiles":
create_basemap_file(
boundary=f"{min_lon},{min_lat},{max_lon},{max_lat}",
outfile=outfile.replace("pmtiles", "mbtiles"),
zooms=zooms,
outdir=tiles_dir,
source=source,
xy=False,
tms=tms,
)
subprocess.call(
"pmtiles convert " f"{outfile.replace('pmtiles', 'mbtiles')} {outfile}",
shell=True,
)
else:
create_basemap_file(
boundary=f"{min_lon},{min_lat},{max_lon},{max_lat}",
outfile=outfile,
zooms=zooms,
outdir=tiles_dir,
source=source,
xy=False,
tms=tms,
)
create_basemap_file(
boundary=f"{min_lon},{min_lat},{max_lon},{max_lat}",
outfile=outfile,
zooms=zooms,
outdir=tiles_dir,
source=source,
xy=False,
tms=tms,
)

log.info(f"Basemap created for project ID {project_id}: {outfile}")

Expand Down
8 changes: 4 additions & 4 deletions src/backend/pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dependencies = [
"cryptography>=42.0.1",
"defusedxml>=0.7.1",
"osm-login-python==1.0.3",
"osm-fieldwork==0.9.2",
"osm-fieldwork==0.10.0",
"osm-rawdata==0.3.0",
"fmtm-splitter==1.2.1",
]
Expand Down

0 comments on commit 441dc9b

Please sign in to comment.