Position class abstract
A base class for geospatial positions.
The known two instantiable sub classes are Projected
(with x, y, z and m
coordinates) and Geographic
(with lon, lat, elev and m coordinates).
It's also possible to create a position using factory methods Position.view, Position.create and Position.parse that create an instance storing coordinate values in a double array.
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);
- Inheritance
-
- Object
- Positionable
- ValuePositionable
- Position
- Implementers
Constructors
- Position()
-
Default
const
constructor to allow extending this abstract class.const - Position.create({required double x, required double y, double? z, double? m})
-
A position from parameters compatible with
CreatePosition
function type.factory - Position.parse(String text, {Pattern delimiter = ',', Coords? type, bool swapXY = false, bool singlePrecision = false})
-
Parses a position from
text
.factory -
Position.subview(List<
double> source, {required int start, Coords type = Coords.xy}) -
A position with coordinate values as a sub view backed by
source
, starting atstart
.factory -
Position.view(List<
double> source, {Coords? type}) -
A position with coordinate values as a view backed by
source
.factory
Properties
- conforming → PositionScheme
-
Returns a position scheme this position 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
- 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 → double
-
The m ("measure") coordinate value. Returns zero if not available.
no setter
- optM → double?
-
The m ("measure") coordinate optionally. Returns null if not available.
no setter
- optZ → double?
-
The z coordinate value optionally. Returns null if not available.
no setter
- positionCount → int
-
A Position object represents a single position, returns always
1
.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 position as an iterable of 2, 3 or 4 items.
no setteroverride
- x → double
-
The x coordinate value.
no setter
- y → double
-
The y coordinate value.
no setter
- z → double
-
The z coordinate value. Returns zero if not available.
no setter
Methods
-
bearingTo2D(
Position destination) → double -
Returns a bearing from this to
destination
calculated in a cartesian 2D plane. -
copyByType(
Coords type) → Position -
Copies
this
as another object according to the giventype
.override -
copyTo<
R extends Position> (CreatePosition< R> factory) → R -
Copies this position to a new position created by the
factory
. -
copyWith(
{double? x, double? y, double? z, double? m}) → Position -
Copies the position with optional
x
,y
,z
andm
overriding values. -
destinationPoint2D(
{required double distance, required double bearing}) → Position -
Returns a destination point located at the given
distance
from this to the direction ofbearing
calculated in a cartesian 2D plane. -
distanceTo2D(
Position destination) → double -
Returns a distance from this to
destination
calculated in a cartesian 2D plane. -
distanceTo3D(
Position destination) → double -
Returns a distance from this to
destination
calculated in a cartesian 3D space. -
equals2D(
covariant Position other, {double toleranceHoriz = defaultEpsilon}) → bool -
True if this position equals with
other
by testing 2D coordinates only.override -
equals3D(
covariant Position other, {double toleranceHoriz = defaultEpsilon, double toleranceVert = defaultEpsilon}) → bool -
True if this position equals with
other
by testing 3D coordinates only.override -
equalsCoords(
covariant Position other) → bool -
True if this and the
other
position equals.override -
expand(
ExpandPosition expand) → Iterable< Position> -
Expands this position to an iterable of zero or more positions of using
expand
. -
intermediatePointTo(
Position destination, {required double fraction}) → Position -
Returns an intermediate point at the given
fraction
between this anddestination
positions calculated in the cartesian coordinate reference system. -
midPointTo(
Position destination) → Position -
Returns a midpoint between this and
destination
positions calculated in the cartesian coordinate reference system. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
packed(
) → Position - Returns a position instance whose coordinate storage contains only coordinate values represented by this position.
-
project(
Projection projection) → Position -
Projects this position to another position using
projection
.override -
toString(
) → String -
A string representation of this object.
override
-
toText(
{String delimiter = ',', int? decimals, bool compactNums = true, bool swapXY = false}) → String -
A string representation of coordinate values separated by
delimiter
.override -
transform(
TransformPosition transform) → Position -
Returns a position transformed from this using
transform
. -
valuesByType(
Coords type) → Iterable< double> -
Coordinate values as a double iterable according to the given
type
.override
Operators
-
operator %(
Position divisor) → Position -
Returns a position with coordinate values of this applied with modulo
operator
%
by values ofdivisor
. -
operator *(
double factor) → Position -
Returns a position with coordinate values of this scaled by
factor
. -
operator +(
Position other) → Position -
Returns a position with coordinate values summed from this and
other
. -
operator -(
Position other) → Position -
Returns a position with coordinate values of this subtracted with values
of
other
. -
operator /(
Position divisor) → Position -
Returns a position with coordinate values of this divided by values of
divisor
. -
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
int index) → double -
A coordinate value by the coordinate axis
index
. -
operator unary-(
) → Position - Returns a position with coordinate values of this negated.
Static Methods
-
buildPosition<
R extends Position> (Iterable< num> coords, {required CreatePosition<R> to, int offset = 0, Coords? type, bool swapXY = false}) → 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>
). -
getValue(
Position position, int index) → double -
A coordinate value of
position
by the coordinate axisindex
. -
getValues(
Position position, {required Coords type}) → Iterable< double> -
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, bool swapXY = false}) → 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, {double toleranceHoriz = defaultEpsilon}) → bool -
True if positions
p1
andp2
equals by testing 2D coordinates only. -
testEquals3D(
Position p1, Position p2, {double toleranceHoriz = defaultEpsilon, double toleranceVert = defaultEpsilon}) → bool -
True if positions
p1
andp2
equals by testing 3D coordinates only. -
writeValues(
Position position, StringSink buffer, {String delimiter = ',', int? decimals, bool compactNums = true, bool swapXY = false}) → void -
Writes coordinate values of
position
tobuffer
separated bydelimiter
.
Constants
- scheme → const PositionScheme
- A position scheme that creates base Position and Box instances for positions and bounding boxes.