/** * Simplify the input coordinate list. * If the distance tolerance is positive, * concavities on the LEFT side of the line are simplified. * If the supplied distance tolerance is negative, * concavities on the RIGHT side of the line are simplified. * * @param inputLine the coordinate list to simplify * @param distanceTol simplification distance tolerance to use * @return the simplified coordinate list */ public static Coordinate[] simplify(Coordinate[] inputLine, double distanceTol) { BufferInputLineSimplifier simp = new BufferInputLineSimplifier(inputLine); return simp.simplify(distanceTol); }
/** * Simplify the input coordinate list. * If the distance tolerance is positive, * concavities on the LEFT side of the line are simplified. * If the supplied distance tolerance is negative, * concavities on the RIGHT side of the line are simplified. * * @param distanceTol simplification distance tolerance to use * @return the simplified coordinate list */ public Coordinate[] simplify(double distanceTol) { this.distanceTol = Math.abs(distanceTol); if (distanceTol < 0) angleOrientation = CGAlgorithms.CLOCKWISE; // rely on fact that boolean array is filled with false value isDeleted = new byte[inputLine.length]; boolean isChanged = false; do { isChanged = deleteShallowConcavities(); } while (isChanged); return collapseLine(); }
int maxIndex = inputLine.length - 1; int midIndex = findNextNonDeletedIndex(index); int lastIndex = findNextNonDeletedIndex(midIndex); if (isDeletable(index, midIndex, lastIndex, distanceTol)) { isDeleted[midIndex] = DELETE; index = midIndex; midIndex = findNextNonDeletedIndex(index); lastIndex = findNextNonDeletedIndex(midIndex);
private boolean isDeletable(int i0, int i1, int i2, double distanceTol) { Coordinate p0 = inputLine[i0]; Coordinate p1 = inputLine[i1]; Coordinate p2 = inputLine[i2]; if (! isConcave(p0, p1, p2)) return false; if (! isShallow(p0, p1, p2, distanceTol)) return false; // MD - don't use this heuristic - it's too restricting // if (p0.distance(p2) > distanceTol) return false; return isShallowSampled(p0, p1, i0, i2, distanceTol); }
private void computeRingBufferCurve(Coordinate[] inputPts, int side, OffsetSegmentGenerator segGen) { // simplify input line to improve performance double distTol = simplifyTolerance(distance); // ensure that correct side is simplified if (side == Position.RIGHT) distTol = -distTol; Coordinate[] simp = BufferInputLineSimplifier.simplify(inputPts, distTol); // Coordinate[] simp = inputPts; int n = simp.length - 1; segGen.initSideSegments(simp[n - 1], simp[0], side); for (int i = 1; i <= n; i++) { boolean addStartPoint = i != 1; segGen.addNextSegment(simp[i], addStartPoint); } segGen.closeRing(); }
/** * Checks for shallowness over a sample of points in the given section. * This helps prevents the siplification from incrementally * "skipping" over points which are in fact non-shallow. * * @param p0 start coordinate of section * @param p2 end coordinate of section * @param i0 start index of section * @param i2 end index of section * @param distanceTol distance tolerance * @return */ private boolean isShallowSampled(Coordinate p0, Coordinate p2, int i0, int i2, double distanceTol) { // check every n'th point to see if it is within tolerance int inc = (i2 - i0) / NUM_PTS_TO_CHECK; if (inc <= 0) inc = 1; for (int i = i0; i < i2; i += inc) { if (! isShallow(p0, p2, inputLine[i], distanceTol)) return false; } return true; }
private boolean isDeletable(int i0, int i1, int i2, double distanceTol) { Coordinate p0 = inputLine[i0]; Coordinate p1 = inputLine[i1]; Coordinate p2 = inputLine[i2]; if (! isConcave(p0, p1, p2)) return false; if (! isShallow(p0, p1, p2, distanceTol)) return false; // MD - don't use this heuristic - it's too restricting // if (p0.distance(p2) > distanceTol) return false; return isShallowSampled(p0, p1, i0, i2, distanceTol); }
/** * Checks for shallowness over a sample of points in the given section. * This helps prevents the siplification from incrementally * "skipping" over points which are in fact non-shallow. * * @param p0 start coordinate of section * @param p2 end coordinate of section * @param i0 start index of section * @param i2 end index of section * @param distanceTol distance tolerance * @return */ private boolean isShallowSampled(Coordinate p0, Coordinate p2, int i0, int i2, double distanceTol) { // check every n'th point to see if it is within tolerance int inc = (i2 - i0) / NUM_PTS_TO_CHECK; if (inc <= 0) inc = 1; for (int i = i0; i < i2; i += inc) { if (! isShallow(p0, p2, inputLine[i], distanceTol)) return false; } return true; }
/** * Simplify the input coordinate list. * If the distance tolerance is positive, * concavities on the LEFT side of the line are simplified. * If the supplied distance tolerance is negative, * concavities on the RIGHT side of the line are simplified. * * @param inputLine the coordinate list to simplify * @param distanceTol simplification distance tolerance to use * @return the simplified coordinate list */ public static Coordinate[] simplify(Coordinate[] inputLine, double distanceTol) { BufferInputLineSimplifier simp = new BufferInputLineSimplifier(inputLine); return simp.simplify(distanceTol); }
/** * Simplify the input coordinate list. * If the distance tolerance is positive, * concavities on the LEFT side of the line are simplified. * If the supplied distance tolerance is negative, * concavities on the RIGHT side of the line are simplified. * * @param distanceTol simplification distance tolerance to use * @return the simplified coordinate list */ public Coordinate[] simplify(double distanceTol) { this.distanceTol = Math.abs(distanceTol); if (distanceTol < 0) angleOrientation = CGAlgorithms.CLOCKWISE; // rely on fact that boolean array is filled with false value isDeleted = new byte[inputLine.length]; boolean isChanged = false; do { isChanged = deleteShallowConcavities(); } while (isChanged); return collapseLine(); }
int maxIndex = inputLine.length - 1; int midIndex = findNextNonDeletedIndex(index); int lastIndex = findNextNonDeletedIndex(midIndex); if (isDeletable(index, midIndex, lastIndex, distanceTol)) { isDeleted[midIndex] = DELETE; index = midIndex; midIndex = findNextNonDeletedIndex(index); lastIndex = findNextNonDeletedIndex(midIndex);
private void computeRingBufferCurve(Coordinate[] inputPts, int side, OffsetSegmentGenerator segGen) { // simplify input line to improve performance double distTol = simplifyTolerance(distance); // ensure that correct side is simplified if (side == Position.RIGHT) distTol = -distTol; Coordinate[] simp = BufferInputLineSimplifier.simplify(inputPts, distTol); // Coordinate[] simp = inputPts; int n = simp.length - 1; segGen.initSideSegments(simp[n - 1], simp[0], side); for (int i = 1; i <= n; i++) { boolean addStartPoint = i != 1; segGen.addNextSegment(simp[i], addStartPoint); } segGen.closeRing(); }