Skip to content

Commit

Permalink
changed loop in esrireader to not use errors. Throw errors on bad lep…
Browse files Browse the repository at this point in the history
…cc decompressions. Removed random if statement in infokernel. Other minor style fixes.
  • Loading branch information
kylemann16 committed Sep 24, 2018
1 parent d83ec04 commit f5ea55b
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 72 deletions.
6 changes: 3 additions & 3 deletions doc/stages/readers.i3s.rst
Expand Up @@ -22,7 +22,7 @@ This example will download the Autzen dataset from the arcgis scene server, repr
``pdal traslate i3s://https://tiles.arcgis.com/tiles/8cv2FuXuWSfF0nbL/arcgis/rest/services/AUTZEN_LiDAR/SceneServer \
autzen.las \
--reprojection filters.reprojection.out_srs=EPSG:3857 \
reprojection --filters.reprojection.out_srs=EPSG:3857 \
--readers.i3s.threads=64 \
--readers.i3s.bounds="([-123.075542,-123.06196],[44.049719,44.06278])"``

Expand All @@ -33,8 +33,8 @@ filename
Exmaple remote file: ``pdal translate i3s://https://tiles.arcgis.com/tiles/8cv2FuXuWSfF0nbL/arcgis/rest/services/AUTZEN_LiDAR/SceneServer autzen.las``

threads
This specifies the number of threads that you would like to use while reading. The default number of threads to buse used is 8. This affects the speed at which files are fetched and added to the PDAL view.
Example: ``--readers.i3s.threads=numThreads``
This specifies the number of threads that you would like to use while reading. The default number of threads to be used is 8. This affects the speed at which files are fetched and added to the PDAL view.
Example: ``--readers.i3s.threads=64``

bounds
The bounds refers to the extents of the resource in X, Y, Z coordinates with the Z dimension being optional. This must be input as a string.
Expand Down
4 changes: 1 addition & 3 deletions kernels/InfoKernel.cpp
Expand Up @@ -277,9 +277,7 @@ MetadataNode InfoKernel::dumpSummary(const QuickInfo& qi)

