MTTileURLTemplate
public struct MTTileURLTemplate
A helper struct for validating and building tile URLs from string templates.
-
Checks if a given template string contains the required minimum tokens.
Declaration
Swift
public static func isValid(template: String) -> BoolParameters
templateThe URL template string.
Return Value
trueif it contains{z},{x}, and either{y}or{-y}. -
Builds a full tile URL from a template string for given coordinates and scheme.
This method seamlessly handles the
{-y}token which implies a TMS-style inverted Y-axis, even if theschemepassed is explicitly XYZ. If{-y}is present, it will invert the Y coordinate.Declaration
Swift
public static func buildURL(template: String, z: Int, x: Int, y: Int, scheme: MTOfflineTileScheme = .xyz) -> URL?Parameters
templateThe URL template string (e.g.,
https://example.com/tiles/{z}/{x}/{y}.pbf).zThe zoom level.
xThe X coordinate.
yThe Y coordinate.
schemeThe coordinate scheme (
.xyzor.tms).Return Value
A valid
URLif the template is correctly formatted,nilotherwise.