From 1c0fb6e8cffd8ab2d4956069de33bb1df7c6ae74 Mon Sep 17 00:00:00 2001 From: Thomas Rasch Date: Thu, 6 Jun 2024 11:35:40 +0200 Subject: [PATCH] Allow to merge tiles with different coordinates, for some weird use cases --- Sources/MVTTools/Merge.swift | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Sources/MVTTools/Merge.swift b/Sources/MVTTools/Merge.swift index 11df7e2..1883a1e 100644 --- a/Sources/MVTTools/Merge.swift +++ b/Sources/MVTTools/Merge.swift @@ -10,13 +10,19 @@ extension VectorTile { /// Merge another vector tile into this tile. @discardableResult - public mutating func merge(_ other: VectorTile) -> Bool { - guard other.x == x, - other.y == y, - other.z == z - else { - (logger ?? VectorTile.logger)?.warning("\(z)/\(x)/\(y): Failed to merge, other has different coordinate \(other.z)/\(other.x)/\(other.y)") - return false + public mutating func merge( + _ other: VectorTile, + ignoreTileCoordinateMismatch: Bool = false) + -> Bool + { + if !ignoreTileCoordinateMismatch { + guard other.x == x, + other.y == y, + other.z == z + else { + (logger ?? VectorTile.logger)?.warning("\(z)/\(x)/\(y): Failed to merge, other has different coordinate \(other.z)/\(other.x)/\(other.y)") + return false + } } if other.projection != projection {