mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 18:05:42 +02:00
Stabilize choice of which three points to keep with different windings
This commit is contained in:
+4
-1
@@ -763,7 +763,9 @@ drawvec fix_polygon(drawvec &geom) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// then figure out which point is furthest from *that*
|
// then figure out which point is furthest from *that*,
|
||||||
|
// which will hopefully be a good origin point since it should be
|
||||||
|
// at a far edge of the shape.
|
||||||
long long dist2b = 0;
|
long long dist2b = 0;
|
||||||
long long furthestb = 0;
|
long long furthestb = 0;
|
||||||
for (size_t a = 0; a + 1 < ring.size(); a++) {
|
for (size_t a = 0; a + 1 < ring.size(); a++) {
|
||||||
@@ -785,6 +787,7 @@ drawvec fix_polygon(drawvec &geom) {
|
|||||||
// Copy ring into output, fixing the moveto/lineto ops if necessary because of
|
// Copy ring into output, fixing the moveto/lineto ops if necessary because of
|
||||||
// reversal or closing
|
// reversal or closing
|
||||||
|
|
||||||
|
printf("chose %lld,%lld for ring of size %zu\n", ring[furthestb].x, ring[furthestb].y, ring.size());
|
||||||
for (size_t a = 0; a < ring.size(); a++) {
|
for (size_t a = 0; a < ring.size(); a++) {
|
||||||
size_t a2 = (a + furthestb) % (ring.size() - 1);
|
size_t a2 = (a + furthestb) % (ring.size() - 1);
|
||||||
|
|
||||||
|
|||||||
@@ -2280,6 +2280,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
printf("%zu: ", j - i);
|
||||||
|
|
||||||
// j - 1 because we don't want the duplicate last point
|
// j - 1 because we don't want the duplicate last point
|
||||||
for (size_t k = i; k < j - 1; k++) {
|
for (size_t k = i; k < j - 1; k++) {
|
||||||
@@ -2289,6 +2290,8 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
|||||||
sf.geometry[(k + 2 - i) % (j - 1 - i) + i]);
|
sf.geometry[(k + 2 - i) % (j - 1 - i) + i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("%lld,%lld ", sf.geometry[i].x, sf.geometry[i].y);
|
||||||
|
|
||||||
// since the starting point is never simplified away,
|
// since the starting point is never simplified away,
|
||||||
// don't let it be simplified away in any other polygons either.
|
// don't let it be simplified away in any other polygons either.
|
||||||
// Needs to appear twice here so that the check below will see
|
// Needs to appear twice here so that the check below will see
|
||||||
@@ -2307,12 +2310,14 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
|||||||
double xd = sf.geometry[k].x - sf.geometry[i].x;
|
double xd = sf.geometry[k].x - sf.geometry[i].x;
|
||||||
double yd = sf.geometry[k].y - sf.geometry[i].y;
|
double yd = sf.geometry[k].y - sf.geometry[i].y;
|
||||||
double d = xd * xd + yd * yd;
|
double d = xd * xd + yd * yd;
|
||||||
if (d > far) {
|
if (d > far ||
|
||||||
|
((d == far) && (sf.geometry[k] < sf.geometry[which]))) {
|
||||||
far = d;
|
far = d;
|
||||||
which = k;
|
which = k;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("%lld,%lld ", sf.geometry[which].x, sf.geometry[which].y);
|
||||||
shared_nodes.push_back(sf.geometry[which]);
|
shared_nodes.push_back(sf.geometry[which]);
|
||||||
shared_nodes.push_back(sf.geometry[which]);
|
shared_nodes.push_back(sf.geometry[which]);
|
||||||
|
|
||||||
@@ -2330,12 +2335,15 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
|||||||
double yd2 = sf.geometry[k].y - sf.geometry[which].y;
|
double yd2 = sf.geometry[k].y - sf.geometry[which].y;
|
||||||
double d1 = xd * xd + yd * yd;
|
double d1 = xd * xd + yd * yd;
|
||||||
double d2 = xd2 * xd2 + yd2 * yd2;
|
double d2 = xd2 * xd2 + yd2 * yd2;
|
||||||
if (d1 + d2 > far && d1 != 0 && d2 != 0) {
|
if (d1 != 0 && d2 != 0 &&
|
||||||
|
(d1 + d2 > far ||
|
||||||
|
((d1 + d2 == far) && (sf.geometry[k] < sf.geometry[which2])))) {
|
||||||
far = d1 + d2;
|
far = d1 + d2;
|
||||||
which2 = k;
|
which2 = k;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("%lld,%lld\n", sf.geometry[which2].x, sf.geometry[which2].y);
|
||||||
shared_nodes.push_back(sf.geometry[which2]);
|
shared_nodes.push_back(sf.geometry[which2]);
|
||||||
shared_nodes.push_back(sf.geometry[which2]);
|
shared_nodes.push_back(sf.geometry[which2]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user