Repository navigation
Description
Today: map.terrain's "block" object sets the whole block (#1914). A key left out goes back to its default, not to what the block had. So {"block": {"walls": "#E0D0B0"}} on a block with "extent": [...] and "depth": 300 also puts the extent back to the DEM's and the depth back to half the relief. The same holds for "walls": {"layer": …} and, since #2377, "water": taking the water out of the walls with {"block": {"water": false}} drops the box the user drew. The rest of map.terrain works the other way: a key left out of the call ("exaggeration", "water", "block" itself) stays as it was. In an agent's or a script's session, a block is usually tuned one key at a time (box, then depth, then the walls' layer, then the water), and each step undoes the last.
Proposal
A "block" object changes only the keys it gives; the others stay as the block had them.
nullfor a key puts it back to its default ("extent": null→ the DEM's extent,"depth": null→ half the relief,"walls": null→#C8B89Awith no layer,"water": nullorfalse→ no water in the walls).- Without a block yet, the keys left out take their defaults, as today.
"block": truekeeps today's meaning (a block with every default) when there is none. When there is one, it keeps the block as it is."block": false/nullstill takes the block off.- Inside
"walls", the same rule:{"walls": {"layer": "Geologia"}}keeps the walls' colour. - The command's output already returns the whole block, so a caller sees what was kept.
- The
map.terraindescription and docs/user-guide/maps.md say so: "keys left out stay as they were; null puts one back to its default".
Tests
- A block with an extent, a depth of 300 and a walls layer, then
{"block": {"water": {"depth": 5}}}: extent, depth and walls layer unchanged, water set. - Then
{"block": {"depth": null}}: depth back to its default, the rest unchanged. - No block, then
{"block": {"depth": 200}}: the DEM's extent, default walls, depth 200. {"block": {"walls": {"layer": "Geologia"}}}on walls coloured#E0D0B0: the colour is kept.{"block": false}: no block.
Choices in this proposal
- Keep, not reset: it matches how the rest of
map.terraintreats keys left out, and how a block is built step by step. A script that wants a clean block can still sendfalsefirst, or give every key. nullfor a default: inside the block it already means the default today (each key'snullis read as left out), so only keys left out change meaning. Outside the block,nullkeeps its present meanings ("exaggeration": nullstays as it was,"block": nulltakes the block off).trueon an existing block keeps it: reading it as "reset everything" would be the one surprising reset left.- Saved projects unchanged: a saved block is always whole, so the file format and the
requireslist don't move. - Related: [Feature]: Block diagrams: terrain cut to a box, with side walls down to a base, optionally coloured by a polygon layer #1914 (block), feat(render): a block diagram's walls show the water they cut (#2317) #2377 (block water, whose refusal text now asks for the block to be given whole again).
Activity
fix(terrain): a "block" object in map.terrain changes only the keys i…