Package org.opengis.referencing.operation

Examples of org.opengis.referencing.operation.Matrix


    /**
     * Tests (indirectly) {@link Formatter#append(Matrix)}.
     */
    @Test
    public void testAppendMatrix() {
        final Matrix m = new MatrixMock(4, 4,
                1, 0, 4, 0,
               -2, 1, 0, 0,
                0, 0, 1, 7,
                0, 0, 0, 1);
        assertWktEquals(
View Full Code Here


                HardCodedAxes.GEODETIC_LONGITUDE,
                HardCodedAxes.GEODETIC_LATITUDE);
        final CoordinateSystem φλ = new DefaultEllipsoidalCS(singletonMap(NAME_KEY, "(φ,λ)"),
                HardCodedAxes.GEODETIC_LATITUDE,
                HardCodedAxes.GEODETIC_LONGITUDE);
        final Matrix expected = Matrices.create(3, 3, new double[] {
                0, 1, 0,
                1, 0, 0,
                0, 0, 1});
        assertTrue(swapAndScaleAxes(λφ, λφ).isIdentity());
        assertTrue(swapAndScaleAxes(φλ, φλ).isIdentity());
View Full Code Here

                HardCodedAxes.ELLIPSOIDAL_HEIGHT);
        final CoordinateSystem φλh = new DefaultEllipsoidalCS(singletonMap(NAME_KEY, "(φ,λ,h)"),
                HardCodedAxes.GEODETIC_LATITUDE,
                HardCodedAxes.GEODETIC_LONGITUDE,
                HardCodedAxes.ELLIPSOIDAL_HEIGHT);
        final Matrix expected = Matrices.create(4, 4, new double[] {
                0, 1, 0, 0,
                1, 0, 0, 0,
                0, 0, 1, 0,
                0, 0, 0, 1});
        assertTrue(swapAndScaleAxes(λφh, λφh).isIdentity());
