/** * Simplify a collection of TaggedLineStrings * * @param taggedLines the collection of lines to simplify */ public void simplify(Collection taggedLines) { for (Iterator i = taggedLines.iterator(); i.hasNext(); ) { inputIndex.add((TaggedLineString) i.next()); } for (Iterator i = taggedLines.iterator(); i.hasNext(); ) { TaggedLineStringSimplifier tlss = new TaggedLineStringSimplifier(inputIndex, outputIndex); tlss.setDistanceTolerance(distanceTolerance); tlss.simplify((TaggedLineString) i.next()); } }
private boolean hasBadIntersection(TaggedLineString parentLine, int[] sectionIndex, LineSegment candidateSeg) { if (hasBadOutputIntersection(candidateSeg)) return true; if (hasBadInputIntersection(parentLine, sectionIndex, candidateSeg)) return true; return false; }
private boolean hasBadInputIntersection(TaggedLineString parentLine, int[] sectionIndex, LineSegment candidateSeg) { List querySegs = inputIndex.query(candidateSeg); for (Iterator i = querySegs.iterator(); i.hasNext(); ) { TaggedLineSegment querySeg = (TaggedLineSegment) i.next(); if (hasInteriorIntersection(querySeg, candidateSeg)) { if (isInLineSection(parentLine, sectionIndex, querySeg)) continue; return true; } } return false; }
int furthestPtIndex = findFurthestPoint(linePts, i, j, distance); sectionIndex[0] = i; sectionIndex[1] = j; if (hasBadIntersection(line, sectionIndex, candidateSeg)) isValidToSimplify = false; LineSegment newSeg = flatten(i, j); line.addToResult(newSeg); return; simplifySection(i, furthestPtIndex, depth); simplifySection(furthestPtIndex, j, depth);
private LineSegment flatten(int start, int end) { // make a new segment for the simplified geometry Coordinate p0 = linePts[start]; Coordinate p1 = linePts[end]; LineSegment newSeg = new LineSegment(p0, p1); // update the indexes remove(line, start, end); outputIndex.add(newSeg); return newSeg; }
private boolean hasBadOutputIntersection(LineSegment candidateSeg) { List querySegs = outputIndex.query(candidateSeg); for (Iterator i = querySegs.iterator(); i.hasNext(); ) { LineSegment querySeg = (LineSegment) i.next(); if (hasInteriorIntersection(querySeg, candidateSeg)) { return true; } } return false; }
int furthestPtIndex = findFurthestPoint(linePts, i, j, distance); sectionIndex[0] = i; sectionIndex[1] = j; if (hasBadIntersection(line, sectionIndex, candidateSeg)) isValidToSimplify = false; LineSegment newSeg = flatten(i, j); line.addToResult(newSeg); return; simplifySection(i, furthestPtIndex, depth); simplifySection(furthestPtIndex, j, depth);
/** * Flattens a section of the line between * indexes <code>start</code> and <code>end</code>, * replacing them with a line between the endpoints. * The input and output indexes are updated * to reflect this. * * @param start the start index of the flattened section * @param end the end index of the flattened section * @return the new segment created */ private LineSegment flatten(int start, int end) { // make a new segment for the simplified geometry Coordinate p0 = linePts[start]; Coordinate p1 = linePts[end]; LineSegment newSeg = new LineSegment(p0, p1); // update the indexes remove(line, start, end); outputIndex.add(newSeg); return newSeg; }
private boolean hasBadOutputIntersection(LineSegment candidateSeg) { List querySegs = outputIndex.query(candidateSeg); for (Iterator i = querySegs.iterator(); i.hasNext(); ) { LineSegment querySeg = (LineSegment) i.next(); if (hasInteriorIntersection(querySeg, candidateSeg)) { return true; } } return false; }
/** * Simplify a collection of TaggedLineStrings * * @param taggedLines the collection of lines to simplify */ public void simplify(Collection taggedLines) { for (Iterator i = taggedLines.iterator(); i.hasNext(); ) { inputIndex.add((TaggedLineString) i.next()); } for (Iterator i = taggedLines.iterator(); i.hasNext(); ) { TaggedLineStringSimplifier tlss = new TaggedLineStringSimplifier(inputIndex, outputIndex); tlss.setDistanceTolerance(distanceTolerance); tlss.simplify((TaggedLineString) i.next()); } }
private boolean hasBadIntersection(TaggedLineString parentLine, int[] sectionIndex, LineSegment candidateSeg) { if (hasBadOutputIntersection(candidateSeg)) return true; if (hasBadInputIntersection(parentLine, sectionIndex, candidateSeg)) return true; return false; }
private boolean hasBadInputIntersection(TaggedLineString parentLine, int[] sectionIndex, LineSegment candidateSeg) { List querySegs = inputIndex.query(candidateSeg); for (Iterator i = querySegs.iterator(); i.hasNext(); ) { TaggedLineSegment querySeg = (TaggedLineSegment) i.next(); if (hasInteriorIntersection(querySeg, candidateSeg)) { if (isInLineSection(parentLine, sectionIndex, querySeg)) continue; return true; } } return false; }