Package org.geotools.referencing.operation.matrix

Examples of org.geotools.referencing.operation.matrix.GeneralMatrix


    public Point worldToPixel( Coordinate coord ) {
        return getViewportModel().worldToPixel(coord);
    }

    public MathTransform2D worldToScreenMathTransform() {
        GeneralMatrix matrix = new GeneralMatrix(getViewportModelInternal()
                .worldToScreenTransform());
        try {
            return (MathTransform2D) ReferencingFactoryFinder.getMathTransformFactory(null)
                    .createAffineTransform(matrix);
        } catch (Exception e) {
View Full Code Here


    public Shape toShape( Geometry geometry, CoordinateReferenceSystem crs ) {
        try {
            MathTransform transform = CRS.findMathTransform(crs, getCRS(), true);
            MathTransformFactory factory = ReferencingFactoryFinder.getMathTransformFactory(null);
            MathTransform toScreen = factory.createAffineTransform(new GeneralMatrix(
                    worldToScreenTransform()));
            transform = factory.createConcatenatedTransform(transform, toScreen);
            return new LiteShape2(geometry, transform, new Decimator(transform), false);
        } catch (FactoryException e) {
            return null;
View Full Code Here

        return ScaleUtils.worldToPixel(coord, getImageBounds(), getImageSize());
    }

    @Override
    public MathTransform2D worldToScreenMathTransform() {
        GeneralMatrix matrix = new GeneralMatrix(worldToScreenTransform());
        try {
            return (MathTransform2D) ReferencingFactoryFinder.getMathTransformFactory(null)
                    .createAffineTransform(matrix);
        } catch (Exception e) {
            return null;
View Full Code Here

    /*
     * Test method for 'org.locationtech.udig.tools.edit.support.LazyCoord.get(Point)'
     */
    @Test
    public void testGet() throws Exception{
        MathTransform layerTransform = ReferencingFactoryFinder.getMathTransformFactory(null).createAffineTransform(new GeneralMatrix(new AffineTransform()));
        EditBlackboard bb = new EditBlackboard(100,100, new AffineTransform(), layerTransform);

        Point startingPoint = Point.valueOf(10,10);
        LazyCoord coord=new LazyCoord(startingPoint, bb.toCoord(startingPoint),bb);
       
View Full Code Here

         */
        Geometry decimate(Geometry geom) {
          DefaultMathTransformFactory f= new DefaultMathTransformFactory();
            MathTransform xform=null;
      try {
        xform = f.createAffineTransform(new GeneralMatrix(worldToScreen.createInverse()));
        Decimator decimator=new Decimator(xform,mapArea);
              geom=decimator.decimate(geom);
      } catch (FactoryException e1) {
       
      } catch (NoninvertibleTransformException e1) {
View Full Code Here

                matrix[4] = tx.get( "scaleY") != null ? tx.get( "scaleY") : matrix[4];
                matrix[5] = tx.get( "translateY") != null ? tx.get( "translateY") : matrix[5];
                matrix[8] = 1.0;
               
                MathTransform gridToCRS = new DefaultMathTransformFactory()
                    .createAffineTransform( new GeneralMatrix(3,3,matrix));
                coverage.setGrid( new GridGeometry2D(range,gridToCRS,crs) );
            }
            else {
                coverage.setGrid( new GridGeometry2D( range, gridEnvelope ) );
            }
View Full Code Here

        }
        mt = opFactory.createOperation(crs0, crs1).getMathTransform();
        assertFalse(mt.isIdentity());
        assertTrue(mt instanceof LinearTransform);
        matrix = ((LinearTransform) mt).getMatrix();
        assertEquals(new GeneralMatrix(new double[][] {
            {0, 1, 0},
            {1, 0, 0},
            {0, 0, 1}}), new GeneralMatrix(matrix));
        /*
         * Tests a WGS84 geographic CRS (3D) with (NORTH, EAST, UP) axis directions.
         * Because this CRS uses sexagesimal units, conversions are not supported and
         * will not be tested.
         */
        code = "4329";
        crs0 = factory0.createCoordinateReferenceSystem(code);
        crs1 = factory1.createCoordinateReferenceSystem(code);
        assertNotSame(crs0, crs1);
        assertNotSame(crs0.getCoordinateSystem(), crs1.getCoordinateSystem());
        assertSame(((SingleCRS) crs0).getDatum(), ((SingleCRS) crs1).getDatum());
        assertFalse(crs0.getIdentifiers().isEmpty());
        if (METADATA_ERASED) {
            assertTrue(crs1.getIdentifiers().isEmpty());
        } else {
            assertEquals(crs0.getIdentifiers(), crs1.getIdentifiers());
        }
        /*
         * Tests a WGS84 geographic CRS (3D) with (NORTH, EAST, UP) axis directions.
         * The factory should reorder the axis with no more operation than an axis swap.
         */
        code = "63266413";
        crs0 = factory0.createCoordinateReferenceSystem(code);
        crs1 = factory1.createCoordinateReferenceSystem(code);
        assertNotSame(crs0, crs1);
        assertNotSame(crs0.getCoordinateSystem(), crs1.getCoordinateSystem());
        assertSame(((SingleCRS) crs0).getDatum(), ((SingleCRS) crs1).getDatum());
        assertFalse(crs0.getIdentifiers().isEmpty());
        if (METADATA_ERASED) {
            assertTrue(crs1.getIdentifiers().isEmpty());
        } else {
            assertEquals(crs0.getIdentifiers(), crs1.getIdentifiers());
        }
        mt = opFactory.createOperation(crs0, crs1).getMathTransform();
        assertFalse(mt.isIdentity());
        assertTrue(mt instanceof LinearTransform);
        matrix = ((LinearTransform) mt).getMatrix();
        assertEquals(new GeneralMatrix(new double[][] {
            {0, 1, 0, 0},
            {1, 0, 0, 0},
            {0, 0, 1, 0},
            {0, 0, 0, 1}}), new GeneralMatrix(matrix));
        /*
         * Tests a projected CRS with (EAST, NORTH) axis orientation. No axis reordering is needed,
         * which means that their coordinate systems are identical and the math transform should be
         * the identity one. Note that while no axis swap is needed, the base GeographicCRS are not
         * the same since an axis reordering has been done there.
         */
        code = "2027";
        crs0 = factory0.createCoordinateReferenceSystem(code);
        crs1 = factory1.createCoordinateReferenceSystem(code);
        assertNotSame(crs0, crs1);
        assertSame(crs0.getCoordinateSystem(), crs1.getCoordinateSystem());
        assertSame(((SingleCRS) crs0).getDatum(), ((SingleCRS) crs1).getDatum());
        assertNotSame(((ProjectedCRS) crs0).getBaseCRS(), ((ProjectedCRS) crs1).getBaseCRS());
        assertFalse(crs0.getIdentifiers().isEmpty());
        if (METADATA_ERASED) {
            assertTrue(crs1.getIdentifiers().isEmpty());
        } else {
            assertEquals(crs0.getIdentifiers(), crs1.getIdentifiers());
        }
        mt = opFactory.createOperation(crs0, crs1).getMathTransform();
        assertTrue(mt.isIdentity());
        /*
         * Tests a projected CRS with (WEST, SOUTH) axis orientation.
         * The factory should arrange the axis with no more operation than a direction change.
         * While the end result is a matrix like the GeographicCRS case, the path that lead to
         * this result is much more complex.
         */
        code = "22275";
        crs0 = factory0.createCoordinateReferenceSystem(code);
        crs1 = factory1.createCoordinateReferenceSystem(code);
        assertNotSame(crs0, crs1);
        assertNotSame(crs0.getCoordinateSystem(), crs1.getCoordinateSystem());
        assertSame(((SingleCRS) crs0).getDatum(), ((SingleCRS) crs1).getDatum());
        assertFalse(crs0.getIdentifiers().isEmpty());
        if (METADATA_ERASED) {
            assertTrue(crs1.getIdentifiers().isEmpty());
        } else {
            assertEquals(crs0.getIdentifiers(), crs1.getIdentifiers());
        }
        mt = opFactory.createOperation(crs0, crs1).getMathTransform();
        assertFalse(mt.isIdentity());
        assertTrue(mt instanceof LinearTransform);
        matrix = ((LinearTransform) mt).getMatrix();
        assertEquals(new GeneralMatrix(new double[][] {
            {-100},
            { 0, -10},
            { 001}}), new GeneralMatrix(matrix));
        /*
         * Tests the cache.
         */
        assertSame(cacheTest, factory1.createCoordinateReferenceSystem("4326"));
    }
View Full Code Here

        assertEquals("Expected a left-handed CS.",  -90, getAngle(standard), EPS);
        assertEquals("Expected a right-handed CS.", +90, getAngle(modified), EPS);
        final MathTransform transform = CRS.findMathTransform(standard, modified);
        assertTrue(transform instanceof LinearTransform);
        final Matrix matrix = ((LinearTransform) transform).getMatrix();
        assertEquals(new GeneralMatrix(new double[][] {
            { 010},
            { 100},
            { 001}}), new GeneralMatrix(matrix));
    }
View Full Code Here

          LOGGER.log(Level.FINE, builder.toString());
        }

     
      // here is the matrix we need to build
      final GeneralMatrix gm = new GeneralMatrix(3);
      final double scaleRaster2ModelLongitude = pixScales.getScaleX();
      final double scaleRaster2ModelLatitude = -pixScales.getScaleY();
      // "raster" space
      final double tiePointColumn = tiePoints[0].getValueAt(0)+ (rasterType == GeoTiffConstants.RasterPixelIsArea ? - 0.5: 0);
     
      // coordinates
      // (indicies)
      final double tiePointRow = tiePoints[0].getValueAt(1)+ (rasterType == GeoTiffConstants.RasterPixelIsArea ? - 0.5: 0);

      // compute an "offset and scale" matrix
      gm.setElement(0, 0, scaleRaster2ModelLongitude);
      gm.setElement(1, 1, scaleRaster2ModelLatitude);
      gm.setElement(0, 1, 0);
      gm.setElement(1, 0, 0);

      gm.setElement(0, 2, tiePoints[0].getValueAt(3) - (scaleRaster2ModelLongitude * tiePointColumn));
      gm.setElement(1, 2, tiePoints[0].getValueAt(4) - (scaleRaster2ModelLatitude * tiePointRow));

      // make it a LinearTransform
      xform = ProjectiveTransform.create(gm);

    } else if (hasModelTransformation) {
View Full Code Here

     */
    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);
       
View Full Code Here

TOP

Related Classes of org.geotools.referencing.operation.matrix.GeneralMatrix

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.