Search in sources :

Example 6 with ParameterName

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

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

Example 8 with ParameterName

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

the class EsriCoordinateSystemsLoader method vertical.

private void vertical() {
    final Map<ByteArray, Map<Integer, VerticalCoordinateSystem>> csBymd5 = new LinkedHashMap<>();
    try (RecordReader reader = RecordReader.newRecordReader(this.mainPath + "data/esri/esriVerticalCs.tsv");
        final ChannelWriter writer = ChannelWriter.newChannelWriter(this.mainPath + "resources/CoordinateSystems/esri/Vertical.cs")) {
        for (final Record record : reader) {
            final int id = record.getInteger("ID");
            final String wkt = record.getString("WKT");
            final VerticalCoordinateSystem coordinateSystem = WktCsParser.read(wkt);
            final byte[] digest = coordinateSystem.md5Digest();
            Maps.addToMap(Maps::newTree, csBymd5, new ByteArray(digest), id, coordinateSystem);
            final VerticalDatum datum = coordinateSystem.getDatum();
            if (datum != null) {
                final Map<ParameterName, ParameterValue> parameterValues = coordinateSystem.getParameterValues();
                final LinearUnit linearUnit = coordinateSystem.getLinearUnit();
                final String csName = coordinateSystem.getCoordinateSystemName();
                this.geographicIdByName.put(csName, id);
                final String datumName = datum.getName();
                final String linearUnitName = linearUnit.getName();
                final double conversionFactor = linearUnit.getConversionFactor();
                writer.putInt(id);
                writer.putStringUtf8ByteCount(csName);
                writer.putStringUtf8ByteCount(datumName);
                writeParameters(writer, parameterValues);
                writer.putStringUtf8ByteCount(linearUnitName);
                writer.putDouble(conversionFactor);
            }
        }
    }
    writeDigestFile(csBymd5, "Vertical");
}
Also used : LinearUnit(com.revolsys.geometry.cs.unit.LinearUnit) ParameterValue(com.revolsys.geometry.cs.ParameterValue) RecordReader(com.revolsys.record.io.RecordReader) VerticalDatum(com.revolsys.geometry.cs.datum.VerticalDatum) ParameterName(com.revolsys.geometry.cs.ParameterName) LinkedHashMap(java.util.LinkedHashMap) ChannelWriter(com.revolsys.io.channels.ChannelWriter) Maps(com.revolsys.collection.map.Maps) VerticalCoordinateSystem(com.revolsys.geometry.cs.VerticalCoordinateSystem) Record(com.revolsys.record.Record) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 9 with ParameterName

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

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

the class EpsgCoordinateSystems method newCoordinateSystemProjected.

private static ProjectedCoordinateSystem newCoordinateSystemProjected(final int id, final String name, final Area area, final CoordinateSystem sourceCoordinateSystem, final CoordinateOperation operation, final List<Axis> axis, final boolean deprecated) {
    final EpsgAuthority authority = new EpsgAuthority(id);
    final LinearUnit linearUnit = (LinearUnit) axis.get(0).getUnit();
    final CoordinateOperationMethod method = operation.getMethod();
    final Map<ParameterName, ParameterValue> parameterValues = operation.getParameterValues();
    if (sourceCoordinateSystem instanceof GeographicCoordinateSystem) {
        final GeographicCoordinateSystem geographicCoordinateSystem = (GeographicCoordinateSystem) sourceCoordinateSystem;
        return new ProjectedCoordinateSystem(id, name, geographicCoordinateSystem, area, method, parameterValues, linearUnit, axis, authority, deprecated);
    } else if (!Arrays.asList(5819, 5820, 5821).contains(id)) {
        Logs.error(EpsgCoordinateSystems.class, id + " " + name + " has a projected coordinate system");
        return null;
    } else {
        return null;
    }
}
Also used : LinearUnit(com.revolsys.geometry.cs.unit.LinearUnit) ParameterValue(com.revolsys.geometry.cs.ParameterValue) CoordinateOperationMethod(com.revolsys.geometry.cs.CoordinateOperationMethod) ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) ParameterName(com.revolsys.geometry.cs.ParameterName) GeographicCoordinateSystem(com.revolsys.geometry.cs.GeographicCoordinateSystem)

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