PositionSeries class abstract

A fixed-length (and random-access) view to a series of positions.

Implementations of this abstract class can use at least two different structures to store coordinate values of positions contained in a series:

  • A list of Position objects (each object contain x and y coordinates, and optionally z and m too).
  • A list of double values as a flat structure. For example a double list could contain coordinates like [x0, y0, z0, x1, y1, z1, x2, y2, z2] that represents three positions each with x, y and z coordinates.

It's also possible to create a position data instance using factory methods PositionSeries.view and PositionSeries.parse that create an instance storing coordinate values of positions in a double array. The factory PositionSeries.from creates an instance storing positions objects in an array. The factory PositionSeries.empty returns an empty series.

See Position for description about supported coordinate values.

For PositionSeries and sub classes equality by operator == and hashCode is not testing coordinate values for contained positions. Methods equalsCoords, equals2D and equals3D should be used to test coordinate values between two PositionSeries instances.

Inheritance
Implemented types
Available Extensions

Constructors

PositionSeries.empty([Coords type = Coords.xy])
An empty series of positions without any positions.
factory
PositionSeries.from(Iterable<Position> source, {Coords? type})
A series of positions as a view backed by source containing Position objects.
factory
PositionSeries.parse(String text, {Pattern delimiter = ',', Coords type = Coords.xy, bool swapXY = false, bool singlePrecision = false})
Parses a series of positions from text containing coordinate values of positions.
factory
PositionSeries.view(List<double> source, {Coords type = Coords.xy})
A series of positions as a view backed by source containing coordinate values of positions.
factory

Properties

bounds Box?
An optional bounding box explicitely set (or otherwise directly available) for this object.
no setterinherited
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
firstOrNull Position?
The first position or null (if empty collection).
no setter
hashCode int
The hash code for this object.
no setterinherited
is3D bool
True for 3D positions (with z or elevation coordinate).
no setterinherited
isClosed bool
True if the first and last position equals in 2D.
no setter
isEmptyByGeometry bool
Returns true if this series has no positions.
no setteroverride
isMeasured bool
True if a measure value is available (or the m coordinate for a position).
no setterinherited
lastOrNull Position?
The last position or null (if empty collection).
no setter
positionCount int
The number of positions in this series.
no setteroverride
positions Iterable<Position>
All positions in this series as an iterable.
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) on a position.
no setterinherited
type Coords
The coordinate type.
no setterinherited
valueCount int
The number of coordinate values for all positions in this series.
no setteroverride
values Iterable<double>
Coordinate values of all positions in this series as an iterable.
no setteroverride

Methods

added(Iterable<Position> iterable) PositionSeries
Returns a position series with iterable of positions added to positions of this series.
boundsAligned2D({Aligned align = Aligned.center, PositionScheme scheme = Position.scheme}) Position?
Returns an aligned 2D position relative to a bounding box accessed by getBounds.
inherited
calculateBounds({PositionScheme scheme = Position.scheme}) Box?
Calculate a bounding box for this object.
override
centroid2D({Dimensionality dimensionality = Dimensionality.areal, PositionScheme scheme = Position.scheme}) Position?
Returns the centroid of a geometry represented by this position series calculated in a cartesian 2D plane.
copyByType(Coords type) PositionSeries
Copies this series of positions as another series with positions mapped by the given coordinate type.
override
equals2D(covariant PositionSeries other, {double toleranceHoriz = defaultEpsilon}) bool
True if this series of positions equals with other by testing 2D coordinates of all positions (that must be in same order in both series).
override
equals3D(covariant PositionSeries other, {double toleranceHoriz = defaultEpsilon, double toleranceVert = defaultEpsilon}) bool
True if this series of positions equals with other by testing 3D coordinates of all positions (that must be in same order in both views).
override
equalsCoords(covariant PositionSeries other) bool
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
expand(ExpandPosition expand) PositionSeries
Expands this position to an iterable of zero or more positions of using expand.
filtered(bool test(int count, int index, Position element)) PositionSeries
Returns a position series with all positions of this series that satisfy the predicate test.
get<R extends Position>(int index, {required CreatePosition<R> to}) → R
The position at the given index as an object of R using to factory.
getBounds({PositionScheme scheme = Position.scheme}) Box?
Returns the current bounds if it's populated and conforms to scheme, or otherwise returns one calculated by calculateBounds.
inherited
inserted(int index, Iterable<Position> iterable) PositionSeries
Returns a position series with iterable of positions inserted at index of this series.
isClosedBy([double toleranceHoriz = defaultEpsilon]) bool
True if the first and last position equals in 2D within toleranceHoriz.
length2D() double
Returns the length of a line string represented by this position series calculated in a cartesian 2D plane.
length3D() double
Returns the length of a line string represented by this position series calculated in a cartesian 3D space.
m(int index) double
The m coordinate of the position at the given index.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
optM(int index) double?
The m coordinate of the position at the given index.
optZ(int index) double?
The z coordinate of the position at the given index.
packed({bool singlePrecision = false, Coords? type}) PositionSeries
Returns a position series with coordinate values packed in a flat structure.
populated({bool onBounds = true, PositionScheme scheme = Position.scheme}) PositionSeries
Returns an object of the same subtype as this with certain data members populated.
override
positionsAs<R extends Position>({required CreatePosition<R> to}) Iterable<R>
All positions in this series as an iterable of positions typed as R using to factory.
project(Projection projection) PositionSeries
Projects this series of positions to another series using projection.
override
range(int start, [int? end]) PositionSeries
Returns a subseries with positions from start (inclusive) to end (exclusive).
rangeRemoved(int start, [int? end]) PositionSeries
Returns a position series with positions from start (inclusive) to end (exclusive) removed.
rangeReplaced(int start, int end, Iterable<Position> replacements) PositionSeries
Returns a position series with positions from start (inclusive) to end (exclusive) replaced with replacements.
reversed() PositionSeries
Returns a position series with all positions in reversed order compared to this.
signedArea2D() double
Returns the signed area of a linear ring (polygon) represented by this position series calculated in a cartesian 2D plane.
sorted(int compare(Position a, Position b)) PositionSeries
Returns a position series with all positions of this series sorted to the order specified by compare.
toString() String
A string representation of this object.
override
toText({String delimiter = ',', String? positionDelimiter, int? decimals, bool compactNums = true, bool swapXY = false}) String
A string representation of coordinate values of all positions (in this series) separated by delimiter.
override
transform(TransformPosition transform) PositionSeries
Returns a position series with all positions transformed using transform.
unpopulated({bool onBounds = true}) PositionSeries
Returns an object of the same subtype as this with certain data members unpopulated (or cleared).
override
valuesByType(Coords type) Iterable<double>
Coordinate values of all positions in this series as an iterable.
override
x(int index) double
The x coordinate of the position at the given index.
y(int index) double
The y coordinate of the position at the given index.
z(int index) double
The z coordinate of the position at the given index.

Operators

operator *(double factor) PositionSeries
Returns a position series with coordinate values of all positions scaled by factor.
operator ==(Object other) bool
The equality operator.
inherited
operator [](int index) Position
The position at the given index.
operator unary-() PositionSeries
Returns a position series with coordinate values of all positions negated.