Repository navigation
Conversation
Phase 4 of making the projection system generic: move WKT CRS identification into the projection registry and round out test coverage for the coder and MapTile paths. - ProjectionDefinition gains wktMatchers: [[String]] - each inner list is an alternative fragment set, every fragment of one set must be contained for a match. This preserves the previous A && (B || C) semantics (e.g. "WGS 84" or "WGS_1984") exactly. - ProjectionRegistry probes definitions in registry order (specific patterns first: EPSG:3857 "Pseudo-Mercator" before EPSG:3395 "Mercator"); Projection.init?(wkt:) now delegates to it. noSRID registers no patterns and never matches. - MapTile tests: tile bounding boxes in EPSG:3395/EPSG:32662 verified against manual reprojection of the EPSG:4326 bounds, plus centerCoordinate round trips (the generic pixel-projection path already handles the new projections). - Coder tests: WKT round trips with SRID embedded in the string, TWKB decode fixtures for the new projections (decode-only API), and ProjectionWktMatcherTests covering the 3857/3395 disambiguation, both geographic fragment alternatives and unrecognized strings (GEOGCS["ETRS89"] -> nil). - Test rename: NewProjectionAlgorithmTests.swift split into projection-named files (Epsg3395Tests.swift, Epsg32662Tests.swift) so the names stay meaningful as more projections are added. Behavior note: WKTCoder.decode with an explicit sourceSrid does not consume an embedded "SRID=...;" prefix - decoders of strings produced by WKTCoder.encode must use sourceSrid: nil so the SRID is detected from the string.
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 4 of making the projection system generic. Stacks on #239 (phase 3: EPSG:3395/32662) — review/merge the chain in order. Completes the remaining phase 4 items; the WKB/WKT/TWKB coordinate-constructor simplification was already done in #239.
Registry-driven CRS matching
ProjectionDefinitiongainswktMatchers: [[String]]— each inner list is one alternative fragment set, and every fragment of a set must be contained for the alternative to match. This preserves the previousA && (B || C)semantics exactly (e.g."WGS 84"or"WGS_1984")ProjectionRegistry.definition(matchingWkt:)probes definitions in registry order — specific patterns first (EPSG:3857 "Pseudo-Mercator" before EPSG:3395 "Mercator") — andProjection.init?(wkt:)now delegates to itif/elsechains: future projections register their WKT patterns in their own definition. noSRID registers no patterns and never matchesTest coverage
centerCoordinateround trips. EPSG:32662 longitudes asserted as exactly linear (tile width = 360/2ᶻ)ProjectionWktMatcherTests: 3857/3395 disambiguation, both geographic fragment alternatives, unrecognized strings (PROJCS["Something Else"],GEOGCS["ETRS89"]→ nil)Epsg3395Tests.swift,Epsg32662Tests.swift) so the names stay meaningful as projections accumulateBehavior note (documented, unchanged behavior)
WKTCoder.decode(wkt:sourceSrid:targetProjection:)with an explicitsourceSriddoes not consume an embeddedSRID=...;prefix — decoding strings produced byWKTCoder.encode(which always writes the prefix) requiressourceSrid: nilso the SRID is detected from the string. Surfaced by the new round-trip tests.Testing
Full suite: 2450 tests in 175 suites, zero warnings (+8 vs. phase 3).