You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The class definition for features could be modified to include a generic type parameter to specify what type of geometry a feature holds. e.g.
classFeature<outT:Geometry?>(
valgeometry:T// Rest of Feature class definition...valp:Feature<Point> = Feature(Point(...))
p.geometry // is Point
This would facilitate passing Features in to turf functions as noted in #71.
Pros
Feature geometry can be made type-safe, reducing the number of runtime type checks on a feature's geometry in some cases
The Turf port can take advantage of this allowing for only certain types of features to be passed into some functions
Cons
Collections of features often hold many different types of geometry so any type-safety gains from this feature would be lost, and either star-projection or filling the generic type with Geometry or Geometry? repeatedly would be required.
Some Turf function signatures will conflict for specialized feature overloads. e.g. length(feature: Feature<?>, ...)
Open Questions
Should FeatureCollections have a generic type applied to them too?
FeatureCollection<LineString> // denotes a collection of LineString features
Should the properties of the feature class also be made a generic type to allow for type-safe feature properties?
The text was updated successfully, but these errors were encountered:
Regarding the cons, is it despite to use a generic type parameter? Then I'd like to open a PR for it. I think a FeatureCollection shouldn't have a generic type parameter. Cause the features could be polymorph so in many cases it would be FeatureCollection<Geometry>, which may be some overhead to define it every time. Even on updating/edit a collection this type parameter may have to be updated, this is unhandy on consumer side.
The class definition for features could be modified to include a generic type parameter to specify what type of geometry a feature holds. e.g.
This would facilitate passing
Feature
s in to turf functions as noted in #71.Pros
Cons
Geometry
orGeometry?
repeatedly would be required.length(feature: Feature<?>, ...)
Open Questions
FeatureCollection
s have a generic type applied to them too?The text was updated successfully, but these errors were encountered: