Skip to content

Commit fda26ce

Browse files
authored
PDAL 2.5.1 (#65)
* PDAL 2.5.x upd * Refactor JavaPipeline * Improve tests * javah re-reun * Make core more java compatible * CHANGELOG.md rotate
1 parent 0bc459b commit fda26ce

25 files changed

+555
-201
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
matrix:
1616
os: [ubuntu-latest]
17-
image: ['daunnc/pdal-ubuntu:2.4.3']
17+
image: ['daunnc/pdal-ubuntu:2.5.1']
1818
runs-on: ${{ matrix.os }}
1919
container:
2020
image: ${{ matrix.image }}
@@ -43,7 +43,7 @@ jobs:
4343
os: [macos-latest]
4444
java: [8]
4545
distribution: [temurin]
46-
pdal: [2.4.3]
46+
pdal: [2.5.0]
4747
runs-on: ${{ matrix.os }}
4848

4949
steps:
@@ -69,9 +69,7 @@ jobs:
6969
brew extract --version=${{ matrix.pdal }} pdal $USER/local-pdal
7070
7171
- name: Install PDAL
72-
run: |
73-
brew update
74-
brew install pdal@${{ matrix.pdal }} || true
72+
run: brew install pdal@${{ matrix.pdal }} || true
7573

7674
- name: Check formatting
7775
run: sbt scalafmtCheckAll
@@ -88,7 +86,7 @@ jobs:
8886
strategy:
8987
matrix:
9088
os: [ubuntu-latest]
91-
image: ['daunnc/pdal-ubuntu:2.4.3']
89+
image: ['daunnc/pdal-ubuntu:2.5.1']
9290
runs-on: ${{ matrix.os }}
9391
needs: [linux, macos]
9492
container:

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
## Added
9+
* PDAL 2.5.1 [#65](https://github.com/pdal/java/pull/65) (@pomadchin)
810

911
## [2.4.0] - 2021-08-01
1012
## Added

build.sbt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name := "pdal-jni"
22

33
val scala212 = "2.12.17"
44
val scala213 = "2.13.10"
5-
val scala3 = "3.2.1"
5+
val scala3 = "3.2.2"
66
val scalaVersions = Seq(scala3, scala213, scala212)
77

88
lazy val commonSettings = Seq(
@@ -71,7 +71,10 @@ lazy val core = project
7171
.settings(name := "pdal")
7272
.settings(javah / target := (native / nativeCompile / sourceDirectory).value / "include")
7373
.settings(sbtJniCoreScope := Compile)
74-
.settings(libraryDependencies += Dependencies.scalaTest % Test)
74+
.settings(libraryDependencies ++= Seq(
75+
Dependencies.scalaTest % Test,
76+
Dependencies.circe("parser") % Test
77+
))
7578
.dependsOn(Environment.dependOnNative(native % Runtime): _*)
7679

7780
lazy val native = project
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* **************************************************************************** Copyright (c) 2016, hobu Inc.
3+
4+
*
5+
* All rights reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
8+
* following conditions are met:
9+
*
10+
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the following
11+
* disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
12+
* the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the
13+
* name of Hobu, Inc. nor the names of its contributors may be used to endorse or promote products derived from this
14+
* software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
17+
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23+
*/
24+
25+
package io.pdal
26+
27+
object LogLevel {
28+
val Error = 0
29+
val Warning = 1
30+
val Info = 2
31+
val Debug = 3
32+
val Debug1 = 4
33+
val Debug2 = 5
34+
val Debug3 = 6
35+
val Debug4 = 7
36+
val Debug5 = 8
37+
val None = 9
38+
}

core/src/main/scala/io/pdal/Pipeline.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ package io.pdal
2626

2727
import com.github.sbt.jni.syntax.NativeLoader
2828

29-
class Pipeline(val json: String) extends Native {
29+
class Pipeline(val json: String, val logLevel: Int) extends Native {
3030
Pipeline // reference the object so that the nativeLoader will load the JNI native libraries
3131

3232
@native def initialize(): Unit
3333
@native def execute(): Unit
3434
@native def getPointViews(): PointViewIterator
3535
@native def close(): Unit
36+
@native def getSrsWKT2(): String
37+
@native def getPipeline(): String
3638
@native def getMetadata(): String
3739
@native def getSchema(): String
3840
@native def validate(): Boolean
@@ -41,6 +43,8 @@ class Pipeline(val json: String) extends Native {
4143
@native def getLog(): String
4244
}
4345

44-
object Pipeline extends NativeLoader("pdaljni.2.4") {
45-
def apply(json: String): Pipeline = { val p = new Pipeline(json); p.initialize(); p }
46+
object Pipeline extends NativeLoader("pdaljni.2.5") {
47+
def apply(json: String, logLevel: Int = LogLevel.Error): Pipeline = {
48+
val p = new Pipeline(json, logLevel); p.initialize(); p
49+
}
4650
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"pipeline": [
3+
{
4+
"filename": "core/src/test/resources/1.2-with-color.las",
5+
"spatialreference": "EPSG:2993",
6+
"tag": "readers_las1",
7+
"type": "readers.las"
8+
}
9+
]
10+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"metadata": {
3+
"readers.las": [
4+
{
5+
"compressed": false,
6+
"copc": false,
7+
"count": 1065,
8+
"creation_doy": 0,
9+
"creation_year": 0,
10+
"dataformat_id": 3,
11+
"dataoffset": 229,
12+
"filesource_id": 0,
13+
"global_encoding": 0,
14+
"global_encoding_base64": "AAA=",
15+
"header_size": 227,
16+
"major_version": 1,
17+
"maxx": 638982.55,
18+
"maxy": 853535.43,
19+
"maxz": 586.38,
20+
"minor_version": 2,
21+
"minx": 635619.85,
22+
"miny": 848899.7,
23+
"minz": 406.59,
24+
"offset_x": 0,
25+
"offset_y": 0,
26+
"offset_z": 0,
27+
"point_length": 34,
28+
"project_id": "00000000-0000-0000-0000-000000000000",
29+
"scale_x": 0.01,
30+
"scale_y": 0.01,
31+
"scale_z": 0.01,
32+
"software_id": "TerraScan",
33+
"system_id": ""
34+
}
35+
]
36+
}
37+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{
2+
"schema":
3+
{
4+
"dimensions":
5+
[
6+
{
7+
"name": "X",
8+
"size": 8,
9+
"type": "floating"
10+
},
11+
{
12+
"name": "Y",
13+
"size": 8,
14+
"type": "floating"
15+
},
16+
{
17+
"name": "Z",
18+
"size": 8,
19+
"type": "floating"
20+
},
21+
{
22+
"name": "Intensity",
23+
"size": 2,
24+
"type": "unsigned"
25+
},
26+
{
27+
"name": "ReturnNumber",
28+
"size": 1,
29+
"type": "unsigned"
30+
},
31+
{
32+
"name": "NumberOfReturns",
33+
"size": 1,
34+
"type": "unsigned"
35+
},
36+
{
37+
"name": "ScanDirectionFlag",
38+
"size": 1,
39+
"type": "unsigned"
40+
},
41+
{
42+
"name": "EdgeOfFlightLine",
43+
"size": 1,
44+
"type": "unsigned"
45+
},
46+
{
47+
"name": "Classification",
48+
"size": 1,
49+
"type": "unsigned"
50+
},
51+
{
52+
"name": "ScanAngleRank",
53+
"size": 4,
54+
"type": "floating"
55+
},
56+
{
57+
"name": "UserData",
58+
"size": 1,
59+
"type": "unsigned"
60+
},
61+
{
62+
"name": "PointSourceId",
63+
"size": 2,
64+
"type": "unsigned"
65+
},
66+
{
67+
"name": "GpsTime",
68+
"size": 8,
69+
"type": "floating"
70+
},
71+
{
72+
"name": "Red",
73+
"size": 2,
74+
"type": "unsigned"
75+
},
76+
{
77+
"name": "Green",
78+
"size": 2,
79+
"type": "unsigned"
80+
},
81+
{
82+
"name": "Blue",
83+
"size": 2,
84+
"type": "unsigned"
85+
}
86+
]
87+
}
88+
}

core/src/test/scala/io/pdal/PipelineSpec.scala

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
package io.pdal
2626

27+
import io.circe.parser
2728
import java.nio.{ByteBuffer, ByteOrder}
2829

2930
import scala.collection.JavaConverters._
@@ -34,7 +35,7 @@ class PipelineSpec extends TestEnvironmentSpec {
3435
val badPipeline = Pipeline(badJson)
3536
badPipeline.validate() should be(false)
3637
badPipeline.close()
37-
(badPipeline.ptr() should be(0))
38+
badPipeline.ptr() should be(0)
3839
}
3940

4041
it("should validate json") {
@@ -160,23 +161,29 @@ class PipelineSpec extends TestEnvironmentSpec {
160161
it("should read crs correct") {
161162
val pvi = pipeline.getPointViews()
162163
val pv = pvi.next()
163-
pv.getCrsProj4() should (be(proj4String).or(be(proj4StringMac)))
164+
pv.getCrsProj4() should be(proj4String).or(be(proj4StringMac))
164165
pv.close()
165166
pvi.close()
166167
}
167168

168-
it("should fail with InitializationException") {
169+
it("should fail with InitializationException when the input json is null") {
169170
intercept[InitializationException] { Pipeline(null) }
170171
}
171172

172-
it("should fail with ExecutionException") {
173-
val pipeline = Pipeline("{")
174-
intercept[ExecutionException] { pipeline.execute() }
175-
intercept[ExecutionException] { pipeline.getPointViews() }
176-
intercept[ExecutionException] { pipeline.getMetadata() }
177-
intercept[ExecutionException] { pipeline.getSchema() }
173+
it("should fail with ExecutionException when the input json is invalid") {
174+
intercept[InitializationException] { Pipeline("{") }
175+
}
176+
177+
it("should get pipeline") {
178+
parser.parse(pipeline.getPipeline()) shouldBe jsonExpectedJson
179+
}
180+
181+
it("should get schema") {
182+
parser.parse(pipeline.getSchema()) shouldBe schemaJson
183+
}
178184

179-
pipeline.close()
185+
it("should get metadata") {
186+
parser.parse(pipeline.getMetadata()) shouldBe metadataJson
180187
}
181188

182189
it("should extract mesh in iterative fashion") {

core/src/test/scala/io/pdal/TestEnvironmentSpec.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
package io.pdal
2626

27+
import io.circe.{parser, Json, ParsingFailure}
2728
import org.scalatest.BeforeAndAfterAll
2829
import org.scalatest.funspec.AnyFunSpec
2930
import org.scalatest.matchers.should.Matchers
@@ -52,6 +53,10 @@ trait TestEnvironmentSpec extends AnyFunSpec with Matchers with BeforeAndAfterAl
5253
|}
5354
""".stripMargin
5455

56+
val jsonExpectedJson: Either[ParsingFailure, Json] = parser.parse(getJson("/las-expected.json"))
57+
val schemaJson: Either[ParsingFailure, Json] = parser.parse(getJson("/schema.json"))
58+
val metadataJson: Either[ParsingFailure, Json] = parser.parse(getJson("/metadata.json"))
59+
5560
val proj4String =
5661
"+proj=lcc +lat_0=41.75 +lon_0=-120.5 +lat_1=43 +lat_2=45.5 +x_0=400000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
5762
val proj4StringMac =

0 commit comments

Comments
 (0)