Package org.locationtech.jts.noding
Class InteriorIntersectionFinder
- java.lang.Object
-
- org.locationtech.jts.noding.InteriorIntersectionFinder
-
- All Implemented Interfaces:
SegmentIntersector
public class InteriorIntersectionFinder extends java.lang.Object implements SegmentIntersector
Finds an interior intersection in a set ofSegmentString
s, if one exists. Only the first intersection found is reported.- Version:
- 1.7
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
findAllIntersections
private Coordinate
interiorIntersection
private int
intersectionCount
private java.util.List
intersections
private Coordinate[]
intSegments
private boolean
isCheckEndSegmentsOnly
private boolean
keepIntersections
private LineIntersector
li
-
Constructor Summary
Constructors Constructor Description InteriorIntersectionFinder(LineIntersector li)
Creates an intersection finder which finds an interior intersection if one exists
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
count()
Gets the count of intersections found.static InteriorIntersectionFinder
createAllIntersectionsFinder(LineIntersector li)
Creates an intersection finder which finds all interior intersections.static InteriorIntersectionFinder
createAnyIntersectionFinder(LineIntersector li)
Creates an intersection finder which tests if there is at least one interior intersection.static InteriorIntersectionFinder
createIntersectionCounter(LineIntersector li)
Creates an intersection finder which counts all interior intersections.Coordinate
getInteriorIntersection()
Gets the computed location of the intersection.java.util.List
getIntersections()
Gets the intersections found.Coordinate[]
getIntersectionSegments()
Gets the endpoints of the intersecting segments.boolean
hasIntersection()
Tests whether an intersection was found.boolean
isDone()
Reports whether the client of this class needs to continue testing all intersections in an arrangement.private boolean
isEndSegment(SegmentString segStr, int index)
Tests whether a segment in aSegmentString
is an end segment.void
processIntersections(SegmentString e0, int segIndex0, SegmentString e1, int segIndex1)
This method is called by clients of theSegmentIntersector
class to process intersections for two segments of theSegmentString
s being intersected.void
setCheckEndSegmentsOnly(boolean isCheckEndSegmentsOnly)
Sets whether only end segments should be tested for interior intersection.void
setFindAllIntersections(boolean findAllIntersections)
Sets whether all intersections should be computed.void
setKeepIntersections(boolean keepIntersections)
Sets whether intersection points are recorded.
-
-
-
Field Detail
-
findAllIntersections
private boolean findAllIntersections
-
isCheckEndSegmentsOnly
private boolean isCheckEndSegmentsOnly
-
li
private LineIntersector li
-
interiorIntersection
private Coordinate interiorIntersection
-
intSegments
private Coordinate[] intSegments
-
intersections
private java.util.List intersections
-
intersectionCount
private int intersectionCount
-
keepIntersections
private boolean keepIntersections
-
-
Constructor Detail
-
InteriorIntersectionFinder
public InteriorIntersectionFinder(LineIntersector li)
Creates an intersection finder which finds an interior intersection if one exists- Parameters:
li
- the LineIntersector to use
-
-
Method Detail
-
createAnyIntersectionFinder
public static InteriorIntersectionFinder createAnyIntersectionFinder(LineIntersector li)
Creates an intersection finder which tests if there is at least one interior intersection. Uses short-circuiting for efficient performance. The intersection found is recorded.- Parameters:
li
- a line intersector- Returns:
- a intersection finder which tests if there is at least one interior intersection.
-
createAllIntersectionsFinder
public static InteriorIntersectionFinder createAllIntersectionsFinder(LineIntersector li)
Creates an intersection finder which finds all interior intersections. The intersections are recorded for later inspection.- Parameters:
li
- a line intersector- Returns:
- a intersection finder which finds all interior intersections.
-
createIntersectionCounter
public static InteriorIntersectionFinder createIntersectionCounter(LineIntersector li)
Creates an intersection finder which counts all interior intersections. The intersections are note recorded to reduce memory usage.- Parameters:
li
- a line intersector- Returns:
- a intersection finder which counts all interior intersections.
-
setFindAllIntersections
public void setFindAllIntersections(boolean findAllIntersections)
Sets whether all intersections should be computed. When this isfalse
(the default value) the value ofisDone()
istrue
after the first intersection is found.Default is
false
.- Parameters:
findAllIntersections
- whether all intersections should be computed
-
setKeepIntersections
public void setKeepIntersections(boolean keepIntersections)
Sets whether intersection points are recorded. If the only need is to count intersection points, this can be set tofalse
.Default is
true
.- Parameters:
keepIntersections
- indicates whether intersections should be recorded
-
getIntersections
public java.util.List getIntersections()
Gets the intersections found.- Returns:
- a List of
Coordinate
-
count
public int count()
Gets the count of intersections found.- Returns:
- the intersection count
-
setCheckEndSegmentsOnly
public void setCheckEndSegmentsOnly(boolean isCheckEndSegmentsOnly)
Sets whether only end segments should be tested for interior intersection. This is a performance optimization that may be used if the segments have been previously noded by an appropriate algorithm. It may be known that any potential noding failures will occur only in end segments.- Parameters:
isCheckEndSegmentsOnly
- whether to test only end segments
-
hasIntersection
public boolean hasIntersection()
Tests whether an intersection was found.- Returns:
- true if an intersection was found
-
getInteriorIntersection
public Coordinate getInteriorIntersection()
Gets the computed location of the intersection. Due to round-off, the location may not be exact.- Returns:
- the coordinate for the intersection location
-
getIntersectionSegments
public Coordinate[] getIntersectionSegments()
Gets the endpoints of the intersecting segments.- Returns:
- an array of the segment endpoints (p00, p01, p10, p11)
-
processIntersections
public void processIntersections(SegmentString e0, int segIndex0, SegmentString e1, int segIndex1)
This method is called by clients of theSegmentIntersector
class to process intersections for two segments of theSegmentString
s being intersected. Note that some clients (such asMonotoneChain
s) may optimize away this call for segment pairs which they have determined do not intersect (e.g. by an disjoint envelope test).- Specified by:
processIntersections
in interfaceSegmentIntersector
-
isEndSegment
private boolean isEndSegment(SegmentString segStr, int index)
Tests whether a segment in aSegmentString
is an end segment. (either the first or last).- Parameters:
segStr
- a segment stringindex
- the index of a segment in the segment string- Returns:
- true if the segment is an end segment
-
isDone
public boolean isDone()
Description copied from interface:SegmentIntersector
Reports whether the client of this class needs to continue testing all intersections in an arrangement.- Specified by:
isDone
in interfaceSegmentIntersector
- Returns:
- true if there is no need to continue testing segments
-
-