geojson: handle extra/foreign members in featureCollection#56
Merged
geojson: handle extra/foreign members in featureCollection#56
Conversation
no speed improvement but lots of bytes saved benchmark old bytes new bytes delta BenchmarkFeatureUnmarshalJSON-12 941182 828250 -12.00%
b171dd5 to
3cb1eb0
Compare
This was referenced Oct 12, 2021
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.
Foreign Members are those that aren’t in the spec. i.e. properties in the feature collection object that aren’t the big 3,
type,bboxandfeatures.Support for this has been requested 3 times. #1 #13 #42
This PR adds full support to those features by storing them in a
ExtraMembersmap in the feature collection. These members will be encoded/decoded to/from the base feature collection as expected.Concerns
There was an example and issue response suggesting to embed a feature collection in another object like so
This approach will no longer work and has been abandoned because marshaling/encoding was not supported. To maintain this behavior one can add a
UnmarshalJSON()method on the new struct type like so:Note: you could still do this to keep things type safe but the reverse
MarshalJSONwould also need to be implemented for encoding to work.Performance
Benchmarks did no show any meaningful change in performance after this change.