Skip to content

Commit

Permalink
EPT resolution limit.
Browse files Browse the repository at this point in the history
  • Loading branch information
connormanning committed Dec 19, 2018
1 parent 9265296 commit 0807cf9
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 9 deletions.
35 changes: 31 additions & 4 deletions io/EptReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ void EptReader::addArgs(ProgramArgs& args)
args.add("bounds", "Bounds to fetch", m_args.boundsArg());
args.add("origin", "Origin of source file to fetch", m_args.originArg());
args.add("threads", "Number of worker threads", m_args.threadsArg());
args.add("resolution2d", "2D resolution limit", m_args.resolution2dArg());
args.add("resolution3d", "3D resolution limit", m_args.resolution3dArg());
}

BOX3D EptReader::Args::bounds() const
Expand Down Expand Up @@ -161,9 +163,33 @@ void EptReader::initialize()
m_queryBounds = m_args.bounds();
handleOriginQuery();

log()->get(LogLevel::Debug) << "Query bounds: " << m_queryBounds <<
std::endl;
log()->get(LogLevel::Debug) << "Threads: " << m_pool->size() << std::endl;

// Figure out our max depth.
const double querySpacing(m_args.spacing());
if (querySpacing)
{
double spacing = (m_info->bounds().maxx - m_info->bounds().minx) /
m_info->span();

log()->get(LogLevel::Debug) << "Root spacing: " << spacing << std::endl;

m_depthEnd = 1;

while (spacing > querySpacing)
{
spacing /= 2;
++m_depthEnd;
}

log()->get(LogLevel::Debug) <<
"Query spacing: " << querySpacing << "\n" <<
"Actual spacing: " << spacing << "\n" <<
"Depth end: " << m_depthEnd << std::endl;
}

log()->get(LogLevel::Debug) <<
"Query bounds: " << m_queryBounds << "\n"
"Threads: " << m_pool->size() << std::endl;
}

void EptReader::handleOriginQuery()
Expand Down Expand Up @@ -193,7 +219,7 @@ void EptReader::handleOriginQuery()
// Otherwise it's a file path (or part of one - for example selecting
// by a basename or a tile ID rather than a full path is convenient).
// Find it within the sources list, and make sure it's specified
// uniquely enough to select only one filt.
// uniquely enough to select only one file.
for (Json::ArrayIndex i(0); i < sources.size(); ++i)
{
const Json::Value& entry(sources[i]);
Expand Down Expand Up @@ -352,6 +378,7 @@ void EptReader::overlaps()
void EptReader::overlaps(const Json::Value& hier, const Key& key)
{
if (!key.b.overlaps(m_queryBounds)) return;
if (m_depthEnd && key.d >= m_depthEnd) return;
const int64_t np(hier[key.toString()].asInt64());
if (!np) return;

Expand Down
26 changes: 21 additions & 5 deletions io/EptReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,31 @@ class PDAL_DLL EptReader : public Reader
Bounds& boundsArg() { return m_bounds; }
BOX3D bounds() const;

std::string& originArg() { return m_originArg; }
const std::string& origin() const { return m_originArg; }

std::string& originArg() { return m_origin; }
uint64_t& threadsArg() { return m_threads; }
double& resolution2dArg() { return m_resolution2d; }
double& resolution3dArg() { return m_resolution3d; }

std::string origin() const { return m_origin; }
uint64_t threads() const { return std::max<uint64_t>(4, m_threads); }
double spacing() const
{
if (m_resolution2d && m_resolution3d)
throw std::runtime_error(
"Cannot supply both 2D and 3D resolutions");
if (m_resolution2d)
return 1.0 / std::sqrt(m_resolution2d);
if (m_resolution3d)
return 1.0 / std::cbrt(m_resolution3d);
return 0;
}

private:
Bounds m_bounds;
std::string m_originArg;
uint64_t m_threads;
std::string m_origin;
uint64_t m_threads = 0;
double m_resolution2d = 0;
double m_resolution3d = 0;
};

Args m_args;
Expand All @@ -129,6 +144,7 @@ class PDAL_DLL EptReader : public Reader

std::set<Key> m_overlapKeys;
uint64_t m_overlapPoints = 0;
uint64_t m_depthEnd = 0;

std::unique_ptr<FixedPointLayout> m_remoteLayout;
DimTypeList m_dimTypes;
Expand Down
3 changes: 3 additions & 0 deletions io/private/EptSupport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class PDAL_DLL EptInfo
{
m_bounds = toBox3d(m_info["bounds"]);
m_points = m_info["points"].asUInt64();
m_span = m_info["span"].asUInt64();
m_srs = m_info["srs"]["wkt"].asString();

if (m_srs.empty())
Expand Down Expand Up @@ -131,6 +132,7 @@ class PDAL_DLL EptInfo

const BOX3D& bounds() const { return m_bounds; }
uint64_t points() const { return m_points; }
uint64_t span() const { return m_span; }
DataType dataType() const { return m_dataType; }
const std::string& srs() const { return m_srs; }
const Json::Value& schema() const { return m_info["schema"]; }
Expand All @@ -154,6 +156,7 @@ class PDAL_DLL EptInfo
const Json::Value m_info;
BOX3D m_bounds;
uint64_t m_points = 0;
uint64_t m_span = 0;
DataType m_dataType;
std::string m_srs;
};
Expand Down

0 comments on commit 0807cf9

Please sign in to comment.