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);
}
}
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;
}
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;
}
Aggregations