Skip to content

Commit 3162e47

Browse files
committed
refactor(goatlib): simplify anchor layer check in PMTiles sync task
1 parent 4175700 commit 3162e47

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

packages/python/goatlib/src/goatlib/tasks/sync_pmtiles.py

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -411,28 +411,9 @@ def _detect_geometry_type(
411411

412412
@staticmethod
413413
def _has_anchor_layer(pmtiles_path: "Path") -> bool:
414-
"""Check if a layer already has anchor label points.
415-
416-
Checks for a separate anchor PMTiles file (new two-file approach)
417-
or a default_anchor layer in the main file (legacy merged approach).
418-
"""
419-
# New approach: separate anchor PMTiles file
414+
"""Check if a layer already has a separate anchor PMTiles file."""
420415
anchor_path = pmtiles_path.with_name(pmtiles_path.stem + "_anchor.pmtiles")
421-
if anchor_path.exists():
422-
return True
423-
424-
# Legacy: check for default_anchor layer inside merged PMTiles
425-
try:
426-
from pmtiles.reader import MmapSource
427-
from pmtiles.reader import Reader as PMTilesReader
428-
429-
with open(pmtiles_path, "rb") as f:
430-
reader = PMTilesReader(MmapSource(f))
431-
meta = reader.metadata()
432-
layers = [layer["id"] for layer in meta.get("vector_layers", [])]
433-
return "default_anchor" in layers
434-
except Exception:
435-
return False
416+
return anchor_path.exists()
436417

437418
def _process_layer(
438419
self: Self,

0 commit comments

Comments
 (0)