use of com.revolsys.elevation.cloud.las.pointformat.LasPoint in project com.revolsys.open by revolsys.
the class LazDecompressGpsTime11V1 method read.
@Override
public void read(final LasPoint point) {
int multi;
if (this.gpstimeDiff == 0) {
// if the last integer difference was zero
multi = this.decoder.decodeSymbol(this.gpsTime0Diff);
if (multi == 1) {
// the difference can be represented with 32 bits
this.gpstimeDiff = this.decompressGpsTime.decompress(0, 0);
this.gpsTime += this.gpstimeDiff;
} else if (multi == 2) {
// the difference is huge
this.gpsTime = this.decoder.getLong();
}
} else {
multi = this.decoder.decodeSymbol(this.gpsTimeMulti);
if (multi < LASZIP_GPSTIME_MULTIMAX - 2) {
int gpstime_diff;
if (multi == 1) {
gpstime_diff = this.decompressGpsTime.decompress(this.gpstimeDiff, 1);
this.gpstimeDiff = gpstime_diff;
this.multiExtremeCounter = 0;
} else if (multi == 0) {
gpstime_diff = this.decompressGpsTime.decompress(this.gpstimeDiff / 4, 2);
this.multiExtremeCounter++;
if (this.multiExtremeCounter > 3) {
this.gpstimeDiff = gpstime_diff;
this.multiExtremeCounter = 0;
}
} else if (multi < 10) {
gpstime_diff = this.decompressGpsTime.decompress(multi * this.gpstimeDiff, 3);
} else if (multi < 50) {
gpstime_diff = this.decompressGpsTime.decompress(multi * this.gpstimeDiff, 4);
} else {
gpstime_diff = this.decompressGpsTime.decompress(multi * this.gpstimeDiff, 5);
if (multi == LASZIP_GPSTIME_MULTIMAX - 3) {
this.multiExtremeCounter++;
if (this.multiExtremeCounter > 3) {
this.gpstimeDiff = gpstime_diff;
this.multiExtremeCounter = 0;
}
}
}
this.gpsTime += gpstime_diff;
} else if (multi < LASZIP_GPSTIME_MULTIMAX - 1) {
this.gpsTime = this.decoder.getLong();
}
}
point.setGpsTime(Double.longBitsToDouble(this.gpsTime));
}
use of com.revolsys.elevation.cloud.las.pointformat.LasPoint in project com.revolsys.open by revolsys.
the class LazDecompressPoint10V1 method read.
@Override
public void read(final LasPoint point) {
final int medianX = median(this.lastDiffX);
final int medianY = median(this.lastDiffY);
// decompress x y z coordinates
final int diffX = this.decompressDeltaX.decompress(medianX);
this.x += diffX;
// we use the number k of bits corrector bits to switch contexts
// unsigned
final int kBitsX = this.decompressDeltaX.getK();
final int diffY = this.decompressDeltaY.decompress(medianY, kBitsX < 19 ? kBitsX : 19);
this.y += diffY;
final int kBitsY = (kBitsX + this.decompressDeltaY.getK()) / 2;
this.z = this.decompressZ.decompress(this.z, kBitsY < 19 ? kBitsY : 19);
final int changedValues = this.decoder.decodeSymbol(this.decompressChangedValues);
if (changedValues != 0) {
if ((changedValues & 32) != 0) {
this.intensity = this.decompressIntensity.decompress(this.intensity);
}
if ((changedValues & 16) != 0) {
this.returnByte = read(this.decompressBitByte, this.returnByte);
}
if ((changedValues & 8) != 0) {
this.classificationByte = read(this.decompressClassification, this.classificationByte);
}
if ((changedValues & 4) != 0) {
this.scanAngleRank = (byte) this.decompressScanAngleRank.decompress(this.scanAngleRank, kBitsY < 3 ? 1 : 0);
}
if ((changedValues & 2) != 0) {
this.userData = read(this.decompressUserData, this.userData);
}
if ((changedValues & 1) != 0) {
this.pointSourceId = this.decompressPointSourceId.decompress(this.pointSourceId);
}
}
// record the difference
this.lastDiffX[this.lastIncrement] = diffX;
this.lastDiffY[this.lastIncrement] = diffY;
this.lastIncrement++;
if (this.lastIncrement > 2) {
this.lastIncrement = 0;
}
postRead(point);
}
use of com.revolsys.elevation.cloud.las.pointformat.LasPoint in project com.revolsys.open by revolsys.
the class LazDecompressPoint10V2 method read.
@Override
public void read(final LasPoint point) {
final int changedValues = this.decoder.decodeSymbol(this.decompressChangedValues);
final int m;
int returnNumber;
int returnCount;
final int l;
if (changedValues == 0) {
returnNumber = this.returnByte & 0b111;
returnCount = this.returnByte >> 3 & 0b111;
m = Common_v2.NUMBER_RETURN_MAP[returnCount][returnNumber];
l = Common_v2.NUMBER_RETURN_LEVEL[returnCount][returnNumber];
} else {
// decompress the edge_of_flight_line, scan_direction_flag, ... if it has changed
if ((changedValues & 32) != 0) {
this.returnByte = read(this.decompressBitByte, this.returnByte);
}
returnNumber = this.returnByte & 0b111;
returnCount = this.returnByte >> 3 & 0b111;
m = Common_v2.NUMBER_RETURN_MAP[returnCount][returnNumber];
l = Common_v2.NUMBER_RETURN_LEVEL[returnCount][returnNumber];
// decompress the intensity if it has changed
if ((changedValues & 16) != 0) {
this.intensity = this.decompressIntensity.decompress(this.lastIntensity[m], m < 3 ? m : 3);
this.lastIntensity[m] = this.intensity;
} else {
this.intensity = this.lastIntensity[m];
}
if ((changedValues & 8) != 0) {
this.classificationByte = read(this.decompressClassification, this.classificationByte);
}
// decompress the scan_angle_rank ... if it has changed
if ((changedValues & 4) != 0) {
ArithmeticModel model;
if (this.scanDirectionFlag) {
model = this.decompressScanAngleRankTrue;
} else {
model = this.decompressScanAngleRankFalse;
}
final int val = this.decoder.decodeSymbol(model);
this.scanAngleRank = (byte) Byte.toUnsignedInt(MyDefs.U8_FOLD(val + this.scanAngleRank));
}
if ((changedValues & 2) != 0) {
this.userData = read(this.decompressUserData, this.userData);
}
// decompress the point_source_ID ... if it has changed
if ((changedValues & 1) != 0) {
this.pointSourceId = this.decompressPointSourceId.decompress(this.pointSourceId);
}
}
// decompress x coordinate
final int medianX = this.lastXDiffMedian5[m].get();
final int diffX = this.decompressDeltaX.decompress(medianX, returnCount == 1 ? 1 : 0);
this.x += diffX;
this.lastXDiffMedian5[m].add(diffX);
// decompress y coordinate
final int medianY = this.lastYDiffMedian5[m].get();
final int kBitsY = this.decompressDeltaX.getK();
final int diffY = this.decompressDeltaY.decompress(medianY, (returnCount == 1 ? 1 : 0) + (kBitsY < 20 ? MyDefs.U32_ZERO_BIT_0(kBitsY) : 20));
this.y += diffY;
this.lastYDiffMedian5[m].add(diffY);
// decompress z coordinate
final int kBitsZ = (this.decompressDeltaX.getK() + this.decompressDeltaY.getK()) / 2;
this.z = this.decompressZ.decompress(this.last_height[l], (returnCount == 1 ? 1 : 0) + (kBitsZ < 18 ? MyDefs.U32_ZERO_BIT_0(kBitsZ) : 18));
this.last_height[l] = this.z;
postRead(point);
this.scanDirectionFlag = point.isScanDirectionFlag();
}
use of com.revolsys.elevation.cloud.las.pointformat.LasPoint in project com.revolsys.open by revolsys.
the class LazDecompressRgb12V2 method read.
@Override
public void read(final LasPoint point) {
final int lastRed = this.red;
final int lastGreen = this.green;
final int lastBlue = this.blue;
byte corr;
int diff = 0;
final int sym = this.decoder.decodeSymbol(this.byteUsed);
if ((sym & 1 << 0) != 0) {
corr = (byte) this.decoder.decodeSymbol(this.rgbDiff0);
this.red = MyDefs.U8_FOLD(corr + (lastRed & 255));
} else {
this.red = lastRed & 0xFF;
}
if ((sym & 1 << 1) != 0) {
corr = (byte) this.decoder.decodeSymbol(this.rgbDiff1);
this.red |= MyDefs.U8_FOLD(corr + (lastRed >>> 8)) << 8;
} else {
this.red |= lastRed & 0xFF00;
}
if ((sym & 1 << 6) != 0) {
diff = (this.red & 0x00FF) - (lastRed & 0x00FF);
if ((sym & 1 << 2) != 0) {
corr = (byte) this.decoder.decodeSymbol(this.rgbDiff2);
this.green = MyDefs.U8_FOLD(corr + MyDefs.U8_CLAMP(diff + (lastGreen & 255)));
} else {
this.green = lastGreen & 0xFF;
}
if ((sym & 1 << 4) != 0) {
corr = (byte) this.decoder.decodeSymbol(this.rgbDiff4);
diff = (diff + (this.green & 0x00FF) - (lastGreen & 0x00FF)) / 2;
this.blue = MyDefs.U8_FOLD(corr + MyDefs.U8_CLAMP(diff + (lastBlue & 255)));
} else {
this.blue = lastBlue & 0xFF;
}
diff = (this.red >>> 8) - (lastRed >>> 8);
if ((sym & 1 << 3) != 0) {
corr = (byte) this.decoder.decodeSymbol(this.rgbDiff3);
this.green |= MyDefs.U8_FOLD(corr + MyDefs.U8_CLAMP(diff + (lastGreen >>> 8))) << 8;
} else {
this.green |= lastGreen & 0xFF00;
}
if ((sym & 1 << 5) != 0) {
corr = (byte) this.decoder.decodeSymbol(this.rgbDiff5);
diff = (diff + (this.green >>> 8) - (lastGreen >>> 8)) / 2;
this.blue |= MyDefs.U8_FOLD(corr + MyDefs.U8_CLAMP(diff + (lastBlue >>> 8))) << 8;
} else {
this.blue |= lastBlue & 0xFF00;
}
} else {
this.green = this.red;
this.blue = this.red;
}
super.read(point);
}
use of com.revolsys.elevation.cloud.las.pointformat.LasPoint in project com.revolsys.open by revolsys.
the class LasPointCloud method addPoint.
@SuppressWarnings("unchecked")
public <P extends LasPoint0Core> P addPoint(final double x, final double y, final double z) {
final LasPoint lasPoint = this.header.newLasPoint(this, x, y, z);
this.points.add(lasPoint);
return (P) lasPoint;
}
Aggregations