Skip to content

Commit

Permalink
Use floor for coordinate transformation (#229)
Browse files Browse the repository at this point in the history
This solves artifacts from asymmetric rounding around zero. See
t-rex-tileserver/t-rex#319
  • Loading branch information
pka committed Aug 23, 2024
1 parent 9645970 commit 2e4476d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions geozero/src/mvt/mvt_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2e4476d

Please sign in to comment.