Repository navigation
Render single-image base maps (Blue Marble) in SVG output on every platform - #46
Merged
Merged
Conversation
…atform Move the inverse-projection sampler for `BaseMap` out of the Apple-only CoreGraphics code into a pure-Swift `renderBaseMapBitmap`, the way the tile compositor already works, and have `drawSVG` embed the result as a base64 PNG `<image>` next to tiled base maps. The CoreGraphics renderer now wraps that bitmap in a `CGImage`, so both paths share one sampler. `BaseMapImage.decode(pngData:)` and `BaseMap(pngData:)` decode a PNG via swift-png on any platform; the README notes that Linux has no JPEG decoder (convert NASA's Blue Marble once) and what a 4096×2048 image costs in memory. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ting (#47) - Projection gains an optional `longitudeScale` (Mercator, Gall–Peters, Equirectangular) and `cylindricalTransform(to:)` - Tile and single-image samplers scale and shift instead of the inverse/forward round trip when map and raster share a cylindrical projection, e.g. Mercator tiles on a Mercator map - ProjectionMode is CaseIterable - Equirectangular's width uses its standard parallel in radians; the Cassini example no longer converts it twice Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…#48) - MapBounds.crossings(atY:) gives where a polygon boundary crosses a row; the tile and single-image samplers test each row's pixels against it instead of walking the polygon per pixel - Danseiji's inverse tests its edge through a precomputed InsideGrid; only cells the edge crosses walk the polygon - Danseiji IV bounds plus inverse over 1.25M points: 1.35 s to 0.07 s on an M-series Mac, single-threaded Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Why
GeoProjector#45 taught
drawSVGto composite tiled base maps in pure Swift so the Lambda can drape MapTiler tiles under Maparoni's renders. The single-imageBaseMap(NASA Blue Marble / Black Marble in equirectangular) still lived only in the CoreGraphics code and was skipped by the SVG writer. World- and continent-scale renders, where street tiles look busy, need the Marble look on Linux too, and that is the blocker for the thumbnails and projected-view-mode directions in Maparoni.What
renderBaseMapBitmap, mirroring the tile compositor. The CoreGraphics renderer wraps its bitmap in aCGImage, so there is one sampler for both paths. Works with any target projection (orthographic, Equal Earth, Mercator, ...), since the pixel lookup goes throughprojection.inverseand the source projection's forward transform.drawSVGembeds.baseMapas a base64 PNG<image>at the drawer's size timespixelDensity, in content order alongside.tiledBaseMap.BaseMapImage.decode(pngData:)andBaseMap(pngData:)decode PNGs through swift-png on every platform. The README documents that Linux has no JPEG decoder (convert NASA's JPEG once) and the memory cost: 4096×2048 is about 32 MB resident.BaseMapSVGTestsrenders a synthetic quadrant-coloured equirectangular image under a world-scale orthographic and a Mercator drawer, decodes the embedded PNG and checks that the colours land where the inverse projection says, that corners outside the globe are transparent, thatpixelDensityscales the raster, and that the PNG decoder round-trips. The existing CoreGraphicsBaseMapTestsstill pass through the refactored wrapper.Verified with
swift teston macOS and inswift:6.3-amazonlinux2023(82 tests pass). No consumer pins bumped; GeoLogicKit and Lambdaroni follow up separately.Manual testing
Render a real Blue Marble on Linux, e.g. in the Lambda or a scratch executable:
Open the SVG (or
rsvg-convertit): the globe should show the Americas facing you, continents in the right place relative to the outline, and the corners transparent.🤖 Generated with Claude Code