Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scans info file and adds dimensions to pointtable layout
- Loading branch information
1 parent
866cf9c
commit b6bdaef
Showing
9 changed files
with
232 additions
and
5 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
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
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,22 @@ | ||
cd ubuild | ||
|
||
echo CMake.... | ||
|
||
cmake .. \ | ||
-G "Unix Makefiles" \ | ||
-DCMAKE_INSTALL_PREFIX=/home/kylea/Documents/I3S/PDAL/ubuild \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DCMAKE_MAKE_PROGRAM=make \ | ||
-DBUILD_PLUGIN_PYTHON=ON \ | ||
-DBUILD_PLUGIN_GREYHOUND=ON \ | ||
-DBUILD_PLUGIN_SQLITE=ON \ | ||
-DBUILD_PLUGIN_I3S=ON \ | ||
-DWITH_LASZIP=ON \ | ||
-DWITH_LAZPERF=ON \ | ||
-DCMAKE_INSTALL_PREFIX=/usr \ | ||
-DCMAKE_INSTALL_LIBDIR=lib \ | ||
; \ | ||
|
||
echo Make... | ||
|
||
make -j 4 |
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
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
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
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,10 @@ | ||
|
||
PDAL_ADD_PLUGIN(reader_libname reader i3s | ||
FILES | ||
io/i3sReader.cpp | ||
LINK_WITH | ||
${PDAL_JSONCPP_LIB_NAME} | ||
${WINSOCK_LIBRARY} | ||
) | ||
|
||
|
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,135 @@ | ||
// I3SReader.cpp | ||
|
||
#include "i3sReader.hpp" | ||
|
||
#include <pdal/util/ProgramArgs.hpp> | ||
#include <pdal/pdal_features.hpp> | ||
#include <pdal/compression/LazPerfCompression.hpp> | ||
|
||
|
||
namespace pdal | ||
{ | ||
static PluginInfo const s_info | ||
{ | ||
"readers.i3s", | ||
"Read file from i3s server", | ||
"http://why.com/doyouthink/ihave/documentation" | ||
}; | ||
|
||
CREATE_SHARED_STAGE(I3SReader, s_info) | ||
|
||
|
||
|
||
std::string I3SReader::getName() const { return s_info.name; } | ||
|
||
void I3SReader::initialize(PointTableRef table) | ||
{ | ||
|
||
Json::Value config; | ||
if (log()->getLevel() > LogLevel::Debug4) | ||
config["arbiter"]["verbose"] = true; | ||
m_arbiter.reset(new arbiter::Arbiter(config)); | ||
|
||
|
||
if (m_filename.size() && m_args.url.empty()) | ||
{ | ||
m_args.url = m_filename; | ||
const std::string pre("i3s://"); | ||
if (m_args.url.find(pre) == 0) | ||
m_args.url = m_args.url.substr(pre.size()); | ||
if (m_args.url.find("https://") == std::string::npos) | ||
m_args.url = "https://" + m_args.url; | ||
} | ||
|
||
log()->get(LogLevel::Debug) << "Fetching info from " << m_args.url << | ||
std::endl; | ||
|
||
|
||
/*request 3scenelayerinfo: URL Pattern <scene-server-url/layers/<layer-id>*/ | ||
try | ||
{ | ||
m_args.body = parse(m_arbiter->get(m_args.url)); | ||
} | ||
catch (std::exception& e) | ||
{ | ||
throw pdal_error(std::string("Failed to fetch info: ") + e.what()); | ||
} | ||
Json::StreamWriterBuilder writer; | ||
writer.settings_["indentation"] = ""; | ||
m_args.name = Json::writeString(writer, m_args.body["name"]); | ||
m_args.itemId = Json::writeString(writer, m_args.body["serviceItemId"]); | ||
} | ||
|
||
void I3SReader::addArgs(ProgramArgs& args) | ||
{ | ||
args.add("url", "URL", m_args.url); | ||
args.add("body", "JSON formatted body", m_args.body); | ||
args.add("itemId", "ID of the current item", m_args.itemId); | ||
args.add("name", "Name of the point cloud data", m_args.name); | ||
|
||
} | ||
|
||
void I3SReader::addDimensions(PointLayoutPtr layout) | ||
{ | ||
Json::StreamWriterBuilder writer; | ||
writer.settings_["indentation"] = ""; | ||
|
||
//register default values X, Y and Z | ||
layout->registerDim(Dimension::Id::X); | ||
layout->registerDim(Dimension::Id::Y); | ||
layout->registerDim(Dimension::Id::Z); | ||
|
||
|
||
Json::Value attributes = m_args.body["layers"][0]["attributeStorageInfo"]; | ||
for(int i = 0; i < attributes.size(); i ++) | ||
{ | ||
std::string name = Json::writeString(writer, attributes[i]["name"]); | ||
name.erase( | ||
remove( name.begin(), name.end(), '\"' ), | ||
name.end() | ||
); | ||
std::cout << name << "\n"; | ||
std::string type; | ||
|
||
if (attributes[0].isMember("attributeValues")) { | ||
type = Json::writeString(writer, | ||
attributes["attributeValues"]["valueType"]); | ||
layout->registerOrAssignDim(name, pdal::Dimension::type(type)); | ||
} | ||
else | ||
layout->registerOrAssignDim(name, Dimension::Type::Double); | ||
} | ||
} | ||
|
||
void I3SReader::ready(PointTableRef) | ||
{ | ||
|
||
SpatialReference ref("EPSG:4385"); | ||
setSpatialReference(ref); | ||
} | ||
|
||
|
||
|
||
point_count_t I3SReader::read(PointViewPtr view, point_count_t count) | ||
{ | ||
/*request 3scenelayerinfo: URL Pattern <scene-server-url/layers/<layer-id>*/ | ||
//node index document: <layer-url >/nodes/<node-id> | ||
//shared resources: <node-url>/shared/ | ||
//feature data: <node-url>/features/<feature-data-bundle-id> | ||
//geometry data: <node-url>/geometries/<geometry-data-bundle-id> | ||
//texture data: <node-url>/textures/<texture-data-bundle-id> | ||
|
||
view->setField(pdal::Dimension::Id::X, 0, 12); | ||
view->setField(pdal::Dimension::Id::Y, 0, 13); | ||
view->setField(pdal::Dimension::Id::Z, 0, 14); | ||
view->setField(pdal::Dimension::Id::INTENSITY, 0, 55); | ||
|
||
return 0; | ||
} | ||
|
||
void I3SReader::done(PointTableRef) | ||
{ | ||
m_stream.reset(); | ||
} | ||
|
||
} //namespace 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,48 @@ | ||
// I3SReader.hpp | ||
|
||
#pragma once | ||
|
||
#include <pdal/PointView.hpp> | ||
#include <pdal/Reader.hpp> | ||
#include <pdal/util/IStream.hpp> | ||
#include "i3sReceiver.hpp" | ||
|
||
|
||
#include <functional> | ||
#include <queue> | ||
#include <vector> | ||
|
||
#include <json/json.h> | ||
|
||
#include <arbiter/arbiter.hpp> | ||
|
||
#include <pdal/StageFactory.hpp> | ||
|
||
|
||
namespace pdal | ||
{ | ||
class I3SReader : public Reader | ||
{ | ||
public: | ||
I3SReader() : Reader() {}; | ||
std::string getName() const; | ||
|
||
private: | ||
std::unique_ptr<ILeStream> m_stream; | ||
point_count_t m_index; | ||
double m_scale_z; | ||
std::unique_ptr<arbiter::Arbiter> m_arbiter; | ||
|
||
I3SArgs m_args; | ||
Json::Value m_info; | ||
|
||
virtual void addArgs(ProgramArgs& args); | ||
virtual void initialize(PointTableRef table) override; | ||
virtual void addDimensions(PointLayoutPtr layout); | ||
virtual void ready(PointTableRef table); | ||
virtual point_count_t read(PointViewPtr view, point_count_t count); | ||
virtual void done(PointTableRef table); | ||
|
||
|
||
}; | ||
} |