From 6dc071546e2cd7447474391f7f5c8bc8b8aa5c6e Mon Sep 17 00:00:00 2001 From: Grigory Date: Mon, 18 Mar 2024 15:24:11 -0400 Subject: [PATCH] Call initialize in the Pipeline public constructor (#94) * Encapsulate init in the aux constructor * Make pipeline.initialize() private --- README.md | 1 - core/src/main/scala/io/pdal/Pipeline.scala | 11 ++++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 27f89d2..97100de 100644 --- a/README.md +++ b/README.md @@ -152,7 +152,6 @@ String json = var pipeline = new Pipeline(json, LogLevel.Error()); -pipeline.initialize(); // initialize the pipeline pipeline.execute(); // execute the pipeline var metadata = pipeline.getMetadata(); // retrieve metadata diff --git a/core/src/main/scala/io/pdal/Pipeline.scala b/core/src/main/scala/io/pdal/Pipeline.scala index 548e90c..67550ba 100644 --- a/core/src/main/scala/io/pdal/Pipeline.scala +++ b/core/src/main/scala/io/pdal/Pipeline.scala @@ -29,9 +29,11 @@ import com.github.sbt.jni.syntax.NativeLoader class Pipeline private (val json: String, val logLevel: Int) extends Native { Pipeline // reference companion object so nativeLoader loads the JNI native libraries - def this(json: String, logLevel: LogLevel.Value = LogLevel.Error) = this(json, logLevel.id) + def this(json: String, logLevel: LogLevel.Value = LogLevel.Error) = { + this(json, logLevel.id); initialize() + } - @native def initialize(): Unit + @native private def initialize(): Unit @native def execute(): Unit @native def getPointViews(): PointViewIterator @native def close(): Unit @@ -46,7 +48,6 @@ class Pipeline private (val json: String, val logLevel: Int) extends Native { } object Pipeline extends NativeLoader("pdaljni.2.6") { - def apply(json: String, logLevel: LogLevel.Value = LogLevel.Error): Pipeline = { - val p = new Pipeline(json, logLevel); p.initialize(); p - } + def apply(json: String, logLevel: LogLevel.Value = LogLevel.Error): Pipeline = + new Pipeline(json, logLevel) }