Repository navigation
Conversation
Phase 1 of making the projection system generic: replace per-EPSG-code branches with dispatch on a semantic projection category, so that new projections registered in a later phase automatically get sensible default behavior. New API: - ProjectionKind enum (geographic / planar / geocentric / undefined) - Projection.kind, isGeographic, isPlanar, isGeocentric, hasSRID - Projection.wraparoundExtent (±180° for 4326, ±originShift for 3857) - Projection.crsLength(fromMeters:) for meter-to-CRS-unit conversion Refactored to kind/capability dispatch (behavior-neutral): - Geodesic ops (distance, bearing, destination, midpoint, rhumb *) - AntimeridianCutting: duplicated 4326/3857 helpers collapsed into implementations parameterized by wraparoundExtent - BoundingBox date-line splits, padding, expansion, size, normalize - Antimeridian-span checks, unit conversions, grid cell sizing across ~20 algorithm files Also adds a .swiftformat configuration file. Per-CRS switch matrices (Coordinate3D.projected, coders, MapTile) are intentionally unchanged; they become registry data in phase 2.
trasch
marked this pull request as draft
September 14, 2026 13:54
trasch
force-pushed
the
generic-projection-kinds
branch
from
September 14, 2026 14:17
4a05232 to
676ce10
Compare
This was referenced Sep 14, 2026
Contributor
Author
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.
Summary
Phase 1 of making the projection system generic ( groundwork for supporting a wider range of CRSs beyond the fixed set of EPSG:4326, EPSG:3857, EPSG:4978 and noSRID).
Instead of switching on specific EPSG codes, algorithms now dispatch on a semantic projection category. New projections registered in a later phase will automatically get sensible default behavior.
New API
ProjectionKindenum:.geographic/.planar/.geocentric/.undefined(new fileProjectionKind.swift)Projection.kind, plus convenience flagsisGeographic,isPlanar,isGeocentric,hasSRIDProjection.wraparoundExtent: Double?— the horizontal wraparound boundary (±180° for EPSG:4326, ±originShiftfor EPSG:3857,nilfor EPSG:4978/noSRID)Projection.crsLength(fromMeters:)— shared meters-to-CRS-units conversion (replaces several duplicatedtolerance / 111_325.0switches)Refactored to kind/capability dispatch (behavior-neutral)
ProjectionKind; geographic/planar/geocentric compute via the EPSG:4326 pivot,noSRIDkeeps its planar fallbackwraparoundExtent;crossesAntimeridian/cutAtAntimeridiandispatch onwraparoundExtentcontains/intersects/intersection, padding, expansion,sizeandnormalized()now dispatch on kind /wraparoundExtentprojection == .epsg4326→isGeographic), unit-conversion switches →crsLength(fromMeters:), grid cell sizing →!isGeographic, geocentric-recurse checks →isGeocentricIntentionally unchanged
Per-CRS switch matrices in
Coordinate3D.projected(to:),clamped(),BoundingBox.expanded(byDistance:),Random.worldBox, the WKT/WKB coders andMapTileremain as-is — they become registry data in phase 2.Also included
.swiftformatconfiguration file for the project's formatting conventionsTesting
ProjectionTests.swiftcoverkind, the kind flags,wraparoundExtentandcrsLength(fromMeters:)