FAILURE MAP
← Case archive

FA-69951 / Map projection transforms / Open access

Bing-style quadkey encoding of a tile: column digit weight · case 01

East and south quadrants are confused in generated keys.

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

ROOT CAUSE

The column bit contributes 2 and the row bit 2 as well, conflating columns with rows.

VERIFIED REPAIR

At the column digit weight step restore `if col & mask: d += 1`, leaving the rest of the model unchanged.

Unsuccessful approach: The patched weight is dropped whenever the row bit is also set, so quadrant 3 becomes 2.

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 += 2
        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 #11', [2, 0, 3], '22'), ('boundary #12', [0, 0, 0], '')], [('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'), ('control #11', [2, 0, 3], '22'), ('boundary #12', [0, 0, 0], ''), ('boundary #13', [3, 8, 0], None)], [('control #3', [3, 5, 2], '121'), ('control #4', [3, 3, 5], '213'), ('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 #4', [3, 3, 5], '213'), ('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 #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 fixtureActualExpectedOutcome
control #000Passed
control #143Failed
control #22413Failed
control #3222121Failed
control #4224213Failed
control #522221221Failed
control #112222Passed
boundary #12Passed

SHA-256 / 02f5aafaa090c74cf02cabb263dd4c05797bc89a6e2f86c7601b4772c01beb6b

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 not row & mask else 0
        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 #11', [2, 0, 3], '22'), ('boundary #12', [0, 0, 0], '')], [('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'), ('control #11', [2, 0, 3], '22'), ('boundary #12', [0, 0, 0], ''), ('boundary #13', [3, 8, 0], None)], [('control #3', [3, 5, 2], '121'), ('control #4', [3, 3, 5], '213'), ('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 #4', [3, 3, 5], '213'), ('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 #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 fixtureActualExpectedOutcome
control #000Passed
control #123Failed
control #21213Failed
control #3121121Passed
control #4212213Failed
control #512211221Passed
control #112222Passed
boundary #12Passed

SHA-256 / 21f338071aeebd9aa567e919a262615129bc57ebb9690d7f20867c50a19174cd

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 #11', [2, 0, 3], '22'), ('boundary #12', [0, 0, 0], '')], [('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'), ('control #11', [2, 0, 3], '22'), ('boundary #12', [0, 0, 0], ''), ('boundary #13', [3, 8, 0], None)], [('control #3', [3, 5, 2], '121'), ('control #4', [3, 3, 5], '213'), ('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 #4', [3, 3, 5], '213'), ('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 #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 fixtureActualExpectedOutcome
control #000Passed
control #133Passed
control #21313Passed
control #3121121Passed
control #4213213Passed
control #512211221Passed
control #112222Passed
boundary #12Passed

SHA-256 / 27bca8de3fa635be75c4c4b8393775488d45e0e495d0e2c1cde16f40c8662f98

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

Case digest / a36f77accf17b177c1ba6f57e78ce81d7fc1019ff2c2859f7e0b4b15cad13b52