mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-04 17:35:42 +02:00
Griddy, but could be a lot worse
This commit is contained in:
+30
-14
@@ -869,9 +869,17 @@ static void douglas_peucker(drawvec &geom, int start, int n, double e, size_t ke
|
|||||||
|
|
||||||
double distance = std::fabs(temp_dist);
|
double distance = std::fabs(temp_dist);
|
||||||
|
|
||||||
if ((distance > e || kept < retain) && distance > max_distance) {
|
if ((distance > e || kept < retain) && distance >= max_distance) {
|
||||||
farthest_element_index = i;
|
if (distance > max_distance) {
|
||||||
max_distance = distance;
|
farthest_element_index = i;
|
||||||
|
max_distance = distance;
|
||||||
|
} else if (geom[i].y > geom[farthest_element_index].y) {
|
||||||
|
farthest_element_index = i;
|
||||||
|
max_distance = distance;
|
||||||
|
} else if (geom[i].y == geom[farthest_element_index].y && geom[i].x == geom[farthest_element_index].x) {
|
||||||
|
farthest_element_index = i;
|
||||||
|
max_distance = distance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -968,20 +976,28 @@ drawvec simplify_lines(drawvec &geom, int z, int detail, bool mark_tile_bounds,
|
|||||||
geom[i].necessary = 1;
|
geom[i].necessary = 1;
|
||||||
geom[j - 1].necessary = 1;
|
geom[j - 1].necessary = 1;
|
||||||
|
|
||||||
// empirical mapping from douglas-peucker simplifications
|
size_t start = i;
|
||||||
// to visvalingam simplifications that yield similar
|
for (size_t k = start + 1; k <= j - 1; k++) {
|
||||||
// output sizes
|
if (geom[k].necessary) {
|
||||||
double sim = simplification * (0.1596 * z + 0.878);
|
if (k - start > 1) {
|
||||||
double scale = (res * sim) * (res * sim);
|
// empirical mapping from douglas-peucker simplifications
|
||||||
scale = exp(1.002 * log(scale) + 0.3043);
|
// to visvalingam simplifications that yield similar
|
||||||
|
// output sizes
|
||||||
|
double sim = simplification * (0.1596 * z + 0.878);
|
||||||
|
double scale = (res * sim) * (res * sim);
|
||||||
|
scale = exp(1.002 * log(scale) + 0.3043);
|
||||||
|
|
||||||
if (j - i > 1) {
|
if (additional[A_VISVALINGAM]) {
|
||||||
if (additional[A_VISVALINGAM]) {
|
visvalingam(geom, start, k + 1, scale, retain);
|
||||||
visvalingam(geom, i, j, scale, retain);
|
} else {
|
||||||
} else {
|
douglas_peucker(geom, start, k + 1 - start, res * simplification, 2, retain);
|
||||||
douglas_peucker(geom, i, j - i, res * simplification, 2, retain);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
start = k;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
i = j - 1;
|
i = j - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -588,9 +588,29 @@ void *partial_feature_worker(void *v) {
|
|||||||
std::vector<struct partial> *partials = a->partials;
|
std::vector<struct partial> *partials = a->partials;
|
||||||
std::set<std::pair<long long, long long>> kept;
|
std::set<std::pair<long long, long long>> kept;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < (*partials).size(); i++) {
|
||||||
|
for (size_t j = 0; j < (*partials)[i].geoms.size(); j++) {
|
||||||
|
(*partials)[i].geoms[j] = remove_noop((*partials)[i].geoms[j], (*partials)[i].t, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t n = 0; n < 20; n++) {
|
||||||
|
size_t before = kept.size();
|
||||||
|
|
||||||
|
for (size_t i = a->task; i < (*partials).size(); i += a->tasks) {
|
||||||
|
auto stash = (*partials)[i].geoms;
|
||||||
|
double area = simplify_partial(&((*partials)[i]), *(a->shared_nodes), kept);
|
||||||
|
(*partials)[i].geoms = stash;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%zu nodes kept\n", kept.size());
|
||||||
|
if (kept.size() == before) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (size_t i = a->task; i < (*partials).size(); i += a->tasks) {
|
for (size_t i = a->task; i < (*partials).size(); i += a->tasks) {
|
||||||
double area = simplify_partial(&((*partials)[i]), *(a->shared_nodes), kept);
|
double area = simplify_partial(&((*partials)[i]), *(a->shared_nodes), kept);
|
||||||
|
|
||||||
signed char t = (*partials)[i].t;
|
signed char t = (*partials)[i].t;
|
||||||
int z = (*partials)[i].z;
|
int z = (*partials)[i].z;
|
||||||
int out_detail = (*partials)[i].extra_detail;
|
int out_detail = (*partials)[i].extra_detail;
|
||||||
|
|||||||
Reference in New Issue
Block a user