Repository navigation
Description
Before you start
- I searched the existing issues and the roadmap and did not find a duplicate request.
What problem does this solve?
Most maps of one area share a base: towns, main roads, main rivers, boundaries. Each layer has its symbols, labels and visibility range, and setting them up again for every project is the slow part. A group (#413, nested since #836) is the right container for that base, but it can't leave its project as one thing:
layer.savewrites one layer to a.rgislyr, so a base of 12 layers is 12 files to add, and the groups are made again by hand.layer.savewith a group's name answersno layer named 'base_cartografica'.- Add Data refuses a map file (
unsupported file type: rgismap), and Add Layer File too (not a RustGIS layer file: missing field id). - A project template keeps no features.
What works in 0.8.0 is to carry the group in a map file: map.import, then layer.copy with the group, layer.paste in the working map, and map.remove for the imported one. I tried it with a base of Minas Gerais, Brazil (12 layers in four subgroups, 14 MB with its features), from the command line:
The nested groups, symbols, labels, visibility ranges and features all came through, also when the files the layers were made from weren't there (RustGIS 0.8.0; names in Portuguese; data: IBGE BC250, 2025; soils: IDE-Sisema, by UFV, Cetec, UFLA and Feam, 2010). So the pieces exist. What is missing is one file and one step, in the window as well as in a script.
Proposed solution
A layer file can hold a group: the group, its subgroups and their layers.
layer.save={"group":"base_cartografica","path":"base.rgislyr"}
layer.addLayerFile={"path":"base.rgislyr"}
- Saving: Save Group File… in the group's menu in the Layers pane, beside Copy Group, and
"group"inlayer.save. The layers are the ones Copy Group takes, saved as a layer file saves one today: features inside, local rasters embedded within one budget for the whole file, recognized credentials removed. Layers that stay linked to a file outside are said by name, as packages do ([Feature]: Add Data asks whether to copy a file into the project or link to it #2350). - Adding: Add Data, Add Layer File and a drop on the window, all of which take
.rgislyrtoday. The groups come in nested as saved, with their visibility, transparency, visibility ranges and folding, the layers in their order, at the top of the map."group"and"to"place them elsewhere, as inlayer.paste. - The answer gives the layers' and groups' ids, and the notice counts them: "Added 5 groups and 12 layers".
- One undo step. The view stays, as for a layer file of one layer.
- Add Style File (
style.import) takes the styles of all its layers, as it does from a map file.
The file: the same header as today, and lists in place of the one layer:
{"format": 2, "requires": ["layer-group", …], "groups": [LayerGroup, …], "layers": [Layer, …]}
layer-group is a capability of its own, so a release without it refuses the file by that name. A file of one layer keeps its bytes.
In two pull requests:
- Reading:
layer.addLayerFile, Add Data, drop andstyle.import, the capability and its checks. - Writing:
layer.savewith"group", the group's menu, the docs. It can wait for a release that has part 1, asdocs/maintaining.mdasks where a change allows it.
I can do both.
Choices in this proposal
- The same extension. It is opened by the same commands and for the same reason, and the header tells the two apart.
- Copies, not links. The layers added belong to the project, and later changes to the file don't reach it. A shared group kept in sync across projects is a larger matter, which the split of project and data in Tracking: project format 2, a .rgis that links to its data and .rgispkg as the complete package #1853 bears on.
- Adding works as pasting does: a name the map already has gets " copy", a mask follows its layer when that came too, and one the map lacks is cleared and said. The code can be shared. A layer file of one layer keeps its " (2)".
- All or nothing. A damaged file adds none of its layers. Nor does one that would take the map past its limits of groups (2,000) or levels (eight). A layer linked to a file that isn't there comes in as it does from a layer file today.
- No tile layers. They are never inside a group, so a file can't hold any. A base with a tile basemap still needs a map file.
- The addresses are held to where the file came from (fix(project): a file received from the internet reaches only the internet #2845), and login bindings are cleared, layer by layer as today.
- The legend still lists each layer. A group is a container; drawing it as a single layer is not proposed.
Any of these can change if you prefer another way.
Estimated scope
Medium: a broader feature that is feasible in a reasonable timeframe
Alternatives considered
- A map file through Add Data. It would bring the basemap, the projection, the bookmarks and the map's other settings into the question of what to take.
- Several layers picked, without a group, in one file. The same format could hold it, with an empty
groups. Left out until someone asks. - A task (
.rgistask) that adds each file and groups them. It needs all the files at hand, at the same paths. - A plugin. It can add layers one by one, which is how I do it for some of them now, but every user of a base would need the plugin.
- The map file and paste, as above. It works, and takes four steps and leaves a map to remove.
Activity
fix(layers): tell a group file from a map file, and audit its guides …
feat(layers): add a layer file that holds a group, whole (opengeos#2870…
fix(layers): save a group with no layer active, and refuse an empty l…
feat(layers): save a layer group as a layer file (opengeos#2870, part…