Position class abstract
A base interface for geospatial positions.
The known sub classes are Projected
(with x, y, z and m coordinates) and
Geographic
(with lon, lat, elev and m coordinates).
All implementations must contain at least x and y coordinate values, but z and m coordinates are optional (getters should return zero value when such a coordinate axis is not available).
When a position contains geographic coordinates, then by default x represents longitude, y represents latitude, and z represents elevation (or height or altitude).
A projected map position might be defined as easting (E) and northing (N) coordinates. It's suggested that then E == x and N == y, but a coordinate reference system might specify something else too.
m represents a measurement or a value on a linear referencing system (like time). It could be associated with a 2D position (x, y, m) or a 3D position (x, y, z, m).
For 2D coordinates the coordinate axis indexes are:
Index | Projected | Geographic |
---|---|---|
0 | x | lon |
1 | y | lat |
2 | m | m |
For 3D coordinates the coordinate axis indexes are:
Index | Projected | Geographic |
---|---|---|
0 | x | lon |
1 | y | lat |
2 | z | elev |
3 | m | m |
Sub classes containing coordinate values mentioned above, should implement equality and hashCode methods as:
@override
bool operator ==(Object other) =>
other is Position && Position.testEquals(this, other);
@override
int get hashCode => Position.hash(this);
Constructors
- Position()
-
Default
const
constructor to allow extending this abstract class.const
Properties
- coordinateDimension → int
-
The number of coordinate values (2, 3 or 4).
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- 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
- m → num
-
The m ("measure") coordinate value. Returns zero if not available.
no setter
- optM → num?
-
The m ("measure") coordinate optionally. Returns null if not available.
no setter
- optZ → num?
-
The z coordinate value optionally. Returns null if not available.
no setter
- 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).
no setterinherited
- type → Coords
-
The coordinate type.
no setterinherited
-
values
→ Iterable<
num> -
Coordinate values of this position as an iterable of 2, 3 or 4 items.
no setter
- x → num
-
The x coordinate value.
no setter
- y → num
-
The y coordinate value.
no setter
- z → num
-
The z coordinate value. Returns zero if not available.
no setter
Methods
-
copyTo<
R extends Position> (CreatePosition< R> factory) → R -
Copies this position to a new position created by the
factory
. -
copyWith(
{num? x, num? y, num? z, num? m}) → Position -
Copies the position with optional
x
,y
,z
andm
overriding values. -
equals2D(
Position other, {num? toleranceHoriz}) → bool -
True if this position equals with
other
by testing 2D coordinates only. -
equals3D(
Position other, {num? toleranceHoriz, num? toleranceVert}) → bool -
True if this position equals with
other
by testing 3D coordinates only. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
-
transform(
TransformPosition transform) → Position - Returns a position with all points transformed using transform.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
int index) → num -
A coordinate value by the coordinate axis
index
.
Static Methods
-
buildPosition<
R extends Position> (Iterable< num> coords, {required CreatePosition<R> to, int offset = 0, Coords? type}) → R -
Builds a position of
R
fromcoords
starting fromoffset
. -
createFromObject<
R extends Position> (Object position, {required CreatePosition< R> to, Coords? type}) → R -
Creates a position of
R
fromposition
(ofR
orIterable<num>
). -
getDoubleList(
Position position) → List< double> -
Coordinate values of
position
as a double list of 2, 3 or 4 items. -
getValue(
Position position, int index) → num -
A coordinate value of
position
by the coordinate axisindex
. -
getValues(
Position position) → Iterable< num> -
Coordinate values of
position
as an iterable of 2, 3 or 4 items. -
hash(
Position position) → int -
The hash code for
position
.override -
parsePosition<
R extends Position> (String text, {required CreatePosition< R> to, Pattern? delimiter = ',', Coords? type}) → R -
Parses a position of
R
fromtext
. -
testEquals(
Position p1, Position p2) → bool -
True if positions
p1
andp2
equals by testing all coordinate values. -
testEquals2D(
Position p1, Position p2, {num? toleranceHoriz}) → bool -
True if positions
p1
andp2
equals by testing 2D coordinates only. -
testEquals3D(
Position p1, Position p2, {num? toleranceHoriz, num? toleranceVert}) → bool -
True if positions
p1
andp2
equals by testing 3D coordinates only.