View Full Code Here

    public void testScaleAndSwapAxesNonSquare() throws ConversionException {
        final DefaultCartesianCS cs = new DefaultCartesianCS(singletonMap(NAME_KEY, "Test"),
                new DefaultCoordinateSystemAxis(getProperties(HardCodedAxes.SOUTHING), "y", AxisDirection.SOUTH, SI.CENTIMETRE),
                new DefaultCoordinateSystemAxis(getProperties(HardCodedAxes.EASTING)"x", AxisDirection.EAST,  SI.MILLIMETRE));

        Matrix matrix = swapAndScaleAxes(HardCodedCS.CARTESIAN_2D, cs);
        assertMatrixEquals("(x,y) → (y,x)", Matrices.create(3, 3, new double[] {
                0,  -100,    0,
                10000,    0,
                0,     0,    1
        }), matrix, STRICT);
View Full Code Here

         */
        String code;
        CoordinateReferenceSystem crs0, crs1;
        CoordinateOperationFactory opFactory = ReferencingFactoryFinder.getCoordinateOperationFactory(null);
        MathTransform mt;
        Matrix matrix;
        /*
         * Tests a WGS84 geographic CRS (2D) with (NORTH, EAST) axis directions.
         * The factory should reorder the axis with no more operation than an axis swap.
         */
        code = "4326";
View Full Code Here

        final CoordinateReferenceSystem modified = CRS.decode("EPSG:4326", true );
        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

        Assert.assertFalse(true);
      }
      catch (UnsupportedOperationException e) {
        // TODO: handle exception
      }
      Matrix m= p0.derivative(inDP);
      Assert.assertTrue(m.getNumCol()==1);
      Assert.assertTrue(m.getNumRow()==1);
      Assert.assertTrue(m.getElement(0, 0)==1);
     
      ////
      //
      //testing the transform
      //
      ////
      final DefaultPiecewiseTransform1D<DefaultPiecewiseTransform1DElement> piecewise =
          new DefaultPiecewiseTransform1D<DefaultPiecewiseTransform1DElement>(new DefaultPiecewiseTransform1DElement[] { p0 },11);
   
      Assert.assertEquals(piecewise.getApproximateDomainRange().getMinimum(), 0.0, 0.0);
      Assert.assertEquals(piecewise.getApproximateDomainRange().getMaximum(), 1.0, 0.0);
      Assert.assertEquals(piecewise.transform(0.5), 0.5, 0.0);
      Assert.assertEquals(piecewise.transform(
          new GeneralDirectPosition(new double[] { 0.5 }), null)
          .getOrdinate(0), 0.5, 0.0);
      Assert.assertEquals(piecewise.transform(1.5), 0.0, 11.0);
     
      try{
   
        piecewise.transform(new double[]{0.5},0,(double[])null,0,0);
        Assert.assertFalse(true);
      }
      catch (UnsupportedOperationException e) {
        // TODO: handle exception
      }
     
      try{
   
        piecewise.transform(new float[]{0.5f},0,(float[])null,0,0);
        Assert.assertFalse(true);
      }
      catch (UnsupportedOperationException e) {
        // TODO: handle exception
      }
     
     
      try{
        piecewise.toWKT();
        Assert.assertFalse(true);
      }
      catch (UnsupportedOperationException e) {
        // TODO: handle exception
      }
     
      try{
        m= piecewise.derivative(inDP);
        Assert.assertFalse(true);
      }
      catch (UnsupportedOperationException e) {
        // TODO: handle exception
      }
     
      ////
      //
      //testing the passthrough through indirect instantion
      //
      ////
      final DefaultPassthroughPiecewiseTransform1DElement p1 = new DefaultPassthroughPiecewiseTransform1DElement(
          "p1");
      Assert.assertEquals(p1.getTargetDimensions(), 1);
      Assert.assertEquals(p1.getSourceDimensions(), 1);
      Assert.assertTrue(p1.isIdentity());
      Assert.assertEquals(p1.inverse(), LinearTransform1D.IDENTITY);
      Assert.assertEquals(p1.transform(0.5), 0.5, 0.0);
      Assert.assertEquals(p1.transform(111.5), 111.5, 0.0);
      Assert.assertEquals(p1.transform(
          new GeneralDirectPosition(new double[] { 123.5 }), null)
          .getOrdinate(0), 123.5, 0.0);
      Assert.assertEquals(p1.inverse().transform(
          new GeneralDirectPosition(new double[] { 657.5 }), null)
          .getOrdinate(0), 657.5, 0.0);
      Assert.assertEquals(p1.derivative(1.0), 1.0, 0.0);
      final DirectPosition1D inDP1 = new DirectPosition1D(0.6);
      final DirectPosition outDP1= p1.transform(inDP1, null);
      Assert.assertTrue(outDP1.getOrdinate(0)==0.6);
      try{
   
        p1.transform(new double[]{1233444.5},0,(double[])null,0,0);
        Assert.assertFalse(true);
      }
      catch (UnsupportedOperationException e) {
        // TODO: handle exception
      }
     
      try{
   
        p1.transform(new float[]{6595.5f},0,(float[])null,0,0);
        Assert.assertFalse(true);
      }
      catch (UnsupportedOperationException e) {
        // TODO: handle exception
      }
     
     
      try{
        p1.toWKT();
        Assert.assertFalse(true);
      }
      catch (UnsupportedOperationException e) {
        // TODO: handle exception
      }
      Matrix m1= p1.derivative(inDP1);
      Assert.assertTrue(m1.getNumCol()==1);
      Assert.assertTrue(m1.getNumRow()==1);
      Assert.assertTrue(m1.getElement(0, 0)==1);
   
    }
