Search in sources :

Example 11 with ChannelReader

use of com.revolsys.io.channels.ChannelReader in project com.revolsys.open by revolsys.

the class EpsgCoordinateSystems method loadCoordOperationMethod.

private static IntHashMap<CoordinateOperationMethod> loadCoordOperationMethod(final IntHashMap<List<ParameterName>> paramOrderByMethodId, final IntHashMap<List<Byte>> paramReversalByMethodId) {
    final IntHashMap<CoordinateOperationMethod> methodById = new IntHashMap<>();
    try (ChannelReader reader = newChannelReader("coordOperationMethod")) {
        while (true) {
            final int id = reader.getInt();
            final String name = reader.getStringUtf8ByteCount();
            final boolean reverse = readBoolean(reader);
            final boolean deprecated = readBoolean(reader);
            final List<ParameterName> parameterNames = paramOrderByMethodId.getOrDefault(id, Collections.emptyList());
            final List<Byte> reversal = paramReversalByMethodId.getOrDefault(id, Collections.emptyList());
            final CoordinateOperationMethod method = new CoordinateOperationMethod(id, name, reverse, deprecated, parameterNames);
            methodById.put(id, method);
        }
    } catch (final NoSuchResourceException e) {
    } catch (final WrappedException e) {
        if (Exceptions.isException(e, EOFException.class)) {
        } else {
            throw e;
        }
    }
    return methodById;
}
Also used : WrappedException(com.revolsys.util.WrappedException) ParameterName(com.revolsys.geometry.cs.ParameterName) ParameterValueString(com.revolsys.geometry.cs.ParameterValueString) NoSuchResourceException(com.revolsys.spring.resource.NoSuchResourceException) IntHashMap(com.revolsys.collection.map.IntHashMap) ChannelReader(com.revolsys.io.channels.ChannelReader) CoordinateOperationMethod(com.revolsys.geometry.cs.CoordinateOperationMethod) EOFException(java.io.EOFException)

Example 12 with ChannelReader

use of com.revolsys.io.channels.ChannelReader 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 13 with ChannelReader

use of com.revolsys.io.channels.ChannelReader in project com.revolsys.open by revolsys.

the class EpsgCoordinateSystems method loadPrimeMeridians.

private static void loadPrimeMeridians() {
    try (ChannelReader reader = newChannelReader("primeMeridian")) {
        while (true) {
            final int id = reader.getInt();
            final String name = reader.getStringUtf8ByteCount();
            final AngularUnit unit = (AngularUnit) readCode(reader, UNIT_BY_ID);
            final double longitude = reader.getDouble();
            final double longitudeDegrees = unit.toDegrees(longitude);
            final EpsgAuthority authority = new EpsgAuthority(id);
            final PrimeMeridian primeMeridian = new PrimeMeridian(name, longitudeDegrees, authority, false);
            PRIME_MERIDIAN_BY_ID.put(id, primeMeridian);
        }
    } catch (final NoSuchResourceException e) {
    } catch (final WrappedException e) {
        if (Exceptions.isException(e, EOFException.class)) {
        } else {
            throw e;
        }
    }
}
Also used : NoSuchResourceException(com.revolsys.spring.resource.NoSuchResourceException) WrappedException(com.revolsys.util.WrappedException) ChannelReader(com.revolsys.io.channels.ChannelReader) EOFException(java.io.EOFException) ParameterValueString(com.revolsys.geometry.cs.ParameterValueString) AngularUnit(com.revolsys.geometry.cs.unit.AngularUnit) PrimeMeridian(com.revolsys.geometry.cs.PrimeMeridian)

Example 14 with ChannelReader

use of com.revolsys.io.channels.ChannelReader in project com.revolsys.open by revolsys.

the class EpsgCoordinateSystems method loadArea.

private static void loadArea() {
    try (ChannelReader reader = newChannelReader("area")) {
        while (true) {
            final int code = reader.getInt();
            final String name = reader.getStringUtf8ByteCount();
            final double minX = reader.getDouble();
            final double minY = reader.getDouble();
            final double maxX = reader.getDouble();
            final double maxY = reader.getDouble();
            final boolean deprecated = readBoolean(reader);
            final Authority authority = new EpsgAuthority(code);
            BoundingBox boundingBox;
            if (Double.isFinite(minX) || Double.isFinite(minX) || Double.isFinite(minX) || Double.isFinite(minX)) {
                boundingBox = new BoundingBoxDoubleXY(minX, minY, maxX, maxY);
            } else {
                boundingBox = BoundingBox.empty();
            }
            final Area area = new Area(name, boundingBox, authority, deprecated);
            AREA_BY_ID.put(code, area);
        }
    } catch (final NoSuchResourceException e) {
    } catch (final WrappedException e) {
        if (Exceptions.isException(e, EOFException.class)) {
        } else {
            throw e;
        }
    }
}
Also used : WrappedException(com.revolsys.util.WrappedException) Authority(com.revolsys.geometry.cs.Authority) ParameterValueString(com.revolsys.geometry.cs.ParameterValueString) BoundingBoxDoubleXY(com.revolsys.geometry.model.impl.BoundingBoxDoubleXY) NoSuchResourceException(com.revolsys.spring.resource.NoSuchResourceException) Area(com.revolsys.geometry.cs.Area) ChannelReader(com.revolsys.io.channels.ChannelReader) BoundingBox(com.revolsys.geometry.model.BoundingBox) EOFException(java.io.EOFException)

