mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 18:05:42 +02:00
Find the matching bins
This commit is contained in:
@@ -1285,7 +1285,7 @@ mvt_tile assign_to_bins(mvt_tile const &features, std::vector<mvt_layer> const &
|
|||||||
unsigned long long start, end;
|
unsigned long long start, end;
|
||||||
|
|
||||||
if (features.layers[i].features[j].geometry.size() > 0) {
|
if (features.layers[i].features[j].geometry.size() > 0) {
|
||||||
get_bbox(bins[i].features[j].geometry, &xmin, &ymin, &xmax, &ymax, z, x, y, detail);
|
get_bbox(features.layers[i].features[j].geometry, &xmin, &ymin, &xmax, &ymax, z, x, y, detail);
|
||||||
get_quadkey_bounds(xmin, xmax, ymin, ymax, &start, &end);
|
get_quadkey_bounds(xmin, xmax, ymin, ymax, &start, &end);
|
||||||
events.emplace_back(start, index_event::CHECK, i, j);
|
events.emplace_back(start, index_event::CHECK, i, j);
|
||||||
}
|
}
|
||||||
@@ -1297,32 +1297,35 @@ mvt_tile assign_to_bins(mvt_tile const &features, std::vector<mvt_layer> const &
|
|||||||
|
|
||||||
for (auto &e : events) {
|
for (auto &e : events) {
|
||||||
if (e.kind == index_event::ENTER) {
|
if (e.kind == index_event::ENTER) {
|
||||||
printf("enter\n");
|
|
||||||
active.emplace(e.layer, e.feature);
|
active.emplace(e.layer, e.feature);
|
||||||
} else if (e.kind == index_event::CHECK) {
|
} else if (e.kind == index_event::CHECK) {
|
||||||
printf("check\n");
|
|
||||||
auto const &feature = features.layers[e.layer].features[e.feature];
|
auto const &feature = features.layers[e.layer].features[e.feature];
|
||||||
printf("checking ");
|
printf("checking ");
|
||||||
for (size_t i = 0; i < feature.tags.size(); i += 2) {
|
for (size_t i = 0; i + 1 < feature.tags.size(); i += 2) {
|
||||||
printf("%s ", features.layers[e.layer].values[feature.tags[i] + 1].toString().c_str());
|
printf("%s ", features.layers[e.layer].values[feature.tags[i + 1]].toString().c_str());
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf(": ");
|
||||||
|
|
||||||
|
bool found = false;
|
||||||
for (auto const &a : active) {
|
for (auto const &a : active) {
|
||||||
auto const &bin = bins[a.first].features[a.second];
|
auto const &bin = bins[a.first].features[a.second];
|
||||||
|
|
||||||
bool found = false;
|
|
||||||
if (pnpoly_mp(bin.geometry, feature.geometry[0].x, feature.geometry[0].y)) {
|
if (pnpoly_mp(bin.geometry, feature.geometry[0].x, feature.geometry[0].y)) {
|
||||||
printf("found\n");
|
printf("found: ");
|
||||||
|
|
||||||
|
for (size_t i = 0; i + 1 < bin.tags.size(); i += 2) {
|
||||||
|
printf("%s ", bins[a.first].values[bin.tags[i + 1]].toString().c_str());
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!found) {
|
}
|
||||||
printf("not found\n");
|
if (!found) {
|
||||||
}
|
printf("not found\n");
|
||||||
}
|
}
|
||||||
} else /* EXIT */ {
|
} else /* EXIT */ {
|
||||||
printf("exit\n");
|
|
||||||
auto const &found = active.find({e.layer, e.feature});
|
auto const &found = active.find({e.layer, e.feature});
|
||||||
if (found != active.end()) {
|
if (found != active.end()) {
|
||||||
active.erase(found);
|
active.erase(found);
|
||||||
@@ -1567,9 +1570,7 @@ std::string overzoom(std::vector<source_tile> const &tiles, int nz, int nx, int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%zu bins\n", bins.size());
|
|
||||||
if (bins.size() > 0) {
|
if (bins.size() > 0) {
|
||||||
printf("assigning to bins\n");
|
|
||||||
outtile = assign_to_bins(outtile, bins, nz, nx, ny, detail);
|
outtile = assign_to_bins(outtile, bins, nz, nx, ny, detail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -227,7 +227,6 @@ int main(int argc, char **argv) {
|
|||||||
its.push_back(std::move(t));
|
its.push_back(std::move(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%zu bins\n", bins.size());
|
|
||||||
std::string out = overzoom(its, nz, nx, ny, detail, buffer, keep, true, NULL, demultiply, json_filter, preserve_input_order, attribute_accum, unidecode_data, simplification, tiny_polygon_size, bins);
|
std::string out = overzoom(its, nz, nx, ny, detail, buffer, keep, true, NULL, demultiply, json_filter, preserve_input_order, attribute_accum, unidecode_data, simplification, tiny_polygon_size, bins);
|
||||||
|
|
||||||
FILE *f = fopen(outfile, "wb");
|
FILE *f = fopen(outfile, "wb");
|
||||||
|
|||||||
Reference in New Issue
Block a user