View Full Code Here

        assertEquals(AxisDirection.WEST,  south.getCoordinateSystem().getAxis(0).getDirection());
        assertEquals(AxisDirection.SOUTH, south.getCoordinateSystem().getAxis(1).getDirection());

        MathTransform transform = CRS.findMathTransform(north, south);
        assertTrue(transform instanceof LinearTransform);
        Matrix matrix = ((LinearTransform) transform).getMatrix();
        assertDiagonal(matrix);
        assertFalse(matrix.isIdentity());
        assertEquals("West direction should be unchanged. ",      +1, matrix.getElement(0,0), EPS);
        assertEquals("North-South direction should be reverted.", -1, matrix.getElement(1,1), EPS);
        assertEquals("No easting expected.",                       0, matrix.getElement(0,2), EPS);
        assertEquals("No northing expected.",                      0, matrix.getElement(1,2), EPS);

        /*
         * Tests "Transverse Mercator South Oriented"
         */
        south = parseTransverseMercator(true, true, 1000);
        assertEquals(AxisDirection.WEST,  south.getCoordinateSystem().getAxis(0).getDirection());
        assertEquals(AxisDirection.SOUTH, south.getCoordinateSystem().getAxis(1).getDirection());
        transform = CRS.findMathTransform(north, south);
        assertTrue(transform instanceof LinearTransform);
        matrix = ((LinearTransform) transform).getMatrix();
        assertDiagonal(matrix);
        assertFalse(matrix.isIdentity());
        assertEquals("West direction should be unchanged. ",      +1, matrix.getElement(0,0), EPS);
        assertEquals("North-South direction should be reverted.", -1, matrix.getElement(1,1), EPS);
        assertEquals("No easting expected.",                       0, matrix.getElement(0,2), EPS);
        assertEquals("No northing expected.",                      0, matrix.getElement(1,2), EPS);

        /*
         * Tries with a different northing.
         */
        north = parseTransverseMercator(false, false, 3000);
        transform = CRS.findMathTransform(north, south);
        assertTrue(transform instanceof LinearTransform);
        matrix = ((LinearTransform) transform).getMatrix();
        assertFalse(matrix.isIdentity());
        assertEquals("West direction should be unchanged. ",      +1, matrix.getElement(0,0), EPS);
        assertEquals("North-South direction should be reverted.", -1, matrix.getElement(1,1), EPS);
        assertEquals("No easting expected.",                       0, matrix.getElement(0,2), EPS);
        assertEquals("Northing expected.",                      2000, matrix.getElement(1,2), EPS);
    }
View Full Code Here

        final CoordinateReferenceSystem targetCRS = CRS.parseWKT(prjWKT);
        final MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS);
        assertTrue(transform instanceof ConcatenatedTransform);
        final ConcatenatedTransform ct = (ConcatenatedTransform) transform;
        assertTrue(ct.transform2 instanceof LinearTransform);
        final Matrix matrix = ((LinearTransform) ct.transform2).getMatrix();
        assertDiagonal(matrix);
        assertEquals("East-West direction should be reverted. ",  -1, matrix.getElement(0,0), EPS);
        assertEquals("North-South direction should be reverted.", -1, matrix.getElement(1,1), EPS);
        assertEquals("No easting expected.",                       0, matrix.getElement(0,2), EPS);
        assertEquals("No northing expected.",                      0, matrix.getElement(1,2), EPS);
    }
View Full Code Here

        final Unit<Length> cm = SI.CENTI(SI.METER);
        final Unit<Length> mm = SI.MILLI(SI.METER);
        final AbstractCS cs = new DefaultCartesianCS("Test",
              new DefaultCoordinateSystemAxis("y", SOUTH, cm),
              new DefaultCoordinateSystemAxis("x", EAST,  mm));
        Matrix matrix;
        matrix = AbstractCS.swapAndScaleAxis(DefaultCartesianCS.GENERIC_2D, cs);
        assertEquals(new GeneralMatrix(new double[][] {
            {0,  -100,    0},
            {10000,    0},
            {0,     0,    1}
View Full Code Here

TOP

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

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.