use of com.revolsys.elevation.cloud.las.pointformat.LasPointFormat in project com.revolsys.open by revolsys.
the class LasPointCloud method forEachPointLazChunked.
private void forEachPointLazChunked(final ArithmeticDecoder decoder, final LazDecompress[] pointDecompressors, final Consumer<? super LasPoint> action) {
final ChannelReader reader = this.reader;
final long chunkTableOffset = reader.getLong();
final long chunkSize = getLasZipHeader().getChunkSize();
long chunkReadCount = chunkSize;
final long pointCount = getPointCount();
for (int i = 0; i < pointCount; i++) {
final LasPoint point;
final LasPointFormat pointFormat = getPointFormat();
if (chunkSize == chunkReadCount) {
point = pointFormat.readLasPoint(this, reader);
for (final LazDecompress pointDecompressor : pointDecompressors) {
pointDecompressor.init(point);
}
decoder.reset();
chunkReadCount = 0;
} else {
point = pointFormat.newLasPoint(this);
for (final LazDecompress pointDecompressor : pointDecompressors) {
pointDecompressor.read(point);
}
}
action.accept(point);
chunkReadCount++;
}
}
use of com.revolsys.elevation.cloud.las.pointformat.LasPointFormat in project com.revolsys.open by revolsys.
the class LasPointCloud method forEachPointLazPointwise.
private void forEachPointLazPointwise(final ArithmeticDecoder decoder, final LazDecompress[] pointDecompressors, final Consumer<? super LasPoint> action) {
final LasPointFormat pointFormat = getPointFormat();
{
final ChannelReader reader = this.reader;
final LasPoint point = pointFormat.readLasPoint(this, reader);
for (final LazDecompress pointDecompressor : pointDecompressors) {
pointDecompressor.init(point);
}
decoder.reset();
action.accept(point);
}
final long pointCount = getPointCount();
for (int i = 1; i < pointCount; i++) {
final LasPoint point = pointFormat.newLasPoint(this);
for (final LazDecompress pointDecompressor : pointDecompressors) {
pointDecompressor.read(point);
}
action.accept(point);
}
}
use of com.revolsys.elevation.cloud.las.pointformat.LasPointFormat in project com.revolsys.open by revolsys.
the class LasPointCloud method forEachPoint.
@Override
public void forEachPoint(final Consumer<? super LasPoint> action) {
final long pointCount = getPointCount();
try {
final ChannelReader reader = this.reader;
if (reader == null) {
this.points.forEach(action);
} else if (pointCount == 0) {
this.reader = null;
} else if (this.header.isLaszip()) {
forEachPointLaz(action);
} else {
try (BaseCloseable closable = this) {
final LasPointFormat pointFormat = getPointFormat();
for (int i = 0; i < pointCount; i++) {
final LasPoint point = pointFormat.readLasPoint(this, reader);
action.accept(point);
}
}
}
} finally {
this.reader = null;
}
}
use of com.revolsys.elevation.cloud.las.pointformat.LasPointFormat in project com.revolsys.open by revolsys.
the class LasProjection method setCoordinateSystem.
protected static void setCoordinateSystem(final LasPointCloudHeader header, final CoordinateSystem coordinateSystem) {
if (coordinateSystem != null) {
header.removeLasProperties(LASF_PROJECTION);
final LasPointFormat pointFormat = header.getPointFormat();
if (pointFormat.getId() <= 5) {
final int coordinateSystemId = coordinateSystem.getCoordinateSystemId();
int keyId;
if (coordinateSystem instanceof ProjectedCoordinateSystem) {
keyId = TiffImage.PROJECTED_COORDINATE_SYSTEM_ID;
} else {
keyId = TiffImage.GEOGRAPHIC_COORDINATE_SYSTEM_ID;
}
final ByteArrayOutputStream byteOut = new ByteArrayOutputStream(1024);
try (final EndianOutput out = new EndianOutputStream(byteOut)) {
out.writeLEUnsignedShort(1);
out.writeLEUnsignedShort(1);
out.writeLEUnsignedShort(0);
out.writeLEUnsignedShort(1);
{
out.writeLEUnsignedShort(keyId);
out.writeLEUnsignedShort(0);
out.writeLEUnsignedShort(1);
out.writeLEUnsignedShort(coordinateSystemId);
}
}
final byte[] bytes = byteOut.toByteArray();
final LasVariableLengthRecord property = new LasVariableLengthRecord(LASF_PROJECTION, LASF_PROJECTION_TIFF_GEO_KEY_DIRECTORY_TAG, "TIFF GeoKeyDirectoryTag", bytes, coordinateSystem);
header.addProperty(property);
} else {
final String wkt = EpsgCoordinateSystems.toWkt(coordinateSystem);
final byte[] stringBytes = wkt.getBytes(StandardCharsets.UTF_8);
final byte[] bytes = new byte[stringBytes.length + 1];
System.arraycopy(stringBytes, 0, bytes, 0, stringBytes.length);
final LasVariableLengthRecord property = new LasVariableLengthRecord(LASF_PROJECTION, LASF_PROJECTION_WKT_COORDINATE_SYSTEM, "WKT", bytes, coordinateSystem);
header.addProperty(property);
}
}
}
Aggregations