Conversation
biodranik
left a comment
There was a problem hiding this comment.
Verified locally against the Organic Maps checkout with this branch in tools/kothic: tools/unix/generate_drules.sh reproduces organicmaps#13549's dumps byte-for-byte (clean git status after a run), the .bin files and colors.txt are untouched, no stale cNNN reference is left, and no dump line carries more than 2 slash-separated values. python3 -m unittest discover -s tests (59 tests) and ruff check --target-version=py39 pass. The #TTRRGGBB header matches mwm_encode_color (libkomwm.py:107, 255 - alpha).
One real finding (shield plate outline hidden in the single-variant dump) plus two optional notes inline.
Generated by Claude Code
| out = [] | ||
| out.append("# drules text dump, format 1. Generated by generate_drules.sh - do not edit.") | ||
| out.append("# drules text dump, format 2. Generated by generate_drules.sh - do not edit.") | ||
| out.append("# Colors are #TTRRGGBB, where TT is 255 - alpha (00 is opaque), as stored in the rules.") |
There was a problem hiding this comment.
Optional alternative, since the dump is review-only: write opaque colors as plain #RRGGBB and keep the 8-digit form only when TT != 0. 22010 of the 32743 color refs in drules_default.txt (67%) are opaque, so this makes the common case directly greppable against colors.mapcss (@label_halo_light: #FFFFFF ↔ #FFFFFF instead of #00FFFFFF) and cancels a good part of the +22% size growth.
Cons: two forms in one file, and it stops being a literal echo of the stored bytes — which is what this line currently promises. Fine to keep as is; just noting the trade-off was available.
Generated by Claude Code
There was a problem hiding this comment.
Keeping the 8-digit form for now: the dump stays a literal echo of the stored bytes, with one spelling per value, and mixed widths would make column-wise scanning of a diff harder. The +22% is on a review-only artefact. Happy to switch if you prefer the greppability.
The text dump exists only to review style changes, but it referenced colors by palette index. The palette is numbered by first use, so adding or removing a single color renumbered every later reference: removing 19 unused named colors rewrote ~78K lines of the Organic Maps dumps. Write colors by value instead, one per variant only if the variants differ. The binary output is unchanged. The dumps grow by ~22% (+3.5% compressed). Signed-off-by: Alexander Borsuk <me@alex.bio>
aa3c788 to
dce9435
Compare
The text dumps exist only to review style changes, but they referenced colors by palette index. The palette is numbered by first use, so adding or removing a single color renumbers every later reference: dropping 19 unused named colors in organicmaps/organicmaps#13545 rewrote ~78K lines of the dumps.
Colors are now written by value (one per variant,
/-separated, only when the variants differ) and the palette section is gone. The binary output is unchanged.Measured on the Organic Maps dumps:
Tested:
python3 -m unittest discover -s testsandruff check --target-version=py39, plus two new tests (values are inlined; adding a color leaves the other lines untouched).