navibyte / geospatial

Geospatial data structures, tools and utilities for Dart and Flutter.
https://geospatial.navibyte.dev
Other
54 stars 5 forks source link

Populating and unpopulating bounds in geometries and feature objects #197

Closed navispatial closed 1 year ago

navispatial commented 1 year ago

Implicit and explicit bounds was implemented in #141.

This issue suggest some changes to the interface defined in Bounded, especially for the bounded method.

The old API has been (since 0.5.x):

  /// Returns a bounded object with a bounding box populated in [bounds] (and
  /// in any subitem bounding boxes too). Other properties are left intact.
  ///
  /// The returned subtype must be the same as the type of this.
  ///
  /// The [recalculate] parameter:
  /// * false: `bounds` for a returned object is calculated if [bounds] is null
  /// * true: `bounds` for a returned object is always recalculated
  ///
  /// When a calculated bounding box equals to the current bounds of this (or
  /// bounds cannot be calculated), it's allowed for implementations to return
  /// `this`.
  ///
  /// The `bounds` in returned bounded object may still be null, if bounds
  /// cannot be calculated (for example in the case of an empty geometry).
  Bounded bounded({bool recalculate = false});

However there are some inconsistencies on implementations.

The new API would be:

  /// Returns a bounded object of the same subtype as this with certain
  /// properties populated.
  ///
  /// If nothing is populated then `this` is returned.
  ///
  /// If [onBounds] is true (as by default):
  /// * The `bounds` in a returned bounded object is ensured to be populated
  ///   (expect when cannot be calculated, for example in the case of an empty
  ///   geometry).
  /// * If [traverse] is true, then also bounding boxes of any child bounded
  ///   objects are populated.
  Bounded populated({
    bool traverse = false,
    bool onBounds = true,
  });

  /// Returns a bounded object of the same subtype as this with certain
  /// properties unpopulated (or cleared).
  ///
  /// If nothing is unpopulated then `this` is returned.
  ///
  /// If [onBounds] is true (as by default):
  /// * The `bounds` in a returned bounded object is ensured to be unpopulated.
  /// * If [traverse] is true, then also bounding boxes of any child bounded
  ///   objects are unpopulated.
  Bounded unpopulated({
    bool traverse = false,
    bool onBounds = true,
  });

The new API shall be released in version 0.6.x. This old API shall be deprecated, to be removed by version 1.0.0.

navispatial commented 1 year ago

Implemented in geobase 0.6.0