use of com.revolsys.io.channels.ChannelWriter in project com.revolsys.open by revolsys.
the class EpsgCoordinateSystemsLoader method loadDatum.
private void loadDatum() throws IOException {
final List<String> datumTypes = Arrays.asList("geodetic", "vertical", "engineering");
try (final RecordReader reader = newReader("/public/epsg_datum", "datum_code");
ChannelWriter writer = newWriter("datum")) {
for (final Record record : reader) {
writeInt(writer, record, "datum_code");
writeString(writer, record, "datum_name");
writeCodeByte(writer, record, "datum_type", datumTypes);
writeInt(writer, record, "ellipsoid_code", 0);
writeInt(writer, record, "prime_meridian_code", 0);
writeInt(writer, record, "area_of_use_code");
writeDeprecated(writer, record);
}
}
}
use of com.revolsys.io.channels.ChannelWriter in project com.revolsys.open by revolsys.
the class EpsgCoordinateSystemsLoader method loadArea.
private void loadArea() {
try (final RecordReader reader = newReader("/public/epsg_area", "area_code");
ChannelWriter writer = newWriter("area")) {
for (final Record record : reader) {
writeInt(writer, record, "area_code");
writeString(writer, record, "area_name");
writeDouble(writer, record, "area_west_bound_lon");
writeDouble(writer, record, "area_south_bound_lat");
writeDouble(writer, record, "area_east_bound_lon");
writeDouble(writer, record, "area_north_bound_lat");
writeDeprecated(writer, record);
}
}
}
use of com.revolsys.io.channels.ChannelWriter in project com.revolsys.open by revolsys.
the class EpsgCoordinateSystemsLoader method loadPrimeMeridian.
private void loadPrimeMeridian() throws IOException {
try (final RecordReader reader = newReader("/public/epsg_primemeridian", "prime_meridian_code");
ChannelWriter writer = newWriter("primeMeridian")) {
for (final Record record : reader) {
writeInt(writer, record, "prime_meridian_code");
writeString(writer, record, "prime_meridian_name");
writeInt(writer, record, "uom_code");
writeDouble(writer, record, "greenwich_longitude");
if (isDeprecated(record)) {
System.err.println("Add deprecated support to prime meridian");
}
}
}
}
use of com.revolsys.io.channels.ChannelWriter in project com.revolsys.open by revolsys.
the class ScaledIntegerGriddedDigitalElevationModelWriter method writeGrid.
private void writeGrid(final GriddedElevationModel elevationModel) throws IOException {
final ChannelWriter out = this.writer;
final int gridWidth = this.gridWidth;
final int gridHeight = this.gridHeight;
final GeometryFactory geometryFactory = elevationModel.getGeometryFactory();
for (int gridY = 0; gridY < gridHeight; gridY++) {
for (int gridX = 0; gridX < gridWidth; gridX++) {
final double elevation = elevationModel.getElevation(gridX, gridY);
final int zInt = geometryFactory.toIntZ(elevation);
out.putInt(zInt);
}
}
}
use of com.revolsys.io.channels.ChannelWriter in project com.revolsys.open by revolsys.
the class ScaledIntegerTriangulatedIrregularNetworkWriter method write.
@Override
public void write(final TriangulatedIrregularNetwork tin) {
try (ChannelWriter out = this.resource.newChannelWriter()) {
final BoundingBox tinBoundingBox = tin.getBoundingBox();
final GeometryFactory geometryFactory = tin.getGeometryFactory().convertToFixed(1000.0);
out.putBytes(ScaledIntegerTriangulatedIrregularNetwork.FILE_TYPE_BYTES);
out.putShort(ScaledIntegerTriangulatedIrregularNetwork.VERSION);
geometryFactory.writeOffsetScaled3d(out);
// minX
out.putDouble(tinBoundingBox.getMinX());
// minY
out.putDouble(tinBoundingBox.getMinY());
// maxX
out.putDouble(tinBoundingBox.getMaxX());
// maxY
out.putDouble(tinBoundingBox.getMaxY());
tin.forEachTriangle(triangle -> {
for (int i = 0; i < 3; i++) {
final double x = triangle.getX(i);
final double y = triangle.getY(i);
final double z = triangle.getZ(i);
final int intX = geometryFactory.toIntX(x);
out.putInt(intX);
final int intY = geometryFactory.toIntY(y);
out.putInt(intY);
final int intZ = geometryFactory.toIntZ(z);
out.putInt(intZ);
}
});
} catch (final Exception e) {
throw Exceptions.wrap("Unable to write: " + this.resource, e);
}
}
Aggregations