navibyte / geospatial

Geospatial data structures, tools and utilities for Dart and Flutter.
Other
51 stars 5 forks source link

True dimensionality for geometry #231

Closed navispatial closed 2 months ago

navispatial commented 2 months ago

New methods to Geometry:

  /// Returns the true *dimensionality* of this geometry in 2D.
  ///
  /// The value returned:
  /// * If `area2D() > 0.0` then `Dimensionality.areal` is returned.
  /// * Otherwise if `length2D() > 0.0` then `Dimensionality.linear` is
  ///   returned.
  /// * Otherwise `Dimensionality.punctual` is returned.
  ///
  /// This mean that even if a polygon geometry is "areal" the value
  /// `Dimensionality.areal` is returned only if a polygon has non-zero area.
  ///
  /// See also [Dimensionality].
  Dimensionality dimensionality2D() {
    if (area2D() > 0.0) {
      return Dimensionality.areal;
    } else if (length2D() > 0.0) {
      return Dimensionality.linear;
    }

    return Dimensionality.punctual;
  }
navispatial commented 2 months ago

Implemented in geobase version 1.1.0, see milestone.