Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use MutableInteger as context for LASreadItem.read() and LASreadItemC… #143

Merged
merged 2 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@

public abstract class LASreadItem {

public abstract PointDataRecord read(int context);
public abstract PointDataRecord read(MutableInteger context);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@

public abstract class LASreadItemCompressed extends LASreadItem {

public abstract void init(PointDataRecord seedItem, int context);
public abstract void init(PointDataRecord seedItem, MutableInteger context);
public abstract boolean chunk_sizes();
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public LASreadItemCompressed_BYTE14_v3(IByteStreamInProvider instreamProvider, i
}

@Override
public void init(PointDataRecord seedItem, int context) {
public void init(PointDataRecord seedItem, MutableInteger context) {

int i;

Expand Down Expand Up @@ -183,7 +183,7 @@ public void init(PointDataRecord seedItem, int context) {

/* set scanner channel as current context */

current_context = context; // all other items use context set by POINT14 reader
current_context = context.get(); // all other items use context set by POINT14 reader

/* create and init models and decompressors */

Expand All @@ -206,22 +206,22 @@ public boolean chunk_sizes() {
}

@Override
public PointDataRecord read(int context) {
public PointDataRecord read(MutableInteger context) {
// get last

PointDataRecordBytes last_item = contexts[current_context].last_item;

// check for context switch

if (current_context != context)
if (current_context != context.get())
{
current_context = context; // all other items use context set by POINT14 reader
current_context = context.get(); // all other items use context set by POINT14 reader
if (contexts[current_context].unused)
{
createAndInitModelsAndDecompressors(current_context, last_item);
last_item = contexts[current_context].last_item;
}
last_item = contexts[current_context].last_item;
}
}

// decompress
PointDataRecordBytes result = new PointDataRecordBytes(number);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public LASreadItemCompressed_BYTE_v1(ArithmeticDecoder dec, int number)
}

@Override
public void init(PointDataRecord seedItem, int notUsed)
public void init(PointDataRecord seedItem, MutableInteger notUsed)
{
/* init state */

Expand All @@ -41,7 +41,7 @@ public void init(PointDataRecord seedItem, int notUsed)
}

@Override
public PointDataRecord read(int notUsed)
public PointDataRecord read(MutableInteger notUsed)
{
PointDataRecordBytes result = new PointDataRecordBytes(number);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public LASreadItemCompressed_BYTE_v2(ArithmeticDecoder dec, int number)
}

@Override
public void init(PointDataRecord seedItem, int notUsed)
public void init(PointDataRecord seedItem, MutableInteger notUsed)
{
int i;
/* init state */
Expand All @@ -54,7 +54,7 @@ public void init(PointDataRecord seedItem, int notUsed)
}

@Override
public PointDataRecord read(int notUsed)
public PointDataRecord read(MutableInteger notUsed)
{
PointDataRecordBytes result = new PointDataRecordBytes(number);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public LASreadItemCompressed_GPSTIME11_v1(ArithmeticDecoder dec)
}

@Override
public void init(PointDataRecord seedItem, int notUsed)
public void init(PointDataRecord seedItem, MutableInteger notUsed)
{
/* init state */
last_gpstime_diff = 0;
Expand All @@ -52,7 +52,7 @@ public void init(PointDataRecord seedItem, int notUsed)
}

@Override
public PointDataRecordGpsTime read(int notUsed)
public PointDataRecordGpsTime read(MutableInteger notUsed)
{
int multi;
if (last_gpstime_diff == 0) // if the last integer difference was zero
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public LASreadItemCompressed_GPSTIME11_v2(ArithmeticDecoder dec)
}

@Override
public void init(PointDataRecord seedItem, int notUsed)
public void init(PointDataRecord seedItem, MutableInteger notUsed)
{
/* init state */
last = 0; next = 0;
Expand All @@ -68,7 +68,7 @@ public void init(PointDataRecord seedItem, int notUsed)
}

@Override
public PointDataRecord read(int notUsed)
public PointDataRecord read(MutableInteger notUsed)
{
PointDataRecordGpsTime result = new PointDataRecordGpsTime();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public LASreadItemCompressed_POINT10_v1(ArithmeticDecoder dec) {
}

@Override
public void init(PointDataRecord seedItem, int notUsed) {
public void init(PointDataRecord seedItem, MutableInteger notUsed) {

int i;

Expand Down Expand Up @@ -81,7 +81,7 @@ public void init(PointDataRecord seedItem, int notUsed) {
}

@Override
public PointDataRecord read(int notUsed) {
public PointDataRecord read(MutableInteger notUsed) {

// find median difference for x and y from 3 preceding differences
int median_x;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public LASreadItemCompressed_POINT10_v2(ArithmeticDecoder dec)
}

@Override
public void init(PointDataRecord seedItem, int notUsed)
public void init(PointDataRecord seedItem, MutableInteger notUsed)
{
int i; // unsigned

Expand Down Expand Up @@ -99,7 +99,7 @@ public void init(PointDataRecord seedItem, int notUsed)
}

@Override
public PointDataRecord read(int notUsed)
public PointDataRecord read(MutableInteger notUsed)
{
int r, n, m, l; // unsigned
int k_bits; // unsigned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public LASreadItemCompressed_POINT14_v3(IByteStreamInProvider instreamProvider,
}

@Override
public void init(PointDataRecord seedItem, int notUsed) {
public void init(PointDataRecord seedItem, MutableInteger context) {

ByteStreamIn instream = instreamProvider.getByteStreamIn();

Expand Down Expand Up @@ -404,14 +404,15 @@ public void init(PointDataRecord seedItem, int notUsed) {
/* set scanner channel as current context */

current_context = ((PointDataRecordPoint14)seedItem).getScannerChannel();
context.set(current_context); // the POINT14 reader sets context for all other items

/* create and init models and decompressors */

createAndInitModelsAndDecompressors(current_context, (PointDataRecordPoint14)seedItem);
}

@Override
public PointDataRecord read(int context)
public PointDataRecord read(MutableInteger context)
{
// get last

Expand Down Expand Up @@ -449,6 +450,7 @@ public PointDataRecord read(int context)
}
// switch context to current scanner channel
current_context = scanner_channel;
context.set(current_context); // the POINT14 reader sets context for all other items

// get last for new context
last_item = contexts[current_context].last_item;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public LASreadItemCompressed_RGB12_v1(ArithmeticDecoder dec)
}

@Override
public void init(PointDataRecord seedItem, int notUsed)
public void init(PointDataRecord seedItem, MutableInteger notUsed)
{
/* init state */

Expand All @@ -44,7 +44,7 @@ public void init(PointDataRecord seedItem, int notUsed)
}

@Override
public PointDataRecord read(int notUsed)
public PointDataRecord read(MutableInteger notUsed)
{
PointDataRecordRGB result = new PointDataRecordRGB();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public LASreadItemCompressed_RGB12_v2(ArithmeticDecoder dec)
}

@Override
public void init(PointDataRecord seedItem, int notUsed)
public void init(PointDataRecord seedItem, MutableInteger notUsed)
{
/* init state */

Expand All @@ -60,7 +60,7 @@ public void init(PointDataRecord seedItem, int notUsed)
}

@Override
public PointDataRecord read(int notUsed)
public PointDataRecord read(MutableInteger notUsed)
{
int corr;
int diff = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public LASreadItemCompressed_RGB14_v3(IByteStreamInProvider instreamProvider, in
}

@Override
public void init(PointDataRecord seedItem, int context) {
public void init(PointDataRecord seedItem, MutableInteger context) {

ByteStreamIn instream = instreamProvider.getByteStreamIn();

Expand Down Expand Up @@ -101,7 +101,7 @@ public void init(PointDataRecord seedItem, int context) {
contexts[c].unused = true;
}

current_context = context; // all other items use context set by POINT14 reader
current_context = context.get(); // all other items use context set by POINT14 reader

createAndInitModelsAndDecompressors(current_context, (PointDataRecordRGB)seedItem);
}
Expand All @@ -118,7 +118,7 @@ public boolean chunk_sizes() {
}

@Override
public PointDataRecord read(int context) {
public PointDataRecord read(MutableInteger context) {

PointDataRecordRGB result = new PointDataRecordRGB();

Expand All @@ -127,14 +127,14 @@ public PointDataRecord read(int context) {

// check for context switch

if (current_context != context)
if (current_context != context.get())
{
current_context = context; // all other items use context set by POINT14 reader
current_context = context.get(); // all other items use context set by POINT14 reader
if (contexts[current_context].unused)
{
createAndInitModelsAndDecompressors(current_context, last_item);
last_item = contexts[current_context].last_item;
}
last_item = contexts[current_context].last_item;
}

// decompress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public LASreadItemCompressed_RGBNIR14_v3(IByteStreamInProvider instreamProvider,
}

@Override
public void init(PointDataRecord seedItem, int context) {
public void init(PointDataRecord seedItem, MutableInteger context) {

ByteStreamIn instream = instreamProvider.getByteStreamIn();

Expand Down Expand Up @@ -156,7 +156,7 @@ public void init(PointDataRecord seedItem, int context) {

/* set scanner channel as current context */

current_context = context; // all other items use context set by POINT14 reader
current_context = context.get(); // all other items use context set by POINT14 reader

/* create and init models and decompressors */

Expand All @@ -176,22 +176,22 @@ public boolean chunk_sizes() {
}

@Override
public PointDataRecord read(int context) {
public PointDataRecord read(MutableInteger context) {

// get last

PointDataRecordRgbNIR last_item = contexts[current_context].last_item;

// check for context switch

if (current_context != context)
if (current_context != context.get())
{
current_context = context; // all other items use context set by POINT14 reader
current_context = context.get(); // all other items use context set by POINT14 reader
if (contexts[current_context].unused)
{
createAndInitModelsAndDecompressors(current_context, last_item);
last_item = contexts[current_context].last_item;
}
last_item = contexts[current_context].last_item;
}

// decompress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public LASreadItemCompressed_WAVEPACKET13_v1(ArithmeticDecoder dec)
last_item = null;
}

public void init(PointDataRecord seedItem, int notUsed)
public void init(PointDataRecord seedItem, MutableInteger notUsed)
{
/* init state */
last_diff_32 = 0;
Expand All @@ -66,7 +66,7 @@ public void init(PointDataRecord seedItem, int notUsed)
last_item = new PointDataRecordWavepacket((PointDataRecordWavepacket)seedItem);
}

public PointDataRecord read(int notUsed)
public PointDataRecord read(MutableInteger notUsed)
{
PointDataRecordWavepacket result = new PointDataRecordWavepacket();
result.DescriptorIndex = (short)dec.decodeSymbol(m_packet_index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public LASreadItemCompressed_WAVEPACKET14_v3(IByteStreamInProvider instreamProvi
}

@Override
public void init(PointDataRecord seedItem, int context) {
public void init(PointDataRecord seedItem, MutableInteger context) {

ByteStreamIn instream = instreamProvider.getByteStreamIn();

Expand Down Expand Up @@ -114,7 +114,7 @@ public void init(PointDataRecord seedItem, int context) {

/* set scanner channel as current context */

current_context = context; // all other items use context set by POINT14 reader
current_context = context.get(); // all other items use context set by POINT14 reader

/* create and init models and decompressors */

Expand All @@ -134,21 +134,21 @@ public boolean chunk_sizes() {
}

@Override
public PointDataRecord read(int context) {
public PointDataRecord read(MutableInteger context) {
// get last

PointDataRecordWavepacket last_item = contexts[current_context].last_item;

// check for context switch

if (current_context != context)
if (current_context != context.get())
{
current_context = context; // all other items use context set by POINT14 reader
current_context = context.get(); // all other items use context set by POINT14 reader
if (contexts[current_context].unused)
{
createAndInitModelsAndDecompressors(current_context, last_item);
last_item = contexts[current_context].last_item;
}
last_item = contexts[current_context].last_item;
}

// decompress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public LASreadItemRaw_BYTE(int byteCount) {
}

@Override
public PointDataRecordBytes read(int notUsed) {
public PointDataRecordBytes read(MutableInteger notUsed) {

PointDataRecordBytes result = new PointDataRecordBytes(byteCount);
instream.getBytes(result.Bytes, byteCount);
Expand Down
Loading
Loading