Checkpoint on parameterizing 32s

This commit is contained in:
Erica Fischer
2024-03-14 13:30:38 -07:00
parent e796400377
commit cea16d3f7e
6 changed files with 48 additions and 44 deletions
+14 -14
View File
@@ -69,7 +69,7 @@ drawvec simple_clip_poly(drawvec &geom, long long minx, long long miny, long lon
}
drawvec simple_clip_poly(drawvec &geom, int z, int buffer, drawvec &edge_nodes, bool prevent_simplify_shared_nodes) {
long long area = 1LL << (32 - z);
long long area = 1LL << (GLOBAL_DETAIL - z);
long long clip_buffer = buffer * area / 256;
return simple_clip_poly(geom, -clip_buffer, -clip_buffer, area + clip_buffer, area + clip_buffer,
@@ -78,7 +78,7 @@ drawvec simple_clip_poly(drawvec &geom, int z, int buffer, drawvec &edge_nodes,
drawvec clip_point(drawvec &geom, int z, long long buffer) {
long long min = 0;
long long area = 1LL << (32 - z);
long long area = 1LL << (GLOBAL_DETAIL - z);
min -= buffer * area / 256;
area += buffer * area / 256;
@@ -100,7 +100,7 @@ drawvec clip_point(drawvec &geom, long long minx, long long miny, long long maxx
drawvec clip_lines(drawvec &geom, int z, long long buffer) {
long long min = 0;
long long area = 1LL << (32 - z);
long long area = 1LL << (GLOBAL_DETAIL - z);
min -= buffer * area / 256;
area += buffer * area / 256;
@@ -294,7 +294,7 @@ drawvec clean_or_clip_poly(drawvec &geom, int z, int buffer, bool clip, bool try
if (clip) {
long long area = 0xFFFFFFFF;
if (z != 0) {
area = 1LL << (32 - z);
area = 1LL << (GLOBAL_DETAIL - z);
}
long long clip_buffer = buffer * area / 256;
@@ -383,15 +383,15 @@ 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 (32 - detail - z < 0) {
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 << (-(32 - detail - z))));
geom[i].y = std::round((double) geom[i].y * (1LL << (-(32 - detail - z))));
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))));
}
} else {
for (size_t i = 0; i < geom.size(); i++) {
geom[i].x = std::round((double) geom[i].x / (1LL << (32 - detail - z)));
geom[i].y = std::round((double) geom[i].y / (1LL << (32 - detail - z)));
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)));
}
}
}
@@ -400,8 +400,8 @@ drawvec from_tile_scale(drawvec const &geom, int z, int detail) {
drawvec out;
for (size_t i = 0; i < geom.size(); i++) {
draw d = geom[i];
d.x *= (1LL << (32 - detail - z));
d.y *= (1LL << (32 - detail - z));
d.x *= (1LL << (GLOBAL_DETAIL - detail - z));
d.y *= (1LL << (GLOBAL_DETAIL - detail - z));
out.push_back(d);
}
return out;
@@ -526,7 +526,7 @@ double get_area(const drawvec &geom, size_t i, size_t j) {
// do not use the full precision, shift them nearer to the origin so
// their product is more likely to be exactly representable as a double.
//
// (In practice they are actually 34-bit integers: 32 bits for the
// (In practice they are actually (GLOBAL_DETAIL + 2)-bit integers: GLOBAL_DETAIL bits for the
// Mercator world plane, plus another two bits so features can stick
// off either the left or right side. But that is still too many bits
// for the product to fit either in a 64-bit long long or in a
@@ -931,7 +931,7 @@ std::string overzoom(const mvt_tile &tile, int oz, int ox, int oy, int nz, int n
// Convert feature geometry to world coordinates
long long tilesize = 1LL << (32 - oz); // source tile size in world coordinates
long long tilesize = 1LL << (GLOBAL_DETAIL - oz); // source tile size in world coordinates
draw ring_closure(0, 0, 0);
bool sametile = (nz == oz && nx == ox && ny == oy && outlayer.extent >= layer.extent);
@@ -953,7 +953,7 @@ std::string overzoom(const mvt_tile &tile, int oz, int ox, int oy, int nz, int n
// Now offset from world coordinates to output tile coordinates,
// but retain world scale, because that is what tippecanoe clipping expects
long long outtilesize = 1LL << (32 - nz); // destination tile size in world coordinates
long long outtilesize = 1LL << (GLOBAL_DETAIL - nz); // destination tile size in world coordinates
for (auto &g : geom) {
g.x -= nx * outtilesize;
g.y -= ny * outtilesize;