mirror of
https://github.com/felt/tippecanoe.git
synced 2026-12-05 06:41:41 +01:00
Identify features for shared-edge detection by layer, segment, and seq
Features don't necessarily have IDs, and sequence numbers are only unique within a layer and a reading segment: the flatgeobuf, geobuf, and CSV readers start every segment's sequence at the same offset and parse in parallel, so two different features can have the same seq. Record all three in each vertex record, and only count an edge as shared if it is part of polygons that differ in any of them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CQ6vQUJtmGZnqz7RmVYQaJ
This commit is contained in:
@@ -1231,10 +1231,10 @@ int vertexcmp(const void *void1, const void *void2) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (v1->feature < v2->feature) {
|
||||
if (v1->feature_less(*v2)) {
|
||||
return -1;
|
||||
}
|
||||
if (v1->feature > v2->feature) {
|
||||
if (v2->feature_less(*v1)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -2070,26 +2070,26 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
|
||||
|
||||
// All the vertices with the same central point, which are adjacent after sorting
|
||||
std::vector<vertex> group;
|
||||
// The polygon neighbors of the central point, and which feature each is from
|
||||
std::vector<std::pair<draw, long long>> neighbors;
|
||||
// The polygon neighbors of the central point, and which feature (vertex) each is from
|
||||
std::vector<std::pair<draw, vertex const *>> neighbors;
|
||||
|
||||
auto finish_group = [&]() {
|
||||
// A neighbor that is connected to the central point by more than one
|
||||
// polygon feature is the other end of a shared edge
|
||||
neighbors.clear();
|
||||
for (auto const &g : group) {
|
||||
if (g.feature >= 0) {
|
||||
neighbors.emplace_back(g.p1, g.feature);
|
||||
if (g.is_polygon()) {
|
||||
neighbors.emplace_back(g.p1, &g);
|
||||
if (g.p2 != g.p1) {
|
||||
neighbors.emplace_back(g.p2, g.feature);
|
||||
neighbors.emplace_back(g.p2, &g);
|
||||
}
|
||||
}
|
||||
}
|
||||
std::sort(neighbors.begin(), neighbors.end(), [](std::pair<draw, long long> const &a, std::pair<draw, long long> const &b) {
|
||||
std::sort(neighbors.begin(), neighbors.end(), [](std::pair<draw, vertex const *> const &a, std::pair<draw, vertex const *> const &b) {
|
||||
if (a.first < b.first) {
|
||||
return true;
|
||||
} else if (a.first == b.first) {
|
||||
return a.second < b.second;
|
||||
return a.second->feature_less(*b.second);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
@@ -2097,7 +2097,7 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
|
||||
size_t l;
|
||||
bool multiple = false;
|
||||
for (l = k + 1; l < neighbors.size() && neighbors[l].first == neighbors[k].first; l++) {
|
||||
if (neighbors[l].second != neighbors[k].second) {
|
||||
if (!neighbors[l].second->same_feature(*neighbors[k].second)) {
|
||||
multiple = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user