mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-06 10:25:41 +02:00
Pass a serial_feature to rewrite instead of many broken-down arguments
This commit is contained in:
@@ -260,9 +260,11 @@ serial_feature deserialize_feature(std::string &geoms, unsigned z, unsigned tx,
|
|||||||
sf.has_id = false;
|
sf.has_id = false;
|
||||||
if (sf.layer & (1 << FLAG_MINZOOM)) {
|
if (sf.layer & (1 << FLAG_MINZOOM)) {
|
||||||
deserialize_int(&cp, &sf.tippecanoe_minzoom);
|
deserialize_int(&cp, &sf.tippecanoe_minzoom);
|
||||||
|
sf.has_tippecanoe_minzoom = true;
|
||||||
}
|
}
|
||||||
if (sf.layer & (1 << FLAG_MAXZOOM)) {
|
if (sf.layer & (1 << FLAG_MAXZOOM)) {
|
||||||
deserialize_int(&cp, &sf.tippecanoe_maxzoom);
|
deserialize_int(&cp, &sf.tippecanoe_maxzoom);
|
||||||
|
sf.has_tippecanoe_maxzoom = true;
|
||||||
}
|
}
|
||||||
if (sf.layer & (1 << FLAG_ID)) {
|
if (sf.layer & (1 << FLAG_ID)) {
|
||||||
sf.has_id = true;
|
sf.has_id = true;
|
||||||
|
|||||||
@@ -405,8 +405,13 @@ std::vector<coalesce> disassemble_multiplier_clusters(std::vector<std::vector<co
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rewrite(drawvec &geom, int z, int nextzoom, int maxzoom, long long *bbox, unsigned tx, unsigned ty, int buffer, int *within, std::atomic<long long> *geompos, compressor **geomfile, const char *fname, signed char t, int layer, signed char feature_minzoom, int child_shards, int max_zoom_increment, long long seq, int tippecanoe_minzoom, int tippecanoe_maxzoom, int segment, unsigned *initial_x, unsigned *initial_y, std::vector<long long> &metakeys, std::vector<long long> &metavals, bool has_id, unsigned long long id, unsigned long long index, unsigned long long label_point, long long extent) {
|
void rewrite(serial_feature const &osf,
|
||||||
if (geom.size() > 0 && (nextzoom <= maxzoom || additional[A_EXTEND_ZOOMS] || extend_zooms_max > 0)) {
|
int z, unsigned tx, unsigned ty,
|
||||||
|
int nextzoom, int maxzoom, int buffer,
|
||||||
|
int child_shards, int max_zoom_increment,
|
||||||
|
int *within, std::atomic<long long> *geompos, compressor **geomfile, const char *fname,
|
||||||
|
unsigned *initial_x, unsigned *initial_y) {
|
||||||
|
if (osf.geometry.size() > 0 && (nextzoom <= maxzoom || additional[A_EXTEND_ZOOMS] || extend_zooms_max > 0)) {
|
||||||
int xo, yo;
|
int xo, yo;
|
||||||
int span = 1 << (nextzoom - z);
|
int span = 1 << (nextzoom - z);
|
||||||
|
|
||||||
@@ -416,7 +421,7 @@ void rewrite(drawvec &geom, int z, int nextzoom, int maxzoom, long long *bbox, u
|
|||||||
int k;
|
int k;
|
||||||
for (k = 0; k < 4; k++) {
|
for (k = 0; k < 4; k++) {
|
||||||
// Division instead of right-shift because coordinates can be negative
|
// Division instead of right-shift because coordinates can be negative
|
||||||
bbox2[k] = bbox[k] / (1 << (32 - nextzoom - 8));
|
bbox2[k] = osf.bbox[k] / (1 << (32 - nextzoom - 8));
|
||||||
}
|
}
|
||||||
// Decrement the top and left edges so that any features that are
|
// Decrement the top and left edges so that any features that are
|
||||||
// touching the edge can potentially be included in the adjacent tiles too.
|
// touching the edge can potentially be included in the adjacent tiles too.
|
||||||
@@ -442,14 +447,14 @@ void rewrite(drawvec &geom, int z, int nextzoom, int maxzoom, long long *bbox, u
|
|||||||
sx = tx << (32 - z);
|
sx = tx << (32 - z);
|
||||||
sy = ty << (32 - z);
|
sy = ty << (32 - z);
|
||||||
}
|
}
|
||||||
|
|
||||||
drawvec geom2;
|
drawvec geom2;
|
||||||
for (size_t i = 0; i < geom.size(); i++) {
|
for (auto const &g : osf.geometry) {
|
||||||
geom2.push_back(draw(geom[i].op, SHIFT_RIGHT(geom[i].x + sx), SHIFT_RIGHT(geom[i].y + sy)));
|
geom2.emplace_back(g.op, SHIFT_RIGHT(g.x + sx), SHIFT_RIGHT(g.y + sy));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (xo = bbox2[0]; xo <= bbox2[2]; xo++) {
|
for (xo = bbox2[0]; xo <= bbox2[2]; xo++) {
|
||||||
for (yo = bbox2[1]; yo <= bbox2[3]; yo++) {
|
for (yo = bbox2[1]; yo <= bbox2[3]; yo++) {
|
||||||
|
// We are now writing out tile nextzoom/jx/jy
|
||||||
unsigned jx = tx * span + xo;
|
unsigned jx = tx * span + xo;
|
||||||
unsigned jy = ty * span + yo;
|
unsigned jy = ty * span + yo;
|
||||||
|
|
||||||
@@ -476,35 +481,16 @@ void rewrite(drawvec &geom, int z, int nextzoom, int maxzoom, long long *bbox, u
|
|||||||
{
|
{
|
||||||
if (!within[j]) {
|
if (!within[j]) {
|
||||||
serialize_int(geomfile[j]->fp, nextzoom, &geompos[j], fname);
|
serialize_int(geomfile[j]->fp, nextzoom, &geompos[j], fname);
|
||||||
serialize_uint(geomfile[j]->fp, tx * span + xo, &geompos[j], fname);
|
serialize_uint(geomfile[j]->fp, jx, &geompos[j], fname);
|
||||||
serialize_uint(geomfile[j]->fp, ty * span + yo, &geompos[j], fname);
|
serialize_uint(geomfile[j]->fp, jy, &geompos[j], fname);
|
||||||
geomfile[j]->begin();
|
geomfile[j]->begin();
|
||||||
within[j] = 1;
|
within[j] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
serial_feature sf;
|
serial_feature sf = osf;
|
||||||
sf.layer = layer;
|
sf.geometry = std::move(geom2);
|
||||||
sf.segment = segment;
|
|
||||||
sf.seq = seq;
|
|
||||||
sf.t = t;
|
|
||||||
sf.has_id = has_id;
|
|
||||||
sf.id = id;
|
|
||||||
sf.has_tippecanoe_minzoom = tippecanoe_minzoom != -1;
|
|
||||||
sf.tippecanoe_minzoom = tippecanoe_minzoom;
|
|
||||||
sf.has_tippecanoe_maxzoom = tippecanoe_maxzoom != -1;
|
|
||||||
sf.tippecanoe_maxzoom = tippecanoe_maxzoom;
|
|
||||||
sf.geometry = geom2;
|
|
||||||
sf.index = index;
|
|
||||||
sf.label_point = label_point;
|
|
||||||
sf.extent = extent;
|
|
||||||
sf.feature_minzoom = feature_minzoom;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < metakeys.size(); i++) {
|
std::string feature = serialize_feature(&sf, SHIFT_RIGHT(initial_x[sf.segment]), SHIFT_RIGHT(initial_y[sf.segment]));
|
||||||
sf.keys.push_back(metakeys[i]);
|
|
||||||
sf.values.push_back(metavals[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string feature = serialize_feature(&sf, SHIFT_RIGHT(initial_x[segment]), SHIFT_RIGHT(initial_y[segment]));
|
|
||||||
geomfile[j]->serialize_long_long(feature.size(), &geompos[j], fname);
|
geomfile[j]->serialize_long_long(feature.size(), &geompos[j], fname);
|
||||||
geomfile[j]->fwrite_check(feature.c_str(), sizeof(char), feature.size(), &geompos[j], fname);
|
geomfile[j]->fwrite_check(feature.c_str(), sizeof(char), feature.size(), &geompos[j], fname);
|
||||||
}
|
}
|
||||||
@@ -1622,7 +1608,12 @@ serial_feature next_feature(decompressor *geoms, std::atomic<long long> *geompos
|
|||||||
|
|
||||||
if (first_time && pass == 0) { /* only write out the next zoom once, even if we retry */
|
if (first_time && pass == 0) { /* only write out the next zoom once, even if we retry */
|
||||||
if (sf.tippecanoe_maxzoom == -1 || sf.tippecanoe_maxzoom >= nextzoom) {
|
if (sf.tippecanoe_maxzoom == -1 || sf.tippecanoe_maxzoom >= nextzoom) {
|
||||||
rewrite(sf.geometry, z, nextzoom, maxzoom, sf.bbox, tx, ty, buffer, within, geompos, geomfile, fname, sf.t, sf.layer, sf.feature_minzoom, child_shards, max_zoom_increment, sf.seq, sf.tippecanoe_minzoom, sf.tippecanoe_maxzoom, sf.segment, initial_x, initial_y, sf.keys, sf.values, sf.has_id, sf.id, sf.index, sf.label_point, sf.extent);
|
rewrite(sf,
|
||||||
|
z, tx, ty,
|
||||||
|
nextzoom, maxzoom, buffer,
|
||||||
|
child_shards, max_zoom_increment,
|
||||||
|
within, geompos, geomfile, fname,
|
||||||
|
initial_x, initial_y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user