Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ README.html

*.sublime-workspace

# VSCode files
.vscode

# Test data files #

java/data
Expand Down
2 changes: 2 additions & 0 deletions .sbtopts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
-J-Xss512M
-Djava.awt.headless=true
-Dsun.io.serialization.extendedDebugInfo=true
-Dsbt.color=always
-Dsbt.supershell=false
23 changes: 14 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,29 @@ sudo: false
matrix:
include:
- os: linux
jdk: oraclejdk8
jdk: openjdk8
language: scala
scala:
- 2.11.12
- 2.13.1
before_install:
- docker pull daunnc/pdal-debian:1.8.0
- docker pull daunnc/pdal-debian:2.0.0
services:
- docker

- os: linux
jdk: oraclejdk8
jdk: openjdk8
language: scala
scala:
- 2.12.8
- 2.12.10
before_install:
- docker pull daunnc/pdal-debian:1.8.0
- docker pull daunnc/pdal-debian:2.0.0
services:
- docker

- os: osx
osx_image: xcode9.3
scala:
- 2.11.12
- 2.13.1
compiler:
- gcc
- clang
Expand All @@ -33,8 +34,9 @@ matrix:
- brew install pdal || true # to make travis happy

- os: osx
osx_image: xcode9.3
scala:
- 2.12.8
- 2.12.10
compiler:
- gcc
- clang
Expand All @@ -47,8 +49,11 @@ addons:

cache:
directories:
- $HOME/.ivy2
- $HOME/.m2
- $HOME/.ivy2/cache
- $HOME/.sbt
- $HOME/.cache
- $HOME/.cache/coursier
- $HOME/Library/Caches/Homebrew

script:
Expand Down
2 changes: 1 addition & 1 deletion .travis/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ else
-v $TRAVIS_BUILD_DIR:/pdal-java \
-e TRAVIS_SCALA_VERSION=$TRAVIS_SCALA_VERSION \
-e TRAVIS_COMMIT=$TRAVIS_COMMIT \
-e TRAVIS_JDK_VERSION=$TRAVIS_JDK_VERSION daunnc/pdal-debian:1.8.0 /bin/bash -c "cd /pdal-java; .travis/test-all.sh"
-e TRAVIS_JDK_VERSION=$TRAVIS_JDK_VERSION daunnc/pdal-debian:2.0.0 /bin/bash -c "cd /pdal-java; .travis/test-all.sh"
fi
2 changes: 1 addition & 1 deletion .travis/test-all.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

if [ `echo $TRAVIS_SCALA_VERSION | cut -f1-2 -d "."` = "2.11" ]; then
if [[ `echo $TRAVIS_SCALA_VERSION | cut -f1-2 -d "."` = "2.13" ]]; then
.travis/test.sh;
else
.travis/test-212.sh;
Expand Down
4 changes: 2 additions & 2 deletions .travis/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
./sbt "project core-scala" test || { exit 1; }

