Package org.opengis.referencing.operation

Examples of org.opengis.referencing.operation.MathTransform2D


        final RenderedImage finalImage = input.getRenderedImage();
        final GridGeometry2D preSymbolizerGridGeometry = (input.getGridGeometry());
        // I need to translate half of a pixel since in wms the envelope
        // map to the corners of the raster space not to the center of the
        // pixels.
        final MathTransform2D finalGCTransform=preSymbolizerGridGeometry.getGridToCRS2D(PixelOrientation.UPPER_LEFT);
        if (!(finalGCTransform instanceof AffineTransform)) {
            throw new UnsupportedOperationException(
                    "Non-affine transformations not yet implemented"); // TODO
        }
        final AffineTransform finalGCgridToWorld = new AffineTransform((AffineTransform) finalGCTransform);
View Full Code Here


            // now create the crop grid to world which can be used to decide
            // which sourceFile area we need to crop in the selected level taking
            // into account the scale factors imposed by the selection of this
            // level together with the base level grid to world transformation
            final MathTransform2D cropGridToWorldCorner = (MathTransform2D) ProjectiveTransform.create(selectedlevel.gridToWorldTransformCorner);
            final MathTransform2D cropWorldToGrid = cropGridToWorldCorner.inverse();

            // computing the crop sourceFile area which leaves straight into the
            // selected level raster space, NOTICE that at the end we need to
            // take into account the fact that we might also decimate therefore
            // we cannot just use the crop grid to world but we need to correct
