LineString class

A LineString is a Feature made up of connected Coordinates to form a line.

Inheritance

Constructors

LineString(List<Coordinate> coordinates, {Map<String, dynamic> properties = const <String, dynamic>{}})
LineString.fromJson(Map<String, dynamic> json)
Creates a LineString from a valid GeoJSON object
factory
LineString.fromWKT(String wkt)
Creates a LineString from a WKT string
factory
LineString.random({int length = 2})
Creates a LineString with random Coordinates with the number of vertices specified length. The length must be greater than 2, or an ArgumentError will be thrown.
factory

Properties

bbox BoundingBox
Returns the BoundingBox of the LineString
no setteroverride
bearing double
Returns the bearing of the LineString in degrees. The bearing is the angle measured in degrees clockwise from true north between the first and last coordinate of the LineString. If the LineString has less than 2 coordinates, 0 will be returned. The bearing will always be between 0 and 360. The bearing will be 0 if the LineString is a closed ring.
no setter
center Point
Returns the center Point of the LineString
no setteroverride
coordinates List<Coordinate>
final
hashCode int
The hash code for this object.
no setteroverride
isClosedRing bool
Returns true if the LineString is a closed ring, meaning that the first and last coordinate are the same.
no setter
length double
Returns the LineString's length in meters. The length is calculated using the Haversine formula.
no setter
properties Map<String, dynamic>
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
segments List<LineString>
Returns each segment (a 2-coordinate LineString) of the LineString in a FeatureCollection
no setter
slope double?
Returns the slope of the line, using only the first and last coordinate. If the line is vertical, null is returned If the line is horizontal, 0 is returned
no setter

Methods

along(double distance) Point
Returns the Point at the distance (in meters) along the LineString. If the distance is greater than the length of the LineString, the last Point in the LineString will be returned. If the distance is less than 0, the first Point in the LineString will be returned.
contains(Point point) bool
Returns true if the Point is on the line
explode() List<Point>
Explodes the LineString into a List of Points
override
intersections(LineString other) FeatureCollection
Returns a FeatureCollection of Points where the LineString intersects with the LineString other. If the LineStrings do not intersect, an empty FeatureCollection is returned.
isParallelTo(LineString other) bool
Returns whether or not the LineString is parallel to the LineString other. If the LineStrings have different lengths, they are not considered parallel.
midpoint() Point
Returns the midPoint of the LineString.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pointAt(double percentage) Point
Returns the Point at the percentage along the LineString. If the percentage is greater than 1, the last Point in the LineString will be returned. If the percentage is less than 0, the first Point in the LineString will be returned. If the percentage is 0, the first Point in the LineString will be returned. If the percentage is 1, the last Point in the LineString will be returned.
reverse() LineString
Returns a LineString that is a copy of the LineString with the coordinates reversed. The first coordinate will become the last, and the last coordinate will become the first. If the LineString is a closed ring, the first and last coordinate will be the same.
toJson() Map<String, dynamic>
Returns a GeoJSON representation of the LineString
override
toPolygon() Polygon
If the LineString is a closed ring, it will be converted to a Polygon. Any properties will be applied to the Polygon.
toString() String
A string representation of this object.
override
toWKT() String
Converts the LineString to a String in WKT format.
override

Operators

operator +(Feature other) FeatureCollection
Adds two Features together to form a FeatureCollection. Each Feature in the FeatureCollection will retain their properties and coordinates.
inherited
operator ==(Object other) bool
The equality operator.
override

Static Properties

type String
final