Skip to content

Commit

Permalink
Update README.md adding java example
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiteSte authored Jan 18, 2024
1 parent e9ce951 commit 65ad2fa
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,50 @@ val pc = ReadLas("/path/to/las") ~ FilterCrop() ~ WriteLas("/path/to/new/las")
// RawExpr accepts a circe.Json type, which can be a json object of any desired complexity
val pcWithRawExpr = ReadLas("/path/to/las") ~ RawExpr(Map("type" -> "filters.crop").asJson) ~ WriteLas("/path/to/new/las")
```
## Use PDAL inside a JAVA environment
This is an example about how to use pdal inside a pure java environment.

```java
// Create the expected json String
String expectedJSON =
"""
|{
| "pipeline" : [
| {
| "filename" : "/path/to/las",
| "type" : "readers.las"
| },
| {
| "type" : "filters.crop"
| },
| {
| "filename" : "/path/to/new/las",
| "type" : "writers.las"
| }
| ]
|}
"""
// Decide the verbosity of your output
int logLevel = 0;
// Initialine a Pipeline object
// Be careful, before version v2.5.0 the constructor was 'new Pipeline(String jsonString)'
Pipeline pipeline = new Pipeline(json,3);
// Initialize the pipeline
pipeline.initialize();
// Execute the pipeline
pipeline.execute();
// Now you can for example extract a PointViewIterator
PointViewIterator pvs = pipeline.getPointViews();
// And a single PointView..
PointView pv = pvs.next();
// Now remember to close the pipeline to avoid a leak of resources
pvs.close();
pipeline.close();
```
### Demo project example
Expand Down

0 comments on commit 65ad2fa

Please sign in to comment.