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
GPX has a ton of well-defined attributes that can be present on each wpt, rtept, and trkpt element, but almost all of them are optional, and very few of them are actually specified on any given instance (different producers seem to favor different sets of them).
This makes it rather awkward to consume an IAttributesTable in order to produce elements from the GPX data model, since every optional value retrieved has to look like:
varfeature=/* some feature */;varattributes= feature.Attributes;vartimestampUtc= attributes.Exists(nameof(GpxWaypoint.TimestampUtc))?(DateTime)attributes[nameof(GpxWaypoint.TimestampUtc)]:default(DateTime?);
I don't think this concept is necessarily limited to GPX (otherwise I'd just live with extension methods). It feels like this abstraction should simplify fetching optional attributes without requiring an extra virtual call and dictionary lookup for each one.
In my fantasy land, I can see myself writing:
varfeature=/* some feature */;varattributes= feature.Attributes;vartimestampUtc=(DateTime?)attributes.GetOptionalValue(nameof(GpxWaypoint.TimestampUtc));
The implementation would be a bit annoying:
publicclassAttributesTable{/* ...*/publicobjectGetOptionalValue(stringattributeName){objectresult=null;
#if SERIALIZATION_COMPAT_NETTOPOLOGYSUITE_FEATURES_ATTRIBUTESTABLE
// System.Collections.Hashtable doesn't have a way to skip this double-lookupif(_attributes.ContainsKey(attributeName)){result= _attributes[attributeName];}
#else
_attributes.TryGetValue(attributeName,out result);
#endif
returnresult;}}
The text was updated successfully, but these errors were encountered:
- All CoordinateSystems types are gone (resolves#7)
- (I)AttributesTable is gone, in favor of bare Dictionary<string, object> (resolves#6) (resolves#3)
- FeatureCollection now inherits from Collection<Feature>
- [Serializable] is now implemented via ISerializable
- All CoordinateSystems types are gone (resolves#7)
- The extension methods dealing with ID values on IFeature instances are gone
- to be moved to GeoJSON
- (I)AttributesTable now has GetOptionalValue (resolves#3)
- FeatureCollection now inherits from Collection<Feature>
- [Serializable] is now implemented via ISerializable
GPX has a ton of well-defined attributes that can be present on each
wpt
,rtept
, andtrkpt
element, but almost all of them are optional, and very few of them are actually specified on any given instance (different producers seem to favor different sets of them).This makes it rather awkward to consume an
IAttributesTable
in order to produce elements from the GPX data model, since every optional value retrieved has to look like:I don't think this concept is necessarily limited to GPX (otherwise I'd just live with extension methods). It feels like this abstraction should simplify fetching optional attributes without requiring an extra virtual call and dictionary lookup for each one.
In my fantasy land, I can see myself writing:
The implementation would be a bit annoying:
The text was updated successfully, but these errors were encountered: