FA-69901 / Map projection transforms / Open access
Slippy map tile index from coordinates: column clamp · case 01
Points exactly on the antimeridian at +180 are placed in column 0 or beyond the grid.
ROOT CAUSE
The column index wraps modulo n, so lon=180 jumps to the westernmost column instead of the last column.
VERIFIED REPAIR
At the column clamp step restore `xt = min(max(math.floor(xf), 0), n - 1)`, leaving the rest of the model unchanged.
Unsuccessful approach: The clamp uses n rather than n-1 as the upper bound, producing a non-existent column.
Case contract
Input [lon, lat, z] with lon in [-180, 180], any latitude, z >= 0. With n = 2**z tiles per axis, column = floor((lon+180)/360*n) and row = floor((1 - asinh(tan(lat))/pi)/2*n) (row 0 at the north edge); both are clamped to [0, n-1] so lon=180 falls in the last column and latitudes beyond the mercator limit fall in the edge rows. Return [z, column, row].
Why this case matters
Tile servers and caches key storage by these indices; an off-by-one or flipped axis fetches the wrong image.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
lon, lat, z = x
n = 2 ** z
phi = math.radians(max(-89.9, min(89.9, lat)))
xf = (lon + 180.0) / 360.0 * n
yf = (1.0 - math.asinh(math.tan(phi)) / math.pi) / 2.0 * n
xt = math.floor(xf) % n
yt = min(max(math.floor(yf), 0), n - 1)
return [z, xt, yt]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('boundary #0', [180.0, 0.0, 3], [3, 7, 4]), ('boundary #1', [-180.0, 10.0, 4], [4, 0, 7]), ('boundary #2', [10.0, 89.0, 5], [5, 16, 0]), ('boundary #3', [10.0, -89.0, 5], [5, 16, 31]), ('control #4', [13.4, 52.5, 10], [10, 550, 335]), ('control #5', [-74.0, 40.7, 12], [12, 1206, 1540]), ('control #6', [151.2, -33.9, 7], [7, 117, 76]), ('boundary #18', [180.0, 45.0, 6], [6, 63, 23])], [('boundary #3', [10.0, -89.0, 5], [5, 16, 31]), ('control #4', [13.4, 52.5, 10], [10, 550, 335]), ('control #5', [-74.0, 40.7, 12], [12, 1206, 1540]), ('control #6', [151.2, -33.9, 7], [7, 117, 76]), ('control #7', [0.0, 0.0, 1], [1, 1, 1]), ('control #8', [2.35, 48.85, 15], [15, 16597, 11274]), ('boundary #18', [180.0, 45.0, 6], [6, 63, 23]), ('boundary #19', [180.0, -60.0, 10], [10, 1023, 726])], [('control #6', [151.2, -33.9, 7], [7, 117, 76]), ('control #7', [0.0, 0.0, 1], [1, 1, 1]), ('control #8', [2.35, 48.85, 15], [15, 16597, 11274]), ('control #9', [-122.4, 37.8, 9], [9, 81, 197]), ('control #10', [100.5, 13.7, 6], [6, 49, 29]), ('control #11', [-58.4, -34.6, 11], [11, 691, 1234]), ('boundary #19', [180.0, -60.0, 10], [10, 1023, 726]), ('boundary #22', [180.0, 86.0, 1], [1, 1, 0])], [('boundary #0', [180.0, 0.0, 3], [3, 7, 4]), ('control #10', [100.5, 13.7, 6], [6, 49, 29]), ('control #11', [-58.4, -34.6, 11], [11, 691, 1234]), ('boundary #12', [179.99, -85.0, 2], [2, 3, 3]), ('control #13', [37.6, 55.75, 8], [8, 154, 80]), ('control #14', [-0.12, 51.5, 16], [16, 32746, 21794]), ('control #15', [18.4, -33.9, 13], [13, 4514, 4916]), ('boundary #22', [180.0, 86.0, 1], [1, 1, 0])], [('boundary #0', [180.0, 0.0, 3], [3, 7, 4]), ('control #13', [37.6, 55.75, 8], [8, 154, 80]), ('control #14', [-0.12, 51.5, 16], [16, 32746, 21794]), ('control #15', [18.4, -33.9, 13], [13, 4514, 4916]), ('boundary #16', [0.0, 0.0, 0], [0, 0, 0]), ('control #17', [139.7, 35.7, 14], [14, 14549, 6450]), ('boundary #18', [180.0, 45.0, 6], [6, 63, 23]), ('boundary #19', [180.0, -60.0, 10], [10, 1023, 726])]]
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 |
|---|---|---|---|
| boundary #0 | [3, 0, 4] | [3, 7, 4] | Failed |
| boundary #1 | [4, 0, 7] | [4, 0, 7] | Passed |
| boundary #2 | [5, 16, 0] | [5, 16, 0] | Passed |
| boundary #3 | [5, 16, 31] | [5, 16, 31] | Passed |
| control #4 | [10, 550, 335] | [10, 550, 335] | Passed |
| control #5 | [12, 1206, 1540] | [12, 1206, 1540] | Passed |
| control #6 | [7, 117, 76] | [7, 117, 76] | Passed |
| boundary #18 | [6, 0, 23] | [6, 63, 23] | Failed |
SHA-256 / 43133f4562aa19ba9605dccb756396d6b2b45d8db57d7bf777fdbf0eb9b77d1f
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
lon, lat, z = x
n = 2 ** z
phi = math.radians(max(-89.9, min(89.9, lat)))
xf = (lon + 180.0) / 360.0 * n
yf = (1.0 - math.asinh(math.tan(phi)) / math.pi) / 2.0 * n
xt = min(math.floor(xf), n)
yt = min(max(math.floor(yf), 0), n - 1)
return [z, xt, yt]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('boundary #0', [180.0, 0.0, 3], [3, 7, 4]), ('boundary #1', [-180.0, 10.0, 4], [4, 0, 7]), ('boundary #2', [10.0, 89.0, 5], [5, 16, 0]), ('boundary #3', [10.0, -89.0, 5], [5, 16, 31]), ('control #4', [13.4, 52.5, 10], [10, 550, 335]), ('control #5', [-74.0, 40.7, 12], [12, 1206, 1540]), ('control #6', [151.2, -33.9, 7], [7, 117, 76]), ('boundary #18', [180.0, 45.0, 6], [6, 63, 23])], [('boundary #3', [10.0, -89.0, 5], [5, 16, 31]), ('control #4', [13.4, 52.5, 10], [10, 550, 335]), ('control #5', [-74.0, 40.7, 12], [12, 1206, 1540]), ('control #6', [151.2, -33.9, 7], [7, 117, 76]), ('control #7', [0.0, 0.0, 1], [1, 1, 1]), ('control #8', [2.35, 48.85, 15], [15, 16597, 11274]), ('boundary #18', [180.0, 45.0, 6], [6, 63, 23]), ('boundary #19', [180.0, -60.0, 10], [10, 1023, 726])], [('control #6', [151.2, -33.9, 7], [7, 117, 76]), ('control #7', [0.0, 0.0, 1], [1, 1, 1]), ('control #8', [2.35, 48.85, 15], [15, 16597, 11274]), ('control #9', [-122.4, 37.8, 9], [9, 81, 197]), ('control #10', [100.5, 13.7, 6], [6, 49, 29]), ('control #11', [-58.4, -34.6, 11], [11, 691, 1234]), ('boundary #19', [180.0, -60.0, 10], [10, 1023, 726]), ('boundary #22', [180.0, 86.0, 1], [1, 1, 0])], [('boundary #0', [180.0, 0.0, 3], [3, 7, 4]), ('control #10', [100.5, 13.7, 6], [6, 49, 29]), ('control #11', [-58.4, -34.6, 11], [11, 691, 1234]), ('boundary #12', [179.99, -85.0, 2], [2, 3, 3]), ('control #13', [37.6, 55.75, 8], [8, 154, 80]), ('control #14', [-0.12, 51.5, 16], [16, 32746, 21794]), ('control #15', [18.4, -33.9, 13], [13, 4514, 4916]), ('boundary #22', [180.0, 86.0, 1], [1, 1, 0])], [('boundary #0', [180.0, 0.0, 3], [3, 7, 4]), ('control #13', [37.6, 55.75, 8], [8, 154, 80]), ('control #14', [-0.12, 51.5, 16], [16, 32746, 21794]), ('control #15', [18.4, -33.9, 13], [13, 4514, 4916]), ('boundary #16', [0.0, 0.0, 0], [0, 0, 0]), ('control #17', [139.7, 35.7, 14], [14, 14549, 6450]), ('boundary #18', [180.0, 45.0, 6], [6, 63, 23]), ('boundary #19', [180.0, -60.0, 10], [10, 1023, 726])]]
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 |
|---|---|---|---|
| boundary #0 | [3, 8, 4] | [3, 7, 4] | Failed |
| boundary #1 | [4, 0, 7] | [4, 0, 7] | Passed |
| boundary #2 | [5, 16, 0] | [5, 16, 0] | Passed |
| boundary #3 | [5, 16, 31] | [5, 16, 31] | Passed |
| control #4 | [10, 550, 335] | [10, 550, 335] | Passed |
| control #5 | [12, 1206, 1540] | [12, 1206, 1540] | Passed |
| control #6 | [7, 117, 76] | [7, 117, 76] | Passed |
| boundary #18 | [6, 64, 23] | [6, 63, 23] | Failed |
SHA-256 / ebef3dec991ace46cc25ed5e982fe75cd1798341afa489796c83d55a26a8f94d
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
lon, lat, z = x
n = 2 ** z
phi = math.radians(max(-89.9, min(89.9, lat)))
xf = (lon + 180.0) / 360.0 * n
yf = (1.0 - math.asinh(math.tan(phi)) / math.pi) / 2.0 * n
xt = min(max(math.floor(xf), 0), n - 1)
yt = min(max(math.floor(yf), 0), n - 1)
return [z, xt, yt]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('boundary #0', [180.0, 0.0, 3], [3, 7, 4]), ('boundary #1', [-180.0, 10.0, 4], [4, 0, 7]), ('boundary #2', [10.0, 89.0, 5], [5, 16, 0]), ('boundary #3', [10.0, -89.0, 5], [5, 16, 31]), ('control #4', [13.4, 52.5, 10], [10, 550, 335]), ('control #5', [-74.0, 40.7, 12], [12, 1206, 1540]), ('control #6', [151.2, -33.9, 7], [7, 117, 76]), ('boundary #18', [180.0, 45.0, 6], [6, 63, 23])], [('boundary #3', [10.0, -89.0, 5], [5, 16, 31]), ('control #4', [13.4, 52.5, 10], [10, 550, 335]), ('control #5', [-74.0, 40.7, 12], [12, 1206, 1540]), ('control #6', [151.2, -33.9, 7], [7, 117, 76]), ('control #7', [0.0, 0.0, 1], [1, 1, 1]), ('control #8', [2.35, 48.85, 15], [15, 16597, 11274]), ('boundary #18', [180.0, 45.0, 6], [6, 63, 23]), ('boundary #19', [180.0, -60.0, 10], [10, 1023, 726])], [('control #6', [151.2, -33.9, 7], [7, 117, 76]), ('control #7', [0.0, 0.0, 1], [1, 1, 1]), ('control #8', [2.35, 48.85, 15], [15, 16597, 11274]), ('control #9', [-122.4, 37.8, 9], [9, 81, 197]), ('control #10', [100.5, 13.7, 6], [6, 49, 29]), ('control #11', [-58.4, -34.6, 11], [11, 691, 1234]), ('boundary #19', [180.0, -60.0, 10], [10, 1023, 726]), ('boundary #22', [180.0, 86.0, 1], [1, 1, 0])], [('boundary #0', [180.0, 0.0, 3], [3, 7, 4]), ('control #10', [100.5, 13.7, 6], [6, 49, 29]), ('control #11', [-58.4, -34.6, 11], [11, 691, 1234]), ('boundary #12', [179.99, -85.0, 2], [2, 3, 3]), ('control #13', [37.6, 55.75, 8], [8, 154, 80]), ('control #14', [-0.12, 51.5, 16], [16, 32746, 21794]), ('control #15', [18.4, -33.9, 13], [13, 4514, 4916]), ('boundary #22', [180.0, 86.0, 1], [1, 1, 0])], [('boundary #0', [180.0, 0.0, 3], [3, 7, 4]), ('control #13', [37.6, 55.75, 8], [8, 154, 80]), ('control #14', [-0.12, 51.5, 16], [16, 32746, 21794]), ('control #15', [18.4, -33.9, 13], [13, 4514, 4916]), ('boundary #16', [0.0, 0.0, 0], [0, 0, 0]), ('control #17', [139.7, 35.7, 14], [14, 14549, 6450]), ('boundary #18', [180.0, 45.0, 6], [6, 63, 23]), ('boundary #19', [180.0, -60.0, 10], [10, 1023, 726])]]
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 |
|---|---|---|---|
| boundary #0 | [3, 7, 4] | [3, 7, 4] | Passed |
| boundary #1 | [4, 0, 7] | [4, 0, 7] | Passed |
| boundary #2 | [5, 16, 0] | [5, 16, 0] | Passed |
| boundary #3 | [5, 16, 31] | [5, 16, 31] | Passed |
| control #4 | [10, 550, 335] | [10, 550, 335] | Passed |
| control #5 | [12, 1206, 1540] | [12, 1206, 1540] | Passed |
| control #6 | [7, 117, 76] | [7, 117, 76] | Passed |
| boundary #18 | [6, 63, 23] | [6, 63, 23] | Passed |
SHA-256 / 568d76cd602b48bde266d393b86516674530e0c63e2fdfeecc42270e58dd240b
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:15.788998+00:00.
Case digest / c7624edb07373a5ecab1a10f8217771d5a1fbd98a6c738b27702abd410f84fdc