Examples of AffineTransform2D


Examples of org.geotools.referencing.operation.transform.AffineTransform2D

           
            if ( reader.hasMoreChildren() ) {
                reader.moveDown(); //transform or crs
            }
           
            AffineTransform2D gridToCRS = null;
            if ( "transform".equals( reader.getNodeName() ) ) {
                double sx,sy,shx,shy,tx,ty;
               
                reader.moveDown(); //scaleX
                sx = Double.parseDouble( reader.getValue() );
                reader.moveUp();
               
                reader.moveDown(); //scaleY
                sy = Double.parseDouble( reader.getValue() );
                reader.moveUp();
               
                reader.moveDown(); //shearX
                shx = Double.parseDouble( reader.getValue() );
                reader.moveUp();
               
                reader.moveDown(); //shearY
                shy = Double.parseDouble( reader.getValue() );
                reader.moveUp();
               
                reader.moveDown(); //translateX
                tx = Double.parseDouble( reader.getValue() );
                reader.moveUp();
               
                reader.moveDown(); //translateY
                ty = Double.parseDouble( reader.getValue() );
                reader.moveUp();
               

                // set tranform
                gridToCRS = new AffineTransform2D(sx, shx, shy, sy, tx, ty);
               
                reader.moveUp();
                if ( reader.hasMoreChildren() ) {
                    reader.moveDown(); //crs
                }
View Full Code Here

Examples of org.geotools.referencing.operation.transform.AffineTransform2D

        raw.put("identifier", getLayerId);
        raw.put("format", "image/geotiff");
        raw.put("BoundingBox", "-45,146,-42,147,urn:ogc:def:crs:EPSG:6.6:4326");

        GridCoverage[] coverages = executeGetCoverageKvp(raw);
        AffineTransform2D tx = (AffineTransform2D) coverages[0].getGridGeometry().getGridToCRS();
        assertEquals(0.0, tx.getTranslateX());
        assertEquals(0.0, tx.getTranslateY());
    }
View Full Code Here

Examples of org.geotools.referencing.operation.transform.AffineTransform2D

        raw.put("GridBaseCRS", "urn:ogc:def:crs:EPSG:6.6:4326");

        GridCoverage[] coverages = executeGetCoverageKvp(raw);
        GridCoverage original = getCatalog().getCoverageByName(getLayerId).getGridCoverage(null, null);

        final AffineTransform2D originalTx = (AffineTransform2D) original.getGridGeometry()
                .getGridToCRS();
        final AffineTransform2D flippedTx = (AffineTransform2D) coverages[0].getGridGeometry()
                .getGridToCRS();
        assertEquals(originalTx.getScaleX(), flippedTx.getShearY(), EPS);
        assertEquals(originalTx.getScaleY(), flippedTx.getShearX(), EPS);
        assertEquals(originalTx.getShearX(), flippedTx.getScaleY(), EPS);
        assertEquals(originalTx.getShearY(), flippedTx.getScaleX(), EPS);
        assertEquals(0.0, flippedTx.getTranslateY(), EPS);
        assertEquals(0.0, flippedTx.getTranslateX(), EPS);
    }
View Full Code Here

Examples of org.geotools.referencing.operation.transform.AffineTransform2D

        raw.put("BoundingBox", "-45,146,-42,147,urn:ogc:def:crs:EPSG:6.6:4326");
        raw.put("GridBaseCRS", "urn:ogc:def:crs:EPSG:6.6:4326");
        raw.put("GridType", "urn:ogc:def:method:WCS:1.1:2dSimpleGrid");
        raw.put("GridOffsets", "0.1,0.1");
        GridCoverage[] coverages = executeGetCoverageKvp(raw);
        final AffineTransform2D flippedTx = (AffineTransform2D) coverages[0].getGridGeometry()
        .getGridToCRS();
        assertEquals(0.0, flippedTx.getShearY(), EPS);
        assertEquals(0.0, flippedTx.getShearX(), EPS);
        assertEquals(0.1, flippedTx.getScaleY(), EPS);
        assertEquals(0.1, flippedTx.getScaleX(), EPS);
        assertEquals(0.0, flippedTx.getTranslateY(), EPS);
        assertEquals(0.0, flippedTx.getTranslateX(), EPS);
    }
View Full Code Here

