Table of Contents

Class LineString

Namespace
NetTopologySuite.Geometries
Assembly
NetTopologySuite.dll

Models an OGC-style LineString

public class LineString : Geometry, IComparable, IComparable<Geometry>, ILineal
Inheritance
LineString
Implements
Derived
Inherited Members

Remarks

A LineString consists of a sequence of two or more vertices, along with all points along the linearly-interpolated curves (line segments) between each pair of consecutive vertices. Consecutive vertices may be equal. The line segments in the line may intersect each other (in other words, the LineString may "curl back" in itself and self-intersect. LineStrings with exactly two identical points are invalid.

A LineString must have either 0 or MinimumValidSize or more points. If these conditions are not met, the constructors throw an ArgumentException.

Constructors

LineString(CoordinateSequence, GeometryFactory)

Initializes a new instance of the LineString class.

public LineString(CoordinateSequence points, GeometryFactory factory)

Parameters

points CoordinateSequence

The points of the LineString, or null to create the empty point. Consecutive points may not be equal.

factory GeometryFactory

Exceptions

ArgumentException

If too few points are provided

LineString(Coordinate[])

Initializes a new instance of the LineString class.

public LineString(Coordinate[] points)

Parameters

points Coordinate[]

The coordinates used for create this LineString.

Remarks

For create this Geometry is used a standard GeometryFactory with PrecisionModel == Floating.

Exceptions

ArgumentException

If too few points are provided

Fields

Empty

Represents an empty LineString.

public static readonly LineString Empty

Field Value

LineString

MinimumValidSize

The minimum number of vertices allowed in a valid non-empty linestring. Empty linestrings with 0 vertices are also valid.

public const int MinimumValidSize = 2

Field Value

int

Properties

Boundary

Returns the boundary, or an empty geometry of appropriate dimension if this Geometry is empty. For a discussion of this function, see the OpenGIS Simple Features Specification. As stated in SFS Section 2.1.13.1, "the boundary of a Geometry is a set of Geometries of the next lower dimension."

public override Geometry Boundary { get; }

Property Value

Geometry

The closure of the combinatorial boundary of this Geometry.

BoundaryDimension

public override Dimension BoundaryDimension { get; }

Property Value

Dimension

Coordinate

public override Coordinate Coordinate { get; }

Property Value

Coordinate

CoordinateSequence

public CoordinateSequence CoordinateSequence { get; }

Property Value

CoordinateSequence

Coordinates

Returns an array containing the values of all the vertices for this geometry.

public override Coordinate[] Coordinates { get; }

Property Value

Coordinate[]

The vertices of this Geometry.

Remarks

If the geometry is a composite, the array will contain all the vertices for the components, in the order in which the components occur in the geometry.

In general, the array cannot be assumed to be the actual internal storage for the vertices. Thus modifying the array may not modify the geometry itself. Use the SetOrdinate(int, int, double) method (possibly on the components) to modify the underlying data. If the coordinates are modified, GeometryChanged() must be called afterwards.

See Also

Count

public int Count { get; }

Property Value

int

Dimension

public override Dimension Dimension { get; }

Property Value

Dimension

EndPoint

Gets a value indicating the end point of this LINESTRING

public Point EndPoint { get; }

Property Value

Point

GeometryType

Returns the name of this object's interface.

public override string GeometryType { get; }

Property Value

string

"LineString"

IsClosed

Gets a value indicating if this LINESTRING is closed.

public virtual bool IsClosed { get; }

Property Value

bool

IsEmpty

public override bool IsEmpty { get; }

Property Value

bool

IsRing

Gets a value indicating if this LINESTRING forms a ring.

public bool IsRing { get; }

Property Value

bool

this[int]

public Coordinate this[int n] { get; set; }

Parameters

n int

Property Value

Coordinate

Length

Returns the length of this LineString

public override double Length { get; }

Property Value

double

The length of the polygon.

NumPoints

public override int NumPoints { get; }

Property Value

int

OgcGeometryType

Gets the OGC geometry type

public override OgcGeometryType OgcGeometryType { get; }

Property Value

OgcGeometryType

SortIndex

Gets a value to sort the geometry

protected override Geometry.SortIndexValue SortIndex { get; }

Property Value

Geometry.SortIndexValue

Remarks

NOTE:
For JTS v1.17 this property's getter has been renamed to getTypeCode(). In order not to break binary compatibility we did not follow.

StartPoint

Gets a value indicating the start point of this LINESTRING

public Point StartPoint { get; }

Property Value

Point

Methods

Apply(ICoordinateFilter)

public override void Apply(ICoordinateFilter filter)

Parameters

filter ICoordinateFilter

Apply(ICoordinateSequenceFilter)

Performs an operation on the coordinates in this Geometry's CoordinateSequences.

public override void Apply(ICoordinateSequenceFilter filter)

Parameters

filter ICoordinateSequenceFilter

The filter to apply

Remarks

If the filter reports that a coordinate value has been changed, GeometryChanged() will be called automatically.

Apply(IEntireCoordinateSequenceFilter)

public override void Apply(IEntireCoordinateSequenceFilter filter)

Parameters

filter IEntireCoordinateSequenceFilter

Apply(IGeometryComponentFilter)

Performs an operation with or on this Geometry and its component Geometry's. Only GeometryCollections and Polygons have component Geometry's; for Polygons they are the LinearRings of the shell and holes.

public override void Apply(IGeometryComponentFilter filter)

Parameters

filter IGeometryComponentFilter

The filter to apply to this Geometry.

Apply(IGeometryFilter)

Performs an operation with or on this Geometry and its subelement Geometrys (if any). Only GeometryCollections and subclasses have subelement Geometry's.

public override void Apply(IGeometryFilter filter)

Parameters

filter IGeometryFilter

The filter to apply to this Geometry (and its children, if it is a GeometryCollection).

CompareToSameClass(object)

protected override int CompareToSameClass(object o)

Parameters

o object

Returns

int

CompareToSameClass(object, IComparer<CoordinateSequence>)

protected override int CompareToSameClass(object o, IComparer<CoordinateSequence> comp)

Parameters

o object
comp IComparer<CoordinateSequence>

Returns

int

ComputeEnvelopeInternal()

protected override Envelope ComputeEnvelopeInternal()

Returns

Envelope

CopyInternal()

protected override Geometry CopyInternal()

Returns

Geometry

EqualsExact(Geometry, double)

public override bool EqualsExact(Geometry other, double tolerance)

Parameters

other Geometry
tolerance double

Returns

bool

GetCoordinateN(int)

public Coordinate GetCoordinateN(int n)

Parameters

n int

Returns

Coordinate

GetOrdinates(Ordinate)

Gets an array of double ordinate values

public override double[] GetOrdinates(Ordinate ordinate)

Parameters

ordinate Ordinate

The ordinate index

Returns

double[]

An array of ordinate values

GetPointN(int)

Gets

public Point GetPointN(int n)

Parameters

n int

Returns

Point

IsCoordinate(Coordinate)

Returns true if the given point is a vertex of this LineString.

public virtual bool IsCoordinate(Coordinate pt)

Parameters

pt Coordinate

The Coordinate to check.

Returns

bool

true if pt is one of this LineString's vertices.

IsEquivalentClass(Geometry)

protected override bool IsEquivalentClass(Geometry other)

Parameters

other Geometry

Returns

bool

Normalize()

Normalizes a LineString. A normalized LineString has the first point which is not equal to it's reflected point less than the reflected point.

public override void Normalize()

Reverse()

Creates a LineString whose coordinates are in the reverse order of this objects.

[Obsolete("Call Geometry.Reverse()")]
public override Geometry Reverse()

Returns

Geometry

A LineString with coordinates in the reverse order.

ReverseInternal()

The actual implementation of the Reverse() function for LINESTRINGs.

protected override Geometry ReverseInternal()

Returns

Geometry

A reversed geometry