[Bug]: layout.addElement of a grid or an extent indicator drops the parameters it doesn't read, without a word

Aperta Adatta ai principianti
#2,890 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
backend

Direzione di ricerca

I due rami per grid ed extentIndicator in crates/engine/src/cmd/layout.rs ritornano prima di place(...), quindi le chiavi del box non vengono mai lette. Inizia dai rifiuti esistenti per tipo per color, fill e outline in quel file e segui il loro schema, aggiungendo un elenco di chiavi per tipo accanto a ciascun ramo. È completato quando entrambi i comandi di riproduzione nell'issue falliscono con un messaggio che nomina la chiave ed elenca ciò che il tipo legge, e le chiamate senza quelle chiavi si comportano come prima.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Before you start
  • I searched the existing issues and did not find a duplicate.
  • This is a bug report, not a usage question (questions belong in Discussions).
What happened?

layout.addElement of a grid or an extentIndicator accepts parameters those kinds don't read and drops them without a word: the command succeeds and the result is the same as without them. Both go on a map frame and have no box or text of their own, so a script that gives x, y, w and h to place one sees a success and nothing placed.

The general notice for unread parameters (#154) doesn't cover this. It names the keys that no kind reads (layout.addElement ignores 'bogus' (it reads …)), and x, text or angle are read by other kinds. A few keys are refused kind by kind (color, fill and outline since #1455, font, radius, dash, rotation, wrap, the chart options, background on these two), and the rest are not.

In crates/engine/src/cmd/layout.rs the two arms return before place(...), so the box is never read.

Found in the review of #2872 (https://github.com/opengeos/RustGIS/pull/2872#discussion_r4687903793), which fixes it for its own new kind, the section line.

Steps to reproduce

With RustGIS 0.8.0:

rustgis-cli run --sample --cmd 'layout.new={"name":"L"}' --cmd 'layout.addElement={"kind":"grid","step":20}' --save g0.rgis
rustgis-cli run --sample --cmd 'layout.new={"name":"L"}' --cmd 'layout.addElement={"kind":"grid","step":20,"x":10,"y":10,"w":50,"h":50,"text":"hi","angle":30,"divisions":4}' --save g1.rgis

Both print {"element": 1} and nothing else, and the layouts of the two files are equal. The same happens with an extent indicator (layout.duplicateElement gives the second frame, 7):

rustgis-cli run --sample --cmd 'layout.new={"name":"L"}' --cmd 'layout.duplicateElement={"element":1}' --cmd 'layout.addElement={"kind":"extentIndicator","frame":7,"of":1,"x":10,"w":50,"text":"hi","step":5,"bold":true}' --save e1.rgis
Expected behavior

A key that the kind doesn't read is refused before anything changes, with a message that names it and lists what the kind reads, as layout.update does for a section object in #2872:

layout.addElement: a grid takes no "x" (it reads layout, kind, frame, type, crs, step, …)

A null value counts as not given, as it does for the keys refused today. Clean calls say nothing.

Choices in this proposal:

  • Refuse, not warn. The keys already checked by kind are refused, and a placed grid that isn't placed is an unusable result rather than an approximate one.
  • One list of keys per kind, next to its arm, rather than one more constant per key: a key added later to another kind is then refused here too.
  • These two kinds first. The others drop keys too: on 0.8.0, {"kind":"rectangle","text":"hi","angle":30,"divisions":4,"step":5,"units":"miles"} and {"kind":"text","text":"a","step":5,"divisions":4,"ticks":3,"angle":20,"head":"end"} both succeed with no notice. They read more keys each, so their lists are better done on their own afterwards, the same way.
How are you running RustGIS?

Command line (rustgis-cli)

Version

v0.8.0. The two arms read the same on main (7ecae773), where I read the code but didn't run it.

Operating system, browser and graphics

Windows 11

Lingua principale
Rust
Stelle
1.9k
Fork
268
Merge medio
8h 43m
PR unite (30g)
931

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di opengeos/RustGIS

Tutte le issue di opengeos/RustGIS

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.