diff --git a/dart/geobase/lib/src/coordinates/base/bounded.dart b/dart/geobase/lib/src/coordinates/base/bounded.dart index 3680ad1..f7a86a4 100644 --- a/dart/geobase/lib/src/coordinates/base/bounded.dart +++ b/dart/geobase/lib/src/coordinates/base/bounded.dart @@ -4,7 +4,6 @@ // // Docs: https://github.com/navibyte/geospatial -import '/src/constants/epsilon.dart'; import '/src/coordinates/base/box.dart'; import '/src/coordinates/projection/projection.dart'; @@ -91,50 +90,4 @@ abstract class Bounded extends Positionable { /// projecting position data. If [bounds] is null, then it's null after /// projecting too. Bounded project(Projection projection); - - /// True if this and [other] contain exactly same coordinate values (or both - /// are empty) in the same order and with the same coordinate type. - bool equalsCoords(covariant Bounded other); - - /// True if this and [other] equals by testing 2D coordinate values of all - /// position data (that must be in same order in both objects) contained - /// directly or by child objects. - /// - /// Returns false if this and [other] are not of the same subtype. - /// - /// Returns false if this or [other] contain "empty geometry" - /// ([isEmptyByGeometry] true). - /// - /// Differences on 2D coordinate values (ie. x and y, or lon and lat) between - /// this and [other] must be within [toleranceHoriz]. - /// - /// Tolerance values must be positive (>= 0.0). - bool equals2D( - covariant Bounded other, { - double toleranceHoriz = defaultEpsilon, - }); - - /// True if this and [other] equals by testing 3D coordinate values of all - /// position data (that must be in same order in both objects) contained - /// directly or by child objects. - /// - /// Returns false if this and [other] are not of the same subtype. - /// - /// Returns false if this or [other] contain "empty geometry" - /// ([isEmptyByGeometry] true). - /// - /// Returns false if this or [other] do not contain 3D coordinates. - /// - /// Differences on 2D coordinate values (ie. x and y, or lon and lat) between - /// this and [other] must be within [toleranceHoriz]. - /// - /// Differences on vertical coordinate values (ie. z or elev) between - /// this and [other] must be within [toleranceVert]. - /// - /// Tolerance values must be positive (>= 0.0). - bool equals3D( - covariant Bounded other, { - double toleranceHoriz = defaultEpsilon, - double toleranceVert = defaultEpsilon, - }); } diff --git a/dart/geobase/lib/src/coordinates/base/box.dart b/dart/geobase/lib/src/coordinates/base/box.dart index 9e01313..547261a 100644 --- a/dart/geobase/lib/src/coordinates/base/box.dart +++ b/dart/geobase/lib/src/coordinates/base/box.dart @@ -452,12 +452,17 @@ abstract class Box extends ValuePositionable { /// box when forward-projecting, and other way when inverse-projecting). Box project(Projection projection); + /// True if this and the [other] box equals. + @override + bool equalsCoords(Box other) => this == other; + /// True if this box equals with [other] by testing 2D coordinates only. /// /// Differences on 2D coordinate values (ie. x and y, or lon and lat) between /// this and [other] must be within [toleranceHoriz]. /// /// Tolerance values must be positive (>= 0.0). + @override bool equals2D(Box other, {double toleranceHoriz = defaultEpsilon}) => Box.testEquals2D(this, other, toleranceHoriz: toleranceHoriz); @@ -472,6 +477,7 @@ abstract class Box extends ValuePositionable { /// this and [other] must be within [toleranceVert]. /// /// Tolerance values must be positive (>= 0.0). + @override bool equals3D( Box other, { double toleranceHoriz = defaultEpsilon, diff --git a/dart/geobase/lib/src/coordinates/base/position.dart b/dart/geobase/lib/src/coordinates/base/position.dart index d23f12f..d700386 100644 --- a/dart/geobase/lib/src/coordinates/base/position.dart +++ b/dart/geobase/lib/src/coordinates/base/position.dart @@ -423,12 +423,17 @@ abstract class Position extends ValuePositionable { /// The returned object should be of the same type as this object has. Position transform(TransformPosition transform); + /// True if this and the [other] position equals. + @override + bool equalsCoords(Position other) => this == other; + /// True if this position equals with [other] by testing 2D coordinates only. /// /// Differences on 2D coordinate values (ie. x and y, or lon and lat) between /// this and [other] must be within [toleranceHoriz]. /// /// Tolerance values must be positive (>= 0.0). + @override bool equals2D( Position other, { double toleranceHoriz = defaultEpsilon, @@ -446,6 +451,7 @@ abstract class Position extends ValuePositionable { /// this and [other] must be within [toleranceVert]. /// /// Tolerance values must be positive (>= 0.0). + @override bool equals3D( Position other, { double toleranceHoriz = defaultEpsilon, diff --git a/dart/geobase/lib/src/coordinates/base/position_series.dart b/dart/geobase/lib/src/coordinates/base/position_series.dart index ca4d870..bfcc931 100644 --- a/dart/geobase/lib/src/coordinates/base/position_series.dart +++ b/dart/geobase/lib/src/coordinates/base/position_series.dart @@ -493,6 +493,7 @@ abstract class PositionSeries implements ValuePositionable { /// Returns true if this and [other] contain exactly same coordinate values /// (or both are empty) in the same order and with the same coordinate type. + @override bool equalsCoords(PositionSeries other) { if (identical(this, other)) return true; if (positionCount != other.positionCount) return false; @@ -522,6 +523,7 @@ abstract class PositionSeries implements ValuePositionable { /// this and [other] must be within [toleranceHoriz]. /// /// Tolerance values must be positive (>= 0.0). + @override bool equals2D( PositionSeries other, { double toleranceHoriz = defaultEpsilon, @@ -563,6 +565,7 @@ abstract class PositionSeries implements ValuePositionable { /// this and [other] must be within [toleranceVert]. /// /// Tolerance values must be positive (>= 0.0). + @override bool equals3D( PositionSeries other, { double toleranceHoriz = defaultEpsilon, diff --git a/dart/geobase/lib/src/coordinates/base/positionable.dart b/dart/geobase/lib/src/coordinates/base/positionable.dart index 27f346e..e627a44 100644 --- a/dart/geobase/lib/src/coordinates/base/positionable.dart +++ b/dart/geobase/lib/src/coordinates/base/positionable.dart @@ -5,6 +5,7 @@ // Docs: https://github.com/navibyte/geospatial import '/src/codes/coords.dart'; +import '/src/constants/epsilon.dart'; /// A positionable object contains data structures for (geospatial) position /// data, directly or within child objects. @@ -30,4 +31,48 @@ abstract class Positionable { /// `Coords.xym`, then `Coords.xy` is returned. When all items are /// `Coords.xyz`, then `Coords.xyz` is returned. Coords get coordType; + + /// True if this and [other] contain exactly same coordinate values (or both + /// are empty) in the same order and with the same coordinate type. + bool equalsCoords(covariant Positionable other); + + /// True if this and [other] equals by testing 2D coordinate values of all + /// position data (that must be in same order in both objects) contained + /// directly or by child objects. + /// + /// Returns false if this and [other] are not of the same subtype. + /// + /// Returns false if this or [other] contain "empty geometry". + /// + /// Differences on 2D coordinate values (ie. x and y, or lon and lat) between + /// this and [other] must be within [toleranceHoriz]. + /// + /// Tolerance values must be positive (>= 0.0). + bool equals2D( + covariant Positionable other, { + double toleranceHoriz = defaultEpsilon, + }); + + /// True if this and [other] equals by testing 3D coordinate values of all + /// position data (that must be in same order in both objects) contained + /// directly or by child objects. + /// + /// Returns false if this and [other] are not of the same subtype. + /// + /// Returns false if this or [other] contain "empty geometry". + /// + /// Returns false if this or [other] do not contain 3D coordinates. + /// + /// Differences on 2D coordinate values (ie. x and y, or lon and lat) between + /// this and [other] must be within [toleranceHoriz]. + /// + /// Differences on vertical coordinate values (ie. z or elev) between + /// this and [other] must be within [toleranceVert]. + /// + /// Tolerance values must be positive (>= 0.0). + bool equals3D( + covariant Positionable other, { + double toleranceHoriz = defaultEpsilon, + double toleranceVert = defaultEpsilon, + }); } diff --git a/dart/geobase/test/coordinates/position_test.dart b/dart/geobase/test/coordinates/position_test.dart index dd9b7fd..362aa4c 100644 --- a/dart/geobase/test/coordinates/position_test.dart +++ b/dart/geobase/test/coordinates/position_test.dart @@ -677,6 +677,9 @@ class _TestXYZM implements Projected { @override String toString() => '$x,$y,$z,$m'; + @override + bool equalsCoords(Position other) => this == other; + @override bool equals2D( Position other, {