FAILURE MAP
← Case archive

FA-69956 / Map projection transforms / Open access

Bing-style quadkey encoding of a tile: zoom zero key · case 01

The world tile at zoom 0 gets a one-character key that collides with a zoom-1 tile.

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

ROOT CAUSE

Zoom 0 is special-cased to "0" instead of producing the empty quadkey.

VERIFIED REPAIR

At the zoom zero key step restore `return None digits`, leaving the rest of the model unchanged.

Unsuccessful approach: Returning None for zoom 0 treats the valid root tile as out of range.

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
    if z == 0:
        return "0"
    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'), ('control #6', [5, 17, 30], '32221'), ('boundary #12', [0, 0, 0], '')], [('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 #12', [0, 0, 0], '')], [('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 #12', [0, 0, 0], ''), ('boundary #13', [3, 8, 0], 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
control #63222132221Passed
boundary #120Failed

SHA-256 / 2f95ee704d12bcdb79465e19cb8b8e2f267a4d60532234cd177e311d469c9791

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
    if z == 0:
        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'), ('control #6', [5, 17, 30], '32221'), ('boundary #12', [0, 0, 0], '')], [('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 #12', [0, 0, 0], '')], [('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 #12', [0, 0, 0], ''), ('boundary #13', [3, 8, 0], 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
control #63222132221Passed
boundary #12NoneFailed

SHA-256 / 56067a7ad0327654bf9b7b1668f7acafc1533942fecacca569a02f325c43d3ea

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'), ('control #6', [5, 17, 30], '32221'), ('boundary #12', [0, 0, 0], '')], [('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 #12', [0, 0, 0], '')], [('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 #12', [0, 0, 0], ''), ('boundary #13', [3, 8, 0], 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
control #63222132221Passed
boundary #12Passed

SHA-256 / ff32047745ffcc0b094e8809a88a31448feee9c0ca0166f1a31b0da32b282dfe

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

Case digest / 2a94ebe7b43f9faa9dca6ec6e29db4886c64d097ff1455ff0213fd4cb225f0b5