Examples of DatumFactory


Examples of org.opengis.referencing.datum.DatumFactory

        out.println();
        out.println("Testing CRS creations");
        out.println("---------------------");
        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:
View Full Code Here

Examples of org.opengis.referencing.datum.DatumFactory

        final String           name1 = "Nouvelle_Triangulation_Francaise_Paris";
        final String           name2 = "D_NTF";
        final String           name3 = "NTF (Paris meridian)";
        final Ellipsoid    ellipsoid = DefaultEllipsoid.WGS84;
        final PrimeMeridian meridian = DefaultPrimeMeridian.GREENWICH;
        DatumFactory         factory = new ReferencingObjectFactory();
        final Map<String,?> properties = Collections.singletonMap("name", name1);
        GeodeticDatum datum = factory.createGeodeticDatum(properties, ellipsoid, meridian);
        assertTrue(datum.getAlias().isEmpty());

        for (int i=0; i<3; i++) {
            switch (i) {
                case  0: factory = new DatumAliases(factory);                      break;
                case  1: factory = ReferencingFactoryFinder.getDatumFactory(null); break;
                case  2: ((DatumAliases) factory).freeUnused();                    break;
                default: throw new AssertionError(); // Should not occurs.
            }
            final String pass = "Pass #"+i;
            datum = factory.createGeodeticDatum(properties, ellipsoid, meridian);
            final GenericName[] aliases = datum.getAlias().toArray(new GenericName[0]);
            assertEquals(pass, 4, aliases.length);
            assertEquals(pass, name0, aliases[0].tip().toString());
            assertEquals(pass, name1, aliases[1].tip().toString());
            assertEquals(pass, name2, aliases[2].tip().toString());
            assertEquals(pass, name3, aliases[3].tip().toString());
            assertTrue  (pass, aliases[0] instanceof ScopedName);
            assertTrue  (pass, aliases[1] instanceof ScopedName);
            assertTrue  (pass, aliases[2] instanceof ScopedName);
            assertTrue  (pass, aliases[3] instanceof ScopedName);
        }

        datum = factory.createGeodeticDatum(Collections.singletonMap("name", "Tokyo"), ellipsoid, meridian);
        Collection<GenericName> aliases = datum.getAlias();
        assertEquals(4, aliases.size());

        ((DatumAliases) factory).freeUnused();
        datum = factory.createGeodeticDatum(Collections.singletonMap("name", "_toKyo  _"), ellipsoid, meridian);
        assertEquals(4, datum.getAlias().size());
        assertTrue(aliases.equals(datum.getAlias()));

        datum = factory.createGeodeticDatum(Collections.singletonMap("name", "D_Tokyo"), ellipsoid, meridian);
        assertEquals(4, datum.getAlias().size());

        datum = factory.createGeodeticDatum(Collections.singletonMap("name", "Luxembourg 1930"), ellipsoid, meridian);
        assertEquals(3, datum.getAlias().size());

        datum = factory.createGeodeticDatum(Collections.singletonMap("name", "Dummy"), ellipsoid, meridian);
        assertTrue("Non existing datum should have no alias.", datum.getAlias().isEmpty());

        datum = factory.createGeodeticDatum(Collections.singletonMap("name", "WGS 84"), ellipsoid, meridian);
        assertTrue (AbstractIdentifiedObject.nameMatches(datum, "WGS 84"));
        assertTrue (AbstractIdentifiedObject.nameMatches(datum, "WGS_1984"));
        assertTrue (AbstractIdentifiedObject.nameMatches(datum, "World Geodetic System 1984"));
        assertFalse(AbstractIdentifiedObject.nameMatches(datum, "WGS 72"));
    }
View Full Code Here

Examples of org.opengis.referencing.datum.DatumFactory

    // factories start
    Hints hints = null; // configure hints for the group of factories
    ReferencingFactoryContainer group = new ReferencingFactoryContainer(hints);
    CRSFactory crsFactory = group.getCRSFactory();
    CSFactory csFactory = group.getCSFactory();
    DatumFactory datumFactory = group.getDatumFactory();
    // factories end
}
View Full Code Here

Examples of org.opengis.referencing.datum.DatumFactory

}

