Bringing back reverted overflow changes, one at a time

This commit is contained in:
Erica Fischer
2024-03-18 12:37:24 -07:00
parent cf63945c37
commit 686ab56c4a
4 changed files with 12 additions and 12 deletions
+5 -5
View File
@@ -177,7 +177,7 @@ int clip(long long *x0, long long *y0, long long *x1, long long *y1, long long x
} else { } else {
// failed both tests, so calculate the line segment to clip // failed both tests, so calculate the line segment to clip
// from an outside point to an intersection with clip edge // from an outside point to an intersection with clip edge
long long x = *x0, y = *y0; __int128 x = *x0, y = *y0;
// At least one endpoint is outside the clip rectangle; pick it. // At least one endpoint is outside the clip rectangle; pick it.
int outcodeOut = outcode0 ? outcode0 : outcode1; int outcodeOut = outcode0 ? outcode0 : outcode1;
@@ -187,16 +187,16 @@ int clip(long long *x0, long long *y0, long long *x1, long long *y1, long long x
// Now find the intersection point; // Now find the intersection point;
// use formulas y = y0 + slope * (x - x0), x = x0 + (1 / slope) * (y - y0) // use formulas y = y0 + slope * (x - x0), x = x0 + (1 / slope) * (y - y0)
if (outcodeOut & TOP) { // point is above the clip rectangle if (outcodeOut & TOP) { // point is above the clip rectangle
x = *x0 + (*x1 - *x0) * (ymax - *y0) / (*y1 - *y0); x = *x0 + (__int128) (*x1 - *x0) * (ymax - *y0) / (*y1 - *y0);
y = ymax; y = ymax;
} else if (outcodeOut & BOTTOM) { // point is below the clip rectangle } else if (outcodeOut & BOTTOM) { // point is below the clip rectangle
x = *x0 + (*x1 - *x0) * (ymin - *y0) / (*y1 - *y0); x = *x0 + (__int128) (*x1 - *x0) * (ymin - *y0) / (*y1 - *y0);
y = ymin; y = ymin;
} else if (outcodeOut & RIGHT) { // point is to the right of clip rectangle } else if (outcodeOut & RIGHT) { // point is to the right of clip rectangle
y = *y0 + (*y1 - *y0) * (xmax - *x0) / (*x1 - *x0); y = *y0 + (__int128) (*y1 - *y0) * (xmax - *x0) / (*x1 - *x0);
x = xmax; x = xmax;
} else if (outcodeOut & LEFT) { // point is to the left of clip rectangle } else if (outcodeOut & LEFT) { // point is to the left of clip rectangle
y = *y0 + (*y1 - *y0) * (xmin - *x0) / (*x1 - *x0); y = *y0 + (__int128) (*y1 - *y0) * (xmin - *x0) / (*x1 - *x0);
x = xmin; x = xmin;
} }
+1 -1
View File
@@ -2431,7 +2431,7 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
double total_tile_count = 0; double total_tile_count = 0;
for (int i = 1; i <= maxzoom; i++) { for (int i = 1; i <= maxzoom; i++) {
double tile_count = ceil(area_sum / ((1LL << (GLOBAL_DETAIL - i)) * (1LL << (GLOBAL_DETAIL - i)))); double tile_count = ceil(area_sum / ((__int128) (1LL << (GLOBAL_DETAIL - i)) * (__int128) (1LL << (GLOBAL_DETAIL - i))));
total_tile_count += tile_count; total_tile_count += tile_count;
// 2M tiles is an arbitrary limit, chosen to make tiling jobs // 2M tiles is an arbitrary limit, chosen to make tiling jobs
+3 -3
View File
@@ -383,10 +383,10 @@ serial_feature parse_feature(json_pull *jp, int z, unsigned x, unsigned y, std::
// Scale and offset geometry from global to tile // Scale and offset geometry from global to tile
double scale = 1LL << geometry_scale; double scale = 1LL << geometry_scale;
for (size_t i = 0; i < dv.size(); i++) { for (size_t i = 0; i < dv.size(); i++) {
unsigned sx = 0, sy = 0; long long sx = 0, sy = 0;
if (z != 0) { if (z != 0) {
sx = x << (GLOBAL_DETAIL - z); sx = (long long) x << (GLOBAL_DETAIL - z);
sy = y << (GLOBAL_DETAIL - z); sy = (long long) y << (GLOBAL_DETAIL - z);
} }
dv[i].x = std::round(dv[i].x / scale) * scale - sx; dv[i].x = std::round(dv[i].x / scale) * scale - sx;
dv[i].y = std::round(dv[i].y / scale) * scale - sy; dv[i].y = std::round(dv[i].y / scale) * scale - sy;
+3 -3
View File
@@ -1263,10 +1263,10 @@ void *run_prefilter(void *v) {
tmp_feature.dropped = sf.dropped; tmp_feature.dropped = sf.dropped;
// Offset from tile coordinates back to world coordinates // Offset from tile coordinates back to world coordinates
unsigned sx = 0, sy = 0; long long sx = 0, sy = 0;
if (rpa->z != 0) { if (rpa->z != 0) {
sx = rpa->tx << (GLOBAL_DETAIL - rpa->z); sx = (long long) rpa->tx << (GLOBAL_DETAIL - rpa->z);
sy = rpa->ty << (GLOBAL_DETAIL - rpa->z); sy = (long long) rpa->ty << (GLOBAL_DETAIL - rpa->z);
} }
for (size_t i = 0; i < tmp_feature.geometry.size(); i++) { for (size_t i = 0; i < tmp_feature.geometry.size(); i++) {
tmp_feature.geometry[i].x += sx; tmp_feature.geometry[i].x += sx;