Repository navigation
RustyMappr 0.2.0: full port of PyMappr - #94
Merged
Merged
Conversation
One dispatch for every backend command, used by the Tauri app and a dev HTTP bridge so the UI can be driven from a browser. The project state now mirrors PyMappr's schema with its real defaults, and api.ts holds the full rendering contract. Background jobs report through a pollable table. Version 0.2.0.
The downloader is a port of PyMappr's fetch_data.py and runs as a pollable job. Maps can now be saved as JPEG, LZW TIFF (greyscale when the map has no colour), WebP and PDF. Imports report points far from the rest, and the app can check GitHub for a newer release.
…PyMappr's geometry
Not wired into the page yet; the old proof-of-concept components still reference the removed style tables, so the frontend does not build at this commit.
Menu bar with PyMappr's File/View/Help items and shortcuts, a toolbar with home/back/forward and a light/dark switch, and the five panel tabs (Data, Legend, Map, Layers, Labels) with every PyMappr control. The Advanced checkbox hides the political extras. Saving maps uses the print-size figure and the new formats; map data can be downloaded from the app.
… and raster basemaps
…esults and HTTP/keyring deps
…r harness The font is bundled for the UI and compiled into the export renderer so map text matches matplotlib's glyphs. scripts/pymappr_reference.py render draws a project with PyMappr itself and dumps every text, marker, patch and axes position for the parity check.
… marker-paths.ts; allow matplotlib's fonts
Compares two renderings of a project: exact geometry (axes, texts, markers, legend frames within 0.01 pt) and pixels, allowing differences only on anti-aliased edges. Writes a report and a diff image.
…pped inverse longitudes, view wrapping, inset placement; add reference tests
… into the app Points and the legend now come from the port of PyMappr's styles and legend code, drawn with matplotlib's marker shapes and DejaVu fonts. The File menu opens, saves, imports and exports .pymappr projects, the session is saved on exit and restored at launch, and the Data tab has presets, manual entry, combine columns and the legend rows editor. A filter bar sits under the map, and Export map as code opens the Python and R export with its AI check.
… the preview, tidy for clippy
scripts/parity.py renders each fixture project in PyMappr and in RustyMappr (its dev-only /parity page in headless Chrome) and compares geometry and pixels. Labels and tick labels are now positioned from DejaVu's ascent and descent as matplotlib does; base layers fill with the nonzero rule, the inset sits where the backend places it, and the map fonts load before the legend measures its text.
Writing the view into the project from the template tripped Svelte's state_unsafe_mutation check, so Export map as code showed an error. Also word the typed-in points status for a single point.
The DejaVu faces are hinted at FreeType's rounded ppem with skrifa's TrueType interpreter and shaped with harfrust using the hinted advances and HarfBuzz's kerning scale, which reproduces FT2Font.set_text's width, height and descent. Path mode reproduces TextToPath, which draws text that has a path effect. Checked against 150,516 measurements from matplotlib 3.11.1 (12 faces, sizes 5-24 pt, 72-600 dpi): all equal.
RustyMappr joins CalebHendren/PyMappr as its own long-lived branch: the working agreement now says to open PRs against rustymappr and never push to it, main or minimappr directly. PyMappr's PR checks run here too.
A text_shapes command returns each string's Agg metrics and glyph outlines. The legend, labels, tick labels, scale bar labels and the compass are laid out like matplotlib's Text and TextArea with them and drawn as the glyphs Agg draws (TextToPath outlines with the halo for text that has one); vector exports keep editable text. Straight-edged frames, ticks and swatches are snapped to the pixel grid as Agg snaps them, and the arrow compass follows FancyArrowPatch's clipping and head. The parity page waits for the shapes and also compares text boxes.
…jections, nested legend and portrait pymappr_reference.py gains a variant command that merges a patch into a project's state in PyMappr (optionally framing the data) and saves it. The portrait mat uses PyMappr's default colour in the harness, and the reference screen keeps the figure's own face colour.
matplotlib's best placement counts every artist on the axes: text and rectangle boxes, other shapes by vertex and edge crossing, collection offsets. The legend now does the same with the labels, the Natural Earth markers, the scale bar, the compass and the inset's extent box. The PyMappr reference geometry is taken right after the screen render, and only for texts actually drawn.
The PyMappr dump includes child axes, the inset's points carry their geometry, and the headless render stops once the page has written its files, retrying while Vite reloads.
Markers are stamped at the nearest pixel corner with straight-edged ones snapped and others centred on a pixel (draw_markers), and the alpha applies to each marker's fill and edge. Straight grid lines and the inset's box are snapped per line, and the axes clip box is rounded to whole pixels.
Shared borders are stroked once per country, so their weight and anti-aliasing match PyMappr's. The backend returns where each feature's path starts in a layer's path data.
PyMappr clips a regional map's layers to its latitude band only; the longitude span limits labels. Rings crossing the cut meridian are still split rather than smeared.
A pixel counts as different only when nothing within one pixel of it in the other image is close, so anti-aliasing differences between the two rasterisers pass while missing or misplaced features fail. The compare also writes a side-by-side image.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The full Rust + TypeScript port of PyMappr, on top of the proof of concept that is now the base of the
rustymapprbranch. A Tauri 2 desktop app: Rust for the map logic, Svelte 5 and Tailwind for the interface.What it covers:
.pymapprprojects and.pymappr-presetpresets read and written in PyMappr's format (PyMappr's own loader opens the re-saved files); session saved on exit and restored at launch.fetch_data.py), light/dark switch, Ko-fi link, update check.Checks: about 160 Rust tests and about 244 vitest tests, many against reference data generated by running PyMappr itself (legend layouts, code export, framing, ticks, labels, scale bars, insets).
scripts/parity.pyrenders projects in both apps and compares geometry and pixels.Parity with PyMappr: all 12 projects in
scripts/parity.py(the two fixtures plusscripts/parity-projects/: ticks, labels, scale bar and compass corners, inset, Robinson, Lambert Europe, nested legend, portrait) match. Text, markers, legend, scale bar, compass and inset agree within 0.01 pt, and the images agree by eye; only anti-aliasing differs, since the two apps use different rasterisers. Each run writes a side-by-side image per project.npm run tauri build -- --no-bundlebuilds. Version 0.2.0.