mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 09:55:41 +02:00
Compare segments to the current pool as they come into scope
This commit is contained in:
+18
-22
@@ -372,36 +372,31 @@ void snap_round(std::vector<segment> &segs) {
|
|||||||
// do the scan
|
// do the scan
|
||||||
|
|
||||||
std::set<size_t> active;
|
std::set<size_t> active;
|
||||||
std::set<std::pair<size_t, size_t>> already;
|
|
||||||
size_t bottom = 0;
|
size_t bottom = 0;
|
||||||
|
|
||||||
for (size_t i = 0; i < tops.size(); i++) {
|
for (size_t i = 0; i < tops.size(); i++) {
|
||||||
// activate anything that is coming into view
|
// activate anything that is coming into view.
|
||||||
|
|
||||||
active.insert(tops[i].segment);
|
active.insert(tops[i].segment);
|
||||||
if (i + 1 < tops.size() && tops[i + 1].y == tops[i].y) {
|
// fprintf(stderr, "into scope: %zu at %lld\n", tops[i].segment, tops[i].y);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// look at the active segments
|
// compare anything coming into view with the other
|
||||||
|
// currently-active segments
|
||||||
|
|
||||||
for (size_t s1 : active) {
|
for (size_t s2 : active) {
|
||||||
for (size_t s2 : active) {
|
size_t s1 = tops[i].segment;
|
||||||
if (s1 < s2) {
|
|
||||||
if (previously_affected.size() == 0 || // first time
|
|
||||||
previously_affected.count(segs[s1]) > 0 ||
|
|
||||||
previously_affected.count(segs[s2]) > 0) {
|
|
||||||
if (already.find(std::make_pair(s1, s2)) == already.end()) {
|
|
||||||
if (intersect(segs, s1, s2, affected)) {
|
|
||||||
// if the segments intersected,
|
|
||||||
// we need to do another scan,
|
|
||||||
// because introducing a new node
|
|
||||||
// may have caused new intersections
|
|
||||||
again = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
already.insert(std::make_pair(s1, s2));
|
if (s1 != s2) {
|
||||||
}
|
if (previously_affected.size() == 0 || // first time
|
||||||
|
previously_affected.count(segs[s1]) > 0 ||
|
||||||
|
previously_affected.count(segs[s2]) > 0) {
|
||||||
|
// fprintf(stderr, "check %zu vs %zu\n", s1, s2);
|
||||||
|
if (intersect(segs, s1, s2, affected)) {
|
||||||
|
// if the segments intersected,
|
||||||
|
// we need to do another scan,
|
||||||
|
// because introducing a new node
|
||||||
|
// may have caused new intersections
|
||||||
|
again = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -413,6 +408,7 @@ void snap_round(std::vector<segment> &segs) {
|
|||||||
while (bottom < bottoms.size() && bottoms[bottom].y < tops[i + 1].y) {
|
while (bottom < bottoms.size() && bottoms[bottom].y < tops[i + 1].y) {
|
||||||
auto found = active.find(bottoms[bottom].segment);
|
auto found = active.find(bottoms[bottom].segment);
|
||||||
active.erase(found);
|
active.erase(found);
|
||||||
|
// fprintf(stderr, "out of scope: %zu at %lld\n", bottoms[bottom].segment, bottoms[bottom].y);
|
||||||
bottom++;
|
bottom++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user