Package org.opengis.referencing.operation

Examples of org.opengis.referencing.operation.MathTransform.transform()


        assertNotNull(crs);
       
        MathTransform mt = CRS.findMathTransform(DefaultGeographicCRS.WGS84, crs);
        double[] source = new double[] {-20, 35};
        double[] dest = new double[2];
        mt.transform(source, 0, dest, 0, 1);
       
        // reference values computed using cs2cs +init=epsg:4326 +to +init=epsg:32662
        assertEquals(-2226389.82, dest[0], 0.01);
        assertEquals(3896182.18, dest[1], 0.01);
    }
View Full Code Here


       
        // forward
        double[] src = new double[] {20000, 10000};
        double[] dst = new double[2];
        MathTransform mt = CRS.findMathTransform(tombak, ng39);
        mt.transform(src, 0, dst, 0, 1);
       
        assertEquals(618336.748, dst[0], 0.001);
        assertEquals(3067774.210, dst[1], 0.001);
       
        // and back
View Full Code Here

        assertTrue(mt.toWKT().contains("NADCON"));
    
        double[] src = new double[] {56.575, -169.625};
        double[] expected = new double [] {56.576034, -169.62744};
        double[] p = new double[2];
        mt.transform(src, 0, p, 0, 1);
        assertEquals(expected[0], p[0], 1e-6);
        assertEquals(expected[1], p[1], 1e-6);
    }
   
    /**
 
View Full Code Here

        // test coordinate: Berne, old reference point
        // see http://www.swisstopo.admin.ch/internet/swisstopo/en/home/topics/survey/sys/refsys/switzerland.html
        DirectPosition2D source = new DirectPosition2D(sourceCRS, 46.9510827861504654, 7.4386324175389165);
        DirectPosition2D result = new DirectPosition2D();

        transform.transform(source, result);
        assertEquals(600000.0, result.x, 0.1);
        assertEquals(200000.0, result.y, 0.1);
    }
   
    public void testGetMapProjection() throws Exception {
View Full Code Here

    public void testMathTransform() throws FactoryException, TransformException {
        final MathTransformFactory mtFactory = ReferencingFactoryFinder.getMathTransformFactory(null);
        final ParameterValueGroup p = mtFactory.getDefaultParameters("Earth gravitational model");
        final MathTransform mt = mtFactory.createParameterizedTransform(p);
        DirectPosition pos = new GeneralDirectPosition(new double[] {45, 45, 1000});
        pos = mt.transform(pos, pos);
        assertEquals45.000, pos.getOrdinate(0), 0.001);
        assertEquals45.000, pos.getOrdinate(1), 0.001);
        assertEquals(1001.515, pos.getOrdinate(2), 0.001);
    }
}
View Full Code Here

    cs[3] = p2.y;

    // transform the provided crs to WGS84 lon,lat
    final MathTransform transform = CRS.findMathTransform(tempCRS,
        DefaultGeographicCRS.WGS84, true);
    transform.transform(cs, 0, csLatLong, 0, 2);

    // in long/lat format
    if ((csLatLong[0] < -180) || (csLatLong[0] > 180)
        || (csLatLong[2] < -180) || (csLatLong[2] > 180)
        || (csLatLong[1] < -90) || (csLatLong[1] > 90)
View Full Code Here

      newCsLatLong[1] = Math.min(Math.max(csLatLong[1], -90), 90);
      newCsLatLong[2] = Math.min(Math.max(csLatLong[2], -180), 180);
      newCsLatLong[3] = Math.min(Math.max(csLatLong[3], -90), 90);

      double[] origProject = new double[4];
      transform.transform(newCsLatLong, 0, origProject, 0, 2);

      // have the truncated bbox in the original projection, so we can
      // find the image (x,y) for the two points.
      double image_min_x = (origProject[0] - envelope.getMinX())
          / envelope.getWidth() * imageWidth;
 
View Full Code Here

        try {
            CoordinateReferenceSystem targetCRS = renderingEnvelope.getCoordinateReferenceSystem();
            MathTransform mt = CRS.findMathTransform(WGS84, targetCRS, true);
            double[] src = new double[] { centralMeridian, 0, 180 + centralMeridian, 0 };
            double[] dst = new double[4];
            mt.transform(src, 0, dst, 0, 2);

            if (CRS.getAxisOrder(targetCRS) == CRS.AxisOrder.NORTH_EAST) {
                radius = Math.abs(dst[3] - dst[1]);
            } else {
                radius = Math.abs(dst[2] - dst[0]);
View Full Code Here

        // compute the x of the dateline in the rendering CRS
        try {
            double[] ordinates = new double[] { 180, -80, 180, 80 };
            MathTransform mt = CRS.findMathTransform(DefaultGeographicCRS.WGS84,
                    renderingEnvelope.getCoordinateReferenceSystem());
            mt.transform(ordinates, 0, ordinates, 0, 2);
            datelineX = ordinates[0];
        } catch (Exception e) {
            // should never happen...
            throw new RuntimeException(e);
        }
View Full Code Here

        final MathTransform test = factory.createParameterizedTransform(param);
        final GeneralDirectPosition position = new GeneralDirectPosition(3);
        position.setOrdinate(0, 3771793.97);
        position.setOrdinate(1140253.34);
        position.setOrdinate(2, 5124304.35);
        assertSame(position, test.transform(position, position));
        assertEquals(3771878.84, position.getOrdinate(0), 1E-5);
        assertEquals( 140349.83, position.getOrdinate(1), 1E-5);
        assertEquals(5124421.30, position.getOrdinate(2), 1E-5);
    }
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.