Package uk.ac.rdg.resc.edal.geometry
Class LineString
- java.lang.Object
-
- uk.ac.rdg.resc.edal.geometry.LineString
-
public final class LineString extends Object
Represents a path through a coordinate system. The path consists of a set of linear path elements, drawn between control points.- Author:
- Jon, Guy Griffiths
-
-
Constructor Summary
Constructors Constructor Description LineString(String lineStringSpec, org.opengis.referencing.crs.CoordinateReferenceSystem crs)
Constructs aLineString
from a line string in the form.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
getControlPointDistanceKm(int index)
Returns the fractional distance along the line string to the control point with the given index.List<HorizontalPosition>
getControlPoints()
Returns the list of control points along this line string.org.opengis.referencing.crs.CoordinateReferenceSystem
getCoordinateReferenceSystem()
double
getPathLength()
List<HorizontalPosition>
getPointsOnPath(int n)
Returns a list of n points along the path defined by this line string.
-
-
-
Constructor Detail
-
LineString
public LineString(String lineStringSpec, org.opengis.referencing.crs.CoordinateReferenceSystem crs) throws InvalidLineStringException, InvalidCrsException
Constructs aLineString
from a line string in the form.- Parameters:
lineStringSpec
- the line string as specified in the form "x1 y1, x2 y2, x3 y3".crs
- The coordinate reference system for the line string's coordinates- Throws:
InvalidLineStringException
- if the line string is not correctly specified.InvalidCrsException
NullPointerException
- if crsHelper == null
-
-
Method Detail
-
getControlPoints
public List<HorizontalPosition> getControlPoints()
Returns the list of control points along this line string.- Returns:
- an unmodifiable list of control points.
-
getControlPointDistanceKm
public double getControlPointDistanceKm(int index)
Returns the fractional distance along the line string to the control point with the given index.- Parameters:
index
- The index of the control point. An index of zero represents the start of the line string.- Returns:
- the distance in km along the whole line string to the control point
- Throws:
IndexOutOfBoundsException
- ifindex < 0 || index >= number of control points
-
getPathLength
public double getPathLength()
- Returns:
- The total path length, in km
-
getPointsOnPath
public List<HorizontalPosition> getPointsOnPath(int n)
Returns a list of n points along the path defined by this line string. The first point will be the first control point; the last point will be the last control point. Intermediate points are linearly interpolated between the control points. Note that it is not guaranteed that the intermediate control points will be contained in this list. TODO Add the control points to this list, in the correct location.- Parameters:
n
- The number of points to return- Returns:
- an unmodifiable list of
n
points that lie on this path. - Throws:
IllegalArgumentException
- ifnumPoints < 2
-
getCoordinateReferenceSystem
public org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
-
-