FAILURE MAP
← Case archive

FA-69941 / Map projection transforms / Open access

Bing-style quadkey encoding of a tile: digit significance order · case 01

Quadkeys of neighbouring tiles no longer share their parent prefix.

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

ROOT CAUSE

Digits are emitted from the least significant bit first, reversing the key.

VERIFIED REPAIR

At the digit significance order step restore `for level in range(z, 0, -1):`, leaving the rest of the model unchanged.

Unsuccessful approach: The loop now stops before level 1, dropping the finest digit.

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(1, z + 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'), ('boundary #12', [0, 0, 0], ''), ('boundary #13', [3, 8, 0], None), ('boundary #15', [2, 0, 4], None)], [('control #1', [1, 1, 1], '3'), ('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 #2', [2, 3, 1], '13'), ('control #6', [5, 17, 30], '32221'), ('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 #3', [3, 5, 2], '121'), ('control #7', [6, 40, 12], '103200'), ('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 #4', [3, 3, 5], '213'), ('control #8', [7, 100, 3], '1100122'), ('boundary #12', [0, 0, 0], ''), ('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 #23113Failed
control #3121121Passed
control #4312213Failed
boundary #12Passed
boundary #13NoneNonePassed
boundary #15NoneNonePassed

SHA-256 / d786961043787eaad94c23aa97a40fc2293ac1c4a2e7ea880a1c6112c5b1cfa6

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, 1, -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'), ('boundary #12', [0, 0, 0], ''), ('boundary #13', [3, 8, 0], None), ('boundary #15', [2, 0, 4], None)], [('control #1', [1, 1, 1], '3'), ('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 #2', [2, 3, 1], '13'), ('control #6', [5, 17, 30], '32221'), ('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 #3', [3, 5, 2], '121'), ('control #7', [6, 40, 12], '103200'), ('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 #4', [3, 3, 5], '213'), ('control #8', [7, 100, 3], '1100122'), ('boundary #12', [0, 0, 0], ''), ('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 #00Failed
control #13Failed
control #2113Failed
control #312121Failed
control #421213Failed
boundary #12Passed
boundary #13NoneNonePassed
boundary #15NoneNonePassed

SHA-256 / a7b75c2dfd94899594749d268b07afba2780277076dd7f153a281b1e95141097

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'), ('boundary #12', [0, 0, 0], ''), ('boundary #13', [3, 8, 0], None), ('boundary #15', [2, 0, 4], None)], [('control #1', [1, 1, 1], '3'), ('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 #2', [2, 3, 1], '13'), ('control #6', [5, 17, 30], '32221'), ('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 #3', [3, 5, 2], '121'), ('control #7', [6, 40, 12], '103200'), ('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 #4', [3, 3, 5], '213'), ('control #8', [7, 100, 3], '1100122'), ('boundary #12', [0, 0, 0], ''), ('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
boundary #12Passed
boundary #13NoneNonePassed
boundary #15NoneNonePassed

SHA-256 / d0e65c0331ff298779309612a426cf9d2931515f6c16ac098c172c7dfcd995ea

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

Case digest / 8df9d66a6cabe8b1d382349d8a7a6a9f0c8e0fcd1d090c6b9b711960b262a202