View Full Code Here

    private GridGeometry2D computeReadingGeometry(GridGeometry2D gg,
            CoordinateReferenceSystem readerCRS, Polygon polygon, ProjectionHandler handler)
            throws TransformException,
            FactoryException, IOException {
        GridGeometry2D readingGridGeometry;
        MathTransform2D crsToGrid2D = gg.getCRSToGrid2D();
        MathTransform2D gridToCRS2D = gg.getGridToCRS2D();
        if (sameCRS) {
            Envelope gridEnvelope = JTS.transform(polygon, crsToGrid2D).getEnvelopeInternal();
            GridEnvelope2D gridRange = new GridEnvelope2D((int) gridEnvelope.getMinX(),
                    (int) gridEnvelope.getMinY(), (int) Math.round(gridEnvelope.getWidth()),
                    (int) Math.round(gridEnvelope.getHeight()));
View Full Code Here

                            coverage = null;
                        }
                       
                        if(coverage != null) {
                            // we might also need to scale the coverage to the desired resolution
                            MathTransform2D coverageTx = readGG.getGridToCRS2D();
                            if(coverageTx instanceof AffineTransform) {
                                AffineTransform coverageAt = (AffineTransform) coverageTx;
                                AffineTransform renderingAt = (AffineTransform) gridGeometry.getGridToCRS2D();
                                // we adjust the scale only if we have many more pixels than required (30% or more)
                                final double ratioX = coverageAt.getScaleX() / renderingAt.getScaleX();
View Full Code Here

        //

        // invert the requested grid to world keeping into account the fact that it is related to
        // cell center
        // while the raster is related to cell corner
        MathTransform2D requestedWorldToGrid;
        try {
            requestedWorldToGrid = (MathTransform2D) PixelTranslation.translate(
                    ProjectiveTransform.create(requestedGridToWorld), PixelInCell.CELL_CENTER,
                    PixelInCell.CELL_CORNER).inverse();
        } catch (NoninvertibleTransformException e) {
View Full Code Here

     
      // now create the crop grid to world which can be used to decide
      // which source area we need to crop in the selected level taking
      // into account the scale factors imposed by the selection of this
      // level together with the base level grid to world transformation
      MathTransform2D cropWorldToGrid=(MathTransform2D) PixelTranslation.translate(ProjectiveTransform.create(selectedlevel.gridToWorldTransform), PixelInCell.CELL_CENTER, PixelInCell.CELL_CORNER).inverse();   
     
      // computing the crop source area which leaves straight into the
      // selected level raster space, NOTICE that at the end we need to
      // take into account the fact that we might also decimate therefore
      // we cannot just use the crop grid to world but we need to correct
View Full Code Here

      // We need to invert the requested gridToWorld and then adjust the requested raster area are accordingly
      //
     
      // invert the requested grid to world keeping into account the fact that it is related to cell center
      // while the raster is related to cell corner
      MathTransform2D requestedWorldToGrid;
    try {
      requestedWorldToGrid = (MathTransform2D) PixelTranslation.translate(ProjectiveTransform.create(requestedGridToWorld), PixelInCell.CELL_CENTER, PixelInCell.CELL_CORNER).inverse();
    } catch (NoninvertibleTransformException e) {
      throw new DataSourceException(e);
    }
View Full Code Here

     * Tests the transformation of a single coordinate.
     */
    public void testTransformCoordinate() throws FactoryException, TransformException {
        Coordinate   coord = new Coordinate(10, 10);
        AffineTransform at = AffineTransform.getScaleInstance(0.5, 1);
        MathTransform2D  t = (MathTransform2D) ReferencingFactoryFinder.getMathTransformFactory(null)
                                            .createAffineTransform(new GeneralMatrix(at));
        coord = JTS.transform(coord, coord, t);
        assertEquals(new Coordinate(5, 10), coord);
        coord = JTS.transform(coord, coord, t.inverse());
        assertEquals(new Coordinate(10, 10), coord);
       
        CoordinateReferenceSystem crs = ReferencingFactoryFinder.getCRSFactory(null).createFromWKT(UTM_ZONE_10N);
        t = (MathTransform2D) ReferencingFactoryFinder.getCoordinateOperationFactory(null).createOperation(
                                            DefaultGeographicCRS.WGS84, crs).getMathTransform();
        coord = new Coordinate(-123, 55);
        coord = JTS.transform(coord, coord, t);
        coord = JTS.transform(coord, coord, t.inverse());
        assertEquals(-123, coord.x, EPS);
        assertEquals55, coord.y, EPS);
    }
View Full Code Here

     * Tests the transformation of an envelope.
     */
    public void testTransformEnvelopeMathTransform() throws FactoryException, TransformException {
        Envelope envelope  = new Envelope(0, 10, 0, 10);
        AffineTransform at = AffineTransform.getScaleInstance(0.5, 1);
        MathTransform2D t  = (MathTransform2D) ReferencingFactoryFinder.getMathTransformFactory(null)
                                            .createAffineTransform(new GeneralMatrix(at));
        envelope = JTS.transform(envelope, t);
        assertEquals(new Envelope(0, 5, 0, 10), envelope);
        envelope = JTS.transform(envelope, t.inverse());
        assertEquals(new Envelope(0, 10, 0, 10), envelope);
       
        envelope = JTS.transform(envelope, null, t, 10);
        assertEquals(new Envelope(0, 5, 0, 10), envelope);
        envelope = JTS.transform(envelope, null, t.inverse(), 10);
        assertEquals(new Envelope(0, 10, 0, 10), envelope);
       
        CoordinateReferenceSystem crs = ReferencingFactoryFinder.getCRSFactory(null).createFromWKT(UTM_ZONE_10N);
        t = (MathTransform2D) ReferencingFactoryFinder.getCoordinateOperationFactory(null).createOperation(
                                            DefaultGeographicCRS.WGS84, crs).getMathTransform();
        envelope = new Envelope(-123, -133, 55, 60);
        envelope = JTS.transform(envelope, t);
        envelope = JTS.transform(envelope, t.inverse());
        /*
         * Use a large tolerance factory for comparaisons because an accurate transformed envelope
         * is bigger than the envelope that we get if we transformed only the 4 corners, and the
         * inverse envelope way expand yet again the envelope for exactly the same reason.
         */
 
View Full Code Here

    /**
     * Compares the current implementation with a simplier one.
     */
    @Test
    public void testTransform() throws FactoryException, TransformException {
        final MathTransform2D t;
        final CoordinateReferenceSystem crs;
        crs = ReferencingFactoryFinder.getCRSFactory(null).createFromWKT(JTSTest.UTM_ZONE_10N);
        t = (MathTransform2D) ReferencingFactoryFinder.getCoordinateOperationFactory(null).createOperation(
                                            DefaultGeographicCRS.WGS84, crs).getMathTransform();
        final Random random = new Random(546757437746704345L);
View Full Code Here

TOP

Related Classes of org.opengis.referencing.operation.MathTransform2D

Copyright © 2018 www.massapicom. 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.