Skip to content

Commit

Permalink
Merge branch 'PDAL:master' into hexbin-h3filter
Browse files Browse the repository at this point in the history
  • Loading branch information
ibell13 authored Oct 2, 2024
2 parents 9f5094f + 9cfd7f6 commit d37312e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

- uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-variant: Miniforge3
miniforge-version: latest
use-mamba: true
auto-update-conda: true
Expand Down
33 changes: 21 additions & 12 deletions filters/GeomDistanceFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ void GeomDistanceFilter::addDimensions(PointLayoutPtr layout)
Dimension::Type::Double);
}

void GeomDistanceFilter::initialize()
{
gdal::registerDrivers();
}

void GeomDistanceFilter::addArgs(ProgramArgs& args)
{
Expand All @@ -96,18 +100,6 @@ void GeomDistanceFilter::addArgs(ProgramArgs& args)
args.add("ring", "Compare edges (demote polygons to linearrings)", m_args->m_doRingMode, false);
args.add("ogr", "OGR filter geometries", m_args->m_ogr);

if (!m_args->m_ogr.is_null())
{
std::vector<Polygon> polys = gdal::getPolygons(m_args->m_ogr);
if (!polys.size())
throwError("No polygons were selected from 'ogr'!");
m_args->m_geometry = polys[0];
// log()->get(LogLevel::Debug) << "First polygon selected from 'ogr' data" << std::endl;

}

if (m_args->m_doRingMode)
m_args->m_geometry = m_args->m_geometry.getRing();

}

Expand All @@ -122,6 +114,23 @@ void GeomDistanceFilter::prepared(PointTableRef table)

}

void GeomDistanceFilter::ready(PointTableRef table)
{
if (!m_args->m_ogr.is_null())
{
std::vector<Polygon> polys = gdal::getPolygons(m_args->m_ogr);
if (!polys.size())
throwError("No polygons were selected from 'ogr'!");
m_args->m_geometry = polys[0];
}

if (m_args->m_doRingMode)
m_args->m_geometry = m_args->m_geometry.getRing();

if (!m_args->m_geometry.getOGRHandle())
throwError("Candidate polygon in filters.geomdistance was NULL!");
}


void GeomDistanceFilter::filter(PointView& view)
{
Expand Down
2 changes: 2 additions & 0 deletions filters/GeomDistanceFilter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class PDAL_DLL GeomDistanceFilter : public Filter, public Streamable
virtual void filter(PointView& view) override;
virtual void addDimensions(PointLayoutPtr layout) override;
virtual void prepared(PointTableRef table) override;
virtual void initialize() override;
virtual void ready(PointTableRef table) override;
virtual bool processOne(PointRef& point) override;

GeomDistanceFilter& operator=(const GeomDistanceFilter&) = delete;
Expand Down
3 changes: 3 additions & 0 deletions pdal/Geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ BOX3D Geometry::bounds() const
double Geometry::distance(double x, double y, double z) const
{
OGRPoint p(x, y, z);
throwNoGeos();
if(!m_geom)
throw pdal_error("Cannot compare distance of null geometry!");
return m_geom->Distance((OGRGeometry*)&p);
}

Expand Down

0 comments on commit d37312e

Please sign in to comment.