Skip to content

Commit

Permalink
use pdal::Polygon
Browse files Browse the repository at this point in the history
  • Loading branch information
hobu committed May 26, 2020
1 parent cb74ff7 commit 4fa6caf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
25 changes: 11 additions & 14 deletions kernels/TIndexKernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

#include <pdal/GDALUtils.hpp>
#include <pdal/PDALUtils.hpp>
#include <pdal/Polygon.hpp>
#include <pdal/StageFactory.hpp>
#include <pdal/util/FileUtils.hpp>

Expand Down Expand Up @@ -320,17 +321,10 @@ void TIndexKernel::mergeFile()

FieldIndexes indexes = getFields();

SpatialRef outSrs(m_tgtSrsString);
if (!outSrs)
throw pdal_error("Couldn't interpret target SRS string.");

if (!m_wkt.empty())
{
Geometry g(m_wkt, outSrs);

if (!g)
throw pdal_error("Couldn't interpret geometry filter string.");
OGR_L_SetSpatialFilter(m_layer, g.get());
pdal::Polygon g(m_wkt, m_tgtSrsString);
OGR_L_SetSpatialFilter(m_layer, g.getOGRHandle());
}

std::vector<FileInfo> files;
Expand Down Expand Up @@ -484,8 +478,8 @@ bool TIndexKernel::createFeature(const FieldIndexes& indexes,
}

// Set the geometry in the feature
Geometry g = prepareGeometry(fileInfo);
OGR_F_SetGeometry(hFeature, g.get());
Polygon g = prepareGeometry(fileInfo);
OGR_F_SetGeometry(hFeature, g.getOGRHandle());

const bool bRet = (OGR_L_CreateFeature(m_layer, hFeature) == OGRERR_NONE);
OGR_F_Destroy(hFeature);
Expand Down Expand Up @@ -683,13 +677,16 @@ TIndexKernel::FieldIndexes TIndexKernel::getFields()
}


gdal::Geometry TIndexKernel::prepareGeometry(const FileInfo& fileInfo)
pdal::Polygon TIndexKernel::prepareGeometry(const FileInfo& fileInfo)
{
using namespace gdal;

Geometry g(fileInfo.m_boundary, fileInfo.m_srs);
Polygon g(fileInfo.m_boundary, fileInfo.m_srs);
if (m_tgtSrsString.size())
g.transform(m_tgtSrsString);
{
SpatialReference out(m_tgtSrsString);
g.transform(out);
}
return g;
}

Expand Down
5 changes: 2 additions & 3 deletions kernels/TIndexKernel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@

namespace pdal
{
class Polygon;

class SrsTransform;
namespace gdal
{
class Geometry;
class SpatialRef;
}

Expand Down Expand Up @@ -90,7 +89,7 @@ class PDAL_DLL TIndexKernel : public SubcommandKernel
bool getFileInfo(StageFactory& factory, const std::string& filename,
FileInfo& info);
bool createFeature(const FieldIndexes& indexes, FileInfo& info);
gdal::Geometry prepareGeometry(const FileInfo& fileInfo);
pdal::Polygon prepareGeometry(const FileInfo& fileInfo);
void createFields();
bool fastBoundary(Stage& reader, FileInfo& fileInfo);
bool slowBoundary(Stage& hexer, FileInfo& fileInfo);
Expand Down

0 comments on commit 4fa6caf

Please sign in to comment.