Repository navigation
Conversation
Three follow-ups to the projection-genericity effort: Validation API: - Coordinate3D.isValid and BoundingBox.isValid report whether the coordinate/box lies within the valid extent of its projection, resolved through the projection registry. Always true for unbounded projections (EPSG:4978, noSRID). UTM convenience API: - UtmHemisphere is now public (it appears in the public API below) - Projection.utmZone / Projection.utmHemisphere accessors return the zone number or hemisphere of a UTM zone projection, nil for non-UTM projections - Projection(utmZone:hemisphere:) creates a zone projection from a zone number (1...60) and hemisphere Benchmarks: - ProjectionBenchmarks suite (skipped in CI like the other suites): compares the pre-registry inline formulas as a baseline against the registry path, with correctness cross-checks. An EPSG:4326 pivot short-circuit in Coordinate3D.projected(to:) skips the registry lookup and identity copy in the two most common directions (behavior-identical). - Decomposition tests isolate lookup, fixed-definition projection and full-path costs (release: ~5 ns baseline, ~30 ns lookup, ~125 ns full path per coordinate). The overhead only matters for bulk reprojection; algorithm hot paths reproject per feature, and the analysis is documented in the suite docs along with the options if a batch reprojection use case appears. Tests: ValidityTests (extent boundaries for 4326/3857/UTM sectors, unbounded projections, invalid-then-clamp) and UtmDefinitionTests.utmConvenienceApi (zone sweep, invalid zones, non-UTM accessors).
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
Three follow-ups to the projection work chain (#237–#244). Stacks on #244.
Validation API
Coordinate3D.isValid/BoundingBox.isValid— report whether the coordinate/box lies within the valid extent of its projection, resolved through theProjectionRegistry. Alwaystruefor unbounded projections (EPSG:4978, noSRID)clamped()/normalized(): report first, fix secondUTM convenience API
UtmHemisphereis nowpublic(it appears in the public API)Projection.utmZone: Int?/Projection.utmHemisphere: UtmHemisphere?Projection(utmZone:hemisphere:)—Projection(utmZone: 19, hemisphere: .north)==.epsg32619; validates zone1 ... 60Benchmarks (
ProjectionBenchmarks, skipped in CI like the other benchmark suites)Baseline = the pre-registry inline formulas (verbatim copies of the old math), with correctness cross-checks. Release-build findings per coordinate:
projected(to:)Reacted to the first numbers: added an EPSG:4326 pivot short-circuit in
Coordinate3D.projected(to:)— skips the registry lookup + identity coordinate copy when projecting from or to the pivot (the two most common directions). Behavior-identical (guarded by the round-trip correctness assertions). ~1.79 → ~1.68 ms/10k.Documented verdict (in the suite docs): the remaining ~125 ns/op is bounded by dictionary reads + existential dispatch; closing the gap fully requires a non-existential registry redesign. Not worth it now — algorithm hot paths reproject per geometry feature, not per point cloud. Revisit only if bulk reprojection of large point clouds becomes a use case (batch API / restructure, noted as options). Decomposition tests (
lookupAlone,fixedDefinitionForward) isolate the components so future profiling has a starting point.Testing (+15)
ValidityTests: extent boundaries for 4326/3857/UTM sectors, unbounded projections always valid, invalid-then-clamp round tripUtmDefinitionTests.utmConvenienceApi: zone sweep across zones 1/19/33/60 × hemispheres, invalid zone numbers, non-UTM accessors return nilFull suite: 2482 tests in 179 suites, zero warnings.