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.
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
LineString(CoordinateSequence, GeometryFactory)
Initializes a new instance of the LineString class.
public LineString(CoordinateSequence points, GeometryFactory factory)
Parameters
points
CoordinateSequenceThe points of the
LineString
, ornull
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
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
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
Coordinate
public override Coordinate Coordinate { get; }
Property Value
CoordinateSequence
public CoordinateSequence CoordinateSequence { get; }
Property Value
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
Dimension
public override Dimension Dimension { get; }
Property Value
EndPoint
Gets a value indicating the end point of this LINESTRING
public Point EndPoint { get; }
Property Value
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
IsEmpty
public override bool IsEmpty { get; }
Property Value
IsRing
Gets a value indicating if this LINESTRING
forms a ring.
public bool IsRing { get; }
Property Value
this[int]
public Coordinate this[int n] { get; set; }
Parameters
n
int
Property Value
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
OgcGeometryType
Gets the OGC geometry type
public override OgcGeometryType OgcGeometryType { get; }
Property Value
SortIndex
Gets a value to sort the geometry
protected override Geometry.SortIndexValue SortIndex { get; }
Property Value
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
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
ICoordinateSequenceFilterThe 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
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
IGeometryComponentFilterThe filter to apply to this
Geometry
.
Apply(IGeometryFilter)
Performs an operation with or on this Geometry
and its
subelement Geometry
s (if any).
Only GeometryCollections and subclasses
have subelement Geometry's.
public override void Apply(IGeometryFilter filter)
Parameters
filter
IGeometryFilterThe filter to apply to this
Geometry
(and its children, if it is aGeometryCollection
).
CompareToSameClass(object)
protected override int CompareToSameClass(object o)
Parameters
o
object
Returns
CompareToSameClass(object, IComparer<CoordinateSequence>)
protected override int CompareToSameClass(object o, IComparer<CoordinateSequence> comp)
Parameters
o
objectcomp
IComparer<CoordinateSequence>
Returns
ComputeEnvelopeInternal()
protected override Envelope ComputeEnvelopeInternal()
Returns
CopyInternal()
protected override Geometry CopyInternal()
Returns
EqualsExact(Geometry, double)
public override bool EqualsExact(Geometry other, double tolerance)
Parameters
Returns
GetCoordinateN(int)
public Coordinate GetCoordinateN(int n)
Parameters
n
int
Returns
GetOrdinates(Ordinate)
Gets an array of double ordinate values
public override double[] GetOrdinates(Ordinate ordinate)
Parameters
ordinate
OrdinateThe ordinate index
Returns
- double[]
An array of ordinate values
GetPointN(int)
Gets
public Point GetPointN(int n)
Parameters
n
int
Returns
IsCoordinate(Coordinate)
Returns true if the given point is a vertex of this LineString
.
public virtual bool IsCoordinate(Coordinate pt)
Parameters
pt
CoordinateThe
Coordinate
to check.
Returns
- bool
true
ifpt
is one of thisLineString
's vertices.
IsEquivalentClass(Geometry)
protected override bool IsEquivalentClass(Geometry other)
Parameters
other
Geometry
Returns
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 LINESTRING
s.
protected override Geometry ReverseInternal()
Returns
- Geometry
A reversed geometry