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