Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Aug 5, 2024
2 parents 387ef6a + b53be04 commit 31a7128
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion osm_fieldwork/basemapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,16 @@ def customTMS(self, url: str, is_oam: bool = False, is_xy: bool = False):
# FIXME handle other formats for custom TMS
suffix = "jpg"

# Replace "{z}/{x}/{y}" with "%s"
# If placeholders present, validate they have no additional spaces
pattern = re.compile(r"\{\s*[xyz]+\s*\}")
if bool(pattern.search(url)):
msg = "Invalid TMS URL format. Please check the URL placeholders {z}/{x}/{y}."
log.error(msg)
raise ValueError(msg)

# Remove "{z}/{x}/{y}" placeholders if they are present
url = re.sub(r"/{[xyz]+\}", "", url)
# Append "%s" to the end of the URL to later add the tile path
url = url + r"/%s"

if is_oam:
Expand Down

0 comments on commit 31a7128

Please sign in to comment.