mreutegg / laszip4j

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

Is it possible to write las file from LasReader.insideRectangle ? #92

Closed AlexandreBrown closed 10 months ago

AlexandreBrown commented 11 months ago

Hello, I am developing a tiling algorithm that needs to read a las/laz using .insideRectangle() from the LASReader and create a tile file from this region.
The following snippet does not work for me and I was wondering if this is expected or not :

val lasReader = LASReader(File(parentTilePath)).insideRectangle(xMin, yMin, xMax, yMax)

val childTileOutputFile = File(outputFolderAbsolutePath, "${UUID.randomUUID()}.laz")

val writer = LASWriter(lasReader)
writer.write(childTileOutputFile)

Stacktrace :


Conversion = 'l'
java.util.UnknownFormatConversionException: Conversion = 'l'
    at java.base/java.util.Formatter$FormatSpecifier.conversion(Formatter.java:2858)
    at java.base/java.util.Formatter$FormatSpecifier.<init>(Formatter.java:2884)
    at java.base/java.util.Formatter.parse(Formatter.java:2729)
    at java.base/java.util.Formatter.format(Formatter.java:2671)
    at java.base/java.io.PrintStream.format(PrintStream.java:1209)
    at java.base/java.io.PrintStream.printf(PrintStream.java:1105)
    at org.gradle.internal.io.LinePerThreadBufferingOutputStream.printf(LinePerThreadBufferingOutputStream.java:148)
    at com.github.mreutegg.laszip4j.clib.Cstdio.fprintf(Cstdio.java:39)
    at com.github.mreutegg.laszip4j.laslib.LASwriterLAS.close(LASwriterLAS.java:389)
    at com.github.mreutegg.laszip4j.laslib.LASwriter.close(LASwriter.java:35)
    at com.github.mreutegg.laszip4j.LASWriter.write(LASWriter.java:56)
    at com.mdai.core.datasources.pointcloud.PointCloudOnDiskDataSource.createChildTile(PointCloudOnDiskDataSource.kt:54)
    at com.mdai.core.datasources.pointcloud.PointCloudOnDiskDataSourceTest$1$1.invokeSuspend(PointCloudOnDiskDataSourceTest.kt:77)
    at com.mdai.core.datasources.pointcloud.PointCloudOnDiskDataSourceTest$1$1.invoke(PointCloudOnDiskDataSourceTest.kt)
    at com.mdai.core.datasources.pointcloud.PointCloudOnDiskDataSourceTest$1$1.invoke(PointCloudOnDiskDataSourceTest.kt)
    at io.kotest.core.spec.style.scopes.FreeSpecContainerScope$invoke$2.invokeSuspend(FreeSpecContainerScope.kt:33)
    at io.kotest.core.spec.style.scopes.FreeSpecContainerScope$invoke$2.invoke(FreeSpecContainerScope.kt)
    at io.kotest.core.spec.style.scopes.FreeSpecContainerScope$invoke$2.invoke(FreeSpecContainerScope.kt)
    at io.kotest.engine.test.TestCaseExecutor$execute$innerExecute$1.invokeSuspend(TestCaseExecutor.kt:83)
    at io.kotest.engine.test.TestCaseExecutor$execute$innerExecute$1.invoke(TestCaseExecutor.kt)
    at io.kotest.engine.test.TestCaseExecutor$execute$innerExecute$1.invoke(TestCaseExecutor.kt)
    at io.kotest.engine.test.interceptors.CoroutineDebugProbeInterceptor.intercept(CoroutineDebugProbeInterceptor.kt:29)
    at io.kotest.engine.test.TestCaseExecutor$execute$3$1.invokeSuspend(TestCaseExecutor.kt:92)
    at io.kotest.engine.test.TestCaseExecutor$execute$3$1.invoke(TestCaseExecutor.kt)
    at io.kotest.engine.test.TestCaseExecutor$execute$3$1.invoke(TestCaseExecutor.kt)
    at io.kotest.engine.test.interceptors.TestDispatcherInterceptor.intercept(TestDispatcherInterceptor.kt:34)
    at io.kotest.engine.test.TestCaseExecutor$execute$3$1.invokeSuspend(TestCaseExecutor.kt:92)
    at io.kotest.engine.test.TestCaseExecutor$execute$3$1.invoke(TestCaseExecutor.kt)
    at io.kotest.engine.test.TestCaseExecutor$execute$3$1.invoke(TestCaseExecutor.kt)
    at io.kotest.engine.test.interceptors.InvocationTimeoutInterceptor$intercept$3.invokeSuspend(InvocationTimeoutInterceptor.kt:43)
    at io.kotest.engine.test.interceptors.InvocationTimeoutInterceptor$intercept$3.invoke(InvocationTimeoutInterceptor.kt)
    at io.kotest.engine.test.interceptors.InvocationTimeoutInterceptor$intercept$3.invoke(InvocationTimeoutInterceptor.kt)
    at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturnIgnoreTimeout(Undispatched.kt:100)
    at kotlinx.coroutines.TimeoutKt.setupTimeout(Timeout.kt:146)
    at kotlinx.coroutines.TimeoutKt.withTimeoutOrNull(Timeout.kt:103)
    at io.kotest.engine.test.interceptors.InvocationTimeoutInterceptor.intercept(InvocationTimeoutInterceptor.kt:42)
    at io.kotest.engine.test.TestCaseExecutor$execute$3$1.invokeSuspend(TestCaseExecutor.kt:92)
    at io.kotest.engine.test.TestCaseExecutor$execute$3$1.invoke(TestCaseExecutor.kt)
    at io.kotest.engine.test.TestCaseExecutor$execute$3$1.invoke(TestCaseExecutor.kt)
    at io.kotest.engine.test.TestInvocationInterceptor$intercept$2$3.invokeSuspend(TestInvocationInterceptor.kt:36)
    at io.kotest.engine.test.TestInvocationInterceptor$intercept$2$3.invoke(TestInvocationInterceptor.kt)
    at io.kotest.engine.test.TestInvocationInterceptor$intercept$2$3.invoke(TestInvocationInterceptor.kt)
    at io.kotest.mpp.ReplayKt.replay(replay.kt:18)
    at io.kotest.engine.test.TestInvocationInterceptor$intercept$2.invokeSuspend(TestInvocationInterceptor.kt:31)
    at io.kotest.engine.test.TestInvocationInterceptor$intercept$2.invoke(TestInvocationInterceptor.kt)
    at io.kotest.engine.test.TestInvocationInterceptor$intercept$2.invoke(TestInvocationInterceptor.kt)
    at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
    at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:264)
    at io.kotest.engine.test.TestInvocationInterceptor.intercept(TestInvocationInterceptor.kt:30)
    at io.kotest.engine.test.TestCaseExecutor$execute$3$1.invokeSuspend(TestCaseExecutor.kt:92)
    at io.kotest.engine.test.TestCaseExecutor$execute$3$1.invoke(TestCaseExecutor.kt)
    at io.kotest.engine.test.TestCaseExecutor$execute$3$1.invoke(TestCaseExecutor.kt)
    at io.kotest.engine.test.interceptors.TimeoutInterceptor.intercept(TimeoutInterceptor.kt:33)
    at io.kotest.engine.test.TestCaseExecutor$execute$3$1.invokeSuspend(TestCaseExecutor.kt:92)
    at io.kotest.engine.test.TestCaseExecutor$execute$3$1.invoke(TestCaseExecutor.kt)
    at io.kotest.engine.test.TestCaseExecutor$execute$3$1.invoke(TestCaseExecutor.kt)

Dummy test laz file : Generated using python laspy.
Download it here

I also tried reading and/or writing a .las file but got the same error.
It only works when I remove .insideRectangle(xMin, yMin, xMax, yMax) but in my case I would need that since I only want the points from the region.
If this is expected behaviour then let me know.

mreutegg commented 10 months ago

Thanks for reporting. This is an unexpected behaviour and an issue in the warn message format.

Fixed it with https://github.com/mreutegg/laszip4j/pull/97