From dcf760a4396bead605ed053a8e51be84de94c98c Mon Sep 17 00:00:00 2001 From: Erica Fischer Date: Thu, 14 Mar 2024 23:15:04 -0700 Subject: [PATCH] Fix z1 at least --- clip.cpp | 12 ++++++------ geometry.cpp | 2 +- geometry.hpp | 2 +- tile.cpp | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/clip.cpp b/clip.cpp index 4b5c5fb1..63dd8c6f 100644 --- a/clip.cpp +++ b/clip.cpp @@ -386,13 +386,13 @@ drawvec clean_or_clip_poly(drawvec &geom, int z, int buffer, bool clip, bool try void to_tile_scale(drawvec &geom, int z, int detail) { if (GLOBAL_DETAIL - detail - z < 0) { for (size_t i = 0; i < geom.size(); i++) { - geom[i].x = std::round((double) geom[i].x * (1LL << (-(GLOBAL_DETAIL - detail - z)))); - geom[i].y = std::round((double) geom[i].y * (1LL << (-(GLOBAL_DETAIL - detail - z)))); + geom[i].x = geom[i].x * (1LL << (-(GLOBAL_DETAIL - detail - z))); + geom[i].y = geom[i].y * (1LL << (-(GLOBAL_DETAIL - detail - z))); } } else { for (size_t i = 0; i < geom.size(); i++) { - geom[i].x = std::round((double) geom[i].x / (1LL << (GLOBAL_DETAIL - detail - z))); - geom[i].y = std::round((double) geom[i].y / (1LL << (GLOBAL_DETAIL - detail - z))); + geom[i].x = std::llround((double) geom[i].x / (1LL << (GLOBAL_DETAIL - detail - z))); + geom[i].y = std::llround((double) geom[i].y / (1LL << (GLOBAL_DETAIL - detail - z))); } } } @@ -415,8 +415,8 @@ drawvec remove_noop(drawvec geom, int type, int shift) { drawvec out; for (size_t i = 0; i < geom.size(); i++) { - long long nx = std::round((double) geom[i].x / (1LL << shift)); - long long ny = std::round((double) geom[i].y / (1LL << shift)); + long long nx = std::llround((double) geom[i].x / (1LL << shift)); + long long ny = std::llround((double) geom[i].y / (1LL << shift)); if (geom[i].op == VT_LINETO && nx == ox && ny == oy) { continue; diff --git a/geometry.cpp b/geometry.cpp index 47a7858e..e25e58e6 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -21,7 +21,7 @@ #include "errors.hpp" #include "projection.hpp" -drawvec decode_geometry(const char **meta, int z, unsigned tx, unsigned ty, long long *bbox, long long initial_x, long long initial_y) { +drawvec decode_geometry(const char **meta, int z, long long tx, long long ty, long long *bbox, long long initial_x, long long initial_y) { drawvec out; bbox[0] = LLONG_MAX; diff --git a/geometry.hpp b/geometry.hpp index 5a18d589..48c70646 100644 --- a/geometry.hpp +++ b/geometry.hpp @@ -67,7 +67,7 @@ struct draw { typedef std::vector drawvec; struct serial_feature; -drawvec decode_geometry(const char **meta, int z, unsigned tx, unsigned ty, long long *bbox, long long initial_x, long long initial_y); +drawvec decode_geometry(const char **meta, int z, long long tx, long long ty, long long *bbox, long long initial_x, long long initial_y); void to_tile_scale(drawvec &geom, int z, int detail); drawvec from_tile_scale(drawvec const &geom, int z, int detail); drawvec remove_noop(drawvec geom, int type, int shift); diff --git a/tile.cpp b/tile.cpp index 2f8cfe0b..776d9684 100644 --- a/tile.cpp +++ b/tile.cpp @@ -447,7 +447,7 @@ static void rewrite(serial_feature const &osf, int z, int nextzoom, int maxzoom, int k; for (k = 0; k < 4; k++) { // Division instead of right-shift because coordinates can be negative - bbox2[k] = osf.bbox[k] / (1 << (GLOBAL_DETAIL - nextzoom - 8)); + bbox2[k] = osf.bbox[k] / (1LL << (GLOBAL_DETAIL - nextzoom - 8)); } // Decrement the top and left edges so that any features that are // touching the edge can potentially be included in the adjacent tiles too.