Fix: legend/basemap settings not persisted + coordinate drift on repeated saves#16
Fix: legend/basemap settings not persisted + coordinate drift on repeated saves#16flamuf wants to merge 5 commits into
Conversation
Legend thresholds and basemap style were saved but never correctly restored on reopen.
|
Unfortunately the coordinate caching code is incomplete since it doesn't handle the cases where the UI user adds a new object, deletes an object, moves an object or edits a link's vertices. I also feel that it adds a lot of specialized code to address a rather infrequently occurring issue (a lot of users might be running their models without using a web basemap). Two alternative approaches that might avoid any coordinate drift are:
|
|
Thanks for taking the time to look at this and for the honest feedback - you're I ran some rough comparisons of zoom performance with a web basemap If it's helpful, it could be worth trying to make the cache reactive There might also be a cleaner longer-term option: keeping the native Thank you much for the feedback. |
This PR fixes two related persistence bugs where display settings are
saved to the project .ini file but never correctly restored on reopen:
Legend interval thresholds (NodeIntervals/LinkIntervals) - only
colors were being saved, never the numeric threshold values that
define which value range maps to which legend color.
Basemap grayscale/brightness style - neither was being persisted
at all.
Root cause: both settings were being read too early in the load
sequence, before later initialization steps (InitThemes for legend
intervals, LoadBasemapFromWeb for basemap style) overwrite them with
defaults. The fix adds two new restore functions
(ReadLegendIntervals, ReadBasemapStyle) called at the correct point
in InitFormContents, after the respective reset happens.
Tested manually: legend thresholds and basemap grayscale/brightness
now correctly survive save -> close -> reopen.
Update: This PR now also includes a fix for a separate issue (#15) -
coordinate rounding drift on repeated saves. See details below.
Fixes #15 (follow-up to the Save() fix suggested there).
The originally suggested fix for #15 works, but transforms coordinates
through PROJ on every save (native EPSG -> WGS84 -> native EPSG). Since
each transform introduces a small floating-point rounding error, this
accumulates with repeated saves - nodes that started very close
together can drift apart or overlap after enough save cycles.
This adds a different approach: node, vertex, and label coordinates in
their native (pre-transform) CRS are cached exactly once, right before
the first transform to WGS84 happens. Save() then writes out these
pristine cached values directly - no transform call involved - and
restores the live WGS84 display values afterward.
Tested manually over many repeated save/close/reopen cycles with a
network using Swiss LV95 (EPSG:2056) coordinates - no drift observed.