Box class abstract
A base class for axis-aligned bounding boxes with min & max coordinates.
The known two sub classes are ProjBox
(with minX, minY, minZ, minM, maxX,
maxY, maxZ and maxM coordinates) and GeoBox
(with west, south, minElev,
minM, east, north, maxElev and maxM coordinates).
It's also possible to create a bounding box using factory methods Box.view, Box.create, Box.from and Box.parse that create an instance storing coordinate values in a double array.
Supported coordinate value combinations by coordinate type:
Type | Bounding box values |
---|---|
xy | minX, minY, maxX, maxY |
xyz | minX, minY, minZ, maxX, maxY, maxZ |
xym | minX, minY, minM, maxX, maxY, maxM |
xyzm | minX, minY, minZ, minM, maxX, maxY, maxZ, maxM |
For geographic bounding boxes:
Type | Bounding box values |
---|---|
xy | west, south, east, north |
xyz | west, south, minElev, east, north, maxElev |
xym | west, south, minM, east, north, maxM |
xyzm | west, south, minElev, minM, east, north, maxElev, maxM |
Sub classes containing coordinate values mentioned above, should implement equality and hashCode methods as:
@override
bool operator ==(Object other) =>
other is Box && Box.testEquals(this, other);
@override
int get hashCode => Box.hash(this);
- Inheritance
- Implementers
Constructors
- Box()
-
Default
const
constructor to allow extending this abstract class.const - Box.create({required double minX, required double minY, double? minZ, double? minM, required double maxX, required double maxY, double? maxZ, double? maxM})
-
A bounding box from parameters compatible with
CreateBox
function type.factory -
Box.from(Iterable<
Position> positions) -
A minimum bounding box calculated from
positions
.factory - Box.parse(String text, {Pattern delimiter = ',', Coords? type, bool swapXY = false, bool singlePrecision = false})
-
Parses a bounding box from
text
.factory -
Box.view(List<
double> source, {Coords? type}) -
A bounding box with coordinate values as a view backed by
source
.factory
Properties
- conforming → PositionScheme
-
Returns a position scheme this bounding box is conforming to.
no setter
- coordinateDimension → int
-
The number of coordinate values (2, 3 or 4) on a position.
no setterinherited
- coordType → Coords
-
A value of Coords representing the coordinate type of position data
contained directly or within child objects.
no setterinherited
-
corners2D
→ Iterable<
Position> -
Returns all distinct (in 2D) corners for this axis aligned bounding box.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → double
-
The height of the bounding box, equals to
maxY - minY
.no setter - is3D → bool
-
True for 3D positions (with z or elevation coordinate).
no setterinherited
- isMeasured → bool
-
True if a measure value is available (or the m coordinate for a position).
no setterinherited
- max → Position
-
The maximum position (or east-north) of this bounding box.
no setter
- maxM → double?
-
The maximum m coordinate optionally. Returns null if not available.
no setter
- maxX → double
-
The maximum x (or east) coordinate.
no setter
- maxY → double
-
The maximum y (or north) coordinate.
no setter
- maxZ → double?
-
The maximum z coordinate optionally. Returns null if not available.
no setter
- min → Position
-
The minimum position (or west-south) of this bounding box.
no setter
- minM → double?
-
The minimum m coordinate optionally. Returns null if not available.
no setter
- minX → double
-
The minimum x (or west) coordinate.
no setter
- minY → double
-
The minimum y (or south) coordinate.
no setter
- minZ → double?
-
The minimum z coordinate optionally. Returns null if not available.
no setter
- positionCount → int
-
A Box object represents two positions (min and max), returns always
2
.no setteroverride - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- spatialDimension → int
-
The number of spatial coordinate values (2 for 2D or 3 for 3D) on a
position.
no setterinherited
- type → Coords
-
The coordinate type.
no setterinherited
- valueCount → int
-
The number of coordinate values contained.
no setterinherited
-
values
→ Iterable<
double> -
Coordinate values of this bounding box as an iterable of 4, 6 or 8 items.
no setteroverride
- width → double
-
The width of the bounding box, equals to
maxX - minX
.no setter
Methods
-
aligned2D(
[Aligned align = Aligned.center]) → Position - Returns an aligned 2D position relative to this box.
-
copyByType(
Coords type) → Box -
Copies
this
as another object according to the giventype
.override -
copyTo<
R extends Box> (CreateBox< R> factory) → R -
Copies this box to a new box created by the
factory
. -
copyWith(
{double? minX, double? minY, double? minZ, double? minM, double? maxX, double? maxY, double? maxZ, double? maxM}) → Box - Copies this box with optional attributes overriding values.
-
equals2D(
covariant Box other, {double toleranceHoriz = defaultEpsilon}) → bool -
True if this box equals with
other
by testing 2D coordinates only.override -
equals3D(
covariant Box other, {double toleranceHoriz = defaultEpsilon, double toleranceVert = defaultEpsilon}) → bool -
True if this box equals with
other
by testing 3D coordinates only.override -
equalsCoords(
covariant Box other) → bool -
True if this and the
other
box equals.override -
intersects(
Box other) → bool -
Returns true if this bounding box intesects with
other
box. -
intersects2D(
Box other) → bool -
Returns true if this bounding box intersects with
other
box in 2D. -
intersectsPoint(
Position point) → bool -
Returns true if this bounding box intesects with
point
. -
intersectsPoint2D(
Position point) → bool -
Returns true if this bounding box intesects with
point
in 2D. -
length2D(
) → double - Returns the perimeter of the area represented by this bounding box calculated in a cartesian 2D plane.
-
merge(
Box other) → Box -
Returns a minimum bounding box containing both this and
other
. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
project(
Projection projection) → Box -
Projects this bounding box to another box using
projection
.override -
splitUnambiguously(
) → Iterable< Box> - Returns unambiguous bounding boxes whose merged area equals with this bounding box.
-
toString(
) → String -
A string representation of this object.
override
-
toText(
{String delimiter = ',', int? decimals, bool compactNums = true, bool swapXY = false}) → String -
Returns coordinate values as a string separated by
delimiter
.override -
valuesByType(
Coords type) → Iterable< double> -
Coordinate values as a double iterable according to the given
type
.override
Operators
-
operator *(
double factor) → Box -
Returns a bounding box with coordinate values of this scaled by
factor
. -
operator +(
Position addend) → Box -
Returns a bounding box with min and max coordinate values of this summed
with coordinate values of
addend
. -
operator -(
Position subtract) → Box -
Returns a bounding box with min and max coordinate values of this
subtracted with coordinate values of
subtract
. -
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator unary-(
) → Box - Returns a bounding box with coordinate values of this negated.
Static Methods
-
buildBox<
R extends Box> (Iterable< num> coords, {required CreateBox<R> to, int offset = 0, Coords? type, bool swapXY = false}) → R -
Builds a bounding box of
R
fromcoords
starting fromoffset
. -
createAligned2D<
R extends Position> (Box box, CreatePosition< R> factory, {Aligned align = Aligned.center}) → R -
Returns an aligned 2D position relative to
box
. -
createBoxFrom<
R extends Box> (Iterable< Position> positions, CreateBox<R> factory) → R -
A minimum bounding box created by
factory
, calculated frompositions
. -
createCorners2D<
R extends Position> (Box box, CreatePosition< R> factory) → Iterable<R> - Returns all distinct (in 2D) corners for this axis aligned bounding box.
-
createFromObject<
R extends Box> (Object box, {required CreateBox< R> to, Coords? type}) → R -
Creates a bounding box of
R
frombox
(ofR
orIterable<num>
). -
createMerged<
R extends Box> (Box box1, Box box2, CreateBox< R> factory) → R -
Returns a minimum bounding box created by
factory
containing bothbox1
andbox2
. -
getValues(
Box box, {required Coords type}) → Iterable< double> -
Coordinate values of this bounding box as an iterable of 4, 6 or 8 items
according to
type
. -
hash(
Box box) → int -
The hash code for
box
.override -
parseBox<
R extends Box> (String text, {required CreateBox< R> to, Pattern delimiter = ',', Coords? type, bool swapXY = false}) → R -
Creates a bounding box of
R
fromtext
. -
testEquals(
Box box1, Box box2) → bool -
True if
box1
andbox2
equals by testing all coordinate values. -
testEquals2D(
Box box1, Box box2, {double toleranceHoriz = defaultEpsilon}) → bool -
True if positions
box1
andbox2
equals by testing 2D coordinates only. -
testEquals3D(
Box box1, Box box2, {double toleranceHoriz = defaultEpsilon, double toleranceVert = defaultEpsilon}) → bool -
True if positions
box1
andbox2
equals by testing 3D coordinates only. -
testIntersects(
Box box1, Box box2) → bool -
Returns true if
box1
andbox2
intersects. -
testIntersects2D(
Box box1, Box box2) → bool -
Returns true if
box1
andbox2
intersects in 2D. -
testIntersectsPoint(
Box box, Position point) → bool -
Returns true if
box
intesects withpoint
. -
testIntersectsPoint2D(
Box box, Position point) → bool -
Returns true if
box
intesects withpoint
in 2D. -
writeValues(
Box box, StringSink buffer, {String delimiter = ',', int? decimals, bool compactNums = true, bool swapXY = false}) → void -
Writes coordinate values of
box
tobuffer
separated bydelimiter
.