Search in sources :

Example 11 with ChannelWriter

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);
        }
    }
}
Also used : RecordReader(com.revolsys.record.io.RecordReader) Record(com.revolsys.record.Record) ChannelWriter(com.revolsys.io.channels.ChannelWriter)

Example 12 with ChannelWriter

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);
        }
    }
}
Also used : RecordReader(com.revolsys.record.io.RecordReader) Record(com.revolsys.record.Record) ChannelWriter(com.revolsys.io.channels.ChannelWriter)

Example 13 with ChannelWriter

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");
            }
        }
    }
}
Also used : RecordReader(com.revolsys.record.io.RecordReader) Record(com.revolsys.record.Record) ChannelWriter(com.revolsys.io.channels.ChannelWriter)

Example 14 with ChannelWriter

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);
        }
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) ChannelWriter(com.revolsys.io.channels.ChannelWriter)

Example 15 with ChannelWriter

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);
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) BoundingBox(com.revolsys.geometry.model.BoundingBox) ChannelWriter(com.revolsys.io.channels.ChannelWriter)

Aggregations

ChannelWriter (com.revolsys.io.channels.ChannelWriter)27 Record (com.revolsys.record.Record)19 RecordReader (com.revolsys.record.io.RecordReader)19 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)5 HashMap (java.util.HashMap)4 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)4 Maps (com.revolsys.collection.map.Maps)3 GeographicCoordinateSystem (com.revolsys.geometry.cs.GeographicCoordinateSystem)2 ParameterName (com.revolsys.geometry.cs.ParameterName)2 ParameterValue (com.revolsys.geometry.cs.ParameterValue)2 LinearUnit (com.revolsys.geometry.cs.unit.LinearUnit)2 BoundingBox (com.revolsys.geometry.model.BoundingBox)2 IOException (java.io.IOException)2 List (java.util.List)2 TreeMap (java.util.TreeMap)2 Ellipsoid (com.revolsys.geometry.cs.Ellipsoid)1 PrimeMeridian (com.revolsys.geometry.cs.PrimeMeridian)1 ProjectedCoordinateSystem (com.revolsys.geometry.cs.ProjectedCoordinateSystem)1 VerticalCoordinateSystem (com.revolsys.geometry.cs.VerticalCoordinateSystem)1