Skip to content

RustyMappr 0.2.0: full port of PyMappr - #94

Merged
CalebHendren merged 57 commits into
rustymapprfrom
feature/rustymappr-full-port
Oct 16, 2026
Merged

CalebHendren merged 57 commits into
rustymapprfrom
feature/rustymappr-full-port

Conversation

@CalebHendren

@CalebHendren CalebHendren commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

The full Rust + TypeScript port of PyMappr, on top of the proof of concept that is now the base of the rustymappr branch. A Tauri 2 desktop app: Rust for the map logic, Svelte 5 and Tailwind for the interface.

What it covers:

  • Import (CSV/TSV/text/Excel/ODS) with the column mapper, far-point warnings and manual entry; PyMappr's coordinate parser.
  • All 13 projections; every Natural Earth layer at 1:110m/50m/10m by zoom, bathymetry, relief and Blue Marble rasters, labels, graticule ticks, scale bar, compass, inset map, portrait orientation; political extras behind Show advanced options.
  • Districts outside the US from geoBoundaries (downloaded on request).
  • PyMappr's symbology and legend ported (groups, colour/symbol by, nested and crossed keys, open symbols, row overrides, every legend option, the Standard preset), with matplotlib's marker shapes and DejaVu fonts.
  • .pymappr projects and .pymappr-preset presets read and written in PyMappr's format (PyMappr's own loader opens the re-saved files); session saved on exit and restored at launch.
  • Save as PNG, JPEG, LZW TIFF (greyscale when there is no colour), PDF, SVG and WebP at a print width and DPI.
  • Python/R code export byte-identical to PyMappr's, plus an optional AI check (bring-your-own OpenRouter key, user chooses what is sent, disclaimer, diff before accepting).
  • Map data downloader (a port of 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.py renders projects in both apps and compares geometry and pixels.

Parity with PyMappr: all 12 projects in scripts/parity.py (the two fixtures plus scripts/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-bundle builds. Version 0.2.0.

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.
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.
…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.
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.
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.
@CalebHendren
CalebHendren marked this pull request as ready for review October 16, 2026 11:50
@CalebHendren
CalebHendren merged commit 74599e5 into rustymappr Oct 16, 2026
2 of 3 checks passed
@CalebHendren
CalebHendren deleted the feature/rustymappr-full-port branch October 16, 2026 11:58
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.

1 participant