Skip to content

Layout legend: a label per layer, instead of the layer's name #1654

Closed

Description

@elpidioassinaturas

The problem

A layout legend shows each layer under its name in the project. Plugins name their layers so they can find them again. The BrasilData plugin, for example, uses a prefix: BrasilData: Setores censitários 2022 (MG), BrasilData: Indicadores por município. Every map it lays out then shows that prefix in the legend.

There is no way around it today:

  • The legend element: layout.update takes title, exclude, hideOther, allClasses and columns, but no label for a layer.
  • Renaming the layer: this breaks whatever finds the layer by its name (the plugin itself, scripts, saved styles).
  • A copy under another name: this duplicates the data in the project.

The same happens to a user who keeps technical layer names (setores_mg_2022_clip) but wants a readable legend.

Choices in this proposal

  1. Where the label lives: on the legend element (ElementKind::Legend), as labels: {"<layer name>": "<label>"}, matched as exclude is (by name, any case). The layer keeps its name everywhere else, so nothing that addresses layers changes. Two legends can label the same layer differently, for instance in two languages.
  2. Command: layout.update takes "labels": {"<layer>": "<label>"|null}. A null entry or an empty map goes back to the layer's name. A layer that is not on the map is refused, as exclude refuses one.
  3. Sizing: the legend measures the label it draws, so its box and columns fit the label, not the name.
  4. Saved projects: the map is kept in the .rgislayout and .rgis, with skip_serializing_if = "HashMap::is_empty", so existing files do not change.
  5. Rejected: a display name on the layer. A name used in the legend, the layers pane and the identify popup is more general, but it touches every place a name is shown or matched, and it raises questions this proposal does not need to answer (which one scripts address, which one exports keep).

Use

In BrasilData's Layout button: layout.update {"element": <legend>, "labels": {"BrasilData: Setores censitários 2022 (MG)": "Setores censitários 2022 (MG)"}}.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions