Class LineString
Models an OGC-style LineString
Inherited Members
Namespace: NetTopologySuite.Geometries
Assembly: NetTopologySuite.dll
Syntax
[Serializable]
public class LineString : Geometry, IComparable, IComparable<Geometry>, ILineal
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.
LineString
s 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
| Edit this page View SourceLineString(CoordinateSequence, GeometryFactory)
Initializes a new instance of the LineString class.
Declaration
public LineString(CoordinateSequence points, GeometryFactory factory)
Parameters
Type | Name | Description |
---|---|---|
CoordinateSequence | points | The points of the |
GeometryFactory | factory |
Exceptions
Type | Condition |
---|---|
ArgumentException | If too few points are provided |
LineString(Coordinate[])
Initializes a new instance of the LineString class.
Declaration
public LineString(Coordinate[] points)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | points | The coordinates used for create this LineString. |
Remarks
For create this Geometry is used a standard GeometryFactory
with PrecisionModel ==
Floating.
Exceptions
Type | Condition |
---|---|
ArgumentException | If too few points are provided |
Fields
| Edit this page View SourceEmpty
Represents an empty LineString
.
Declaration
public static readonly LineString Empty
Field Value
Type | Description |
---|---|
LineString |
MinimumValidSize
The minimum number of vertices allowed in a valid non-empty linestring. Empty linestrings with 0 vertices are also valid.
Declaration
public const int MinimumValidSize = 2
Field Value
Type | Description |
---|---|
int |
Properties
| Edit this page View SourceBoundary
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."
Declaration
public override Geometry Boundary { get; }
Property Value
Type | Description |
---|---|
Geometry | The closure of the combinatorial boundary of this |
Overrides
| Edit this page View SourceBoundaryDimension
Declaration
public override Dimension BoundaryDimension { get; }
Property Value
Type | Description |
---|---|
Dimension |
Overrides
| Edit this page View SourceCoordinate
Declaration
public override Coordinate Coordinate { get; }
Property Value
Type | Description |
---|---|
Coordinate |
Overrides
| Edit this page View SourceCoordinateSequence
Declaration
public CoordinateSequence CoordinateSequence { get; }
Property Value
Type | Description |
---|---|
CoordinateSequence |
Coordinates
Returns an array containing the values of all the vertices for this geometry.
Declaration
public override Coordinate[] Coordinates { get; }
Property Value
Type | Description |
---|---|
Coordinate[] | The vertices of this |
Overrides
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
| Edit this page View SourceCount
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int |
Dimension
Declaration
public override Dimension Dimension { get; }
Property Value
Type | Description |
---|---|
Dimension |
Overrides
| Edit this page View SourceEndPoint
Gets a value indicating the end point of this LINESTRING
Declaration
public Point EndPoint { get; }
Property Value
Type | Description |
---|---|
Point |
GeometryType
Returns the name of this object's interface.
Declaration
public override string GeometryType { get; }
Property Value
Type | Description |
---|---|
string | "LineString" |
Overrides
| Edit this page View SourceIsClosed
Gets a value indicating if this LINESTRING
is closed.
Declaration
public virtual bool IsClosed { get; }
Property Value
Type | Description |
---|---|
bool |
IsEmpty
Declaration
public override bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
| Edit this page View SourceIsRing
Gets a value indicating if this LINESTRING
forms a ring.
Declaration
public bool IsRing { get; }
Property Value
Type | Description |
---|---|
bool |
this[int]
Declaration
public Coordinate this[int n] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
int | n |
Property Value
Type | Description |
---|---|
Coordinate |
Length
Returns the length of this LineString
Declaration
public override double Length { get; }
Property Value
Type | Description |
---|---|
double | The length of the polygon. |
Overrides
| Edit this page View SourceNumPoints
Declaration
public override int NumPoints { get; }
Property Value
Type | Description |
---|---|
int |
Overrides
| Edit this page View SourceOgcGeometryType
Gets the OGC geometry type
Declaration
public override OgcGeometryType OgcGeometryType { get; }
Property Value
Type | Description |
---|---|
OgcGeometryType |
Overrides
| Edit this page View SourceSortIndex
Gets a value to sort the geometry
Declaration
protected override Geometry.SortIndexValue SortIndex { get; }
Property Value
Type | Description |
---|---|
Geometry.SortIndexValue |
Overrides
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
Declaration
public Point StartPoint { get; }
Property Value
Type | Description |
---|---|
Point |
Methods
| Edit this page View SourceApply(ICoordinateFilter)
Declaration
public override void Apply(ICoordinateFilter filter)
Parameters
Type | Name | Description |
---|---|---|
ICoordinateFilter | filter |
Overrides
| Edit this page View SourceApply(ICoordinateSequenceFilter)
Performs an operation on the coordinates in this Geometry
's CoordinateSequences.
Declaration
public override void Apply(ICoordinateSequenceFilter filter)
Parameters
Type | Name | Description |
---|---|---|
ICoordinateSequenceFilter | filter | The filter to apply |
Overrides
Remarks
If the filter reports that a coordinate value has been changed, GeometryChanged() will be called automatically.
Apply(IEntireCoordinateSequenceFilter)
Performs an operation on this Geometry
's CoordinateSequences.
Declaration
public override void Apply(IEntireCoordinateSequenceFilter filter)
Parameters
Type | Name | Description |
---|---|---|
IEntireCoordinateSequenceFilter | filter | The filter to apply |
Overrides
Remarks
If the filter reports that a coordinate value has been changed, GeometryChanged() will be called automatically.
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.
Declaration
public override void Apply(IGeometryComponentFilter filter)
Parameters
Type | Name | Description |
---|---|---|
IGeometryComponentFilter | filter | The filter to apply to this |
Overrides
| Edit this page View SourceApply(IGeometryFilter)
Performs an operation with or on this Geometry
and its
subelement Geometry
s (if any).
Only GeometryCollections and subclasses
have subelement Geometry's.
Declaration
public override void Apply(IGeometryFilter filter)
Parameters
Type | Name | Description |
---|---|---|
IGeometryFilter | filter | The filter to apply to this |
Overrides
| Edit this page View SourceCompareToSameClass(object)
Returns whether this Geometry
is greater than, equal to,
or less than another Geometry
having the same class.
Declaration
protected override int CompareToSameClass(object o)
Parameters
Type | Name | Description |
---|---|---|
object | o | A |
Returns
Type | Description |
---|---|
int | A positive number, 0, or a negative number, depending on whether
this object is greater than, equal to, or less than |
Overrides
| Edit this page View SourceCompareToSameClass(object, IComparer<CoordinateSequence>)
Returns whether this Geometry
is greater than, equal to,
or less than another Geometry
of the same class.
using the given IComparer<T>.
Declaration
protected override int CompareToSameClass(object o, IComparer<CoordinateSequence> comp)
Parameters
Type | Name | Description |
---|---|---|
object | o | A |
IComparer<CoordinateSequence> | comp | The comparer |
Returns
Type | Description |
---|---|
int | A positive number, 0, or a negative number, depending on whether
this object is greater than, equal to, or less than |
Overrides
| Edit this page View SourceComputeEnvelopeInternal()
Declaration
protected override Envelope ComputeEnvelopeInternal()
Returns
Type | Description |
---|---|
Envelope |
Overrides
| Edit this page View SourceCopyInternal()
An internal method to copy subclass-specific geometry data.
Declaration
protected override Geometry CopyInternal()
Returns
Type | Description |
---|---|
Geometry | A copy of the target geometry object. |
Overrides
| Edit this page View SourceEqualsExact(Geometry, double)
Declaration
public override bool EqualsExact(Geometry other, double tolerance)
Parameters
Type | Name | Description |
---|---|---|
Geometry | other | |
double | tolerance |
Returns
Type | Description |
---|---|
bool |
Overrides
| Edit this page View SourceGetCoordinateN(int)
Declaration
public Coordinate GetCoordinateN(int n)
Parameters
Type | Name | Description |
---|---|---|
int | n |
Returns
Type | Description |
---|---|
Coordinate |
GetOrdinates(Ordinate)
Gets an array of double ordinate values
Declaration
public override double[] GetOrdinates(Ordinate ordinate)
Parameters
Type | Name | Description |
---|---|---|
Ordinate | ordinate | The ordinate index |
Returns
Type | Description |
---|---|
double[] | An array of ordinate values |
Overrides
| Edit this page View SourceGetPointN(int)
Gets
Declaration
public Point GetPointN(int n)
Parameters
Type | Name | Description |
---|---|---|
int | n |
Returns
Type | Description |
---|---|
Point |
IsCoordinate(Coordinate)
Returns true if the given point is a vertex of this LineString
.
Declaration
public virtual bool IsCoordinate(Coordinate pt)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | pt | The |
Returns
Type | Description |
---|---|
bool |
|
IsEquivalentClass(Geometry)
Returns whether the two Geometry
s are equal, from the point
of view of the EqualsExact
method. Called by EqualsExact
. In general, two Geometry
classes are considered to be
"equivalent" only if they are the same class. An exception is LineString
, which is considered to be equivalent to its subclasses.
Declaration
protected override bool IsEquivalentClass(Geometry other)
Parameters
Type | Name | Description |
---|---|---|
Geometry | other | The |
Returns
Type | Description |
---|---|
bool |
|
Overrides
| Edit this page View SourceNormalize()
Normalizes a LineString
. A normalized LineString
has the first point which is not equal to it's reflected point
less than the reflected point.
Declaration
public override void Normalize()
Overrides
| Edit this page View SourceReverse()
Creates a LineString whose coordinates are in the reverse order of this objects.
Declaration
[Obsolete("Call Geometry.Reverse()")]
public override Geometry Reverse()
Returns
Type | Description |
---|---|
Geometry | A LineString with coordinates in the reverse order. |
Overrides
| Edit this page View SourceReverseInternal()
The actual implementation of the Reverse() function for LINESTRING
s.
Declaration
protected override Geometry ReverseInternal()
Returns
Type | Description |
---|---|
Geometry | A reversed geometry |