mreutegg / laszip4j

The LASzip library ported to Java
GNU Lesser General Public License v2.1
35 stars 16 forks source link

There is no RGB in the file, attempting to read the RGB will throw a NullPointerException #131

Closed Aynamic closed 4 months ago

Aynamic commented 6 months ago

If the file has no color, a NullPointerException occurs when trying to read the R G B

        LASReader lasReader = new LASReader(new File("D:\\110.las"));
        CloseablePointIterable closeablePoints = lasReader.getCloseablePoints();
        for (LASPoint lasPoint : closeablePoints) {
            char red = lasPoint.getRed();
        }

图片

mreutegg commented 4 months ago

Thanks for reporting this issue. I updated LASPoint with a method to check for RGB data and throw an IllegalStateException when getRed(), getGreen() or getBlue() is called on a point without RGB data.

See https://github.com/mreutegg/laszip4j/commit/a9ce67eef5170c9b4be02b73875f27e6324a3399

mreutegg commented 4 months ago

Change is included in laszip4j 0.18 release.