Search in sources :

Example 1 with Datum

use of com.revolsys.geometry.cs.datum.Datum in project com.revolsys.open by revolsys.

the class EpsgCoordinateSystems method loadDatum.

private static void loadDatum() {
    final IntHashMap<Ellipsoid> ellipsoids = loadEllipsoid();
    try (ChannelReader reader = newChannelReader("datum")) {
        while (true) {
            final int id = reader.getInt();
            final String name = reader.getStringUtf8ByteCount();
            final int datumType = reader.getByte();
            final Ellipsoid ellipsoid = readCode(reader, ellipsoids);
            final PrimeMeridian primeMeridian = readCode(reader, PRIME_MERIDIAN_BY_ID);
            final Area area = readCode(reader, AREA_BY_ID);
            final boolean deprecated = readBoolean(reader);
            final EpsgAuthority authority = new EpsgAuthority(id);
            Datum datum;
            if (datumType == 0) {
                datum = new GeodeticDatum(authority, name, area, deprecated, ellipsoid, primeMeridian);
            } else if (datumType == 1) {
                datum = new VerticalDatum(authority, name, area, deprecated);
            } else if (datumType == 2) {
                datum = new EngineeringDatum(authority, name, area, deprecated);
            } else {
                throw new IllegalArgumentException("Unknown datumType=" + datumType);
            }
            DATUM_BY_ID.put(id, datum);
        }
    } catch (final NoSuchResourceException e) {
    } catch (final WrappedException e) {
        if (Exceptions.isException(e, EOFException.class)) {
        } else {
            throw e;
        }
    }
}
Also used : WrappedException(com.revolsys.util.WrappedException) Datum(com.revolsys.geometry.cs.datum.Datum) EngineeringDatum(com.revolsys.geometry.cs.datum.EngineeringDatum) GeodeticDatum(com.revolsys.geometry.cs.datum.GeodeticDatum) VerticalDatum(com.revolsys.geometry.cs.datum.VerticalDatum) GeodeticDatum(com.revolsys.geometry.cs.datum.GeodeticDatum) VerticalDatum(com.revolsys.geometry.cs.datum.VerticalDatum) ParameterValueString(com.revolsys.geometry.cs.ParameterValueString) PrimeMeridian(com.revolsys.geometry.cs.PrimeMeridian) NoSuchResourceException(com.revolsys.spring.resource.NoSuchResourceException) EngineeringDatum(com.revolsys.geometry.cs.datum.EngineeringDatum) Area(com.revolsys.geometry.cs.Area) ChannelReader(com.revolsys.io.channels.ChannelReader) EOFException(java.io.EOFException) Ellipsoid(com.revolsys.geometry.cs.Ellipsoid)

Example 2 with Datum

use of com.revolsys.geometry.cs.datum.Datum in project com.revolsys.open by revolsys.

the class EpsgCoordinateSystems method loadCoordinateReferenceSystem.

