Package org.opengis.referencing.operation

Examples of org.opengis.referencing.operation.MathTransformFactory


    }

    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;
        } catch( TransformException e){
            return null;
View Full Code Here


    /**
     * Tests the creation of the math transform from the factory.
     */
    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

     * section 2.4.3.1.
     */
    @Test
    public void testTranslation() throws FactoryException, TransformException {
        final String        classification = "Geocentric translations (geog2d domain)";
        final MathTransformFactory factory = ReferencingFactoryFinder.getMathTransformFactory(null);
        final ParameterValueGroup    param = factory.getDefaultParameters(classification);

        param.parameter("dx").setValue( 84.87);
        param.parameter("dy").setValue( 96.49);
        param.parameter("dz").setValue(116.95);

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

     * section 2.4.3.2.1.
     */
    @Test
    public void testSevenParam() throws FactoryException, TransformException {
        final String        classification = "Position Vector transformation (geog2d domain)";
        final MathTransformFactory factory = ReferencingFactoryFinder.getMathTransformFactory(null);
        final ParameterValueGroup    param = factory.getDefaultParameters(classification);

        param.parameter("dx") .setValue(0.000);
        param.parameter("dy") .setValue(0.000);
        param.parameter("dz") .setValue(4.5);
        param.parameter("ex") .setValue(0.000);
        param.parameter("ey") .setValue(0.000);
        param.parameter("ez") .setValue(0.554);
        param.parameter("ppm").setValue(0.219);

        final MathTransform test = factory.createParameterizedTransform(param);
        final GeneralDirectPosition position = new GeneralDirectPosition(3);
        position.setOrdinate(0, 3657660.66);
        position.setOrdinate(1255768.55);
        position.setOrdinate(2, 5201382.11);
        assertSame(position, test.transform(position, position));
View Full Code Here

     * section 2.4.3.2.2.
     */
    @Test
    public void testFrameRotation() throws FactoryException, TransformException {
        final String        classification = "Coordinate Frame rotation (geog2d domain)";
        final MathTransformFactory factory = ReferencingFactoryFinder.getMathTransformFactory(null);
        final ParameterValueGroup    param = factory.getDefaultParameters(classification);

        param.parameter("dx") .setValue( 0.000);
        param.parameter("dy") .setValue( 0.000);
        param.parameter("dz") .setValue( 4.5);
        param.parameter("ex") .setValue( 0.000);
        param.parameter("ey") .setValue( 0.000);
        param.parameter("ez") .setValue(-0.554);
        param.parameter("ppm").setValue( 0.219);

        final MathTransform test = factory.createParameterizedTransform(param);
        final GeneralDirectPosition position = new GeneralDirectPosition(3);
        position.setOrdinate(0, 3657660.66);
        position.setOrdinate(1255768.55);
        position.setOrdinate(2, 5201382.11);
        assertSame(position, test.transform(position, position));
View Full Code Here

     * an external source of test points for this test.
     */
    @Test
    public void testGeotoolsExtensions() throws FactoryException, TransformException {
        final String        classification = "Coordinate Frame rotation (geog2d domain)";
        final MathTransformFactory factory = ReferencingFactoryFinder.getMathTransformFactory(null);
        final ParameterValueGroup    param = factory.getDefaultParameters(classification);
        final Ellipsoid    sourceEllipsoid = DefaultEllipsoid.INTERNATIONAL_1924;
        final Ellipsoid    targetEllipsoid = DefaultEllipsoid.WGS84;

        param.parameter("dx") .setValue( 0.000);
        param.parameter("dy") .setValue( 0.000);
        param.parameter("dz") .setValue( 4.5);
        param.parameter("ex") .setValue( 0.000);
        param.parameter("ey") .setValue( 0.000);
        param.parameter("ez") .setValue(-0.554);
        param.parameter("ppm").setValue( 0.219);

        param.parameter("src_dim").setValue(3);
        param.parameter("tgt_dim").setValue(3);
        param.parameter("src_semi_major").setValue(sourceEllipsoid.getSemiMajorAxis());
        param.parameter("src_semi_minor").setValue(sourceEllipsoid.getSemiMinorAxis());
        param.parameter("tgt_semi_major").setValue(targetEllipsoid.getSemiMajorAxis());
        param.parameter("tgt_semi_minor").setValue(targetEllipsoid.getSemiMinorAxis());

        final MathTransform test = factory.createParameterizedTransform(param);
        final GeneralDirectPosition position = new GeneralDirectPosition(3);
        position.setOrdinate(0,    4.00); // Longitude
        position.setOrdinate(1,   55.00); // Latitude
        position.setOrdinate(2, -191.61); // Height

View Full Code Here

     * Tests the example provided by the EPSG guidance.
     * See "OGP Surveying and Positioning Guidance Note number 7, part 2 – April 2009", page 36
     */
    @Test
    public void testEpsgExample() throws Exception {
        MathTransformFactory mtFactory = ReferencingFactoryFinder.getMathTransformFactory(null);
        final ParameterValueGroup parameters = mtFactory.getDefaultParameters("Cassini-Soldner");
       
        // build the transformation using the guidance provided values
        final double feetToMeter = 0.3048; // ft -> mt
        final double linkToMeter = 0.66 * feetToMeter; // Clark's links -> mt
        parameter(SEMI_MAJOR, parameters).setValue(20926348 * feetToMeter);
        parameter(SEMI_MINOR, parameters).setValue(20855233 * feetToMeter);
        parameter(LATITUDE_OF_ORIGIN, parameters).setValue(dmsToDegree(10, 26, 30));
        parameter(CENTRAL_MERIDIAN, parameters).setValue(-dmsToDegree(61, 20, 0));
        parameter(FALSE_EASTING, parameters).setValue(430000.00 * linkToMeter);
        parameter(FALSE_NORTHING, parameters).setValue(325000.00 * linkToMeter);
        MathTransform transform = mtFactory.createParameterizedTransform(parameters);

        // results as provided by the EPSG guidance
        final double[] point = new double[] { -62, 10 };
        final double[] expected = new double[] { 66644.94 * linkToMeter, 82536.22 * linkToMeter };
       
View Full Code Here

    /**
     * Make a simple spherical Mercator (Google Mercator) CRS.  We just use this as
     * a simple example of a MapProjection since that class is abstract.
     */
  private static MapProjection createGoogleMercator() throws FactoryException {
        MathTransformFactory mtFactory = ReferencingFactoryFinder.getMathTransformFactory(null);
        final ParameterValueGroup parameters = mtFactory.getDefaultParameters("Mercator_1SP");
        parameters.parameter(SEMI_MAJOR.getName().getCode()).setValue(6378137.0);
        parameters.parameter(SEMI_MINOR.getName().getCode()).setValue(6378137.0);
        return (MapProjection) mtFactory.createParameterizedTransform(parameters);
  }
View Full Code Here

     * @throws FactoryException If the conversion can't be created.
     */
    @Test
    public void testCreateLinearConversion() throws FactoryException {
        final double                     EPS = 1E-12;
        final MathTransformFactory   factory = new DefaultMathTransformFactory();
        final ParameterValueGroup parameters = factory.getDefaultParameters("Mercator_1SP");
        DefaultProjectedCRS sourceCRS, targetCRS;
        MathTransform transform;
        Matrix conversion;

        parameters.parameter("semi_major").setValue(DefaultEllipsoid.WGS84.getSemiMajorAxis());
        parameters.parameter("semi_minor").setValue(DefaultEllipsoid.WGS84.getSemiMinorAxis());
        transform = factory.createParameterizedTransform(parameters);
        sourceCRS = new DefaultProjectedCRS("source", WGS84, transform, PROJECTED);

        parameters.parameter("false_easting" ).setValue(1000);
        parameters.parameter("false_northing").setValue(2000);
        transform = factory.createParameterizedTransform(parameters);
        targetCRS = new DefaultProjectedCRS("source", WGS84, transform, PROJECTED);

        conversion = ProjectionAnalyzer.createLinearConversion(sourceCRS, targetCRS, EPS);
        assertEquals(new Matrix3(
            101000,
            012000,
            00,     1
        ), conversion);

        parameters.parameter("scale_factor").setValue(2);
        transform = factory.createParameterizedTransform(parameters);
        targetCRS = new DefaultProjectedCRS("source", WGS84, transform, PROJECTED);

        conversion = ProjectionAnalyzer.createLinearConversion(sourceCRS, targetCRS, EPS);
        assertEquals(new Matrix3(
            201000,
            022000,
            00,     1
        ), conversion);

        parameters.parameter("semi_minor").setValue(DefaultEllipsoid.WGS84.getSemiMajorAxis());
        transform = factory.createParameterizedTransform(parameters);
        targetCRS = new DefaultProjectedCRS("source", WGS84, transform, PROJECTED);
        conversion = ProjectionAnalyzer.createLinearConversion(sourceCRS, targetCRS, EPS);
        assertNull(conversion);
    }
View Full Code Here

        out.println();
        out.println("create Coodinate Reference System....1: ");
        final         DatumFactory datumFactory = ReferencingFactoryFinder.getDatumFactory        (null);
        final            CSFactory    csFactory = ReferencingFactoryFinder.getCSFactory           (null);
        final           CRSFactory   crsFactory = ReferencingFactoryFinder.getCRSFactory          (null);
        final MathTransformFactory    mtFactory = ReferencingFactoryFinder.getMathTransformFactory(null);

        final Ellipsoid airy1830;
        final Unit<Length> meters = SI.METER;
        airy1830 = datumFactory.createEllipsoid(name("Airy1830"), 6377563.396, 6356256.910, meters);
        out.println();
        out.println("create Coodinate Reference System....2: ");
        out.println(airy1830.toWKT());

        final PrimeMeridian greenwich;
        final Unit<Angle> degrees = NonSI.DEGREE_ANGLE;
        greenwich = datumFactory.createPrimeMeridian(name("Greenwich"), 0, degrees);
        out.println();
        out.println("create Coodinate Reference System....3: ");
        out.println(greenwich.toWKT());

        // NOTE: we could use the following pre-defined constant instead:
        //       DefaultPrimeMeridian.GREENWICH;
        final GeodeticDatum datum;
        datum = datumFactory.createGeodeticDatum(name("Airy1830"), airy1830, greenwich);
        out.println();
        out.println("create Coodinate Reference System....4: ");
        out.println(datum.toWKT());

        // NOTE: we could use the following pre-defined constant instead:
        //       DefaultEllipsoidalCS.GEODETIC_2D;
        final EllipsoidalCS ellCS;
        ellCS = csFactory.createEllipsoidalCS(name("Ellipsoidal"),
                csFactory.createCoordinateSystemAxis(name("Longitude"), "long", AxisDirection.EAST,  degrees),
                csFactory.createCoordinateSystemAxis(name("Latitude")"lat",  AxisDirection.NORTH, degrees));
        out.println();
        out.println("create Coodinate Reference System....5: ");
        out.println(ellCS); // No WKT for coordinate systems

        final GeographicCRS geogCRS;
        geogCRS = crsFactory.createGeographicCRS(name("Airy1830"), datum, ellCS);
        out.println();
        out.println("create Coodinate Reference System....6: ");
        out.println(geogCRS.toWKT());

        final MathTransform p;
        final ParameterValueGroup param = mtFactory.getDefaultParameters("Transverse_Mercator");
        param.parameter("semi_major")        .setValue(airy1830.getSemiMajorAxis());
        param.parameter("semi_minor")        .setValue(airy1830.getSemiMinorAxis());
        param.parameter("central_meridian".setValue(     49);
        param.parameter("latitude_of_origin").setValue(     -2);
        param.parameter("false_easting")     .setValue( 400000);
View Full Code Here

TOP

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

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.