return null; routeGeometry = DouglasPeuckerSimplifier.simplify(routeGeometry, 0.00001);
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(); }
public static GeometryType simplify( GeometryType geom, double tolerance) throws FunctionExecutionException { DouglasPeuckerSimplifier douglasPeuckerSimplifier = new DouglasPeuckerSimplifier(getGeometry(geom)); douglasPeuckerSimplifier.setEnsureValid(false); douglasPeuckerSimplifier.setDistanceTolerance(tolerance); Geometry resultGeometry = douglasPeuckerSimplifier.getResultGeometry(); return getGeometryType(resultGeometry); }
static Geometry computeProductGeometry(Product product) { final GeneralPath[] paths = ProductUtils.createGeoBoundaryPaths(product); final Polygon[] polygons = new Polygon[paths.length]; final GeometryFactory factory = new GeometryFactory(); for (int i = 0; i < paths.length; i++) { polygons[i] = convertAwtPathToJtsPolygon(paths[i], factory); } final DouglasPeuckerSimplifier peuckerSimplifier = new DouglasPeuckerSimplifier( polygons.length == 1 ? polygons[0] : factory.createMultiPolygon(polygons)); return peuckerSimplifier.getResultGeometry(); }
public static GeometryType simplify( GeometryType geom, double tolerance) throws FunctionExecutionException { DouglasPeuckerSimplifier douglasPeuckerSimplifier = new DouglasPeuckerSimplifier(getGeometry(geom)); douglasPeuckerSimplifier.setEnsureValid(false); douglasPeuckerSimplifier.setDistanceTolerance(tolerance); Geometry resultGeometry = douglasPeuckerSimplifier.getResultGeometry(); return getGeometryType(resultGeometry, geom.getSrid()); }
public Geometry computeProductGeometry(Product product) { try { final GeneralPath[] paths = ProductUtils.createGeoBoundaryPaths(product); final Polygon[] polygons = new Polygon[paths.length]; for (int i = 0; i < paths.length; i++) { polygons[i] = convertToJtsPolygon(paths[i].getPathIterator(null)); } final DouglasPeuckerSimplifier peuckerSimplifier = new DouglasPeuckerSimplifier( polygons.length == 1 ? polygons[0] : geometryFactory.createMultiPolygon(polygons)); return peuckerSimplifier.getResultGeometry(); } catch (Exception e) { return null; } }
/** * Simplify the geometry using the douglad peucker algorithm. * * @param geometry * @param distance * @return */ public static Geometry simplify(Geometry geometry, double distance) { if(geometry == null){ return null; } return DouglasPeuckerSimplifier.simplify(geometry, distance); } }
public static Geometry simplify(Geometry geom, double distanceTolerance) { DouglasPeuckerSimplifier tss = new DouglasPeuckerSimplifier(geom); tss.setDistanceTolerance(distanceTolerance); return tss.getResultGeometry(); }
public static GeometryType simplify( GeometryType geom, double tolerance) throws FunctionExecutionException { DouglasPeuckerSimplifier douglasPeuckerSimplifier = new DouglasPeuckerSimplifier(getGeometry(geom)); douglasPeuckerSimplifier.setEnsureValid(false); douglasPeuckerSimplifier.setDistanceTolerance(tolerance); Geometry resultGeometry = douglasPeuckerSimplifier.getResultGeometry(); return getGeometryType(resultGeometry, geom.getSrid()); }
public static Geometry simplify(Geometry g, float amount) { return DouglasPeuckerSimplifier.simplify(g, amount); }
/** * Simplifies a geometry using a given tolerance. * * @param geom geometry to simplify * @param distanceTolerance the tolerance to use * @return a simplified version of the geometry */ public static Geometry simplify(Geometry geom, double distanceTolerance) { DouglasPeuckerSimplifier tss = new DouglasPeuckerSimplifier(geom); tss.setDistanceTolerance(distanceTolerance); return tss.getResultGeometry(); }
public static Geometry simplify(Geometry g, float amount) { return DouglasPeuckerSimplifier.simplify(g, amount); }
@Override public void plot(Canvas canvas, Shape shape) { double density = canvas.getInputMBR().getWidth() * canvas.getInputMBR().getHeight() / ((double) canvas.getWidth() * canvas.getHeight()); OSMPolygon shape2 = (OSMPolygon)shape; Rectangle lakeMBR = shape2.getMBR(); if (lakeMBR.getWidth() * lakeMBR.getHeight() / density > 1.0) { SVGCanvas svgLayer = (SVGCanvas) canvas; try { DouglasPeuckerSimplifier simplifier = new DouglasPeuckerSimplifier(shape2.geom); simplifier.setDistanceTolerance(density); svgLayer.drawShape((int) shape2.id, simplifier.getResultGeometry()); } catch (Exception e) { // Skip } } }
/** * Simplify the geometry using the douglad peucker algorithm. * * @param geometry * @param distance * @return */ public static Geometry simplify(Geometry geometry, double distance) { if(geometry == null){ return null; } return DouglasPeuckerSimplifier.simplify(geometry, distance); } }
private Geometry shrink(Geometry joined, double bufferSize) throws Exception { Geometry bufferedGeom = joined.buffer(bufferSize, QUADRANT_SEGMENTS, ENDCAP_STYLE); return DouglasPeuckerSimplifier.simplify(bufferedGeom, SIMPLIFICATION_DISTANCE_TOLERANCE); }
public Geometry getMergedBuffers() { if (this.mergedBuffers == null) { // synchronized (this) { Collection<Geometry> polygons = new ArrayList<>(); for (Stop stop : this.stops.values()) { if (getStopTimesForStop(stop.stop_id).isEmpty()) { continue; } if (stop.stop_lat > -1 && stop.stop_lat < 1 || stop.stop_lon > -1 && stop.stop_lon < 1) { continue; } Point stopPoint = gf.createPoint(new Coordinate(stop.stop_lon, stop.stop_lat)); Polygon stopBuffer = (Polygon) stopPoint.buffer(.01); polygons.add(stopBuffer); } Geometry multiGeometry = gf.buildGeometry(polygons); this.mergedBuffers = multiGeometry.union(); if (polygons.size() > 100) { this.mergedBuffers = DouglasPeuckerSimplifier.simplify(this.mergedBuffers, .001); } // } } return this.mergedBuffers; }
/** * @param distanceTolerance * @return */ private Coordinate[] createConvexHull( RenderableQualityModel rqm ) { // get 2D projection of 3D object required for calculating convex hull Coordinate[] coordinates = projectToPlane( rqm ); // calculate convex hull using JTS ConvexHull ch = new ConvexHull( coordinates, new com.vividsolutions.jts.geom.GeometryFactory() ); Geometry dp = DouglasPeuckerSimplifier.simplify( ch.getConvexHull(), 0.1 ); if ( dp instanceof Polygon ) { return ( (Polygon) dp ).getExteriorRing().getCoordinates(); } else if ( dp instanceof GeometryCollection ) { GeometryCollection collection = (GeometryCollection) dp; List<Coordinate> allCoordinates = new LinkedList<Coordinate>(); for ( int i = 0; i < collection.getNumGeometries(); ++i ) { Geometry geom = collection.getGeometryN( i ); if ( geom != null ) { if ( geom instanceof Polygon ) { Coordinate[] pC = ( (Polygon) geom ).getExteriorRing().getCoordinates(); allCoordinates.addAll( Arrays.asList( pC ) ); } } } return allCoordinates.toArray( new Coordinate[0] ); } return dp.getCoordinates(); }
Geometry out = DouglasPeuckerSimplifier.simplify(in, tolerance);
public SimpleFeature next() throws NoSuchElementException { SimpleFeature f = delegate.next(); for (Object attribute : f.getAttributes()) { if (attribute instanceof Geometry) { if (preserveTopology) { attribute = DouglasPeuckerSimplifier.simplify((Geometry) attribute, distance); } else { attribute = TopologyPreservingSimplifier.simplify((Geometry) attribute, distance); } } fb.add(attribute); } return fb.buildFeature(f.getID()); }
/** * Utility method for transforming a geometry ROI into the raster space, using the provided affine transformation. * * @param roi a {@link Geometry} in model space. * @param mt2d an {@link AffineTransform} that maps from raster to model space. This is already referred to the pixel corner. * @return a {@link ROI} suitable for using with JAI. * @throws ProcessException in case there are problems with ivnerting the provided {@link AffineTransform}. Very unlikely to happen. */ public static ROI prepareROI(Geometry roi, AffineTransform mt2d) throws ProcessException { // transform the geometry to raster space so that we can use it as a ROI source Geometry rasterSpaceGeometry; try { rasterSpaceGeometry = JTS.transform(roi, new AffineTransform2D(mt2d.createInverse())); } catch (MismatchedDimensionException e) { throw new ProcessException(e); } catch (TransformException e) { throw new ProcessException(e); } catch (NoninvertibleTransformException e) { throw new ProcessException(e); } // simplify the geometry so that it's as precise as the coverage, excess coordinates // just make it slower to determine the point in polygon relationship Geometry simplifiedGeometry = DouglasPeuckerSimplifier.simplify( rasterSpaceGeometry, 1); // build a shape using a fast point in polygon wrapper return new ROIGeometry(simplifiedGeometry); }