FA-70776 / GIS polygon topology / Open access
Snapping ring vertices to a reference layer: collapse result · case 01
Rings snapped down to a doubled segment are returned as polygons.
ROOT CAUSE
The collapse threshold accepts three positions.
VERIFIED REPAIR
At the collapse result step restore `if len(out) < 4 or out[0] != out[-1]:`, leaving the rest of the model unchanged.
Unsuccessful approach: Using <= 4 also rejects rings that snapped to a valid triangle.
Case contract
Input [ring, ref, tol]: a closed ring, reference vertices and a tolerance. Each ring vertex moves to the NEAREST reference vertex within Euclidean distance tol (inclusive; ties go to the lowest reference index), otherwise stays. Consecutive identical snapped vertices merge. If the result has fewer than 4 positions or is not closed return None, else return it.
Why this case matters
Integrating new survey data with an authoritative layer snaps nearby vertices so shared boundaries become identical; snapping to the wrong vertex creates slivers.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
ring, ref, tol = x
out = []
for p in ring:
best, bd = None, None
for q in ref:
d = (p[0] - q[0]) ** 2 + (p[1] - q[1]) ** 2
if d <= tol * tol and (bd is None or d < bd):
best, bd = q, d
np = list(best) if best is not None else list(p)
if not out or out[-1] != np:
out.append(np)
if len(out) < 3 or out[0] != out[-1]:
return None
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control #0', [[[0.4, 0.3], [9.8, 0.1], [10.2, 9.9], [0.1, 10.3], [0.4, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]), ('control #1', [[[1, 1], [8, 1], [8, 8], [1, 1]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[1, 1], [8, 1], [8, 8], [1, 1]]), ('regression #2', [[[5, 5.6], [8, 2], [9, 9], [5, 5.6]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 6], [8, 2], [9, 9], [5, 6]]), ('regression #3', [[[5, 5.4], [8, 2], [9, 9], [5, 5.4]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 5], [8, 2], [9, 9], [5, 5]]), ('regression #4', [[[5, 5.5], [8, 2], [9, 9], [5, 5.5]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 5], [8, 2], [9, 9], [5, 5]]), ('boundary #5', [[[0, 1], [8, 2], [9, 9], [0, 1]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [8, 2], [9, 9], [0, 0]]), ('regression #6', [[[0, 0.8], [8, 2], [9, 9], [0, 0.8]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [8, 2], [9, 9], [0, 0]]), ('regression #8', [[[0.3, 0.3], [9.8, 0.2], [0.2, 0.1], [0.3, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], None)], [('control #0', [[[0.4, 0.3], [9.8, 0.1], [10.2, 9.9], [0.1, 10.3], [0.4, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]), ('regression #2', [[[5, 5.6], [8, 2], [9, 9], [5, 5.6]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 6], [8, 2], [9, 9], [5, 6]]), ('regression #4', [[[5, 5.5], [8, 2], [9, 9], [5, 5.5]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 5], [8, 2], [9, 9], [5, 5]]), ('boundary #5', [[[0, 1], [8, 2], [9, 9], [0, 1]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [8, 2], [9, 9], [0, 0]]), ('regression #6', [[[0, 0.8], [8, 2], [9, 9], [0, 0.8]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [8, 2], [9, 9], [0, 0]]), ('regression #7', [[[0.3, 0.3], [0.1, 0.2], [10, 0.4], [9.7, 9.6], [0.3, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [10, 0], [10, 10], [0, 0]]), ('regression #8', [[[0.3, 0.3], [9.8, 0.2], [0.2, 0.1], [0.3, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], None), ('boundary #9', [[[0.2, 0.2], [9.6, 0.2], [9.8, 0.4], [0.2, 0.2]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], None)], [('control #0', [[[0.4, 0.3], [9.8, 0.1], [10.2, 9.9], [0.1, 10.3], [0.4, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]), ('regression #3', [[[5, 5.4], [8, 2], [9, 9], [5, 5.4]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 5], [8, 2], [9, 9], [5, 5]]), ('regression #7', [[[0.3, 0.3], [0.1, 0.2], [10, 0.4], [9.7, 9.6], [0.3, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [10, 0], [10, 10], [0, 0]]), ('regression #8', [[[0.3, 0.3], [9.8, 0.2], [0.2, 0.1], [0.3, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], None), ('boundary #9', [[[0.2, 0.2], [9.6, 0.2], [9.8, 0.4], [0.2, 0.2]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], None), ('control #10', [[[2, 2], [3, 2], [3, 3], [2, 2]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 0.5], [[2, 2], [3, 2], [3, 3], [2, 2]]), ('regression #11', [[[3, 4], [8, 2], [9, 9], [3, 4]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 3], [[5, 5], [10, 0], [10, 10], [5, 5]]), ('regression #12', [[[1, 1.5], [9, 1.2], [9, 9], [1, 1.5]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 2], [[0, 0], [10, 0], [10, 10], [0, 0]])], [('control #0', [[[0.4, 0.3], [9.8, 0.1], [10.2, 9.9], [0.1, 10.3], [0.4, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]), ('control #1', [[[1, 1], [8, 1], [8, 8], [1, 1]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[1, 1], [8, 1], [8, 8], [1, 1]]), ('regression #4', [[[5, 5.5], [8, 2], [9, 9], [5, 5.5]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 5], [8, 2], [9, 9], [5, 5]]), ('boundary #9', [[[0.2, 0.2], [9.6, 0.2], [9.8, 0.4], [0.2, 0.2]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], None), ('regression #11', [[[3, 4], [8, 2], [9, 9], [3, 4]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 3], [[5, 5], [10, 0], [10, 10], [5, 5]]), ('regression #12', [[[1, 1.5], [9, 1.2], [9, 9], [1, 1.5]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 2], [[0, 0], [10, 0], [10, 10], [0, 0]]), ('regression #13', [[[1.2, 0], [8, 3], [8.5, 8.5], [1.2, 0]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1.5], [[0, 0], [8, 3], [8.5, 8.5], [0, 0]]), ('control #14', [[[19, 19], [30, 19], [30, 30], [19, 19]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1.5], [[20, 20], [30, 19], [30, 30], [20, 20]])], [('control #0', [[[0.4, 0.3], [9.8, 0.1], [10.2, 9.9], [0.1, 10.3], [0.4, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]), ('control #1', [[[1, 1], [8, 1], [8, 8], [1, 1]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[1, 1], [8, 1], [8, 8], [1, 1]]), ('regression #2', [[[5, 5.6], [8, 2], [9, 9], [5, 5.6]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 6], [8, 2], [9, 9], [5, 6]]), ('regression #3', [[[5, 5.4], [8, 2], [9, 9], [5, 5.4]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 5], [8, 2], [9, 9], [5, 5]]), ('regression #4', [[[5, 5.5], [8, 2], [9, 9], [5, 5.5]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 5], [8, 2], [9, 9], [5, 5]]), ('boundary #5', [[[0, 1], [8, 2], [9, 9], [0, 1]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [8, 2], [9, 9], [0, 0]]), ('regression #8', [[[0.3, 0.3], [9.8, 0.2], [0.2, 0.1], [0.3, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], None), ('control #14', [[[19, 19], [30, 19], [30, 30], [19, 19]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1.5], [[20, 20], [30, 19], [30, 30], [20, 20]])]]
for label, args, expected in fixtures[N-1]:
check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| control #0 | [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]] | [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]] | Passed |
| control #1 | [[1, 1], [8, 1], [8, 8], [1, 1]] | [[1, 1], [8, 1], [8, 8], [1, 1]] | Passed |
| regression #2 | [[5, 6], [8, 2], [9, 9], [5, 6]] | [[5, 6], [8, 2], [9, 9], [5, 6]] | Passed |
| regression #3 | [[5, 5], [8, 2], [9, 9], [5, 5]] | [[5, 5], [8, 2], [9, 9], [5, 5]] | Passed |
| regression #4 | [[5, 5], [8, 2], [9, 9], [5, 5]] | [[5, 5], [8, 2], [9, 9], [5, 5]] | Passed |
| boundary #5 | [[0, 0], [8, 2], [9, 9], [0, 0]] | [[0, 0], [8, 2], [9, 9], [0, 0]] | Passed |
| regression #6 | [[0, 0], [8, 2], [9, 9], [0, 0]] | [[0, 0], [8, 2], [9, 9], [0, 0]] | Passed |
| regression #8 | [[0, 0], [10, 0], [0, 0]] | None | Failed |
SHA-256 / 1dda84ba40bc999392fe2102e49ca950511624d764d58d9fb98c1bd358a0536f
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
ring, ref, tol = x
out = []
for p in ring:
best, bd = None, None
for q in ref:
d = (p[0] - q[0]) ** 2 + (p[1] - q[1]) ** 2
if d <= tol * tol and (bd is None or d < bd):
best, bd = q, d
np = list(best) if best is not None else list(p)
if not out or out[-1] != np:
out.append(np)
if len(out) <= 4 or out[0] != out[-1]:
return None
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control #0', [[[0.4, 0.3], [9.8, 0.1], [10.2, 9.9], [0.1, 10.3], [0.4, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]), ('control #1', [[[1, 1], [8, 1], [8, 8], [1, 1]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[1, 1], [8, 1], [8, 8], [1, 1]]), ('regression #2', [[[5, 5.6], [8, 2], [9, 9], [5, 5.6]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 6], [8, 2], [9, 9], [5, 6]]), ('regression #3', [[[5, 5.4], [8, 2], [9, 9], [5, 5.4]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 5], [8, 2], [9, 9], [5, 5]]), ('regression #4', [[[5, 5.5], [8, 2], [9, 9], [5, 5.5]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 5], [8, 2], [9, 9], [5, 5]]), ('boundary #5', [[[0, 1], [8, 2], [9, 9], [0, 1]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [8, 2], [9, 9], [0, 0]]), ('regression #6', [[[0, 0.8], [8, 2], [9, 9], [0, 0.8]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [8, 2], [9, 9], [0, 0]]), ('regression #8', [[[0.3, 0.3], [9.8, 0.2], [0.2, 0.1], [0.3, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], None)], [('control #0', [[[0.4, 0.3], [9.8, 0.1], [10.2, 9.9], [0.1, 10.3], [0.4, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]), ('regression #2', [[[5, 5.6], [8, 2], [9, 9], [5, 5.6]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 6], [8, 2], [9, 9], [5, 6]]), ('regression #4', [[[5, 5.5], [8, 2], [9, 9], [5, 5.5]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 5], [8, 2], [9, 9], [5, 5]]), ('boundary #5', [[[0, 1], [8, 2], [9, 9], [0, 1]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [8, 2], [9, 9], [0, 0]]), ('regression #6', [[[0, 0.8], [8, 2], [9, 9], [0, 0.8]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [8, 2], [9, 9], [0, 0]]), ('regression #7', [[[0.3, 0.3], [0.1, 0.2], [10, 0.4], [9.7, 9.6], [0.3, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [10, 0], [10, 10], [0, 0]]), ('regression #8', [[[0.3, 0.3], [9.8, 0.2], [0.2, 0.1], [0.3, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], None), ('boundary #9', [[[0.2, 0.2], [9.6, 0.2], [9.8, 0.4], [0.2, 0.2]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], None)], [('control #0', [[[0.4, 0.3], [9.8, 0.1], [10.2, 9.9], [0.1, 10.3], [0.4, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]), ('regression #3', [[[5, 5.4], [8, 2], [9, 9], [5, 5.4]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 5], [8, 2], [9, 9], [5, 5]]), ('regression #7', [[[0.3, 0.3], [0.1, 0.2], [10, 0.4], [9.7, 9.6], [0.3, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [10, 0], [10, 10], [0, 0]]), ('regression #8', [[[0.3, 0.3], [9.8, 0.2], [0.2, 0.1], [0.3, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], None), ('boundary #9', [[[0.2, 0.2], [9.6, 0.2], [9.8, 0.4], [0.2, 0.2]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], None), ('control #10', [[[2, 2], [3, 2], [3, 3], [2, 2]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 0.5], [[2, 2], [3, 2], [3, 3], [2, 2]]), ('regression #11', [[[3, 4], [8, 2], [9, 9], [3, 4]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 3], [[5, 5], [10, 0], [10, 10], [5, 5]]), ('regression #12', [[[1, 1.5], [9, 1.2], [9, 9], [1, 1.5]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 2], [[0, 0], [10, 0], [10, 10], [0, 0]])], [('control #0', [[[0.4, 0.3], [9.8, 0.1], [10.2, 9.9], [0.1, 10.3], [0.4, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]), ('control #1', [[[1, 1], [8, 1], [8, 8], [1, 1]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[1, 1], [8, 1], [8, 8], [1, 1]]), ('regression #4', [[[5, 5.5], [8, 2], [9, 9], [5, 5.5]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 5], [8, 2], [9, 9], [5, 5]]), ('boundary #9', [[[0.2, 0.2], [9.6, 0.2], [9.8, 0.4], [0.2, 0.2]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], None), ('regression #11', [[[3, 4], [8, 2], [9, 9], [3, 4]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 3], [[5, 5], [10, 0], [10, 10], [5, 5]]), ('regression #12', [[[1, 1.5], [9, 1.2], [9, 9], [1, 1.5]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 2], [[0, 0], [10, 0], [10, 10], [0, 0]]), ('regression #13', [[[1.2, 0], [8, 3], [8.5, 8.5], [1.2, 0]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1.5], [[0, 0], [8, 3], [8.5, 8.5], [0, 0]]), ('control #14', [[[19, 19], [30, 19], [30, 30], [19, 19]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1.5], [[20, 20], [30, 19], [30, 30], [20, 20]])], [('control #0', [[[0.4, 0.3], [9.8, 0.1], [10.2, 9.9], [0.1, 10.3], [0.4, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]), ('control #1', [[[1, 1], [8, 1], [8, 8], [1, 1]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[1, 1], [8, 1], [8, 8], [1, 1]]), ('regression #2', [[[5, 5.6], [8, 2], [9, 9], [5, 5.6]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 6], [8, 2], [9, 9], [5, 6]]), ('regression #3', [[[5, 5.4], [8, 2], [9, 9], [5, 5.4]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 5], [8, 2], [9, 9], [5, 5]]), ('regression #4', [[[5, 5.5], [8, 2], [9, 9], [5, 5.5]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 5], [8, 2], [9, 9], [5, 5]]), ('boundary #5', [[[0, 1], [8, 2], [9, 9], [0, 1]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [8, 2], [9, 9], [0, 0]]), ('regression #8', [[[0.3, 0.3], [9.8, 0.2], [0.2, 0.1], [0.3, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], None), ('control #14', [[[19, 19], [30, 19], [30, 30], [19, 19]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1.5], [[20, 20], [30, 19], [30, 30], [20, 20]])]]
for label, args, expected in fixtures[N-1]:
check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| control #0 | [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]] | [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]] | Passed |
| control #1 | None | [[1, 1], [8, 1], [8, 8], [1, 1]] | Failed |
| regression #2 | None | [[5, 6], [8, 2], [9, 9], [5, 6]] | Failed |
| regression #3 | None | [[5, 5], [8, 2], [9, 9], [5, 5]] | Failed |
| regression #4 | None | [[5, 5], [8, 2], [9, 9], [5, 5]] | Failed |
| boundary #5 | None | [[0, 0], [8, 2], [9, 9], [0, 0]] | Failed |
| regression #6 | None | [[0, 0], [8, 2], [9, 9], [0, 0]] | Failed |
| regression #8 | None | None | Passed |
SHA-256 / 008b7eafd636e6749f981c3776b034d764f091e52e906c01f13dd6695196329c
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
ring, ref, tol = x
out = []
for p in ring:
best, bd = None, None
for q in ref:
d = (p[0] - q[0]) ** 2 + (p[1] - q[1]) ** 2
if d <= tol * tol and (bd is None or d < bd):
best, bd = q, d
np = list(best) if best is not None else list(p)
if not out or out[-1] != np:
out.append(np)
if len(out) < 4 or out[0] != out[-1]:
return None
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control #0', [[[0.4, 0.3], [9.8, 0.1], [10.2, 9.9], [0.1, 10.3], [0.4, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]), ('control #1', [[[1, 1], [8, 1], [8, 8], [1, 1]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[1, 1], [8, 1], [8, 8], [1, 1]]), ('regression #2', [[[5, 5.6], [8, 2], [9, 9], [5, 5.6]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 6], [8, 2], [9, 9], [5, 6]]), ('regression #3', [[[5, 5.4], [8, 2], [9, 9], [5, 5.4]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 5], [8, 2], [9, 9], [5, 5]]), ('regression #4', [[[5, 5.5], [8, 2], [9, 9], [5, 5.5]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 5], [8, 2], [9, 9], [5, 5]]), ('boundary #5', [[[0, 1], [8, 2], [9, 9], [0, 1]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [8, 2], [9, 9], [0, 0]]), ('regression #6', [[[0, 0.8], [8, 2], [9, 9], [0, 0.8]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [8, 2], [9, 9], [0, 0]]), ('regression #8', [[[0.3, 0.3], [9.8, 0.2], [0.2, 0.1], [0.3, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], None)], [('control #0', [[[0.4, 0.3], [9.8, 0.1], [10.2, 9.9], [0.1, 10.3], [0.4, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]), ('regression #2', [[[5, 5.6], [8, 2], [9, 9], [5, 5.6]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 6], [8, 2], [9, 9], [5, 6]]), ('regression #4', [[[5, 5.5], [8, 2], [9, 9], [5, 5.5]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 5], [8, 2], [9, 9], [5, 5]]), ('boundary #5', [[[0, 1], [8, 2], [9, 9], [0, 1]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [8, 2], [9, 9], [0, 0]]), ('regression #6', [[[0, 0.8], [8, 2], [9, 9], [0, 0.8]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [8, 2], [9, 9], [0, 0]]), ('regression #7', [[[0.3, 0.3], [0.1, 0.2], [10, 0.4], [9.7, 9.6], [0.3, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [10, 0], [10, 10], [0, 0]]), ('regression #8', [[[0.3, 0.3], [9.8, 0.2], [0.2, 0.1], [0.3, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], None), ('boundary #9', [[[0.2, 0.2], [9.6, 0.2], [9.8, 0.4], [0.2, 0.2]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], None)], [('control #0', [[[0.4, 0.3], [9.8, 0.1], [10.2, 9.9], [0.1, 10.3], [0.4, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]), ('regression #3', [[[5, 5.4], [8, 2], [9, 9], [5, 5.4]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 5], [8, 2], [9, 9], [5, 5]]), ('regression #7', [[[0.3, 0.3], [0.1, 0.2], [10, 0.4], [9.7, 9.6], [0.3, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [10, 0], [10, 10], [0, 0]]), ('regression #8', [[[0.3, 0.3], [9.8, 0.2], [0.2, 0.1], [0.3, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], None), ('boundary #9', [[[0.2, 0.2], [9.6, 0.2], [9.8, 0.4], [0.2, 0.2]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], None), ('control #10', [[[2, 2], [3, 2], [3, 3], [2, 2]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 0.5], [[2, 2], [3, 2], [3, 3], [2, 2]]), ('regression #11', [[[3, 4], [8, 2], [9, 9], [3, 4]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 3], [[5, 5], [10, 0], [10, 10], [5, 5]]), ('regression #12', [[[1, 1.5], [9, 1.2], [9, 9], [1, 1.5]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 2], [[0, 0], [10, 0], [10, 10], [0, 0]])], [('control #0', [[[0.4, 0.3], [9.8, 0.1], [10.2, 9.9], [0.1, 10.3], [0.4, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]), ('control #1', [[[1, 1], [8, 1], [8, 8], [1, 1]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[1, 1], [8, 1], [8, 8], [1, 1]]), ('regression #4', [[[5, 5.5], [8, 2], [9, 9], [5, 5.5]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 5], [8, 2], [9, 9], [5, 5]]), ('boundary #9', [[[0.2, 0.2], [9.6, 0.2], [9.8, 0.4], [0.2, 0.2]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], None), ('regression #11', [[[3, 4], [8, 2], [9, 9], [3, 4]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 3], [[5, 5], [10, 0], [10, 10], [5, 5]]), ('regression #12', [[[1, 1.5], [9, 1.2], [9, 9], [1, 1.5]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 2], [[0, 0], [10, 0], [10, 10], [0, 0]]), ('regression #13', [[[1.2, 0], [8, 3], [8.5, 8.5], [1.2, 0]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1.5], [[0, 0], [8, 3], [8.5, 8.5], [0, 0]]), ('control #14', [[[19, 19], [30, 19], [30, 30], [19, 19]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1.5], [[20, 20], [30, 19], [30, 30], [20, 20]])], [('control #0', [[[0.4, 0.3], [9.8, 0.1], [10.2, 9.9], [0.1, 10.3], [0.4, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]), ('control #1', [[[1, 1], [8, 1], [8, 8], [1, 1]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[1, 1], [8, 1], [8, 8], [1, 1]]), ('regression #2', [[[5, 5.6], [8, 2], [9, 9], [5, 5.6]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 6], [8, 2], [9, 9], [5, 6]]), ('regression #3', [[[5, 5.4], [8, 2], [9, 9], [5, 5.4]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 5], [8, 2], [9, 9], [5, 5]]), ('regression #4', [[[5, 5.5], [8, 2], [9, 9], [5, 5.5]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[5, 5], [8, 2], [9, 9], [5, 5]]), ('boundary #5', [[[0, 1], [8, 2], [9, 9], [0, 1]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], [[0, 0], [8, 2], [9, 9], [0, 0]]), ('regression #8', [[[0.3, 0.3], [9.8, 0.2], [0.2, 0.1], [0.3, 0.3]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1], None), ('control #14', [[[19, 19], [30, 19], [30, 30], [19, 19]], [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [5, 6], [20, 20]], 1.5], [[20, 20], [30, 19], [30, 30], [20, 20]])]]
for label, args, expected in fixtures[N-1]:
check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| control #0 | [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]] | [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]] | Passed |
| control #1 | [[1, 1], [8, 1], [8, 8], [1, 1]] | [[1, 1], [8, 1], [8, 8], [1, 1]] | Passed |
| regression #2 | [[5, 6], [8, 2], [9, 9], [5, 6]] | [[5, 6], [8, 2], [9, 9], [5, 6]] | Passed |
| regression #3 | [[5, 5], [8, 2], [9, 9], [5, 5]] | [[5, 5], [8, 2], [9, 9], [5, 5]] | Passed |
| regression #4 | [[5, 5], [8, 2], [9, 9], [5, 5]] | [[5, 5], [8, 2], [9, 9], [5, 5]] | Passed |
| boundary #5 | [[0, 0], [8, 2], [9, 9], [0, 0]] | [[0, 0], [8, 2], [9, 9], [0, 0]] | Passed |
| regression #6 | [[0, 0], [8, 2], [9, 9], [0, 0]] | [[0, 0], [8, 2], [9, 9], [0, 0]] | Passed |
| regression #8 | None | None | Passed |
SHA-256 / 849b4e9b6d09d792c3d37804c857e9716a7cfc37584e698ec2067b65118bb2b7
Verification & scope
Stipulated deterministic toy contract on a bounded input domain; results are rounded as stated and no conformance with any published standard or library is claimed. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:48:23.786406+00:00.
Case digest / c61cfc27152082a1ad2105b178245c10f557817c8f4e159cde40c201c191a649