void InfoKernel::makePipeline(const std::string& filename, bool noPoints)
{
if (filename.find("://") != std::string::npos)
m_log->get(LogLevel::Debug) << "Protocol Found" << std::endl;
else if (!pdal::Utils::fileExists(filename))
if (!pdal::Utils::fileExists(filename))
throw pdal_error("File not found: " + filename);

if (filename == "STDIN")
Expand Down
23 changes: 0 additions & 23 deletions kyle-config.sy

This file was deleted.

4 changes: 2 additions & 2 deletions pdal/StageExtensions.cpp
Expand Up @@ -81,8 +81,8 @@ R"PDALEXTENSIONS(
"readers.mrsid" : "sid",
"readers.rxp" : "rxp",
"readers.fbx" : "fbx",
"readers.i3s" : "i3s",
"readers.slpk" : "slpk"
"readers.slpk" : "slpk",
"readers.i3s" : "i3s"
}
)PDALEXTENSIONS"
Expand Down
8 changes: 3 additions & 5 deletions plugins/i3s/io/EsriReader.cpp
Expand Up @@ -112,16 +112,14 @@ namespace pdal
{
dimData data;
std::string readName = attributes[i]["name"].asString();
int key = std::stoi(attributes[i]["key"].asString());
data.key = key;
data.key = std::stoi(attributes[i]["key"].asString());

if(attributes[i].isMember("valueType"))
{
std::string type = attributes[i]["valueType"].asString();
data.dataType = type;
data.dataType = attributes[i]["valueType"].asString();
}

else if (readName == "RGB")
if (readName == "RGB")
{
layout->registerDim(Dimension::Id::Red);
layout->registerDim(Dimension::Id::Green);
Expand Down
10 changes: 9 additions & 1 deletion plugins/i3s/io/EsriReader.hpp
Expand Up @@ -76,11 +76,19 @@ class EsriReader : public Reader
std::unique_ptr<ILeStream> m_stream;
std::unique_ptr<arbiter::Arbiter> m_arbiter;

struct I3SArgs
{
Bounds bounds;
int threads = 8;
};

I3SArgs m_args;
Json::Value m_info;
std::mutex m_mutex;
BOX3D m_bounds;
int m_nodeCap;
int m_maxNode = 0;


gzip::Decompressor m_decomp;

Expand All @@ -102,7 +110,7 @@ class EsriReader : public Reader
std::string dataType;
};
std::map<Dimension::Id, dimData> m_dimMap;
std::map<std::string, Dimension::Id> m_dimensions {
std::map<std::string, Dimension::Id> const m_dimensions {
{"INTENSITY", Dimension::Id::Intensity},
{"CLASS_CODE", Dimension::Id::ClassFlags},
{"FLAGS", Dimension::Id::Flag},
Expand Down
30 changes: 10 additions & 20 deletions plugins/i3s/io/EsriReceiver.cpp
Expand Up @@ -37,18 +37,15 @@ namespace pdal
{
std::vector<lepcc::Point3D> decompressXYZ(std::vector<char>* compData)
{
unsigned char* c = new unsigned char [compData->size()];

std::copy(compData->begin(), compData->end(), c);

const unsigned char* compressed = c;
int nInfo = lepcc_getBlobInfoSize();
lepcc_ContextHdl ctx(nullptr);
ctx = lepcc_createContext();
lepcc_blobType bt;
lepcc::uint32 blobSize = 0;


const unsigned char* compressed = reinterpret_cast<const unsigned char*>
(compData->data());
lepcc::Byte vec;
lepcc_status stat;
std::vector<lepcc::Point3D> decVec;
Expand All @@ -58,23 +55,22 @@ namespace pdal
(lepcc::ErrCode)lepcc_getBlobInfo(
ctx, compressed, nInfo, &bt, &blobSize);

const lepcc::Byte* pByte = &compressed[0];
const lepcc::Byte* pByte = reinterpret_cast<const lepcc::Byte*>(
compData->data());
int nBytes = (errCode == lepcc::ErrCode::Ok) ? (int)blobSize : -1;
if (nBytes > 0)
{
stat = lepcc_getPointCount(ctx, pByte, nBytes, &xyzPts);
if(stat != (lepcc_status) lepcc::ErrCode::Ok)
{
std::cout << "lepcc_getPointCount() failed. \n";
return decVec;//TODO throw error here
throw (std::string("LEPCC point count fetch failed"));
}
decVec.resize(xyzPts);
stat = lepcc_decodeXYZ(
ctx, &pByte, nBytes, &xyzPts, (double*)(&decVec[0]));
if(stat != (lepcc_status) lepcc::ErrCode::Ok)
{
std::cout << "lepcc_decodeXYZ() failed. \n";
return decVec;//TODO throw error here
throw (std::string("LEPCC decompression failed"));
}
}
return decVec;
Expand Down Expand Up @@ -109,17 +105,14 @@ namespace pdal
stat = lepcc_getRGBCount(ctx, pByte, nBytes, &nPts);
if(stat != (lepcc_status) lepcc::ErrCode::Ok)
{
std::cout << stat << std::endl;
std::cout << "lepcc_getPointRGB() failed. \n";
//TODO throw error here
throw (std::string("RGB point count fetch failed"));
}
rgbVec.resize(nPts);
stat = lepcc_decodeRGB(
ctx, &pByte, nBytes, &nPts, (lepcc::Byte*)(&rgbVec[0]));
if(stat != (lepcc_status) lepcc::ErrCode::Ok)
{
std::cout << "lepcc_decodergb() failed. \n";
return rgbVec;//TODO throw error here
throw (std::string("RGB decompression failed"));
}
}
return rgbVec;
Expand Down Expand Up @@ -154,17 +147,14 @@ namespace pdal
stat = lepcc_getIntensityCount(ctx, pByte, nBytes, &nPts);
if(stat != (lepcc_status) lepcc::ErrCode::Ok)
{
std::cout << stat << std::endl;
std::cout << "lepcc_getPointRGB() failed. \n";
//TODO throw error here
throw (std::string("Intensity point count fetch failed"));
}
intVec.resize(nPts);
stat = lepcc_decodeIntensity(
ctx, &pByte, nBytes, &nPts, (unsigned short*)(&intVec[0]));
if(stat != (lepcc_status) lepcc::ErrCode::Ok)
{
std::cout << "lepcc_decodergb() failed. \n";
return intVec;//TODO throw error here
throw (std::string("Intensity decompression failed"));
}

return intVec;
Expand Down
7 changes: 0 additions & 7 deletions plugins/i3s/io/EsriReceiver.hpp
Expand Up @@ -65,12 +65,6 @@ namespace pdal
return json;
}

struct I3SArgs
{
Bounds bounds;
int threads = 8;
};

struct compare3d
{
bool operator()(const lepcc::Point3D & first,
Expand All @@ -87,7 +81,6 @@ namespace pdal
if(first.z < second.z)
return true;
return false;

}
};

Expand Down
18 changes: 11 additions & 7 deletions plugins/i3s/io/I3SReader.cpp
Expand Up @@ -33,10 +33,6 @@
****************************************************************************/

#include "EsriReader.hpp"
#include "../lepcc/src/include/lepcc_c_api.h"
#include "../lepcc/src/include/lepcc_types.h"
#include "pool.hpp"
#include "SlpkExtractor.hpp"

#include <istream>
#include <cstdint>
Expand All @@ -61,7 +57,7 @@ namespace pdal
{
"readers.i3s",
"I3S Reader",
"http://pdal.io/stages/reader.i3s.html"
"http://pdal.io/stages/readers.i3s.html"
};

CREATE_SHARED_STAGE(I3SReader, i3sInfo)
Expand All @@ -71,6 +67,7 @@ namespace pdal
void I3SReader::initInfo()
{
m_info = parse(m_arbiter->get(m_filename))["layers"][0];

m_filename += "/layers/0";
}

Expand All @@ -87,8 +84,6 @@ namespace pdal
// TODO Avoid doing this by using the max child node to figure out when
// to stop traversing.
nodeIndexJson = parse(m_arbiter->get(nodeUrl));
if (nodeIndexJson.isMember("error"))
return;

int pageSize = nodeIndexJson["nodes"].size();
int initialNode = nodeIndexJson["nodes"][0]["resourceId"].asInt();
Expand All @@ -103,6 +98,15 @@ namespace pdal
{
nodes.push_back(name);
}
//keeps track of largest node so recursive loop knows when to stop
if ((nodeIndexJson["nodes"][i]["firstChild"].asInt() +
cCount - 1) > m_maxNode)
{
m_maxNode = nodeIndexJson["nodes"][i]["firstChild"].asInt() +
cCount - 1;
}
else if (initialNode + i == m_maxNode)
return;
}
buildNodeList(nodes, ++pageIndex);
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/i3s/io/SlpkReader.cpp
Expand Up @@ -61,7 +61,7 @@ namespace pdal
{
"readers.slpk",
"SLPK Reader",
"http://pdal.io/stages/reader.slpk.html"
"http://pdal.io/stages/readers.slpk.html"
};

CREATE_SHARED_STAGE(SlpkReader, slpkInfo)
Expand Down

0 comments on commit f5ea55b

Please sign in to comment.