use of com.revolsys.geometry.cs.ParameterValue 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");
}
use of com.revolsys.geometry.cs.ParameterValue 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;
}
}
use of com.revolsys.geometry.cs.ParameterValue in project com.revolsys.open by revolsys.
the class EpsgCoordinateSystems method loadCoordOperationParamValue.
private static void loadCoordOperationParamValue(final IntHashMap<CoordinateOperationMethod> methodById, final IntHashMap<Map<ParameterName, ParameterValue>> operationParameters, final IntHashMap<List<Byte>> paramReversal) {
try (ChannelReader reader = newChannelReader("coordOperationParamValue")) {
while (true) {
final int operationId = reader.getInt();
final CoordinateOperationMethod method = readCode(reader, methodById);
final ParameterName parameterName = readCode(reader, PARAM_NAME_BY_ID);
final double value = reader.getDouble();
final String fileRef = reader.getStringUtf8ByteCount();
final UnitOfMeasure unit = readCode(reader, UNIT_BY_ID);
final ParameterValue parameterValue;
if (Double.isFinite(value)) {
if (Property.hasValue(fileRef)) {
throw new IllegalArgumentException("Cannot have a value and fileRef for coordOperationParamValue=" + operationId + " " + parameterName);
} else {
parameterValue = new ParameterValueNumber(unit, value);
}
} else {
if (Property.hasValue(fileRef)) {
parameterValue = new ParameterValueString(fileRef);
} else {
parameterValue = null;
}
}
Map<ParameterName, ParameterValue> parameterValues = operationParameters.get(operationId);
if (parameterValues == null) {
parameterValues = Maps.newLinkedHash();
final List<ParameterName> parameterOrder = method.getParameterNames();
for (final ParameterName orderParameterName : parameterOrder) {
parameterValues.put(orderParameterName, null);
}
operationParameters.put(operationId, parameterValues);
}
method.setParameter(parameterValues, parameterName, parameterValue);
}
} catch (final NoSuchResourceException e) {
} catch (final WrappedException e) {
if (Exceptions.isException(e, EOFException.class)) {
} else {
Logs.error(EpsgCoordinateSystems.class, "Error loading coordOperationParamValue", e);
}
}
}
use of com.revolsys.geometry.cs.ParameterValue in project com.revolsys.open by revolsys.
the class EsriCoordinateSystems method getProjectedCoordinateSystem.
public static ProjectedCoordinateSystem getProjectedCoordinateSystem(final int id) {
ProjectedCoordinateSystem coordinateSystem = (ProjectedCoordinateSystem) COORDINATE_SYSTEM_BY_ID.get(id);
if (coordinateSystem == null) {
try (final ChannelReader reader = ChannelReader.newChannelReader("classpath:CoordinateSystems/esri/Projected.cs")) {
while (true) {
final int coordinateSystemId = reader.getInt();
final String csName = reader.getStringUtf8ByteCount();
final int geographicCoordinateSystemId = reader.getInt();
final String projectionName = reader.getStringUtf8ByteCount();
final Map<ParameterName, ParameterValue> parameters = readParameters(reader);
final String unitName = reader.getStringUtf8ByteCount();
final double conversionFactor = reader.getDouble();
if (id == coordinateSystemId) {
LinearUnit linearUnit = LINEAR_UNITS_BY_NAME.get(unitName);
if (linearUnit == null) {
linearUnit = new LinearUnit(unitName, conversionFactor);
LINEAR_UNITS_BY_NAME.put(unitName, linearUnit);
}
final Authority authority = new BaseAuthority("ESRI", coordinateSystemId);
final GeographicCoordinateSystem geographicCoordinateSystem = getGeographicCoordinateSystem(geographicCoordinateSystemId);
coordinateSystem = new ProjectedCoordinateSystem(coordinateSystemId, csName, geographicCoordinateSystem, projectionName, parameters, linearUnit, authority);
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 EsriCoordinateSystemsLoader method writeParameters.
private void writeParameters(final ChannelWriter writer, final Map<ParameterName, ParameterValue> parameterValues) {
final int parameterCount = parameterValues.size();
writer.putByte((byte) parameterCount);
for (final Entry<ParameterName, ParameterValue> entry : parameterValues.entrySet()) {
final ParameterName parameterName = entry.getKey();
final ParameterValue parameterValue = entry.getValue();
final String name = parameterName.getName();
final Object value = parameterValue.getOriginalValue();
writer.putStringUtf8ByteCount(name);
writer.putStringUtf8ByteCount(DataTypes.toString(value));
}
}
Aggregations