feat: decode Q10 map geometry metadata - #881
Conversation
| _WALL_RECORD_SIZE = 8 # two (x, y) int16-BE endpoints | ||
|
|
||
|
|
||
| def parse_virtual_wall_blob(data: bytes | str | None) -> list[Q10Zone]: |
There was a problem hiding this comment.
Can we pick either bytes or str and not both?
| ox, oy = origin | ||
| classify = layers.classifier | ||
| # 1 = floor, 2 = wall/background (blocked), 0 = other. Index by cell. | ||
| klass = bytes( |
There was a problem hiding this comment.
how about (1) lets go ahead and unroll this since its pretty hard to read as one line and (2) Make enums or constants to self document these magic numbers?
(When i read this line klass looks like a single byte, but then below i see it being accessed like a 2d array, so having trouble following)
There was a problem hiding this comment.
Ah I just read the other code and see this is the same. OK maybe we just do the cleanup later.
| return LAYER_FLOOR | ||
|
|
||
|
|
||
| def decompose_layers(packet: "Q10MapPacket") -> GridLayers: |
There was a problem hiding this comment.
Does this work as a @property on Q10MapPacket?
| ], | ||
| ) | ||
| def test_classify_q10_cell(value: int, expected: str) -> None: | ||
| assert classify_q10_cell(value) == expected |
There was a problem hiding this comment.
This function is in the map module, not the grid layers module so testing for it should be in the map module. Here and below with decompose_layers as well
|
I'm going to merge and we can tackle cleanups in additional follow up PRs. |
Summary
Extracts the low-level, independently reviewable map decoding work from #848. The original PR remains open and unchanged as a reference.
Changes
This PR intentionally contains no trait, API orchestration, rendering-composition, or CLI changes.
Validation
uv run pytest tests/map/test_b01_q10_map_parser.py tests/devices/traits/b01/q10/test_map.py— 39 passeduv run pytest— 802 passeduv run pre-commit run --show-diff-on-failure --color=always --all-filesStack
Q7 reuse is proposed independently and does not block the Q10 stack.