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:
Claude
2026-11-30 21:38:40 +00:00
parent 4352b1498f
commit c062c4a240
3 changed files with 42 additions and 19 deletions
+31 -8
View File
@@ -284,12 +284,19 @@ struct vertex {
draw mid;
draw p2;
// Which polygon feature this vertex is part of, or -1 if it is part of a line,
// so that edges shared between different polygon features can be identified
long long feature = -1;
// Which polygon feature this vertex is part of, so that edges shared
// between different polygon features can be identified. Features do not
// necessarily have IDs, and sequence numbers are only unique within a layer
// and a reading segment, so a feature is identified by all three.
// `seq` is -1 if the vertex is part of a line rather than a polygon.
long long seq = -1;
int layer = -1;
int segment = -1;
vertex(draw one, draw joint, draw two, long long feature_ = -1) {
feature = feature_;
vertex(draw one, draw joint, draw two, long long seq_ = -1, int layer_ = -1, int segment_ = -1) {
seq = seq_;
layer = layer_;
segment = segment_;
if (one < two) {
p1 = one;
@@ -302,6 +309,24 @@ struct vertex {
mid = joint;
}
bool is_polygon() const {
return seq >= 0;
}
bool same_feature(const vertex &v) const {
return seq == v.seq && layer == v.layer && segment == v.segment;
}
bool feature_less(const vertex &v) const {
if (layer != v.layer) {
return layer < v.layer;
}
if (segment != v.segment) {
return segment < v.segment;
}
return seq < v.seq;
}
bool operator<(const vertex &v) const {
if (mid < v.mid) {
return true;
@@ -312,9 +337,7 @@ struct vertex {
if (p2 < v.p2) {
return true;
} else if (p2 == v.p2) {
if (feature < v.feature) {
return true;
}
return feature_less(v);
}
}
}