Skip to content

Commit 5b00174

Browse files
authored
Update README.md adding java example (#75)
1 parent e9ce951 commit 5b00174

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,50 @@ val pc = ReadLas("/path/to/las") ~ FilterCrop() ~ WriteLas("/path/to/new/las")
8282
// RawExpr accepts a circe.Json type, which can be a json object of any desired complexity
8383
val pcWithRawExpr = ReadLas("/path/to/las") ~ RawExpr(Map("type" -> "filters.crop").asJson) ~ WriteLas("/path/to/new/las")
8484
```
85+
## Use PDAL inside a JAVA environment
86+
This is an example about how to use pdal inside a pure java environment.
87+
88+
```java
89+
// Create the expected json String
90+
String expectedJSON =
91+
"""
92+
|{
93+
| "pipeline" : [
94+
| {
95+
| "filename" : "/path/to/las",
96+
| "type" : "readers.las"
97+
| },
98+
| {
99+
| "type" : "filters.crop"
100+
| },
101+
| {
102+
| "filename" : "/path/to/new/las",
103+
| "type" : "writers.las"
104+
| }
105+
| ]
106+
|}
107+
"""
108+
// Decide the verbosity of your output
109+
int logLevel = 0;
110+
111+
// Initialine a Pipeline object
112+
// Be careful, before version v2.5.0 the constructor was 'new Pipeline(String jsonString)'
113+
Pipeline pipeline = new Pipeline(json,3);
114+
115+
// Initialize the pipeline
116+
pipeline.initialize();
117+
118+
// Execute the pipeline
119+
pipeline.execute();
120+
121+
// Now you can for example extract a PointViewIterator
122+
PointViewIterator pvs = pipeline.getPointViews();
123+
// And a single PointView..
124+
PointView pv = pvs.next();
125+
// Now remember to close the pipeline to avoid a leak of resources
126+
pvs.close();
127+
pipeline.close();
128+
```
85129
86130
### Demo project example
87131

0 commit comments

Comments
 (0)