Skip to content

Commit

Permalink
Move Raster to private space.
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Jun 24, 2020
1 parent dba1484 commit 142897d
Show file tree
Hide file tree
Showing 14 changed files with 1,382 additions and 1,066 deletions.
6 changes: 5 additions & 1 deletion filters/ColorinterpFilter.cpp
Expand Up @@ -38,11 +38,14 @@
#include <pdal/PointView.hpp>
#include <pdal/util/ProgramArgs.hpp>
#include <pdal/util/Utils.hpp>
#include <pdal/private/gdal/Raster.hpp>

#include <array>
#include <algorithm>
#include <cmath>

#include <cpl_vsi.h>

#include "ColorInterpRamps.hpp"

namespace pdal
Expand Down Expand Up @@ -79,9 +82,10 @@ std::string ColorinterpFilter::getName() const { return s_info.name; }
location = name; \
size = sizeof(name); \
rampFilename = "/vsimem/" + std::string(#name) + ".png"; \
auto tmp(VSIFileFromMemBuffer(rampFilename.c_str(), location, size, FALSE)); \
auto tmp(VSIFileFromMemBuffer(rampFilename.c_str(), location, size, false)); \
}
//

std::shared_ptr<gdal::Raster> openRamp(std::string& rampFilename)
{
// If the user selected a default ramp name, it will be opened by
Expand Down
4 changes: 1 addition & 3 deletions filters/ColorizationFilter.cpp
Expand Up @@ -34,9 +34,9 @@

#include "ColorizationFilter.hpp"

#include <pdal/GDALUtils.hpp>
#include <pdal/PointView.hpp>
#include <pdal/util/ProgramArgs.hpp>
#include <pdal/private/gdal/Raster.hpp>

#include <array>

Expand Down Expand Up @@ -141,8 +141,6 @@ void ColorizationFilter::addArgs(ProgramArgs& args)

void ColorizationFilter::initialize()
{
gdal::registerDrivers();

m_raster.reset(new gdal::Raster(m_rasterFilename));
auto bandTypes = m_raster->getPDALDimensionTypes();
m_raster->close();
Expand Down
9 changes: 4 additions & 5 deletions filters/DEMFilter.cpp
Expand Up @@ -37,7 +37,7 @@
#include <string>
#include <vector>

#include <pdal/GDALUtils.hpp>
#include <pdal/private/gdal/Raster.hpp>
#include "private/DimRange.hpp"

namespace pdal
Expand Down Expand Up @@ -88,19 +88,18 @@ void DEMFilter::addArgs(ProgramArgs& args)

void DEMFilter::ready(PointTableRef table)
{
// open GDAL
gdal::registerDrivers();
m_raster.reset(new gdal::Raster(m_args->m_raster));

m_raster->open();
}


void DEMFilter::prepared(PointTableRef table)
{
const PointLayoutPtr layout(table.layout());
m_args->m_dim = layout->findDim(m_args->m_range.m_name);
if (m_args->m_dim == Dimension::Id::Unknown)
throwError("Missing dimension with name '" + m_args->m_range.m_name + "'in input PointView.");
throwError("Missing dimension with name '" + m_args->m_range.m_name +
"'in input PointView.");
if (m_args->m_band <= 0)
throwError("Band must be greater than 0");

Expand Down
3 changes: 1 addition & 2 deletions filters/HagDemFilter.cpp
Expand Up @@ -34,7 +34,7 @@

#include "HagDemFilter.hpp"

#include <pdal/GDALUtils.hpp>
#include <pdal/private/gdal/Raster.hpp>

namespace pdal
{
Expand Down Expand Up @@ -77,7 +77,6 @@ void HagDemFilter::addDimensions(PointLayoutPtr layout)

void HagDemFilter::ready(PointTableRef table)
{
gdal::registerDrivers();
m_raster.reset(new gdal::Raster(m_rasterName));
m_raster->open();
}
Expand Down
4 changes: 1 addition & 3 deletions io/GDALReader.cpp
Expand Up @@ -36,8 +36,8 @@

#include <sstream>

#include <pdal/GDALUtils.hpp>
#include <pdal/PointView.hpp>
#include <pdal/private/gdal/Raster.hpp>

namespace pdal
{
Expand Down Expand Up @@ -72,8 +72,6 @@ GDALReader::~GDALReader()

void GDALReader::initialize()
{
gdal::registerDrivers();

m_raster.reset(new gdal::Raster(m_filename));
if (m_raster->open() == gdal::GDALError::CantOpen)
throwError("Couldn't open raster file '" + m_filename + "'.");
Expand Down
4 changes: 1 addition & 3 deletions io/GDALWriter.cpp
Expand Up @@ -36,8 +36,8 @@
#include <sstream>

#include <pdal/EigenUtils.hpp>
#include <pdal/GDALUtils.hpp>
#include <pdal/PointView.hpp>
#include <pdal/private/gdal/Raster.hpp>

#include "private/GDALGrid.hpp"

Expand Down Expand Up @@ -152,8 +152,6 @@ void GDALWriter::initialize()
// don't expand by point if we're running in standard mode. That's
// set later in writeView.
m_expandByPoint = !m_fixedGrid;

gdal::registerDrivers();
}


Expand Down
7 changes: 2 additions & 5 deletions pdal/EigenUtils.cpp
Expand Up @@ -33,11 +33,11 @@
****************************************************************************/

#include <pdal/EigenUtils.hpp>
#include <pdal/GDALUtils.hpp>
#include <pdal/PointView.hpp>
#include <pdal/SpatialReference.hpp>
#include <pdal/util/Bounds.hpp>
#include <pdal/util/Utils.hpp>
#include <pdal/private/gdal/Raster.hpp>

#include <array>
#include <cfloat>
Expand Down Expand Up @@ -354,10 +354,6 @@ void writeMatrix(Eigen::MatrixXd data, const std::string& filename,
const std::string& driver, double cell_size, BOX2D bounds,
SpatialReference srs)
{
using namespace Eigen;

gdal::registerDrivers();

std::array<double, 6> pixelToPos;
pixelToPos[0] = bounds.minx;
pixelToPos[1] = cell_size;
Expand All @@ -377,6 +373,7 @@ void writeMatrix(Eigen::MatrixXd data, const std::string& filename,
// but GDALUtils expects row major, so we can convert it. Also, double
// doesn't seem to work for some reason, so maybe we go back and make the
// incoming matrix always be a float, but for now just cast it.
using namespace Eigen;
Eigen::Matrix<float, Dynamic, Dynamic, RowMajor> dataRowMajor;
dataRowMajor = data.cast<float>();

Expand Down

0 comments on commit 142897d

Please sign in to comment.