Skip to content

perf(nad): expose geometryPrecision as a viewer parameter#10

Draft
gautierbureau wants to merge 1 commit into
claude/perf-nad-writer-geometry-precisionfrom
claude/perf-nad-viewer-geometry-precision
Draft

perf(nad): expose geometryPrecision as a viewer parameter#10
gautierbureau wants to merge 1 commit into
claude/perf-nad-writer-geometry-precisionfrom
claude/perf-nad-viewer-geometry-precision

Conversation

@gautierbureau

@gautierbureau gautierbureau commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Context

Follow-up to the geometry-precision PR (#8), and based on its branch (claude/perf-nad-writer-geometry-precision) — not on the powsybl#423 base — because it consumes the geometryPrecision writer option that #8 introduces. Review/merge #8 first.

What

#8 added geometryPrecision to the SVG-writer options but left the viewer to pass it. This PR does that end-to-end wiring so a consumer can set it once through the public viewer parameters:

new NetworkAreaDiagramViewer(container, svg, metadata, svgMetadata, {
    createSvgFromMetadata: true,
    geometryPrecision: 1, // fewer coordinate decimals → smaller, faster SVG
});
  • Adds geometryPrecision?: number to NadViewerParametersOptions (already exported, so it's public).
  • NadViewerParameters.getGeometryPrecision() returns the configured value or undefined.
  • Both new SvgWriter(...) sites in network-area-diagram-viewer.ts — the initial empty-SVG build and the adaptive-zoom redraw — forward it.

undefined leaves the writer on its default precision (2), so behaviour is unchanged unless a consumer opts in. The getter returns undefined rather than a hard-coded 2 to avoid duplicating the default (and a circular import with diagram-utils); the writer owns the default.

Measured impact

This PR is pure plumbing — a single optional-field read per writer construction, no runtime cost of its own. Its value is making #8's savings reachable through the public viewer API. The payoff is #8's, measured on case1354pegase:

viewer geometryPrecision gzip SVG vs default
unset / 2 (default) 168.5 KB
1 156.0 KB −7.4%
0 140.8 KB −16.4%

(Full raw+gzip table and methodology in #8.)

Tests

Draft; its base is #8's branch. Once #8 merges into integration/nad_create_svg_adaptive_zoom, retarget this PR's base to that branch.

🤖 Generated with Claude Code

Forward the SVG-writer geometryPrecision option through the viewer so consumers
can set it once via NadViewerParametersOptions instead of constructing the
writer themselves. NadViewerParameters.getGeometryPrecision() returns the
configured value or undefined, and both new SvgWriter(...) call sites in the
viewer (initial empty-SVG build and adaptive-zoom redraw) pass it through.
Undefined leaves the writer on its default precision (2), so behaviour is
unchanged unless a consumer opts in.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T1fMV9gtgHLBKoSAShYSdA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants