FAILURE MAP
← Case archive

FA-69961 / Map projection transforms / Open access

Bing-style quadkey encoding of a tile: range upper bound · case 01

Tiles one past the grid edge get keys instead of being rejected.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The range check uses > so col or row equal to 2**z is accepted and encoded with a carry digit.

VERIFIED REPAIR

At the range upper bound step restore `col >= 2 ** z or row >= 2 ** z`, leaving the rest of the model unchanged.

Unsuccessful approach: Only the column bound was corrected; a row equal to 2**z is still accepted.

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 - 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 #13', [3, 8, 0], None), ('boundary #15', [2, 0, 4], None)], [('control #3', [3, 5, 2], '121'), ('control #4', [3, 3, 5], '213'), ('control #5', [4, 9, 6], '1221'), ('control #6', [5, 17, 30], '32221'), ('control #7', [6, 40, 12], '103200'), ('control #8', [7, 100, 3], '1100122'), ('control #9', [8, 200, 150], '31021220'), ('boundary #15', [2, 0, 4], None)], [('control #6', [5, 17, 30], '32221'), ('control #7', [6, 40, 12], '103200'), ('control #8', [7, 100, 3], '1100122'), ('control #9', [8, 200, 150], '31021220'), ('control #10', [10, 550, 335], '1202102332'), ('control #11', [2, 0, 3], '22'), ('boundary #13', [3, 8, 0], None), ('boundary #15', [2, 0, 4], None)], [('control #9', [8, 200, 150], '31021220'), ('control #10', [10, 550, 335], '1202102332'), ('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'), ('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), ('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 fixtureActualExpectedOutcome
control #000Passed
control #133Passed
control #21313Passed
control #3121121Passed
control #4213213Passed
control #512211221Passed
boundary #13000NoneFailed
boundary #1500NoneFailed

SHA-256 / a234f90a169ffb011932324b3494242b52bb1e523cef863acbb5e37acba764f4

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 << (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 #13', [3, 8, 0], None), ('boundary #15', [2, 0, 4], None)], [('control #3', [3, 5, 2], '121'), ('control #4', [3, 3, 5], '213'), ('control #5', [4, 9, 6], '1221'), ('control #6', [5, 17, 30], '32221'), ('control #7', [6, 40, 12], '103200'), ('control #8', [7, 100, 3], '1100122'), ('control #9', [8, 200, 150], '31021220'), ('boundary #15', [2, 0, 4], None)], [('control #6', [5, 17, 30], '32221'), ('control #7', [6, 40, 12], '103200'), ('control #8', [7, 100, 3], '1100122'), ('control #9', [8, 200, 150], '31021220'), ('control #10', [10, 550, 335], '1202102332'), ('control #11', [2, 0, 3], '22'), ('boundary #13', [3, 8, 0], None), ('boundary #15', [2, 0, 4], None)], [('control #9', [8, 200, 150], '31021220'), ('control #10', [10, 550, 335], '1202102332'), ('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'), ('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), ('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 fixtureActualExpectedOutcome
control #000Passed
control #133Passed
control #21313Passed
control #3121121Passed
control #4213213Passed
control #512211221Passed
boundary #13NoneNonePassed
boundary #1500NoneFailed

SHA-256 / 18ef344da2a2e0e3a4c0286384693da88f10c1b6b43f019b3ac4be26e2942188

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 #13', [3, 8, 0], None), ('boundary #15', [2, 0, 4], None)], [('control #3', [3, 5, 2], '121'), ('control #4', [3, 3, 5], '213'), ('control #5', [4, 9, 6], '1221'), ('control #6', [5, 17, 30], '32221'), ('control #7', [6, 40, 12], '103200'), ('control #8', [7, 100, 3], '1100122'), ('control #9', [8, 200, 150], '31021220'), ('boundary #15', [2, 0, 4], None)], [('control #6', [5, 17, 30], '32221'), ('control #7', [6, 40, 12], '103200'), ('control #8', [7, 100, 3], '1100122'), ('control #9', [8, 200, 150], '31021220'), ('control #10', [10, 550, 335], '1202102332'), ('control #11', [2, 0, 3], '22'), ('boundary #13', [3, 8, 0], None), ('boundary #15', [2, 0, 4], None)], [('control #9', [8, 200, 150], '31021220'), ('control #10', [10, 550, 335], '1202102332'), ('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'), ('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), ('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 fixtureActualExpectedOutcome
control #000Passed
control #133Passed
control #21313Passed
control #3121121Passed
control #4213213Passed
control #512211221Passed
boundary #13NoneNonePassed
boundary #15NoneNonePassed

SHA-256 / 951fa572678dd80b5be4dded2f024b60f81f2e5cc7f1081cda21e479d33c6934

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.321984+00:00.

Case digest / a8fe867c7b8550c891357265a3b5910c029923f0fc78fe6f33b05157df4cd979