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

Feature Generics #136

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

elcolto
Copy link
Contributor

@elcolto elcolto commented May 6, 2024

This is a proposal to add a generic type parameter to Feature

These changes would lead to several questions. Which are partly already mentioned in #76

  • Accessing features property in FeatureCollection and this class itself would always return a List<Feature<Geometry>>. This would lead to instances checks on each feature. (Could be handled with an exhaustive when)
  • This can cause flaws when a Geometry type in some cases of a FeatureCollection is probably known. For example you know, a function will return a FeatureCollection containing only LineStrings. This may lead to code like this:
featureCollection.forEach { feature ->
    when (feature.geometry) {
        is LineString -> { /* do something */ }
        null -> { /* nothing */ }
        else -> error("type is not applicable in this case")
    }
}

On the other hand, a generic type parameter for containing geometries within containing features on FeatureCollection is misleading. It doesn't has a direct relation to the FeatureCollection itself and it doesn't match really match the case of polymorphic FeatureCollections. This would always be FeatureCollection<Geometry> which is kind of redundant to declare this every time for the most cases.

Please share some thoughts.

@elcolto elcolto force-pushed the feature/issue76-feature-generics branch 2 times, most recently from b9f5f79 to 2d0e351 Compare May 6, 2024 20:34
@elcolto elcolto force-pushed the feature/issue76-feature-generics branch from 2d0e351 to 92e53b4 Compare May 8, 2024 05:53
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