com.vividsolutions.jts.linearref
Class LinearLocation
java.lang.Object
com.vividsolutions.jts.linearref.LinearLocation
- Comparable
public class LinearLocation
extends java.lang.Object
implements Comparable
Represents a location along a
LineString
or
MultiLineString
.
The referenced geometry is not maintained within
this location, but must be provided for operations which require it.
Various methods are provided to manipulate the location value
and query the geometry it references.
LinearLocation() - Creates a location referring to the start of a linear geometry
|
LinearLocation(int segmentIndex, double segmentFraction)
|
LinearLocation(int componentIndex, int segmentIndex, double segmentFraction)
|
void | clamp(Geometry linear) - Ensures the indexes are valid for a given linear
Geometry .
|
Object | clone() - Copies this location
|
int | compareLocationValues(int componentIndex1, int segmentIndex1, double segmentFraction1) - Compares this object with the specified index values for order.
|
static int | compareLocationValues(int componentIndex0, int segmentIndex0, double segmentFraction0, int componentIndex1, int segmentIndex1, double segmentFraction1) - Compares two sets of location values for order.
|
int | compareTo(Object o) - Compares this object with the specified object for order.
|
int | getComponentIndex() - Gets the component index for this location.
|
Coordinate | getCoordinate(Geometry linearGeom) - Gets the
Coordinate along the
given linear Geometry which is
referenced by this location.
|
static LinearLocation | getEndLocation(Geometry linear) - Gets a location which refers to the end of a linear
Geometry .
|
double | getSegmentFraction() - Gets the segment fraction for this location
|
int | getSegmentIndex() - Gets the segment index for this location
|
double | getSegmentLength(Geometry linearGeom) - Gets the length of the segment in the given
Geometry containing this location.
|
boolean | isValid(Geometry linearGeom) - Tests whether this location refers to a valid
location on the given linear
Geometry .
|
boolean | isVertex() - Tests whether this location refers to a vertex
|
static Coordinate | pointAlongSegmentByFraction(Coordinate p0, Coordinate p1, double frac) - Computes the
Coordinate of a point a given fraction
along the line segment (p0, p1).
|
void | setToEnd(Geometry linear) - Sets the value of this location to
refer the end of a linear geometry
|
void | snapToVertex(Geometry linearGeom, double minDistance) - Snaps the value of this location to
the nearest vertex on the given linear
Geometry ,
if the vertex is closer than maxDistance.
|
LinearLocation
public LinearLocation()
Creates a location referring to the start of a linear geometry
LinearLocation
public LinearLocation(int segmentIndex,
double segmentFraction)
LinearLocation
public LinearLocation(int componentIndex,
int segmentIndex,
double segmentFraction)
clamp
public void clamp(Geometry linear)
Ensures the indexes are valid for a given linear
Geometry
.
linear
- a linear geometry
clone
public Object clone()
Copies this location
compareLocationValues
public int compareLocationValues(int componentIndex1,
int segmentIndex1,
double segmentFraction1)
Compares this object with the specified index values for order.
componentIndex1
- a component indexsegmentIndex1
- a segment indexsegmentFraction1
- a segment fraction
- a negative integer, zero, or a positive integer as this
LineStringLocation
is less than, equal to, or greater than the specified locationValues
compareLocationValues
public static int compareLocationValues(int componentIndex0,
int segmentIndex0,
double segmentFraction0,
int componentIndex1,
int segmentIndex1,
double segmentFraction1)
Compares two sets of location values for order.
componentIndex0
- a component indexsegmentIndex0
- a segment indexsegmentFraction0
- a segment fractioncomponentIndex1
- another component indexsegmentIndex1
- another segment indexsegmentFraction1
- another segment fraction
- a negative integer, zero, or a positive integer
as the first set of location values
is less than, equal to, or greater than the second set of locationValues
compareTo
public int compareTo(Object o)
Compares this object with the specified object for order.
o
- the LineStringLocation
with which this Coordinate
is being compared
- a negative integer, zero, or a positive integer as this
LineStringLocation
is less than, equal to, or greater than the specified LineStringLocation
getComponentIndex
public int getComponentIndex()
Gets the component index for this location.
getCoordinate
public Coordinate getCoordinate(Geometry linearGeom)
linearGeom
- a linear geometry
- the Coordinate at the location
getEndLocation
public static LinearLocation getEndLocation(Geometry linear)
Gets a location which refers to the end of a linear
Geometry
.
linear
- the linear geometry
getSegmentFraction
public double getSegmentFraction()
Gets the segment fraction for this location
getSegmentIndex
public int getSegmentIndex()
Gets the segment index for this location
getSegmentLength
public double getSegmentLength(Geometry linearGeom)
Gets the length of the segment in the given
Geometry containing this location.
linearGeom
- a linear geometry
- the length of the segment
isValid
public boolean isValid(Geometry linearGeom)
Tests whether this location refers to a valid
location on the given linear
Geometry
.
linearGeom
- a linear geometry
- true if this location is valid
isVertex
public boolean isVertex()
Tests whether this location refers to a vertex
- true if the location is a vertex
pointAlongSegmentByFraction
public static Coordinate pointAlongSegmentByFraction(Coordinate p0,
Coordinate p1,
double frac)
Computes the
Coordinate
of a point a given fraction
along the line segment
(p0, p1).
If the fraction is greater than 1.0 the last
point of the segment is returned.
If the fraction is less than or equal to 0.0 the first point
of the segment is returned.
p0
- the first point of the line segmentp1
- the last point of the line segmentfrac
- the length to the desired point
- the Coordinate of the desired point
setToEnd
public void setToEnd(Geometry linear)
Sets the value of this location to
refer the end of a linear geometry
linear
- the linear geometry to set
snapToVertex
public void snapToVertex(Geometry linearGeom,
double minDistance)
Snaps the value of this location to
the nearest vertex on the given linear
Geometry
,
if the vertex is closer than
maxDistance.
linearGeom
- a linear geometryminDistance
- the minimum allowable distance to a vertex