Package org.locationtech.jts.simplify
Class TaggedLineStringSimplifier
- java.lang.Object
-
- org.locationtech.jts.simplify.TaggedLineStringSimplifier
-
public class TaggedLineStringSimplifier extends java.lang.Object
Simplifies a TaggedLineString, preserving topology (in the sense that no new intersections are introduced). Uses the recursive Douglas-Peucker algorithm.- Version:
- 1.7
-
-
Field Summary
Fields Modifier and Type Field Description private double
distanceTolerance
private LineSegmentIndex
inputIndex
private LineIntersector
li
private TaggedLineString
line
private Coordinate[]
linePts
private LineSegmentIndex
outputIndex
-
Constructor Summary
Constructors Constructor Description TaggedLineStringSimplifier(LineSegmentIndex inputIndex, LineSegmentIndex outputIndex)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private int
findFurthestPoint(Coordinate[] pts, int i, int j, double[] maxDistance)
private LineSegment
flatten(int start, int end)
Flattens a section of the line between indexesstart
andend
, replacing them with a line between the endpoints.private boolean
hasBadInputIntersection(TaggedLineString parentLine, int[] sectionIndex, LineSegment candidateSeg)
private boolean
hasBadIntersection(TaggedLineString parentLine, int[] sectionIndex, LineSegment candidateSeg)
private boolean
hasBadOutputIntersection(LineSegment candidateSeg)
private boolean
hasInteriorIntersection(LineSegment seg0, LineSegment seg1)
private static boolean
isInLineSection(TaggedLineString line, int[] sectionIndex, TaggedLineSegment seg)
Tests whether a segment is in a section of a TaggedLineStringprivate void
remove(TaggedLineString line, int start, int end)
Remove the segs in the section of the linevoid
setDistanceTolerance(double distanceTolerance)
Sets the distance tolerance for the simplification.(package private) void
simplify(TaggedLineString line)
Simplifies the givenTaggedLineString
using the distance tolerance specified.private void
simplifySection(int i, int j, int depth)
-
-
-
Field Detail
-
li
private LineIntersector li
-
inputIndex
private LineSegmentIndex inputIndex
-
outputIndex
private LineSegmentIndex outputIndex
-
line
private TaggedLineString line
-
linePts
private Coordinate[] linePts
-
distanceTolerance
private double distanceTolerance
-
-
Constructor Detail
-
TaggedLineStringSimplifier
public TaggedLineStringSimplifier(LineSegmentIndex inputIndex, LineSegmentIndex outputIndex)
-
-
Method Detail
-
setDistanceTolerance
public void setDistanceTolerance(double distanceTolerance)
Sets the distance tolerance for the simplification. All vertices in the simplified geometry will be within this distance of the original geometry.- Parameters:
distanceTolerance
- the approximation tolerance to use
-
simplify
void simplify(TaggedLineString line)
Simplifies the givenTaggedLineString
using the distance tolerance specified.- Parameters:
line
- the linestring to simplify
-
simplifySection
private void simplifySection(int i, int j, int depth)
-
findFurthestPoint
private int findFurthestPoint(Coordinate[] pts, int i, int j, double[] maxDistance)
-
flatten
private LineSegment flatten(int start, int end)
Flattens a section of the line between indexesstart
andend
, replacing them with a line between the endpoints. The input and output indexes are updated to reflect this.- Parameters:
start
- the start index of the flattened sectionend
- the end index of the flattened section- Returns:
- the new segment created
-
hasBadIntersection
private boolean hasBadIntersection(TaggedLineString parentLine, int[] sectionIndex, LineSegment candidateSeg)
-
hasBadOutputIntersection
private boolean hasBadOutputIntersection(LineSegment candidateSeg)
-
hasBadInputIntersection
private boolean hasBadInputIntersection(TaggedLineString parentLine, int[] sectionIndex, LineSegment candidateSeg)
-
isInLineSection
private static boolean isInLineSection(TaggedLineString line, int[] sectionIndex, TaggedLineSegment seg)
Tests whether a segment is in a section of a TaggedLineString- Parameters:
line
-sectionIndex
-seg
-- Returns:
-
hasInteriorIntersection
private boolean hasInteriorIntersection(LineSegment seg0, LineSegment seg1)
-
remove
private void remove(TaggedLineString line, int start, int end)
Remove the segs in the section of the line- Parameters:
line
-pts
-sectionStartIndex
-sectionEndIndex
-
-
-