Skip to content

Clear stale geometry fields when decoding into reused objects - #181

Open
vitalivo wants to merge 1 commit into
paulmach:masterfrom
vitalivo:fix/reused-geometry-decoding
Open

vitalivo wants to merge 1 commit into
paulmach:masterfrom
vitalivo:fix/reused-geometry-decoding

Conversation

@vitalivo

Copy link
Copy Markdown

This replaces #180, which was accidentally closed and its source fork deleted. The implementation is unchanged; the original discussion and reviews remain linked there.


Decoding a GeometryCollection into a Geometry that previously held a Point leaves the old Coordinates in place. Geometry() then returns that Point and even sets the decoded type back to Point. In the other direction, stale Geometries remain and can take precedence when the object is marshalled again.

Clear the inactive geometry representation after a successful decode, for both JSON and BSON. Tests reuse objects in both directions and check the stored fields and resulting orb.Geometry.

Validation: all four codec/direction cases fail before the fix. go test -race ./..., go vet ./..., and staticcheck ./geojson pass. GeoJSON statement coverage is 89.3%.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant