Repository navigation
feat(geojson): encode Polygon geometries and validate ring orientation - #22
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #22 +/- ##
===========================================
Coverage 100.00% 100.00%
- Complexity 161 173 +12
===========================================
Files 14 15 +1
Lines 296 317 +21
===========================================
+ Hits 296 317 +21 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Closes #13.
GeoJsonStrategy now encodes Geometry and Geography Polygons in XY/XYZ, including EMPTY, preserving rings, positions, Z and coordinates without reference metadata. For example,
[[[0,0],[2,0],[0,2],[0,0]]]produces{"type":"Polygon","coordinates":[[[0,0],[2,0],[0,2],[0,0]]]}. XYM/XYZM remain rejected, including EMPTY.Every ring is checked using signed XY area: exterior area must be positive, interior area negative, and zero area raises UnsupportedGeometryStructureException. This implements the approved normative decision for RFC 7946 section 3.1.6. Rings are never repaired or reversed. No separate simplicity/self-intersection validation is added; general topology remains the caller's responsibility. Antimeridian coordinates are unchanged, with the deliberate non-application of RFC 7946 section 3.1.9 and interoperability implications documented.
An internal GeoJson/GeometryEncoder now contains the geometry dispatch and private encoding methods. This necessary extraction keeps the existing PHPMD coupling threshold satisfied without weakening rules. GeoJsonStrategy retains dimension checks and JSON exception wrapping. Existing public APIs, exceptions and other strategy behavior remain unchanged; no breaking changes or dependency changes.
Added 36 explicit Polygon examples across both families plus Polygon interface and JSON-failure tests (38 new tests total). Existing GeoJSON tests only gain coverage metadata for the internal extraction. Updated docs/strategies.md and tests/README.md with usage, EMPTY, dimensions, caller responsibilities, invariant findings and the approved policy.
Validation:
vendor/bin/phpunit --no-coverage --filter GeoJson: 194 tests, 656 assertions passed before the internal extraction.composer test: final code passes 914 tests, 1428 assertions with PCOV.composer quality: PHP CS Fixer, PHPStan level 9, PHPMD and PHPCS pass. Existing PHPMD/PDepend dependency deprecation messages remain non-fatal.git diff --cached --check: passed.The normative gate is resolved by the linked approval; no unresolved implementation gate. Signed-area checks are not a general topology validator. No reviewer has been launched or requested, per Alexandre's instruction. Independent review and merge remain outstanding; the Story is not declared Done.