private Geometry getSimpleLine(final Geometry geometry, final double dTolerance) { Geometry simple; if (m_bPreserve) { simple = TopologyPreservingSimplifier.simplify(geometry, dTolerance); } else { simple = DouglasPeuckerSimplifier.simplify(geometry, dTolerance); } return simple; }
/** * 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); } // System.out.println(rasterSpaceGeometry); // System.out.println(rasterSpaceGeometry.getEnvelopeInternal()); // 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); }