Search in sources :

Example 1 with ParameterValue

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

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

use of com.revolsys.geometry.cs.ParameterValue 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)

Example 4 with ParameterValue

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

the class EsriCsWktWriter method write.

public static void write(final Writer out, final VerticalCoordinateSystem coordinateSystem, final int indentLevel) throws IOException {
    out.write("VERTCS[");
    write(out, coordinateSystem.getCoordinateSystemName(), incrementIndent(indentLevel));
    final VerticalDatum datum = coordinateSystem.getDatum();
    if (datum != null) {
        out.write(",");
        indent(out, incrementIndent(indentLevel));
        write(out, datum, incrementIndent(indentLevel));
    }
    for (final Entry<ParameterName, ParameterValue> parameter : coordinateSystem.getParameterValues().entrySet()) {
        final ParameterName name = parameter.getKey();
        final ParameterValue value = parameter.getValue();
        write(out, name, value, incrementIndent(indentLevel));
    }
    final LinearUnit unit = coordinateSystem.getLinearUnit();
    if (unit != null) {
        write(out, unit, incrementIndent(indentLevel));
    }
    indent(out, indentLevel);
    out.write(']');
}
Also used : LinearUnit(com.revolsys.geometry.cs.unit.LinearUnit) ParameterValue(com.revolsys.geometry.cs.ParameterValue) VerticalDatum(com.revolsys.geometry.cs.datum.VerticalDatum) ParameterName(com.revolsys.geometry.cs.ParameterName)

Example 5 with ParameterValue

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

the class EsriCsWktWriter method write.

public static void write(final Writer out, final ProjectedCoordinateSystem coordinateSystem, final int indentLevel) throws IOException {
    out.write("PROJCS[");
    write(out, coordinateSystem.getCoordinateSystemName(), incrementIndent(indentLevel));
    final GeographicCoordinateSystem geoCs = coordinateSystem.getGeographicCoordinateSystem();
    if (geoCs != null) {
        out.write(",");
        indent(out, incrementIndent(indentLevel));
        write(out, geoCs, incrementIndent(indentLevel));
    }
    final CoordinateOperationMethod coordinateOperationMethod = coordinateSystem.getCoordinateOperationMethod();
    if (coordinateOperationMethod != null) {
        out.write(",");
        indent(out, incrementIndent(indentLevel));
        write(out, coordinateOperationMethod, incrementIndent(indentLevel));
    }
    for (final Entry<ParameterName, ParameterValue> parameter : coordinateSystem.getParameterValues().entrySet()) {
        final ParameterName name = parameter.getKey();
        final ParameterValue value = parameter.getValue();
        write(out, name, value, incrementIndent(indentLevel));
    }
    final LinearUnit unit = coordinateSystem.getLinearUnit();
    if (unit != null) {
        write(out, unit, incrementIndent(indentLevel));
    }
    indent(out, indentLevel);
    out.write(']');
}
Also used : LinearUnit(com.revolsys.geometry.cs.unit.LinearUnit) ParameterValue(com.revolsys.geometry.cs.ParameterValue) CoordinateOperationMethod(com.revolsys.geometry.cs.CoordinateOperationMethod) ParameterName(com.revolsys.geometry.cs.ParameterName) GeographicCoordinateSystem(com.revolsys.geometry.cs.GeographicCoordinateSystem)

Aggregations

ParameterName (com.revolsys.geometry.cs.ParameterName)11 ParameterValue (com.revolsys.geometry.cs.ParameterValue)11 LinearUnit (com.revolsys.geometry.cs.unit.LinearUnit)7 CoordinateOperationMethod (com.revolsys.geometry.cs.CoordinateOperationMethod)4 GeographicCoordinateSystem (com.revolsys.geometry.cs.GeographicCoordinateSystem)4 ChannelReader (com.revolsys.io.channels.ChannelReader)4 WrappedException (com.revolsys.util.WrappedException)4 EOFException (java.io.EOFException)4 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 Authority (com.revolsys.geometry.cs.Authority)2 BaseAuthority (com.revolsys.geometry.cs.BaseAuthority)2 ParameterValueString (com.revolsys.geometry.cs.ParameterValueString)2 VerticalCoordinateSystem (com.revolsys.geometry.cs.VerticalCoordinateSystem)2 ChannelWriter (com.revolsys.io.channels.ChannelWriter)2 Record (com.revolsys.record.Record)2 RecordReader (com.revolsys.record.io.RecordReader)2