GeoBox class

A geographic bounding box with west, south, east and north values.

West and east represents geographic longitude coordinates values. South and north represents geographic latitude coordinates values.

For geographic bounding boxes (west-longitude, south-latitude) position represents the most southwesterly point, and (east-longitude, north-latitude) position represents the more northeasterly point. When a bounding box spans the antimeridian, it's possible that "min-longitude" (west) is larger than "max-longitude" (east) as a number. See also RFC 7946 chapter 5 about bounding boxes in GeoJSON for reference.

Optional minElev and maxElev for 3D boxes, and minM and maxM for measured boxes can be provided too.

Supported coordinate value combinations by coordinate type:

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
Inheritance
Annotations
  • @immutable

Constructors

GeoBox({required double west, required double south, double? minElev, double? minM, required double east, required double north, double? maxElev, double? maxM})
A geographic bounding box with west, south, east and north values.
const
GeoBox.build(Iterable<num> coords, {int offset = 0, Coords? type})
Builds a geographic bounding box from coords starting from offset.
factory
GeoBox.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.
const
GeoBox.from(Iterable<Geographic> positions)
A minimum bounding box calculated from positions.
factory
GeoBox.parse(String text, {Pattern delimiter = ',', Coords? type, bool swapXY = false})
Parses a geographic bounding box from text.
factory
GeoBox.parseDms({DmsFormat format = const Dms(), required String west, required String south, String? minElev, String? minM, required String east, required String north, String? maxElev, String? maxM})
Parses a geographic bounding box from west, south, east and north values that are formatted as specified (and parsed) by format.
factory

Properties

complementaryGeographically GeoBox
Returns the "geographically complementary" bounding box for the same latitude band with this.
no setter
conforming PositionScheme
Returns a position scheme this bounding box is conforming to.
no setteroverride
coordinateDimension int
The number of coordinate values (2, 3 or 4) on a position.
no setteroverride
coordType Coords
A value of Coords representing the coordinate type of position data contained directly or within child objects.
no setterinherited
corners2D Iterable<Geographic>
Returns all distinct (in 2D) corners for this axis aligned bounding box.
no setteroverride
east double
The east coordinate as geographic longitude.
no setter
hashCode int
The hash code for this object.
no setteroverride
height double
The height of the bounding box, equals to maxY - minY.
no setteroverride
is3D bool
True for 3D positions (with z or elevation coordinate).
no setteroverride
isMeasured bool
True if a measure value is available (or the m coordinate for a position).
no setteroverride
max Geographic
The "east-north" geographic position of this bounding box.
no setteroverride
maxElev double?
The maximum elevation (or altitude) coordinate in meters optionally.
no setter
maxM double?
The maximum m coordinate optionally. Returns null if not available.
no setteroverride
maxX double
The maximum x (or east) coordinate.
no setteroverride
maxY double
The maximum y (or north) coordinate.
no setteroverride
maxZ double?
The maximum z coordinate optionally. Returns null if not available.
no setteroverride
min Geographic
The "west-south" geographic position of this bounding box.
no setteroverride
minElev double?
The minimum elevation (or altitude) coordinate in meters optionally.
no setter
minM double?
The minimum m coordinate optionally. Returns null if not available.
no setteroverride
minX double
The minimum x (or west) coordinate.
no setteroverride
minY double
The minimum y (or south) coordinate.
no setteroverride
minZ double?
The minimum z coordinate optionally. Returns null if not available.
no setteroverride
north double
The north coordinate as geographic latitude.
no setter
positionCount int
A Box object represents two positions (min and max), returns always 2.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
south double
The south coordinate as geographic latitude.
no setter
spansAntimeridian bool
True when this bounding box spans the antimeridian (that is "min-longitude" (west) is larger than "max-longitude" (east) as a number).
no setter
spatialDimension int
The number of spatial coordinate values (2 for 2D or 3 for 3D) on a position.
no setteroverride
type Coords
The coordinate type.
no setteroverride
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 setterinherited
west double
The west coordinate as geographic longitude.
no setter
width double
The width of the bounding box, equals to maxX - minX.
no setteroverride

Methods

aligned2D([Aligned align = Aligned.center]) Geographic
Returns an aligned 2D position relative to this box.
override
copyByType(Coords type) GeoBox
Copies this as another object according to the given type.
override
copyTo<R extends Box>(CreateBox<R> factory) → R
Copies this box to a new box created by the factory.
inherited
copyWith({double? minX, double? minY, double? minZ, double? minM, double? maxX, double? maxY, double? maxZ, double? maxM}) GeoBox
Copies this box with optional attributes overriding values.
override
eastDms([DmsFormat format = const Dms()]) String
Formats east according to format.
equals2D(covariant Box other, {double toleranceHoriz = defaultEpsilon}) bool
True if this box equals with other by testing 2D coordinates only.
inherited
equals3D(covariant Box other, {double toleranceHoriz = defaultEpsilon, double toleranceVert = defaultEpsilon}) bool
True if this box equals with other by testing 3D coordinates only.
inherited
equalsCoords(covariant Box other) bool
True if this and the other box equals.
inherited
intersects(Box other) bool
Returns true if this bounding box intesects with other box.
override
intersects2D(Box other) bool
Returns true if this bounding box intersects with other box in 2D.
override
intersectsPoint(Position point) bool
Returns true if this bounding box intesects with point.
override
intersectsPoint2D(Position point) bool
Returns true if this bounding box intesects with point in 2D.
override
length2D() double
Returns the perimeter of the area represented by this bounding box calculated in a cartesian 2D plane.
inherited
merge(Box other) GeoBox
Returns a minimum bounding box containing both this and other.
override
mergeGeographically(GeoBox other) GeoBox
Merge this bounding box with other geographically that is considering also cases spanning the antimeridian (on longitude).
northDms([DmsFormat format = const Dms()]) String
Formats north according to format.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
project(Projection projection) ProjBox
Projects this geographic bounding box to a projected box using the forward projection.
override
southDms([DmsFormat format = const Dms()]) String
Formats south according to format.
splitGeographically() Iterable<GeoBox>
Returns two bounding boxes (one to west from antimeridian and another to east) when spansAntimeridian is true.
splitUnambiguously() Iterable<GeoBox>
Returns two bounding boxes (one to west from antimeridian and another to east) when spansAntimeridian is true.
override
toString() String
A string representation of this object.
inherited
toText({String delimiter = ',', int? decimals, bool compactNums = true, bool swapXY = false}) String
Returns coordinate values as a string separated by delimiter.
inherited
valuesByType(Coords type) Iterable<double>
Coordinate values as a double iterable according to the given type.
inherited
westDms([DmsFormat format = const Dms()]) String
Formats west according to format.

Operators

operator *(double factor) GeoBox
Returns a bounding box with coordinate values of this scaled by factor.
override
operator +(Position addend) GeoBox
Returns a bounding box with min and max coordinate values of this summed with coordinate values of addend.
override
operator -(Position subtract) GeoBox
Returns a bounding box with min and max coordinate values of this subtracted with coordinate values of subtract.
override
operator ==(Object other) bool
The equality operator.
override
operator unary-() GeoBox
Returns a bounding box with coordinate values of this negated.
override

Static Methods

fromBox(Box source) GeoBox
Creates a geographic bounding box by copying coordinates from source.