use of com.revolsys.io.channels.ChannelWriter in project com.revolsys.open by revolsys.
the class EsriCoordinateSystemsLoader method geographic.
private void geographic() {
final Map<ByteArray, Map<Integer, GeographicCoordinateSystem>> csBymd5 = new LinkedHashMap<>();
try (RecordReader reader = RecordReader.newRecordReader(this.mainPath + "data/esri/esriGeographicCs.tsv");
final ChannelWriter writer = ChannelWriter.newChannelWriter(this.mainPath + "resources/CoordinateSystems/esri/Geographic.cs")) {
for (final Record record : reader) {
final int id = record.getInteger("ID");
final String wkt = record.getString("WKT");
final GeographicCoordinateSystem coordinateSystem = WktCsParser.read(wkt);
final byte[] digest = coordinateSystem.md5Digest();
Maps.addToMap(Maps::newTree, csBymd5, new ByteArray(digest), id, coordinateSystem);
final GeodeticDatum datum = coordinateSystem.getDatum();
final Ellipsoid ellipsoid = datum.getEllipsoid();
final PrimeMeridian primeMeridian = coordinateSystem.getPrimeMeridian();
final AngularUnit angularUnit = coordinateSystem.getAngularUnit();
final String csName = coordinateSystem.getCoordinateSystemName();
this.geographicIdByName.put(csName, id);
final String datumName = datum.getName();
final String spheroidName = ellipsoid.getName();
final double semiMajorAxis = ellipsoid.getSemiMajorAxis();
final double inverseFlattening = ellipsoid.getInverseFlattening();
final String primeMeridianName = primeMeridian.getName();
final double longitude = primeMeridian.getLongitude();
final String angularUnitName = angularUnit.getName();
final double conversionFactor = angularUnit.getConversionFactor();
writer.putInt(id);
writer.putStringUtf8ByteCount(csName);
writer.putStringUtf8ByteCount(datumName);
writer.putStringUtf8ByteCount(spheroidName);
writer.putDouble(semiMajorAxis);
writer.putDouble(inverseFlattening);
writer.putStringUtf8ByteCount(primeMeridianName);
writer.putDouble(longitude);
writer.putStringUtf8ByteCount(angularUnitName);
writer.putDouble(conversionFactor);
}
}
writeDigestFile(csBymd5, "Geographic");
}
use of com.revolsys.io.channels.ChannelWriter 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.io.channels.ChannelWriter in project com.revolsys.open by revolsys.
the class EpsgCoordinateSystemsLoader method loadCoordOperation.
private void loadCoordOperation() {
try (final RecordReader reader = newReader("/public/epsg_coordoperation", "coord_op_code");
ChannelWriter writer = newWriter("coordOperation")) {
for (final Record record : reader) {
writeInt(writer, record, "coord_op_code");
writeInt(writer, record, "coord_op_method_code", 0);
writeString(writer, record, "coord_op_name");
writeCodeByte(writer, record, "coord_op_type", COORDINATE_OPERATION_TYPES);
writeInt(writer, record, "source_crs_code", 0);
writeInt(writer, record, "target_crs_code", 0);
writeString(writer, record, "coord_tfm_version");
writeInt(writer, record, "coord_op_variant", 0);
writeInt(writer, record, "area_of_use", 0);
writeDouble(writer, record, "coord_op_accuracy");
writeDeprecated(writer, record);
}
}
}
use of com.revolsys.io.channels.ChannelWriter in project com.revolsys.open by revolsys.
the class EpsgCoordinateSystemsLoader method loadCoordOperationParam.
private void loadCoordOperationParam() {
try (RecordReader reader = newReader("/public/epsg_coordoperationparam", "parameter_code");
ChannelWriter writer = newWriter("coordOperationParam")) {
for (final Record record : reader) {
writeInt(writer, record, "parameter_code");
writeString(writer, record, "parameter_name");
writeDeprecated(writer, record);
}
}
}
use of com.revolsys.io.channels.ChannelWriter in project com.revolsys.open by revolsys.
the class EpsgCoordinateSystemsLoader method loadCoordOperationParamUsage.
/**
* Order of parameters for a coordOperation
*/
private void loadCoordOperationParamUsage() {
try (RecordReader reader = newReader("/public/epsg_coordoperationparamusage", "coord_op_method_code", "sort_order");
ChannelWriter writer = newWriter("coordOperationParamUsage")) {
for (final Record record : reader) {
writeInt(writer, record, "coord_op_method_code");
writeInt(writer, record, "parameter_code");
writeInt(writer, record, "sort_order");
writeCodeByte(writer, record, "param_sign_reversal", PARAM_SIGN_REVERSAL);
}
}
}
Aggregations