FA-69946 / Map projection transforms / Open access
Bing-style quadkey encoding of a tile: bit mask position · case 01
Keys read the wrong bit and tiles in odd columns get even-column keys.
ROOT CAUSE
The mask for a level is 1 << level, one bit too high.
VERIFIED REPAIR
At the bit mask position step restore `mask = 1 << (level - 1)`, leaving the rest of the model unchanged.
Unsuccessful approach: Shifting by level-2 fixes nothing for the highest bit and duplicates bit 0 at the two finest levels.
Case contract
Input [z, col, row] with xyz rows. For zoom 0 return the empty string. If col or row is outside [0, 2**z - 1] return None. Otherwise emit z digits from the most significant bit down: digit = (1 if col bit set) + (2 if row bit set).
Why this case matters
Quadkeys are used as cache keys and spatial index prefixes; a wrong digit order breaks prefix containment.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
z, col, row = x
if col < 0 or row < 0 or col >= 2 ** z or row >= 2 ** z:
return None
digits = []
for level in range(z, 0, -1):
mask = 1 << level
d = 0
if col & mask:
d += 1
if row & mask:
d += 2
digits.append(str(d))
return ''.join(digits)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control #0', [1, 0, 0], '0'), ('control #1', [1, 1, 1], '3'), ('control #2', [2, 3, 1], '13'), ('control #3', [3, 5, 2], '121'), ('control #4', [3, 3, 5], '213'), ('control #5', [4, 9, 6], '1221'), ('boundary #12', [0, 0, 0], ''), ('boundary #13', [3, 8, 0], None)], [('control #2', [2, 3, 1], '13'), ('control #4', [3, 3, 5], '213'), ('control #5', [4, 9, 6], '1221'), ('control #6', [5, 17, 30], '32221'), ('control #7', [6, 40, 12], '103200'), ('boundary #12', [0, 0, 0], ''), ('boundary #13', [3, 8, 0], None), ('boundary #15', [2, 0, 4], None)], [('control #3', [3, 5, 2], '121'), ('control #5', [4, 9, 6], '1221'), ('control #8', [7, 100, 3], '1100122'), ('control #9', [8, 200, 150], '31021220'), ('control #10', [10, 550, 335], '1202102332'), ('boundary #12', [0, 0, 0], ''), ('boundary #13', [3, 8, 0], None), ('boundary #15', [2, 0, 4], None)], [('control #4', [3, 3, 5], '213'), ('control #6', [5, 17, 30], '32221'), ('control #11', [2, 0, 3], '22'), ('boundary #12', [0, 0, 0], ''), ('boundary #13', [3, 8, 0], None), ('boundary #14', [3, 7, 7], '333'), ('boundary #15', [2, 0, 4], None), ('boundary #16', [4, -1, 2], None)], [('control #0', [1, 0, 0], '0'), ('control #1', [1, 1, 1], '3'), ('control #5', [4, 9, 6], '1221'), ('control #7', [6, 40, 12], '103200'), ('boundary #14', [3, 7, 7], '333'), ('boundary #15', [2, 0, 4], None), ('boundary #16', [4, -1, 2], None), ('boundary #17', [4, 15, 15], '3333')]]
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 | Passed |
| control #1 | 0 | 3 | Failed |
| control #2 | 01 | 13 | Failed |
| control #3 | 012 | 121 | Failed |
| control #4 | 021 | 213 | Failed |
| control #5 | 0122 | 1221 | Failed |
| boundary #12 | | | Passed |
| boundary #13 | None | None | Passed |
SHA-256 / f67e0b65948a6eff30b8d0815f56a1fcbfca7b658e6a84c7a68e38d896d44daa
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
z, col, row = x
if col < 0 or row < 0 or col >= 2 ** z or row >= 2 ** z:
return None
digits = []
for level in range(z, 0, -1):
mask = 1 << max(level - 2, 0)
d = 0
if col & mask:
d += 1
if row & mask:
d += 2
digits.append(str(d))
return ''.join(digits)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control #0', [1, 0, 0], '0'), ('control #1', [1, 1, 1], '3'), ('control #2', [2, 3, 1], '13'), ('control #3', [3, 5, 2], '121'), ('control #4', [3, 3, 5], '213'), ('control #5', [4, 9, 6], '1221'), ('boundary #12', [0, 0, 0], ''), ('boundary #13', [3, 8, 0], None)], [('control #2', [2, 3, 1], '13'), ('control #4', [3, 3, 5], '213'), ('control #5', [4, 9, 6], '1221'), ('control #6', [5, 17, 30], '32221'), ('control #7', [6, 40, 12], '103200'), ('boundary #12', [0, 0, 0], ''), ('boundary #13', [3, 8, 0], None), ('boundary #15', [2, 0, 4], None)], [('control #3', [3, 5, 2], '121'), ('control #5', [4, 9, 6], '1221'), ('control #8', [7, 100, 3], '1100122'), ('control #9', [8, 200, 150], '31021220'), ('control #10', [10, 550, 335], '1202102332'), ('boundary #12', [0, 0, 0], ''), ('boundary #13', [3, 8, 0], None), ('boundary #15', [2, 0, 4], None)], [('control #4', [3, 3, 5], '213'), ('control #6', [5, 17, 30], '32221'), ('control #11', [2, 0, 3], '22'), ('boundary #12', [0, 0, 0], ''), ('boundary #13', [3, 8, 0], None), ('boundary #14', [3, 7, 7], '333'), ('boundary #15', [2, 0, 4], None), ('boundary #16', [4, -1, 2], None)], [('control #0', [1, 0, 0], '0'), ('control #1', [1, 1, 1], '3'), ('control #5', [4, 9, 6], '1221'), ('control #7', [6, 40, 12], '103200'), ('boundary #14', [3, 7, 7], '333'), ('boundary #15', [2, 0, 4], None), ('boundary #16', [4, -1, 2], None), ('boundary #17', [4, 15, 15], '3333')]]
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 | Passed |
| control #1 | 3 | 3 | Passed |
| control #2 | 33 | 13 | Failed |
| control #3 | 211 | 121 | Failed |
| control #4 | 133 | 213 | Failed |
| control #5 | 2211 | 1221 | Failed |
| boundary #12 | | | Passed |
| boundary #13 | None | None | Passed |
SHA-256 / c1b2e991a2b246f391ed4452fb986be861a22b2b2b7790285d56c45f2905d6ae
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
z, col, row = x
if col < 0 or row < 0 or col >= 2 ** z or row >= 2 ** z:
return None
digits = []
for level in range(z, 0, -1):
mask = 1 << (level - 1)
d = 0
if col & mask:
d += 1
if row & mask:
d += 2
digits.append(str(d))
return ''.join(digits)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control #0', [1, 0, 0], '0'), ('control #1', [1, 1, 1], '3'), ('control #2', [2, 3, 1], '13'), ('control #3', [3, 5, 2], '121'), ('control #4', [3, 3, 5], '213'), ('control #5', [4, 9, 6], '1221'), ('boundary #12', [0, 0, 0], ''), ('boundary #13', [3, 8, 0], None)], [('control #2', [2, 3, 1], '13'), ('control #4', [3, 3, 5], '213'), ('control #5', [4, 9, 6], '1221'), ('control #6', [5, 17, 30], '32221'), ('control #7', [6, 40, 12], '103200'), ('boundary #12', [0, 0, 0], ''), ('boundary #13', [3, 8, 0], None), ('boundary #15', [2, 0, 4], None)], [('control #3', [3, 5, 2], '121'), ('control #5', [4, 9, 6], '1221'), ('control #8', [7, 100, 3], '1100122'), ('control #9', [8, 200, 150], '31021220'), ('control #10', [10, 550, 335], '1202102332'), ('boundary #12', [0, 0, 0], ''), ('boundary #13', [3, 8, 0], None), ('boundary #15', [2, 0, 4], None)], [('control #4', [3, 3, 5], '213'), ('control #6', [5, 17, 30], '32221'), ('control #11', [2, 0, 3], '22'), ('boundary #12', [0, 0, 0], ''), ('boundary #13', [3, 8, 0], None), ('boundary #14', [3, 7, 7], '333'), ('boundary #15', [2, 0, 4], None), ('boundary #16', [4, -1, 2], None)], [('control #0', [1, 0, 0], '0'), ('control #1', [1, 1, 1], '3'), ('control #5', [4, 9, 6], '1221'), ('control #7', [6, 40, 12], '103200'), ('boundary #14', [3, 7, 7], '333'), ('boundary #15', [2, 0, 4], None), ('boundary #16', [4, -1, 2], None), ('boundary #17', [4, 15, 15], '3333')]]
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 | Passed |
| control #1 | 3 | 3 | Passed |
| control #2 | 13 | 13 | Passed |
| control #3 | 121 | 121 | Passed |
| control #4 | 213 | 213 | Passed |
| control #5 | 1221 | 1221 | Passed |
| boundary #12 | | | Passed |
| boundary #13 | None | None | Passed |
SHA-256 / 025b128931c841c9cc355ae16a66d42c0f2958aadffd746ea16c9ec436208d5e
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:16.070785+00:00.
Case digest / 725532d07a62071d3aee59d0d9469d558c683a16517991ceec28f8ae34601200