Package org.locationtech.jts.noding
Class NodedSegmentString
java.lang.Object
org.locationtech.jts.noding.NodedSegmentString
- All Implemented Interfaces:
NodableSegmentString
,SegmentString
Represents a list of contiguous line segments,
and supports noding the segments.
The line segments are represented by an array of
Coordinate
s.
Intended to optimize the noding of contiguous segments by
reducing the number of allocated objects.
SegmentString
s can carry a context object, which is useful
for preserving topological or parentage information.
All noded substrings are initialized with the same context object.
For read-only applications use BasicSegmentString
,
which is (slightly) more lightweight.
- Version:
- 1.7
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionNodedSegmentString
(Coordinate[] pts, Object data) Creates a instance from a list of vertices and optional data object.Creates a new instance from aSegmentString
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addIntersection
(LineIntersector li, int segmentIndex, int geomIndex, int intIndex) Add an SegmentNode for intersection intIndex.void
addIntersection
(Coordinate intPt, int segmentIndex) Adds an intersection node for a given point and segment to this segment string.addIntersectionNode
(Coordinate intPt, int segmentIndex) Adds an intersection node for a given point and segment to this segment string.void
addIntersections
(LineIntersector li, int segmentIndex, int geomIndex) Adds EdgeIntersections for one or both intersections found for a segment of an edge to the edge intersection list.getCoordinate
(int i) Gets the segment string coordinate at a given index.Gets the coordinates in this segment string.getData()
Gets the user-defined data for this segment string.Gets a list of coordinates with all nodes included.static List
getNodedSubstrings
(Collection segStrings) Gets theSegmentString
s which result from splitting this string at node points.static void
getNodedSubstrings
(Collection segStrings, Collection resultEdgelist) Adds the nodedSegmentString
s which result from splitting this string at node points.int
getSegmentOctant
(int index) Gets the octant of the segment starting at vertexindex
.boolean
hasNodes()
Tests whether any nodes have been added.boolean
isClosed()
Tests if a segment string is a closed ring.void
Sets the user-defined data for this segment string.int
size()
Gets the number of coordinates in this segment string.toString()
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.locationtech.jts.noding.SegmentString
nextInRing, prevInRing
-
Constructor Details
-
NodedSegmentString
Creates a instance from a list of vertices and optional data object.- Parameters:
pts
- the vertices of the segment stringdata
- the user-defined data of this segment string (may be null)
-
NodedSegmentString
Creates a new instance from aSegmentString
.- Parameters:
ss
- the segment string to use
-
-
Method Details
-
getNodedSubstrings
Gets theSegmentString
s which result from splitting this string at node points.- Parameters:
segStrings
- a Collection of NodedSegmentStrings- Returns:
- a Collection of NodedSegmentStrings representing the substrings
-
getNodedSubstrings
Adds the nodedSegmentString
s which result from splitting this string at node points.- Parameters:
segStrings
- a Collection of NodedSegmentStringsresultEdgelist
- a List which will collect the NodedSegmentStrings representing the substrings
-
getData
Gets the user-defined data for this segment string.- Specified by:
getData
in interfaceSegmentString
- Returns:
- the user-defined data
-
setData
Sets the user-defined data for this segment string.- Specified by:
setData
in interfaceSegmentString
- Parameters:
data
- an Object containing user-defined data
-
getNodeList
-
size
public int size()Description copied from interface:SegmentString
Gets the number of coordinates in this segment string.- Specified by:
size
in interfaceSegmentString
- Returns:
- the number of coordinates
-
getCoordinate
Description copied from interface:SegmentString
Gets the segment string coordinate at a given index.- Specified by:
getCoordinate
in interfaceSegmentString
- Parameters:
i
- the coordinate index- Returns:
- the coordinate at the index
-
getCoordinates
Description copied from interface:SegmentString
Gets the coordinates in this segment string.- Specified by:
getCoordinates
in interfaceSegmentString
- Returns:
- the coordinates as an array
-
getNodedCoordinates
Gets a list of coordinates with all nodes included.- Returns:
- an array of coordinates include nodes
-
isClosed
public boolean isClosed()Description copied from interface:SegmentString
Tests if a segment string is a closed ring.- Specified by:
isClosed
in interfaceSegmentString
- Returns:
- true if the segment string is closed
-
hasNodes
public boolean hasNodes()Tests whether any nodes have been added.- Returns:
- true if the segment string has nodes
-
getSegmentOctant
public int getSegmentOctant(int index) Gets the octant of the segment starting at vertexindex
.- Parameters:
index
- the index of the vertex starting the segment. Must not be the last index in the vertex list- Returns:
- the octant of the segment at the vertex
-
addIntersections
Adds EdgeIntersections for one or both intersections found for a segment of an edge to the edge intersection list. -
addIntersection
Add an SegmentNode for intersection intIndex. An intersection that falls exactly on a vertex of the SegmentString is normalized to use the higher of the two possible segmentIndexes -
addIntersection
Adds an intersection node for a given point and segment to this segment string.- Specified by:
addIntersection
in interfaceNodableSegmentString
- Parameters:
intPt
- the location of the intersectionsegmentIndex
- the index of the segment containing the intersection
-
addIntersectionNode
Adds an intersection node for a given point and segment to this segment string. If an intersection already exists for this exact location, the existing node will be returned.- Parameters:
intPt
- the location of the intersectionsegmentIndex
- the index of the segment containing the intersection- Returns:
- the intersection node for the point
-
toString
-