Mask the node state out of the operation when marking shared nodes

Geometry that was clipped to --clip-bounding-box while it was being
serialized can already have node states in its operation bytes, so the
unmasked comparison against VT_MOVETO and VT_LINETO failed to recognize
those vertices and lost track of where the following vertices began.
Also stop with an error instead of continuing if the operation is not
one that can appear in serialized geometry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P2nBqZisxNQfmEmon3vE9v
This commit is contained in:
Claude
2026-09-23 18:28:04 +00:00
parent ee5debc4f2
commit 1dee1890e7
+6
View File
@@ -345,6 +345,9 @@ void mark_shared_nodes(char *feature, size_t len, unsigned *initial_x, unsigned
return;
}
// the vertex may already have a node state, from clipping to --clip-bounding-box
op &= OP_MASK;
if (op == VT_MOVETO || op == VT_LINETO) {
long long dx, dy;
@@ -356,6 +359,9 @@ void mark_shared_nodes(char *feature, size_t len, unsigned *initial_x, unsigned
signed char node = is_shared_node(wx, wy, shared_nodes_map, nodepos, shared_nodes_bloom) ? NODE_SHARED : NODE_NOT_SHARED;
*opp = op | (node << NODE_SHIFT);
} else if (op != VT_CLOSEPATH) {
fprintf(stderr, "Internal error: unexpected geometry operation %d marking shared nodes\n", op);
exit(EXIT_IMPOSSIBLE);
}
}