/** * Builds a decimator that will generalize geometries so that two subsequent points will be at * least pixelDistance away from each other when painted on the screen. Set pixelDistance to 0 * if you don't want any generalization (but just a transformation) * * @param screenToWorld * @param paintArea * @param pixelDistance */ public Decimator(MathTransform screenToWorld, Rectangle paintArea, double pixelDistance) { if (screenToWorld != null && pixelDistance > 0) { try { double[] spans = computeGeneralizationDistances(screenToWorld, paintArea, pixelDistance); this.spanx = spans[0]; this.spany = spans[1]; } catch (TransformException e) { throw new RuntimeException( "Could not perform the generalization spans computation", e); } } else { this.spanx = 1; this.spany = 1; } }
double[] dx = Decimator.computeGeneralizationDistances(mt, new Rectangle(10, 10), 1); assertEquals(10, dx[0], 0d); assertEquals(10, dx[1], 0d);
/** * Builds a decimator that will generalize geometries so that two subsequent points * will be at least pixelDistance away from each other when painted on the screen. * Set pixelDistance to 0 if you don't want any generalization (but just a transformation) * * @param screenToWorld * @param paintArea * @param pixelDistance */ public Decimator(MathTransform screenToWorld, Rectangle paintArea, double pixelDistance) { if (screenToWorld != null && pixelDistance > 0) { try { double[] spans = computeGeneralizationDistances(screenToWorld, paintArea, pixelDistance); this.spanx = spans[0]; this.spany = spans[1]; } catch(TransformException e) { throw new RuntimeException("Could not perform the generalization spans computation", e); } } else { this.spanx = 1; this.spany = 1; } }
MathTransform mt = buildFullTransform(crs2D, mapCRS, worldToScreenTransform); double[] spans = Decimator.computeGeneralizationDistances( mt.inverse(), screenSize, generalizationDistance); double distance = spans[0] < spans[1] ? spans[0] : spans[1];
protected static double[] getPixelSize( final ReferencedEnvelope renderingArea, final Rectangle screenSize) { double[] pixelSize; try { pixelSize = Decimator.computeGeneralizationDistances( ProjectiveTransform.create( RendererUtilities.worldToScreenTransform( renderingArea, screenSize)) .inverse(), screenSize, 1.0); } catch (TransformException ex) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.log(Level.WARNING, "Error while computing pixel size", ex); } pixelSize = new double[] { renderingArea.getWidth() / screenSize.getWidth(), renderingArea.getHeight() / screenSize.getHeight() }; } return pixelSize; }
spans_sourceCRS = Decimator.computeGeneralizationDistances(screenToWorld, context.paintArea, 0.8); spans_targetCRS = Decimator.computeGeneralizationDistances(context.targetToScreen.inverse(), context.paintArea,1.0);
Decimator.computeGeneralizationDistances(screenToWorld, context.paintArea, 0.8); Decimator.computeGeneralizationDistances( context.targetToScreen.inverse(), context.paintArea, 1.0);
double[] spans = Decimator.computeGeneralizationDistances(mt.inverse(), screenSize, generalizationDistance); double distance = spans[0] < spans[1] ? spans[0] : spans[1]; for (LiteFeatureTypeStyle fts : styles) {
Decimator.computeGeneralizationDistances( fullTransform.inverse(), new Rectangle(width, height),