Search in sources :

Example 6 with IntArrayScaleGriddedElevationModel

use of com.revolsys.elevation.gridded.IntArrayScaleGriddedElevationModel in project com.revolsys.open by revolsys.

the class UsgsGriddedElevationReader method read.

@Override
public final GriddedElevationModel read() {
    init();
    try {
        final double minX = this.boundingBox.getMinX();
        final double minY = this.boundingBox.getMinY();
        final double width = this.boundingBox.getWidth();
        final double height = this.boundingBox.getHeight();
        final int gridWidth = (int) Math.ceil(width / this.resolutionX);
        final int gridHeight = (int) Math.ceil(width / this.resolutionX);
        final IntArrayScaleGriddedElevationModel elevationModel = new IntArrayScaleGriddedElevationModel(this.geometryFactory, minX, minY, gridWidth, gridHeight, this.resolutionX);
        while (readBuffer()) {
            final int rowIndex = getInteger() - 1;
            int columnIndex = getInteger() - 1;
            final int rowCount = getInteger();
            final int colCount = getInteger();
            final double x1 = getDouble24();
            final double y1 = getDouble24();
            final double z1 = getDouble24();
            final double minZ = getDouble24();
            final double maxZ = getDouble24();
            for (int i = 0; i < colCount; i++) {
                final double x = x1 + i * this.resolutionX;
                for (int j = 0; j < rowCount; j++) {
                    final double y = y1 + j * this.resolutionY;
                    if (j > 145) {
                        final int offset = (j - 146) % 170;
                        if (offset == 0) {
                            readBuffer();
                        }
                    }
                    final int value = getInteger();
                    final double elevation = z1 + value * this.resolutionZ;
                    if (elevation > -32767) {
                        elevationModel.setElevation(x, y, elevation);
                    }
                }
            }
            columnIndex++;
        }
        elevationModel.setResource(this.resource);
        return elevationModel;
    } catch (final IOException e) {
        throw Exceptions.wrap(e);
    }
}
Also used : IntArrayScaleGriddedElevationModel(com.revolsys.elevation.gridded.IntArrayScaleGriddedElevationModel) IOException(java.io.IOException)

Example 7 with IntArrayScaleGriddedElevationModel

use of com.revolsys.elevation.gridded.IntArrayScaleGriddedElevationModel in project com.revolsys.open by revolsys.

the class TinBuilder method newGriddedElevationModel.

default GriddedElevationModel newGriddedElevationModel(final int gridCellSize) {
    final BoundingBox boundingBox = getBoundingBox();
    final int minX = (int) Math.floor(boundingBox.getMinX() / gridCellSize) * gridCellSize;
    final int minY = (int) Math.floor(boundingBox.getMinY() / gridCellSize) * gridCellSize;
    final int maxX = (int) Math.ceil(boundingBox.getMaxX() / gridCellSize) * gridCellSize;
    final int maxY = (int) Math.ceil(boundingBox.getMaxY() / gridCellSize) * gridCellSize;
    final int width = maxX - minX;
    final int height = maxY - minY;
    final int gridWidth = width / gridCellSize;
    final int gridHeight = height / gridCellSize;
    final GeometryFactory geometryFactory = // 
    getGeometryFactory().convertAxisCountAndScales(3, 1000.0, 1000.0, 1000.0);
    final IntArrayScaleGriddedElevationModel elevationModel = new IntArrayScaleGriddedElevationModel(geometryFactory, minX, minY, gridWidth, gridHeight, gridCellSize);
    forEachTriangle(elevationModel::setElevationsForTriangle);
    return elevationModel;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) BoundingBox(com.revolsys.geometry.model.BoundingBox) IntArrayScaleGriddedElevationModel(com.revolsys.elevation.gridded.IntArrayScaleGriddedElevationModel) Point(com.revolsys.geometry.model.Point)

Example 8 with IntArrayScaleGriddedElevationModel

use of com.revolsys.elevation.gridded.IntArrayScaleGriddedElevationModel in project com.revolsys.open by revolsys.

the class GriddedElevationModelTest method newIntArrayModelEmpty.

protected static GriddedElevationModel newIntArrayModelEmpty(final int coordinateSystemId) {
    final GeometryFactory geometryFactory = GeometryFactory.fixed3d(coordinateSystemId, 1000.0, 1000.0, 1000.0);
    final GriddedElevationModel model = new IntArrayScaleGriddedElevationModel(geometryFactory, 0, 0, 255, 255, 1);
    return model;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) IntArrayScaleGriddedElevationModel(com.revolsys.elevation.gridded.IntArrayScaleGriddedElevationModel) GriddedElevationModel(com.revolsys.elevation.gridded.GriddedElevationModel) IntArrayScaleGriddedElevationModel(com.revolsys.elevation.gridded.IntArrayScaleGriddedElevationModel)

Aggregations

IntArrayScaleGriddedElevationModel (com.revolsys.elevation.gridded.IntArrayScaleGriddedElevationModel)8 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)3 IOException (java.io.IOException)3 GriddedElevationModel (com.revolsys.elevation.gridded.GriddedElevationModel)2 BoundingBox (com.revolsys.geometry.model.BoundingBox)2 Point (com.revolsys.geometry.model.Point)2 ChannelReader (com.revolsys.io.channels.ChannelReader)2 ClosedByInterruptException (java.nio.channels.ClosedByInterruptException)2 TriangulatedIrregularNetwork (com.revolsys.elevation.tin.TriangulatedIrregularNetwork)1 IntBuffer (java.nio.IntBuffer)1 MappedByteBuffer (java.nio.MappedByteBuffer)1 FileChannel (java.nio.channels.FileChannel)1 ReadableByteChannel (java.nio.channels.ReadableByteChannel)1