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);
}
}
}
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;
}
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;
}
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(']');
}
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(']');
}
Aggregations