void referencingFactoryContainer2() {
    // referencingFactoryContainer2 start
    Hints hints = GeoTools.getDefaultHints();
    DatumFactory datumFactory = ReferencingFactoryFinder.getDatumFactory( hints );
   
    ReferencingFactoryContainer container = new ReferencingFactoryContainer( hints );
   
    ifdatumFactory == container.getDatumFactory() ){
        System.out.println( "Will be the same DatumFactory");
View Full Code Here

Examples of org.opengis.referencing.datum.DatumFactory

void createCRSByHand2() throws Exception {
    System.out.println("------------------------------------------");
    System.out.println("Creating a CRS by hand:");
    // createCRSByHand2 start
    CRSFactory crsFactory = ReferencingFactoryFinder.getCRSFactory(null);
    DatumFactory datumFactory = ReferencingFactoryFinder.getDatumFactory(null);
    CSFactory csFactory = ReferencingFactoryFinder.getCSFactory(null);
   
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("name", "Clarke 1866");
   
    Ellipsoid clark1866ellipse = datumFactory.createFlattenedSphere(map, 6378206.4,
            294.978698213901, SI.METER);
   
    PrimeMeridian greenwichMeridian = org.geotools.referencing.datum.DefaultPrimeMeridian.GREENWICH;
   
    final BursaWolfParameters toWGS84 = new BursaWolfParameters(DefaultGeodeticDatum.WGS84);
    toWGS84.dx = -3.0;
    toWGS84.dy = 142;
    toWGS84.dz = 183;
   
    map.clear();
    map.put("name", "North American Datum 1927");
    map.put(DefaultGeodeticDatum.BURSA_WOLF_KEY, toWGS84);
   
    GeodeticDatum clark1866datum = datumFactory.createGeodeticDatum(map, clark1866ellipse,
            greenwichMeridian);
    System.out.println(clark1866datum.toWKT());
    // notice all of the lovely datum aliases (used to determine if two
    // datums are the same)
    System.out.println("Identified Datum object:");
View Full Code Here

Examples of org.opengis.referencing.datum.DatumFactory

    System.out.println("------------------------------------------");
    System.out.println("Creating two CRSs by hand:");
   
    // createCRSByHand3 start
    CRSFactory crsFactory = ReferencingFactoryFinder.getCRSFactory(null);
    DatumFactory datumFactory = ReferencingFactoryFinder.getDatumFactory(null);
    CSFactory csFactory = ReferencingFactoryFinder.getCSFactory(null);
    Map<String, Object> map = new HashMap<String, Object>();
   
    //
    // Create a datum used for each CRS
    //
    map.clear();
    map.put("name", "Greenwich Meridian");
    PrimeMeridian greenwichMeridian = datumFactory.createPrimeMeridian(map, 0, NonSI.DEGREE_ANGLE);
   
    map.clear();
    map.put("name", "WGS 84 Ellipsoid Datum");
    Ellipsoid wgs84Ellipsoid = datumFactory.createFlattenedSphere(map, 6378137, 298.257223563,
            SI.METER);
   
    map.clear();
    map.put("name", "WGS84 Height Datum");
    GeodeticDatum wgs84Datum = datumFactory.createGeodeticDatum(map, wgs84Ellipsoid,
            greenwichMeridian);
   
    //
    // Create a geocentric CRS
    //
View Full Code Here

Examples of org.opengis.referencing.datum.DatumFactory

                    properties.put(Datum.REALIZATION_EPOCH_KEY, calendar.getTime());
                } catch (NumberFormatException exception) {
                    // Not a fatal error...
                    Logging.unexpectedException(LOGGER, AbstractEpsgFactory.class, "createDatum", exception);
                }
                final DatumFactory factory = factories.getDatumFactory();
                final Datum datum;
                /*
                 * Now build datum according their datum type. Constructions are straightforward,
                 * except for the "geodetic" datum type which need some special processing:
                 *
                 *   - Because it invokes again 'generateProperties' indirectly (through calls to
                 *     'createEllipsoid' and 'createPrimeMeridian'), it must protect 'properties'
                 *     from changes.
                 *
                 *   - Because 'createBursaWolfParameters' may invokes 'createDatum' recursively,
                 *     we must close the result set if Bursa-Wolf parameters are found. In this
                 *     case, we lost our paranoiac check for duplication.
                 */
                if (type.equals("geodetic")) {
                    properties = new HashMap<String,Object>(properties); // Protect from changes
                    final Ellipsoid         ellipsoid = createEllipsoid    (getString(result,  9, code));
                    final PrimeMeridian      meridian = createPrimeMeridian(getString(result, 10, code));
                    final BursaWolfParameters[] param = generateBursaWolfParameters(primaryKey, result);

                    if (param != null) {
                        result = null; // Already closed by createBursaWolfParameters
                        properties.put(DefaultGeodeticDatum.BURSA_WOLF_KEY, param);
                    }
                    datum = factory.createGeodeticDatum(properties, ellipsoid, meridian);
                } else if (type.equals("vertical")) {
                    // TODO: Find the right datum type.
                    datum = factory.createVerticalDatum(properties, VerticalDatumType.GEOIDAL);
                } else if (type.equals("engineering")) {
                    datum = factory.createEngineeringDatum(properties);
                } else {
                    result.close();
                    throw new FactoryException(Errors.format(ErrorKeys.UNKNOW_TYPE_$1, type));
                }
                returnValue = ensureSingleton(datum, returnValue, code);
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.