cd examples/pdal-jni
./sbt "-211" "runMain com.azavea.Main" || { exit 1; }
./sbt "-211" "runMain com.azavea.MainScala" || { exit 1; }
./sbt "runMain com.azavea.Main" || { exit 1; }
./sbt "runMain com.azavea.MainScala" || { exit 1; }
cd ~-
3 changes: 2 additions & 1 deletion HOWTORELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ Release Process
- Publishing snaphots:
Snapshot can be published without PGP sign, it is published to a snapshot repo and allows immediate snaphot updates.
To publish everything in a local repo use command:
- ./scripts/publish-local.sh (publishes scala 2.11 version)
- ./scripts/publish-local.sh (publishes scala 2.13 version)
- ./scripts/publish-local-212.sh (publishes scala 2.12 version)
- ./scripts/publish-local-211.sh (publishes scala 2.11 version)
- ./scripts/publish-local-native.sh (publishes native dependencies)
To publish everything into sonatype snapshot repo use:
- ./scripts/publish-all.sh
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Build Status](https://api.travis-ci.org/PDAL/java.svg)](http://travis-ci.org/PDAL/java) [![Join the chat at https://gitter.im/PDAL/PDAL](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/PDAL/PDAL?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.pdal/pdal/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.pdal/pdal)

Java bindings to use PDAL on JVM (supports PDAL >= 1.4).
Java bindings to use PDAL on JVM (supports PDAL >= 2.0).
Mac users can experience some issues with bindings that were build against a different PDAL version,
so try to use a consistent PDAL version.

Expand All @@ -18,16 +18,16 @@ resolvers ++= Seq(
)

libraryDependencies ++= Seq(
"io.pdal" %% "pdal" % "1.9.0", // core library
"io.pdal" % "pdal-native" % "1.9.0" // jni bindings
"io.pdal" %% "pdal" % "2.0.0", // core library
"io.pdal" % "pdal-native" % "2.0.0" // jni bindings
)
```

It's required to have native JNI binary in `java.library.path`:

```scala
// Mac OS X example with manual JNI installation
// cp -f native/target/resource_managed/main/native/x86_64-darwin/libpdaljni.1.4.dylib /usr/local/lib/libpdaljni.1.4.dylib
// cp -f native/target/resource_managed/main/native/x86_64-darwin/libpdaljni.2.0.dylib /usr/local/lib/libpdaljni.2.0.dylib
// place built binary into /usr/local/lib, and pass java.library.path to your JVM
javaOptions += "-Djava.library.path=/usr/local/lib"
```
Expand All @@ -41,8 +41,8 @@ Scala API to build pipeline expressions instead of writing a raw JSON.

```scala
libraryDependencies ++= Seq(
"io.pdal" %% "pdal-scala" % "1.9.0", // scala core library
"io.pdal" % "pdal-native" % "1.9.0" // jni bindings
"io.pdal" %% "pdal-scala" % "2.0.0", // scala core library
"io.pdal" % "pdal-native" % "2.0.0" // jni bindings
)
```

Expand Down
28 changes: 14 additions & 14 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name := "pdal-jni"

lazy val commonSettings = Seq(
version := "1.9.1" + Environment.versionSuffix,
scalaVersion := "2.11.12",
crossScalaVersions := Seq("2.12.8", "2.11.12"),
version := "2.0.0" + Environment.versionSuffix,
scalaVersion := "2.13.1",
crossScalaVersions := Seq("2.13.1", "2.12.10", "2.11.12"),
organization := "io.pdal",
description := "PDAL JNI bindings",
licenses := Seq("BSD" -> url("https://github.com/PDAL/PDAL/blob/master/LICENSE.txt")),
Expand All @@ -20,13 +20,13 @@ lazy val commonSettings = Seq(
"-language:existentials",
"-feature"
),
test in assembly := {},
assembly / test := {},
shellPrompt := { s => Project.extract(s).currentProject.id + " > " },
commands ++= Seq(
Commands.processJavastyleCommand("publish"),
Commands.processJavastyleCommand("publishSigned")
),
publishArtifact in Test := false,
Test / publishArtifact := false,
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Expand All @@ -47,8 +47,8 @@ lazy val commonSettings = Seq(
</developer>
</developers>
),
PgpKeys.useGpg in Global := true,
PgpKeys.gpgCommand in Global := "gpg"
Global / PgpKeys.useGpg := true,
Global / PgpKeys.gpgCommand := "gpg"
)

lazy val root = (project in file("."))
Expand All @@ -58,12 +58,12 @@ lazy val root = (project in file("."))
lazy val `core-scala` = project
.settings(commonSettings: _*)
.settings(name := "pdal-scala")
.settings(target in javah := (sourceDirectory in nativeCompile in native).value / "include")
.settings(javah / target := (native / nativeCompile / sourceDirectory).value / "include")
.settings(libraryDependencies ++= Seq(
Dependencies.circeCore,
Dependencies.circeGeneric,
Dependencies.circeGenericExtras,
Dependencies.circeParser,
Dependencies.circe("core").value,
Dependencies.circe("generic").value,
Dependencies.circe("generic-extras").value,
Dependencies.circe("parser").value,
Dependencies.jtsCore,
Dependencies.scalaTest % Test
))
Expand All @@ -74,15 +74,15 @@ lazy val `core-scala` = project
lazy val core = project
.settings(commonSettings: _*)
.settings(name := "pdal")
.settings(target in javah := (sourceDirectory in nativeCompile in native).value / "include")
.settings(javah / target := (native / nativeCompile / sourceDirectory).value / "include")
.settings(libraryDependencies += Dependencies.scalaTest % Test)
.dependsOn(Environment.dependOnNative(native % Runtime): _*)

lazy val native = project
.settings(commonSettings: _*)
.settings(crossPaths := false)
.settings(name := "pdal-native")
.settings(sourceDirectory in nativeCompile := sourceDirectory.value)
.settings(nativeCompile / sourceDirectory := sourceDirectory.value)
.settings(artifactName := { (sv: ScalaVersion, module: ModuleID, artifact: Artifact) =>
artifact.name + "-" + nativePlatform.value + "-" + module.revision + "." + artifact.extension
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ import io.circe._
import io.circe.syntax._
import io.circe.parser._

import org.scalatest._
import org.scalatest.BeforeAndAfterAll
import org.scalatest.funspec.AnyFunSpec
import org.scalatest.matchers.should.Matchers

class PipelineExpressionsSpec extends FunSpec with Matchers with BeforeAndAfterAll {
class PipelineExpressionsSpec extends AnyFunSpec with Matchers with BeforeAndAfterAll {
describe("Pipeline Expressions spec") {
it("should print a correct json, using DSL") {
val expected =
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/io/pdal/Native.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
package io.pdal

trait Native {
protected var nativeHandle = 0l // C++ pointer
protected var nativeHandle = 0L // C++ pointer
def ptr(): Long = nativeHandle
def dispose(): Unit
}
2 changes: 1 addition & 1 deletion core/src/main/scala/io/pdal/Pipeline.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Pipeline(val json: String) extends Native {
@native def getLog(): String
}

@nativeLoader("pdaljni.1.4")
@nativeLoader("pdaljni.2.0")
object Pipeline {
def apply(json: String): Pipeline = { val p = new Pipeline(json); p.initialize(); p }
}
16 changes: 8 additions & 8 deletions core/src/main/scala/io/pdal/PointCloud.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@ package io.pdal
import java.nio.{ByteBuffer, ByteOrder}
import java.util

import scala.collection.JavaConversions._
import scala.collection.JavaConverters._

/**
* PointCloud abstraction to work with packed point(s) in JVM memory.
* SizedDimType contains size and offset for a particular packed point with the current set of dims.
**/
case class PointCloud(bytes: Array[Byte], dimTypes: util.Map[String, SizedDimType]) {
val pointSize: Int = dimTypes.values.map(_.size).sum.toInt
val pointSize: Int = dimTypes.values.asScala.map(_.size).sum.toInt
val length: Int = bytes.length / pointSize
val isPoint: Boolean = length == 1

def dimSize(dim: SizedDimType) = dimTypes(dim.dimType.id).size
def dimSize(dim: DimType) = dimTypes(dim.id).size
def dimSize(dim: String) = dimTypes(dim).size
def findDimType(dim: String) = dimTypes(dim).dimType
def findSizedDimType(dim: String) = dimTypes(dim)
def dimSize(dim: SizedDimType): Long = dimTypes.asScala(dim.dimType.id).size
def dimSize(dim: DimType): Long = dimTypes.asScala(dim.id).size
def dimSize(dim: String): Long = dimTypes.asScala(dim).size
def findDimType(dim: String): DimType = dimTypes.asScala(dim).dimType
def findSizedDimType(dim: String): SizedDimType = dimTypes.asScala(dim)

/**
* Reads a packed point by point id from a set of packed points.
Expand Down Expand Up @@ -114,7 +114,7 @@ case class PointCloud(bytes: Array[Byte], dimTypes: util.Map[String, SizedDimTyp
* Reads dim from a packed point.
*/
def get(packedPoint: Array[Byte], dim: String): Array[Byte] = {
val sdt = dimTypes(dim)
val sdt = dimTypes.asScala(dim)
val from = sdt.offset.toInt
val dimSize = sdt.size.toInt
val result = new Array[Byte](dimSize)
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/scala/io/pdal/PointLayout.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,24 @@
package io.pdal

import java.util
import scala.collection.JavaConversions._
import scala.collection.JavaConverters._

class PointLayout extends Native {
def dimSize(dimType: DimType): Long = dimSize(dimType.id)
def dimPackedOffset(dimType: DimType): Long = dimPackedOffset(dimType.id)

def sizedDimTypes(): util.Map[String, SizedDimType] = toSizedDimTypes(dimTypes())
def toSizedDimTypes(dimTypes: Array[DimType]): util.Map[String, SizedDimType] = {
var (i, offset, length) = (0, 0l, dimTypes.length)
val result = new util.HashMap[String, SizedDimType]()
var (i, offset, length) = (0, 0L, dimTypes.length)
val result = new util.HashMap[String, SizedDimType]().asScala
while(i < length) {
val dt = dimTypes(i)
val size = dimSize(dt)
result += dt.id -> SizedDimType(dt, size, offset)
offset += size
i += 1
}
result
result.asJava
}

@native def dimTypes(): Array[DimType]
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/scala/io/pdal/PipelineSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class PipelineSpec extends TestEnvironmentSpec {
it("should read crs correct") {
val pvi = pipeline.getPointViews()
val pv = pvi.next()
pv.getCrsProj4 should be (proj4String)
pv.getCrsProj4 should (be (proj4String) or be(proj4StringNew))
pv.dispose()
pvi.dispose()
}
Expand Down
6 changes: 3 additions & 3 deletions core/src/test/scala/io/pdal/PointCloudSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ package io.pdal

import java.nio.{ByteBuffer, ByteOrder}

import scala.collection.JavaConversions._
import scala.collection.JavaConverters._

class PointCloudSpec extends TestEnvironmentSpec {
var packedPoints: PointCloud = _
Expand Down Expand Up @@ -116,7 +116,7 @@ class PointCloudSpec extends TestEnvironmentSpec {
it("should read correctly data as a packed point") {
val pvi = pipeline.getPointViews()
val pv = pvi.next()
packedPoints.dimTypes.foreach { case (_, sdt) =>
packedPoints.dimTypes.asScala.foreach { case (_, sdt) =>
pv.get(0, sdt.dimType) should be (packedPoints.get(0, sdt))
}
pv.dispose()
Expand Down Expand Up @@ -162,7 +162,7 @@ class PointCloudSpec extends TestEnvironmentSpec {
val pvi = pipeline.getPointViews()
val pv = pvi.next()
val length = pv.length
val dimTypes = packedPoints.dimTypes.values().map(_.dimType)
val dimTypes = packedPoints.dimTypes.values().asScala.map(_.dimType)
for (i <- 0 until length) {
packedPoints.get(i) should be (pv.getPackedPoint(i))
packedPoints.getX(i) should be (pv.getX(i))
Expand Down
9 changes: 6 additions & 3 deletions core/src/test/scala/io/pdal/TestEnvironmentSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@

package io.pdal

import org.scalatest._
import org.scalatest.BeforeAndAfterAll
import org.scalatest.funspec.AnyFunSpec
import org.scalatest.matchers.should.Matchers

trait TestEnvironmentSpec extends FunSpec with Matchers with BeforeAndAfterAll {
trait TestEnvironmentSpec extends AnyFunSpec with Matchers with BeforeAndAfterAll {
def getJson(resource: String): String = {
val stream = getClass.getResourceAsStream(resource)
val lines = scala.io.Source.fromInputStream(stream).getLines
Expand All @@ -58,7 +60,8 @@ trait TestEnvironmentSpec extends FunSpec with Matchers with BeforeAndAfterAll {
|}
""".stripMargin

val proj4String = "+proj=lcc +lat_1=43 +lat_2=45.5 +lat_0=41.75 +lon_0=-120.5 +x_0=400000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
val proj4String = "+proj=lcc +lat_1=43 +lat_2=45.5 +lat_0=41.75 +lon_0=-120.5 +x_0=400000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
val proj4StringNew = "+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"

val pipeline: Pipeline = Pipeline(json)

Expand Down
Loading