From 2e4476d43b67229d25121aa29517900b09b49b76 Mon Sep 17 00:00:00 2001 From: Pirmin Kalberer Date: Fri, 23 Aug 2024 16:26:16 +0200 Subject: [PATCH] Use floor for coordinate transformation (#229) This solves artifacts from asymmetric rounding around zero. See https://github.com/t-rex-tileserver/t-rex/pull/319 --- geozero/src/mvt/mvt_writer.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/geozero/src/mvt/mvt_writer.rs b/geozero/src/mvt/mvt_writer.rs index dc032392..ffffff06 100644 --- a/geozero/src/mvt/mvt_writer.rs +++ b/geozero/src/mvt/mvt_writer.rs @@ -74,8 +74,8 @@ impl GeomProcessor for MvtWriter { if !last_ring_coord { let (x, y) = if self.extent != 0 { // scale to tile coordinate space - let x = ((x_coord - self.left) * self.x_multiplier) as i32; - let y = ((y_coord - self.bottom) * self.y_multiplier) as i32; + let x = ((x_coord - self.left) * self.x_multiplier).floor() as i32; + let y = ((y_coord - self.bottom) * self.y_multiplier).floor() as i32; // Y is stored as reversed (x, self.extent.saturating_sub(y)) } else {