mreutegg / laszip4j

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

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

Closed Aynamic closed 2 weeks ago

Aynamic commented 2 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 2 weeks 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 2 weeks ago

Change is included in laszip4j 0.18 release.