Repository navigation
Conversation
UTM zone `.prj` files could not be recognized: the fragment-set WKT matching cannot extract the zone number, and a naive fallback would mismatch - UTM `.prj` strings mention "Transverse_Mercator", which the generic EPSG:3395 fragments would match. - File-private UtmWktIdentification namespace with two Swift regex literals: a zone token (UTM / "Universal Transverse Mercator", spaces or underscores as separators, case-insensitive) capturing zone number and hemisphere, and a Central_Meridian parameter for cross-validation against the zone's expected central meridian. - The hemisphere token is mandatory; zones are validated to 1...60; an unparseable or contradicted match yields nil. - A string carrying a UTM zone token short-circuits the matcher: it is resolved to a UTM projection or rejected outright, never falling through to unrelated name fragments. - Tests: realistic ESRI-style `.prj` strings (northern and southern variants), zone/hemisphere token variants, date-line edge zones, central meridian agreement and contradiction cases, and rejected invalid tokens (missing hemisphere, zones outside 1...60). - Clears four redundant #require warnings in the MapTile tests (non-failable boundingBox getters).
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
Follow-up to #241 (UTM zone projections): closes the one remaining gap, per the discussion after the 2467-suite run —
Projection(wkt:)could not recognize UTM zone.prjfiles, since the fragment-set WKT matching can't extract the zone number.The pitfall this explicitly handles
UTM
.prjstrings (ESRI style) containPROJECTION["Transverse_Mercator"]— which the generic EPSG:3395 fragment matcher (PROJCS+Mercator) happily matches. A naïve "fall through to fragments" would therefore silently mislabel a UTM string as EPSG:3395. The implementation short-circuits on a UTM zone token: the string resolves to a UTM projection or is rejected outright — never guessed against unrelated fragments.Implementation
UtmWktIdentificationnamespace inProjection.swift, two Swift regex literals:(?i)(?:UTM|Universal[\s_]+Transverse[\s_]+Mercator)[\s_]*Zone[\s_]*(\d{1,2})[\s_]*([NS])— ESRI underscore variants, spelled-out name, spaces/underscores, case-insensitiveCentral_Meridian:(?i)Central[\s_]*Meridian["]?\s*,\s*(-?\d+(?:\.\d+)?)— when present, must agree with the zone's central meridian (±0.001°), else no match1 ... 60(no guessing); SRID computed as32_600 + zone/32_700 + zoneSendableas static stored properties under strict concurrency); the integer-capture inference (Int128) is normalized via explicitStringconversionTests (+4 funcs, 8 assertions)
.prj:WGS_1984_UTM_Zone_19N+central_meridian,-69→ 32619 (and southern 20S/−63 → 32720)nil(not 3395)utm zone 5n,Universal Transverse Mercator Zone 33 N, date-line edges (1N → 32601, 60S → 32760)UTM Zones→nilAlso clears 4 redundant-
#requirewarnings in the Phase 4 MapTile tests that the test build surfaced.Full suite: 2467 tests in 177 suites, zero warnings.