Search in sources :

Example 1 with ParameterName

use of com.revolsys.geometry.cs.ParameterName 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 2 with ParameterName

use of com.revolsys.geometry.cs.ParameterName 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 3 with ParameterName

use of com.revolsys.geometry.cs.ParameterName 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 4 with ParameterName

use of com.revolsys.geometry.cs.ParameterName in project com.revolsys.open by revolsys.

the class EsriCoordinateSystems method getVerticalCoordinateSystem.

public static VerticalCoordinateSystem getVerticalCoordinateSystem(final int id) {
    VerticalCoordinateSystem coordinateSystem = (VerticalCoordinateSystem) COORDINATE_SYSTEM_BY_ID.get(id);
    if (coordinateSystem == null) {
        try (final ChannelReader reader = ChannelReader.newChannelReader("classpath:CoordinateSystems/esri/Vertical.cs")) {
            while (true) {
                final int coordinateSystemId = reader.getInt();
                final String csName = reader.getStringUtf8ByteCount();
                final String datumName = reader.getStringUtf8ByteCount();
                final Map<ParameterName, ParameterValue> parameters = readParameters(reader);
                final String linearUnitName = reader.getStringUtf8ByteCount();
                final double conversionFactor = reader.getDouble();
                if (id == coordinateSystemId) {
                    final VerticalDatum verticalDatum = new VerticalDatum(null, datumName, 0);
                    LinearUnit linearUnit = LINEAR_UNITS_BY_NAME.get(linearUnitName);
                    if (linearUnit == null) {
                        linearUnit = new LinearUnit(linearUnitName, conversionFactor, null);
                        LINEAR_UNITS_BY_NAME.put(linearUnitName, linearUnit);
                    }
                    final Authority authority = new BaseAuthority("ESRI", coordinateSystemId);
                    coordinateSystem = new VerticalCoordinateSystem(authority, csName, verticalDatum, parameters, linearUnit, Collections.emptyList());
                    COORDINATE_SYSTEM_BY_ID.put(id, coordinateSystem);
                    return coordinateSystem;
                }
            }
        } catch (final WrappedException e) {
            if (Exceptions.isException(e, EOFException.class)) {
                return null;
            } else {
                Logs.error("Cannot load coordinate system=" + id, e);
                throw e;
            }
        }
    }
    return coordinateSystem;
}
Also used : BaseAuthority(com.revolsys.geometry.cs.BaseAuthority) WrappedException(com.revolsys.util.WrappedException) LinearUnit(com.revolsys.geometry.cs.unit.LinearUnit) ParameterValue(com.revolsys.geometry.cs.ParameterValue) Authority(com.revolsys.geometry.cs.Authority) BaseAuthority(com.revolsys.geometry.cs.BaseAuthority) ParameterName(com.revolsys.geometry.cs.ParameterName) SingleParameterName(com.revolsys.geometry.cs.SingleParameterName) VerticalDatum(com.revolsys.geometry.cs.datum.VerticalDatum) ChannelReader(com.revolsys.io.channels.ChannelReader) VerticalCoordinateSystem(com.revolsys.geometry.cs.VerticalCoordinateSystem) EOFException(java.io.EOFException)

Example 5 with ParameterName

use of com.revolsys.geometry.cs.ParameterName in project com.revolsys.open by revolsys.

the class EsriCoordinateSystems method readParameters.

private static Map<ParameterName, ParameterValue> readParameters(final ChannelReader reader) {
    final byte parameterCount = reader.getByte();
    final Map<ParameterName, ParameterValue> parameters = new LinkedHashMap<>();
    for (int i = 0; i < parameterCount; i++) {
        final String name = reader.getStringUtf8ByteCount();
        final String value = reader.getStringUtf8ByteCount();
        final ParameterName parameterName = new SingleParameterName(name);
        final ParameterValue parameterValue = new ParameterValueBigDecimal(value);
        parameters.put(parameterName, parameterValue);
    }
    return parameters;
}
Also used : ParameterValue(com.revolsys.geometry.cs.ParameterValue) ParameterValueBigDecimal(com.revolsys.geometry.cs.ParameterValueBigDecimal) ParameterName(com.revolsys.geometry.cs.ParameterName) SingleParameterName(com.revolsys.geometry.cs.SingleParameterName) SingleParameterName(com.revolsys.geometry.cs.SingleParameterName) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

ParameterName (com.revolsys.geometry.cs.ParameterName)15 ParameterValue (com.revolsys.geometry.cs.ParameterValue)11 LinearUnit (com.revolsys.geometry.cs.unit.LinearUnit)8 ChannelReader (com.revolsys.io.channels.ChannelReader)7 WrappedException (com.revolsys.util.WrappedException)7 EOFException (java.io.EOFException)7 CoordinateOperationMethod (com.revolsys.geometry.cs.CoordinateOperationMethod)6 GeographicCoordinateSystem (com.revolsys.geometry.cs.GeographicCoordinateSystem)5 NoSuchResourceException (com.revolsys.spring.resource.NoSuchResourceException)5 ParameterValueString (com.revolsys.geometry.cs.ParameterValueString)4 Authority (com.revolsys.geometry.cs.Authority)3 ProjectedCoordinateSystem (com.revolsys.geometry.cs.ProjectedCoordinateSystem)3 SingleParameterName (com.revolsys.geometry.cs.SingleParameterName)3 VerticalDatum (com.revolsys.geometry.cs.datum.VerticalDatum)3 LinkedHashMap (java.util.LinkedHashMap)3 Maps (com.revolsys.collection.map.Maps)2 BaseAuthority (com.revolsys.geometry.cs.BaseAuthority)2 VerticalCoordinateSystem (com.revolsys.geometry.cs.VerticalCoordinateSystem)2 ChannelWriter (com.revolsys.io.channels.ChannelWriter)2 Record (com.revolsys.record.Record)2