public static Geometry makeBuffer(Graph graph) { Geometry geom = geometryCollectionFromVertices(graph).buffer(.04, 6); DouglasPeuckerSimplifier simplifier = new DouglasPeuckerSimplifier(geom); simplifier.setDistanceTolerance(0.00001); return simplifier.getResultGeometry(); }
/** * Simplifies the given {@link TaggedLineString} * using the distance tolerance specified. * * @param line the linestring to simplify */ void simplify(TaggedLineString line) { this.line = line; linePts = line.getParentCoordinates(); simplifySection(0, linePts.length - 1, 0); }
public void add(TaggedLineString line) { TaggedLineSegment[] segs = line.getSegments(); for (int i = 0; i < segs.length; i++) { TaggedLineSegment seg = segs[i]; add(seg); } }
nextTransformGeom = TopologyPreservingSimplifier.simplify(nextTransformGeom, .1d); // Can't use 0d, specify value < .5d
return null; routeGeometry = DouglasPeuckerSimplifier.simplify(routeGeometry, 0.00001);
public static Geometry simplify(Geometry geom, double distanceTolerance) { TopologyPreservingSimplifier tss = new TopologyPreservingSimplifier(geom); tss.setDistanceTolerance(distanceTolerance); return tss.getResultGeometry(); }
public Geometry getResultGeometry() { // empty input produces an empty result if (inputGeom.isEmpty()) return (Geometry) inputGeom.clone(); linestringMap = new HashMap(); inputGeom.apply(new LineStringMapBuilderFilter()); lineSimplifier.simplify(linestringMap.values()); Geometry result = (new LineStringTransformer()).transform(inputGeom); return result; }
public static Coordinate[] simplify(Coordinate[] pts, double distanceTolerance) { DouglasPeuckerLineSimplifier simp = new DouglasPeuckerLineSimplifier(pts); simp.setDistanceTolerance(distanceTolerance); return simp.simplify(); }
/** * Tests whether a segment is in a section of a TaggedLineString * @param line * @param sectionIndex * @param seg * @return */ private static boolean isInLineSection( TaggedLineString line, int[] sectionIndex, TaggedLineSegment seg) { // not in this line if (seg.getParent() != line.getParent()) return false; int segIndex = seg.getIndex(); if (segIndex >= sectionIndex[0] && segIndex < sectionIndex[1]) return true; return false; }
private boolean hasBadIntersection(TaggedLineString parentLine, int[] sectionIndex, LineSegment candidateSeg) { if (hasBadOutputIntersection(candidateSeg)) return true; if (hasBadInputIntersection(parentLine, sectionIndex, candidateSeg)) return true; return false; }
/** * Remove the segs in the section of the line * @param line * @param pts * @param sectionStartIndex * @param sectionEndIndex */ private void remove(TaggedLineString line, int start, int end) { for (int i = start; i < end; i++) { TaggedLineSegment seg = line.getSegment(i); inputIndex.remove(seg); } } }
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; }
protected CoordinateSequence transformCoordinates(CoordinateSequence coords, Geometry parent) { // for linear components (including rings), simplify the linestring if (parent instanceof LineString) { TaggedLineString taggedLine = (TaggedLineString) linestringMap.get(parent); return createCoordinateSequence(taggedLine.getResultCoordinates()); } // for anything else (e.g. points) just copy the coordinates return super.transformCoordinates(coords, parent); } }
public Geometry getResultGeometry() { // empty input produces an empty result if (inputGeom.isEmpty()) return (Geometry) inputGeom.clone(); return (new DPTransformer(isEnsureValidTopology)).transform(inputGeom); }
/** * Simplifies a polygon, fixing it if required. */ protected Geometry transformPolygon(Polygon geom, Geometry parent) { Geometry rawGeom = super.transformPolygon(geom, parent); // don't try and correct if the parent is going to do this if (parent instanceof MultiPolygon) { return rawGeom; } return createValidArea(rawGeom); }
public TaggedLineString(LineString parentLine, int minimumSize) { this.parentLine = parentLine; this.minimumSize = minimumSize; init(); }
public Coordinate[] getResultCoordinates() { return extractCoordinates(resultSegs); }
public static Geometry simplify(Geometry geom, double distanceTolerance) { DouglasPeuckerSimplifier tss = new DouglasPeuckerSimplifier(geom); tss.setDistanceTolerance(distanceTolerance); return tss.getResultGeometry(); }
/** * Simplifies a MultiPolygon, fixing it if required. */ protected Geometry transformMultiPolygon(MultiPolygon geom, Geometry parent) { Geometry rawGeom = super.transformMultiPolygon(geom, parent); return createValidArea(rawGeom); }