Search in sources :

Example 6 with NoSuchResourceException

use of com.revolsys.spring.resource.NoSuchResourceException 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)

Example 7 with NoSuchResourceException

use of com.revolsys.spring.resource.NoSuchResourceException in project com.revolsys.open by revolsys.

the class EpsgCoordinateSystems method loadCoordOperationParam.

private static void loadCoordOperationParam() {
    try (ChannelReader reader = newChannelReader("coordOperationParam")) {
        while (true) {
            final int id = reader.getInt();
            String name = reader.getStringUtf8ByteCount();
            if (name != null) {
                name = name.toLowerCase().replaceAll(" ", "_");
            }
            readBoolean(reader);
            final ParameterName parameterName = ParameterNames.getParameterName(id, name);
            PARAM_NAME_BY_ID.put(id, parameterName);
        }
    } 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) ParameterName(com.revolsys.geometry.cs.ParameterName) ParameterValueString(com.revolsys.geometry.cs.ParameterValueString)

Example 8 with NoSuchResourceException

use of com.revolsys.spring.resource.NoSuchResourceException in project com.revolsys.open by revolsys.

the class EpsgCoordinateSystems method loadCoordinateAxisNames.

private static void loadCoordinateAxisNames() {
    try (ChannelReader reader = newChannelReader("coordinateAxisName")) {
        while (true) {
            final int code = reader.getInt();
            final String name = reader.getStringUtf8ByteCount();
            final AxisName axisName = new AxisName(code, name);
            AXIS_NAMES.putInt(code, axisName);
            AXIS_NAME_BY_NAME.put(name.toLowerCase(), axisName);
        }
    } 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) AxisName(com.revolsys.geometry.cs.AxisName) WrappedException(com.revolsys.util.WrappedException) ChannelReader(com.revolsys.io.channels.ChannelReader) EOFException(java.io.EOFException) ParameterValueString(com.revolsys.geometry.cs.ParameterValueString)

Example 9 with NoSuchResourceException

use of com.revolsys.spring.resource.NoSuchResourceException in project com.revolsys.open by revolsys.

the class EpsgCoordinateSystems method loadCoordOperationParamUsage.

private static void loadCoordOperationParamUsage(final IntHashMap<List<ParameterName>> paramOrderByMethodId, final IntHashMap<List<Byte>> paramReversal) {
    try (ChannelReader reader = newChannelReader("coordOperationParamUsage")) {
        while (true) {
            final int methodId = reader.getInt();
            final ParameterName parameterName = readCode(reader, PARAM_NAME_BY_ID);
            final int sortOrder = reader.getInt();
            final byte signReversal = reader.getByte();
            Maps.addToList(paramOrderByMethodId, methodId, parameterName);
            Maps.addToList(paramReversal, methodId, signReversal);
        }
    } catch (final NoSuchResourceException e) {
    } catch (final WrappedException e) {
        if (Exceptions.isException(e, EOFException.class)) {
        } else {
            Logs.error(EpsgCoordinateSystems.class, "Error loading coordOperationParamValue", e);
        }
    }
}
Also used : NoSuchResourceException(com.revolsys.spring.resource.NoSuchResourceException) WrappedException(com.revolsys.util.WrappedException) ChannelReader(com.revolsys.io.channels.ChannelReader) EOFException(java.io.EOFException) ParameterName(com.revolsys.geometry.cs.ParameterName)

Example 10 with NoSuchResourceException

use of com.revolsys.spring.resource.NoSuchResourceException in project com.revolsys.open by revolsys.

the class EpsgCoordinateSystems method loadEllipsoid.

private static IntHashMap<Ellipsoid> loadEllipsoid() {
    final IntHashMap<Ellipsoid> ellipsoids = new IntHashMap<>();
    try (ChannelReader reader = newChannelReader("ellipsoid")) {
        while (true) {
            final int id = reader.getInt();
            final String name = reader.getStringUtf8ByteCount();
            final int unitId = reader.getInt();
            final LinearUnit unit = (LinearUnit) UNIT_BY_ID.get(unitId);
            final double semiMinorAxis = unit.toBase(reader.getDouble());
            final double semiMajorAxis = unit.toBase(reader.getDouble());
            final double inverseFlattening = unit.toBase(reader.getDouble());
            final int ellipsoidShape = reader.getByte();
            final boolean deprecated = readBoolean(reader);
            final EpsgAuthority authority = new EpsgAuthority(id);
            final Ellipsoid ellipsoid = new Ellipsoid(name, semiMajorAxis, semiMinorAxis, inverseFlattening, authority, deprecated);
            ellipsoids.put(id, ellipsoid);
        }
    } catch (final NoSuchResourceException e) {
    } catch (final WrappedException e) {
        if (Exceptions.isException(e, EOFException.class)) {
        } else {
            throw e;
        }
    }
    return ellipsoids;
}
Also used : WrappedException(com.revolsys.util.WrappedException) LinearUnit(com.revolsys.geometry.cs.unit.LinearUnit) ParameterValueString(com.revolsys.geometry.cs.ParameterValueString) NoSuchResourceException(com.revolsys.spring.resource.NoSuchResourceException) IntHashMap(com.revolsys.collection.map.IntHashMap) ChannelReader(com.revolsys.io.channels.ChannelReader) EOFException(java.io.EOFException) Ellipsoid(com.revolsys.geometry.cs.Ellipsoid)

Aggregations

ChannelReader (com.revolsys.io.channels.ChannelReader)14 NoSuchResourceException (com.revolsys.spring.resource.NoSuchResourceException)14 WrappedException (com.revolsys.util.WrappedException)14 EOFException (java.io.EOFException)14 ParameterValueString (com.revolsys.geometry.cs.ParameterValueString)12 ParameterName (com.revolsys.geometry.cs.ParameterName)5 Area (com.revolsys.geometry.cs.Area)4 IntHashMap (com.revolsys.collection.map.IntHashMap)3 CoordinateOperationMethod (com.revolsys.geometry.cs.CoordinateOperationMethod)3 UnitOfMeasure (com.revolsys.geometry.cs.unit.UnitOfMeasure)3 Axis (com.revolsys.geometry.cs.Axis)2 AxisName (com.revolsys.geometry.cs.AxisName)2 CoordinateSystemType (com.revolsys.geometry.cs.CoordinateSystemType)2 Ellipsoid (com.revolsys.geometry.cs.Ellipsoid)2 ParameterValue (com.revolsys.geometry.cs.ParameterValue)2 PrimeMeridian (com.revolsys.geometry.cs.PrimeMeridian)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