Examples of org.geotools.referencing.operation.transform.AffineTransform2D

                        if (gridCRS.getGridType().equals(GridType.GT2dSimpleGrid))
                            offsets = new Double[] { 1.0, 1.0 };
                        else
                            offsets = new Double[] { 1.0, 0.0, 0.0, 1.0 };
                    } else {
                        AffineTransform2D affine = (AffineTransform2D) gridToCRS;
                        if (gridCRS.getGridType().equals(GridType.GT2dSimpleGrid))
                            offsets = new Double[] { affine.getScaleX(), affine.getScaleY() };
                        else
                            offsets = new Double[] { affine.getScaleX(), affine.getShearX(),
                                    affine.getShearY(), affine.getScaleY() };
                    }
                }

                // building the actual transform for the resulting grid geometry
                AffineTransform tx;
                if (gridCRS.getGridType().equals(GridType.GT2dSimpleGrid.getXmlConstant())) {
                    tx = new AffineTransform(offsets[0], 0, 0, offsets[1], origin[0], origin[1]);
                } else {
                    tx = new AffineTransform(offsets[0], offsets[2], offsets[1], offsets[3],
                            origin[0], origin[1]);
                }
                gridToCRS = new AffineTransform2D(tx);
            }

            // now we have enough info to read the coverage, grab the parameters
            // and add the grid geometry info
            final Map parameters = CoverageUtils.getParametersKVP(reader.getFormat()
View Full Code Here

Examples of org.geotools.referencing.operation.transform.AffineTransform2D

        // then rotate the geometry around its center
        final Coordinate center = mapBounds.centre();
        final AffineTransform affineTransform = AffineTransform.getRotateInstance(
                this.transformer.getRotation(), center.x, center.y);
        final MathTransform mathTransform = new AffineTransform2D(affineTransform);

        try {
            final Geometry rotatedBounds = JTS.transform(gfac.toGeometry(mapBounds), mathTransform);
            this.cachedRotatedMapBounds = Optional.of(rotatedBounds);
        } catch (TransformException e) {
View Full Code Here

Examples of org.geotools.referencing.operation.transform.AffineTransform2D

                                              @Nullable final AreaOfInterest areaOfInterest) {
        if (areaOfInterest != null) {
            final AffineTransform worldToScreenTransform = worldToScreenTransform(transformer.toReferencedEnvelope(),
                    transformer.getPaintArea());

            MathTransform mathTransform = new AffineTransform2D(worldToScreenTransform);
            final Polygon screenGeometry;
            try {
                screenGeometry = (Polygon) JTS.transform(areaOfInterest.getArea(), mathTransform);
            } catch (TransformException e) {
                throw new RuntimeException(e);
View Full Code Here

Examples of org.geotools.referencing.operation.transform.AffineTransform2D

    private Geometry rotateExtent(final Geometry mapExtent, final double rotation,
            final ReferencedEnvelope originalEnvelope) {
        final Coordinate center = originalEnvelope.centre();
        final AffineTransform affineTransform = AffineTransform.getRotateInstance(
                Math.toRadians(rotation), center.x, center.y);
        final MathTransform mathTransform = new AffineTransform2D(affineTransform);

        try {
            return JTS.transform(mapExtent, mathTransform);
        } catch (TransformException e) {
            throw new RuntimeException("Failed to rotate map extent", e);
View Full Code Here

Examples of org.geotools.referencing.operation.transform.AffineTransform2D

    private boolean isCurveCompatible(MathTransform mt) {
        if (!(mt instanceof AffineTransform2D)) {
            return false;
        }

        AffineTransform2D at = (AffineTransform2D) mt;
        // return true if we are scaling by the same amount, and the rotational
        // elements are equal in absolute value
        return at.getScaleX() == at.getScaleY()
                && Math.abs(at.getShearX()) == Math.abs(at.getShearY());
    }
View Full Code Here

Examples of org.geotools.referencing.operation.transform.AffineTransform2D

        // Definition of the parameters
        GridCoverageFactory coverageFactory = new GridCoverageFactory(GeoTools.getDefaultHints());
        String coverageName = "test";
        int imageIndex = 0;
        PlanarImage image = ConstantDescriptor.create(10f, 10f, new Byte[]{1}, GeoTools.getDefaultHints());
        MathTransform raster2Model = new AffineTransform2D(AffineTransform.getScaleInstance(2, 2));
        CoordinateReferenceSystem spatialReferenceSystem2D = DefaultGeographicCRS.WGS84;
       
        // Calculate a gridGeometry from the image and the MathTransform
        Rectangle bounds = image.getBounds();
        GridGeometry2D gg2D = new GridGeometry2D(new GridEnvelope2D(bounds), raster2Model, spatialReferenceSystem2D);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.