Example 15 with ChannelReader

use of com.revolsys.io.channels.ChannelReader in project com.revolsys.open by revolsys.

the class EpsgCoordinateSystems method loadCoordOperation.

private static void loadCoordOperation(final IntHashMap<CoordinateOperationMethod> methodById, final IntHashMap<Map<ParameterName, ParameterValue>> operationParameters, final IntHashMap<List<Byte>> paramReversal) {
    try (ChannelReader reader = newChannelReader("coordOperation")) {
        while (true) {
            final int id = reader.getInt();
            final CoordinateOperationMethod method = readCode(reader, methodById);
            final String name = reader.getStringUtf8ByteCount();
            final byte type = reader.getByte();
            final int sourceCrsCode = reader.getInt();
            final int targetCrsCode = reader.getInt();
            final String transformationVersion = reader.getStringUtf8ByteCount();
            final int variant = reader.getInt();
            final Area area = readCode(reader, AREA_BY_ID);
            final double accuracy = reader.getDouble();
            final boolean deprecated = readBoolean(reader);
            final Map<ParameterName, ParameterValue> parameters = operationParameters.getOrDefault(id, Collections.emptyMap());
            final CoordinateOperation coordinateOperation = new CoordinateOperation(id, method, name, type, sourceCrsCode, targetCrsCode, transformationVersion, variant, area, accuracy, parameters, deprecated);
            OPERATION_BY_ID.put(id, coordinateOperation);
        }
    } catch (final NoSuchResourceException e) {
    } catch (final WrappedException e) {
        if (Exceptions.isException(e, EOFException.class)) {
        } else {
            Logs.error(EpsgCoordinateSystems.class, "Error loading coordOperation", e);
        }
    }
}
Also used : WrappedException(com.revolsys.util.WrappedException) ParameterValue(com.revolsys.geometry.cs.ParameterValue) ParameterName(com.revolsys.geometry.cs.ParameterName) ParameterValueString(com.revolsys.geometry.cs.ParameterValueString) NoSuchResourceException(com.revolsys.spring.resource.NoSuchResourceException) Area(com.revolsys.geometry.cs.Area) ChannelReader(com.revolsys.io.channels.ChannelReader) CoordinateOperationMethod(com.revolsys.geometry.cs.CoordinateOperationMethod) EOFException(java.io.EOFException)

Aggregations

ChannelReader (com.revolsys.io.channels.ChannelReader)34 WrappedException (com.revolsys.util.WrappedException)20 EOFException (java.io.EOFException)19 NoSuchResourceException (com.revolsys.spring.resource.NoSuchResourceException)14 ParameterValueString (com.revolsys.geometry.cs.ParameterValueString)12 ParameterName (com.revolsys.geometry.cs.ParameterName)7 Area (com.revolsys.geometry.cs.Area)4 Authority (com.revolsys.geometry.cs.Authority)4 ParameterValue (com.revolsys.geometry.cs.ParameterValue)4 LinearUnit (com.revolsys.geometry.cs.unit.LinearUnit)4 IntHashMap (com.revolsys.collection.map.IntHashMap)3 LasPoint (com.revolsys.elevation.cloud.las.pointformat.LasPoint)3 LasPointFormat (com.revolsys.elevation.cloud.las.pointformat.LasPointFormat)3 BaseAuthority (com.revolsys.geometry.cs.BaseAuthority)3 CoordinateOperationMethod (com.revolsys.geometry.cs.CoordinateOperationMethod)3 Ellipsoid (com.revolsys.geometry.cs.Ellipsoid)3 GeographicCoordinateSystem (com.revolsys.geometry.cs.GeographicCoordinateSystem)3 PrimeMeridian (com.revolsys.geometry.cs.PrimeMeridian)3 GeodeticDatum (com.revolsys.geometry.cs.datum.GeodeticDatum)3 VerticalDatum (com.revolsys.geometry.cs.datum.VerticalDatum)3