private static void loadCoordinateReferenceSystem(final IntHashMap<List<Axis>> axisMap) {
    try (ChannelReader reader = newChannelReader("coordinateReferenceSystem")) {
        while (true) {
            final int id = reader.getInt();
            final String name = reader.getStringUtf8ByteCount();
            final Area area = readCode(reader, AREA_BY_ID);
            final int type = reader.getByte();
            final CoordinateSystemType coordinateSystemType = readCode(reader, COORDINATE_SYSTEM_TYPE_BY_ID);
            final Datum datum = readCode(reader, DATUM_BY_ID);
            final CoordinateSystem sourceCoordinateSystem = readCode(reader, COORDINATE_SYSTEM_BY_ID);
            final CoordinateOperation operation = readCode(reader, OPERATION_BY_ID);
            final CoordinateSystem horizontalCoordinateSystem = readCode(reader, COORDINATE_SYSTEM_BY_ID);
            final VerticalCoordinateSystem verticalCoordinateSystem = (VerticalCoordinateSystem) readCode(reader, COORDINATE_SYSTEM_BY_ID);
            final boolean deprecated = readBoolean(reader);
            final List<Axis> axis;
            if (coordinateSystemType == null) {
                axis = null;
            } else {
                axis = axisMap.get(coordinateSystemType.getId());
            }
            CoordinateSystem coordinateSystem = null;
            if (type == 0) {
                // geocentric
                coordinateSystem = newCoordinateSystemGeocentric(id, name, datum, axis, area, deprecated);
            } else if (type == 1) {
                // geographic 3D
                coordinateSystem = new GeographicCoordinateSystem(id, name, (GeodeticDatum) datum, axis, area, sourceCoordinateSystem, operation, deprecated);
            } else if (type == 2) {
                // geographic 2D
                coordinateSystem = new GeographicCoordinateSystem(id, name, (GeodeticDatum) datum, axis, area, sourceCoordinateSystem, operation, deprecated);
            } else if (type == 3) {
                // projected
                coordinateSystem = newCoordinateSystemProjected(id, name, area, sourceCoordinateSystem, operation, axis, deprecated);
            } else if (type == 4) {
                // engineering
                coordinateSystem = new EngineeringCoordinateSystem(id, name, (EngineeringDatum) datum, axis, area, deprecated);
            } else if (type == 5) {
                // vertical
                coordinateSystem = new VerticalCoordinateSystem(id, name, (VerticalDatum) datum, axis, area, deprecated);
            } else if (type == 6) {
                coordinateSystem = new CompoundCoordinateSystem(id, name, horizontalCoordinateSystem, verticalCoordinateSystem, area, deprecated);
            } else {
                coordinateSystem = null;
            }
            addCoordinateSystem(coordinateSystem);
        }
    } catch (final NoSuchResourceException e) {
    } catch (final WrappedException e) {
        if (Exceptions.isException(e, EOFException.class)) {
        } else {
            throw e;
        }
    }
}
Also used : WrappedException(com.revolsys.util.WrappedException) Datum(com.revolsys.geometry.cs.datum.Datum) EngineeringDatum(com.revolsys.geometry.cs.datum.EngineeringDatum) GeodeticDatum(com.revolsys.geometry.cs.datum.GeodeticDatum) VerticalDatum(com.revolsys.geometry.cs.datum.VerticalDatum) ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) CoordinateSystem(com.revolsys.geometry.cs.CoordinateSystem) GeocentricCoordinateSystem(com.revolsys.geometry.cs.GeocentricCoordinateSystem) CompoundCoordinateSystem(com.revolsys.geometry.cs.CompoundCoordinateSystem) VerticalCoordinateSystem(com.revolsys.geometry.cs.VerticalCoordinateSystem) EngineeringCoordinateSystem(com.revolsys.geometry.cs.EngineeringCoordinateSystem) GeographicCoordinateSystem(com.revolsys.geometry.cs.GeographicCoordinateSystem) CoordinateSystemType(com.revolsys.geometry.cs.CoordinateSystemType) CompoundCoordinateSystem(com.revolsys.geometry.cs.CompoundCoordinateSystem) GeodeticDatum(com.revolsys.geometry.cs.datum.GeodeticDatum) ParameterValueString(com.revolsys.geometry.cs.ParameterValueString) EngineeringCoordinateSystem(com.revolsys.geometry.cs.EngineeringCoordinateSystem) NoSuchResourceException(com.revolsys.spring.resource.NoSuchResourceException) EngineeringDatum(com.revolsys.geometry.cs.datum.EngineeringDatum) Area(com.revolsys.geometry.cs.Area) ChannelReader(com.revolsys.io.channels.ChannelReader) VerticalCoordinateSystem(com.revolsys.geometry.cs.VerticalCoordinateSystem) EOFException(java.io.EOFException) GeographicCoordinateSystem(com.revolsys.geometry.cs.GeographicCoordinateSystem) Axis(com.revolsys.geometry.cs.Axis)

Aggregations

Area (com.revolsys.geometry.cs.Area)2 ParameterValueString (com.revolsys.geometry.cs.ParameterValueString)2 Datum (com.revolsys.geometry.cs.datum.Datum)2 EngineeringDatum (com.revolsys.geometry.cs.datum.EngineeringDatum)2 GeodeticDatum (com.revolsys.geometry.cs.datum.GeodeticDatum)2 VerticalDatum (com.revolsys.geometry.cs.datum.VerticalDatum)2 ChannelReader (com.revolsys.io.channels.ChannelReader)2 NoSuchResourceException (com.revolsys.spring.resource.NoSuchResourceException)2 WrappedException (com.revolsys.util.WrappedException)2 EOFException (java.io.EOFException)2 Axis (com.revolsys.geometry.cs.Axis)1 CompoundCoordinateSystem (com.revolsys.geometry.cs.CompoundCoordinateSystem)1 CoordinateSystem (com.revolsys.geometry.cs.CoordinateSystem)1 CoordinateSystemType (com.revolsys.geometry.cs.CoordinateSystemType)1 Ellipsoid (com.revolsys.geometry.cs.Ellipsoid)1 EngineeringCoordinateSystem (com.revolsys.geometry.cs.EngineeringCoordinateSystem)1 GeocentricCoordinateSystem (com.revolsys.geometry.cs.GeocentricCoordinateSystem)1 GeographicCoordinateSystem (com.revolsys.geometry.cs.GeographicCoordinateSystem)1 PrimeMeridian (com.revolsys.geometry.cs.PrimeMeridian)1 ProjectedCoordinateSystem (com.revolsys.geometry.cs.ProjectedCoordinateSystem)1