public class LinearLocation extends Object implements Comparable
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.Constructor and Description |
---|
LinearLocation()
Creates a location referring to the start of a linear geometry
|
LinearLocation(int segmentIndex,
double segmentFraction) |
LinearLocation(int componentIndex,
int segmentIndex,
double segmentFraction) |
LinearLocation(LinearLocation loc)
Creates a new location equal to a given one.
|
Modifier and Type | Method and Description |
---|---|
void |
clamp(Geometry linear)
Ensures the indexes are valid for a given linear
Geometry . |
Object |
clone()
Deprecated.
|
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.
|
LinearLocation |
copy()
Copies this location
|
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 . |
LineSegment |
getSegment(Geometry linearGeom)
Gets a
LineSegment representing the segment of the
given linear Geometry which contains this location. |
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 |
isEndpoint(Geometry linearGeom)
Tests whether this location is an endpoint of
the linear component it refers to.
|
boolean |
isOnSameSegment(LinearLocation loc)
Tests whether two locations
are on the same segment in the parent
Geometry . |
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 to 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 minDistance. |
LinearLocation |
toLowest(Geometry linearGeom)
Converts a linear location to the lowest equivalent location index.
|
String |
toString() |
public LinearLocation()
public LinearLocation(int segmentIndex, double segmentFraction)
public LinearLocation(int componentIndex, int segmentIndex, double segmentFraction)
public LinearLocation(LinearLocation loc)
loc
- a LinearLocationpublic static LinearLocation getEndLocation(Geometry linear)
Geometry
.linear
- the linear geometrypublic static Coordinate pointAlongSegmentByFraction(Coordinate p0, Coordinate p1, double frac)
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.
The Z ordinate is interpolated from the Z-ordinates of the given points,
if they are specified.p0
- the first point of the line segmentp1
- the last point of the line segmentfrac
- the length to the desired pointpublic void clamp(Geometry linear)
Geometry
.linear
- a linear geometrypublic void snapToVertex(Geometry linearGeom, double minDistance)
Geometry
,
if the vertex is closer than minDistance.linearGeom
- a linear geometryminDistance
- the minimum allowable distance to a vertexpublic double getSegmentLength(Geometry linearGeom)
linearGeom
- a linear geometrypublic void setToEnd(Geometry linear)
linear
- the linear geometry to use to set the endpublic int getComponentIndex()
public int getSegmentIndex()
public double getSegmentFraction()
public boolean isVertex()
public Coordinate getCoordinate(Geometry linearGeom)
Coordinate
along the
given linear Geometry
which is
referenced by this location.linearGeom
- the linear geometry referenced by this locationpublic LineSegment getSegment(Geometry linearGeom)
LineSegment
representing the segment of the
given linear Geometry
which contains this location.linearGeom
- a linear geometrypublic boolean isValid(Geometry linearGeom)
Geometry
.linearGeom
- a linear geometrypublic int compareTo(Object o)
compareTo
in interface Comparable
o
- the LineStringLocation
with which this Coordinate
is being comparedLineStringLocation
is less than, equal to, or greater than the specified LineStringLocation
public int compareLocationValues(int componentIndex1, int segmentIndex1, double segmentFraction1)
componentIndex1
- a component indexsegmentIndex1
- a segment indexsegmentFraction1
- a segment fractionLineStringLocation
is less than, equal to, or greater than the specified locationValuespublic static int compareLocationValues(int componentIndex0, int segmentIndex0, double segmentFraction0, int componentIndex1, int segmentIndex1, double segmentFraction1)
componentIndex0
- a component indexsegmentIndex0
- a segment indexsegmentFraction0
- a segment fractioncomponentIndex1
- another component indexsegmentIndex1
- another segment indexsegmentFraction1
- another segment fractionpublic boolean isOnSameSegment(LinearLocation loc)
Geometry
.loc
- a location on the same geometrypublic boolean isEndpoint(Geometry linearGeom)
linearGeom
- the linear geometry referenced by this locationpublic LinearLocation toLowest(Geometry linearGeom)
Specifically:
linearGeom
- the linear geometry referenced by this locationpublic Object clone()
public LinearLocation copy()
Copyright © 2024. All rights reserved.