forked from PDAL/PDAL
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9af6f7a
commit 361ff60
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
cmake_minimum_required(VERSION 3.6) | ||
project(StreamerTutorial) | ||
|
||
find_package(PDAL 2.0.0 REQUIRED CONFIG) | ||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
||
add_executable(streamer_tutorial streamer_tutorial.cpp) | ||
|
||
target_link_libraries(streamer_tutorial PRIVATE ${PDAL_LIBRARIES}) | ||
target_include_directories(streamer_tutorial PRIVATE | ||
${PDAL_INCLUDE_DIRS} | ||
${PDAL_INCLUDE_DIRS}/pdal) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include <pdal/PointView.hpp> | ||
#include <pdal/PointTable.hpp> | ||
#include <pdal/Dimension.hpp> | ||
#include <pdal/Options.hpp> | ||
#include <pdal/StageFactory.hpp> | ||
|
||
#include <io/BufferReader.hpp> | ||
|
||
#include <vector> | ||
|
||
void fillView(pdal::PointViewPtr view) | ||
{ | ||
struct Point | ||
{ | ||
double x; | ||
double y; | ||
double z; | ||
}; | ||
|
||
for (int i = 0; i < 1000; ++i) | ||
{ | ||
Point p; | ||
|
||
p.x = -93.0 + i*0.001; | ||
p.y = 42.0 + i*0.001; | ||
p.z = 106.0 + i; | ||
|
||
view->setField(pdal::Dimension::Id::X, i, p.x); | ||
view->setField(pdal::Dimension::Id::Y, i, p.y); | ||
view->setField(pdal::Dimension::Id::Z, i, p.z); | ||
} | ||
} | ||
|
||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
using namespace pdal; | ||
|
||
Options options; | ||
options.add("filename", "myfile.las"); | ||
|
||
PointTable table; | ||
table.layout()->registerDim(Dimension::Id::X); | ||
table.layout()->registerDim(Dimension::Id::Y); | ||
table.layout()->registerDim(Dimension::Id::Z); | ||
|
||
PointViewPtr view(new PointView(table)); | ||
|
||
fillView(view); | ||
|
||
BufferReader reader; | ||
reader.addView(view); | ||
|
||
StageFactory factory; | ||
|
||
// StageFactory always "owns" stages it creates. They'll be destroyed with the factory. | ||
Stage *writer = factory.createStage("writers.las"); | ||
|
||
writer->setInput(reader); | ||
writer->setOptions(options); | ||
writer->prepare(table); | ||
writer->execute(table); | ||
} |