Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds generic FeatureCollection #105

Closed
wants to merge 1 commit into from
Closed

adds generic FeatureCollection #105

wants to merge 1 commit into from

Conversation

wagich
Copy link

@wagich wagich commented Apr 2, 2018

This PR adds a generic FeatureCollection<TProps> (and creates an interface for Feature to implement because TGeometry needs to be covariant). This enables the property objects in each feature to be directly serialized using JSON.NET instead of manually using a dictionary. See #104 for use-case.

@supermihi
Copy link
Contributor

Looks good to me. Actuallty, it would be nice to have a non-generic IFeature interface above the generice version. Currently, the situation is somewhat awkward because a Feature<T> is not a Feature (in the OOP sense), which it should semantically be.

@aplitomart
Copy link

aplitomart commented Nov 7, 2019

It would be cool to have generic version of FeatureCollection also because sometimes I have to mark properties inside Properties with JsonPropertyAttribute, and constructor of a non-generic Feature converts properties object into a dictionary with property names as keys ignoring names in JsonPropertyAttribute.

@YaroslavKormushyn
Copy link

@matt-lethargic would this be possible to include in the next RC if I were to adjust it a bit to the latest codebase? I'm using strongly-typed properties in my features, which is a real pain to configure with the serializer/deserializer mechanism right now.

@matt-lethargic
Copy link
Member

Hey @YaroslavKormushyn forgive my memory, what would be the goal be for this?
I've no idea why this got closed TBH

@YaroslavKormushyn
Copy link

Hey @YaroslavKormushyn forgive my memory, what would be the goal be for this?
I've no idea why this got closed TBH

This is a change to the existing rigid typing of FeatureCollection and Feature to make them extendable, e.g. define strongly-typed properties for features and allow to follow the L in SOLID.

Right now (for me at least) to have a strongly-typed properties object in the features and make it work with the json serializer means recreating the collection and feature classes with the necessary types and using those. This PR makes this easier by having generic interfaces. This still should have a default implementation, so that existing code works without change.

@YaroslavKormushyn
Copy link

On that note: is there a way to define a FeatureCollection with features that have strongly-typed properties (and still have the flexibility of omitting the geometry)? Right now we have a FeatureCollection where each Feature has an IDictionary<string, object> properties type. If we want to have that dictionary as a custom type with its own model validation and rich functionality - we should either inherit from existing FeatureCollection or copy-paste the FeatureCollection implementation, but substitute the List<Feature> for List<Feature<IGeometryObject, MyCustomPropertiesType>>.

I may be missing something here because I didn't read through all the available types and how they were written.

@wagich
Copy link
Author

wagich commented Apr 28, 2022

Nice to see this get some traction 👍 TBH I've since switched to different library, but would be happy to help.

@YaroslavKormushyn: regarding your last comment, I'm not sure I follow…
The generic feature collection from the PR already doesn't really care about the geometry, the list is typed as IFeature<out TGeometry, TProps> where TGeometry is covariant so you can add a feature with any geometry.

@YaroslavKormushyn
Copy link

@wagich yeah, you followed it perfectly, the PR covers everything we need :)

@YaroslavKormushyn
Copy link

I will be creating a PR with these changes to the current codebase later today. I'll mention the original authors so that we can trace these changes correctly and add a mention to this PR.

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.

5 participants