GeometryIntersectsClusterFinder.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2020-2021 Daniel Baston
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************/
#pragma once
#include <geos/operation/cluster/AbstractClusterFinder.h>
#include <geos/geom/Geometry.h>
#include <geos/geom/prep/PreparedGeometry.h>
#include <geos/geom/prep/PreparedGeometryFactory.h>
namespace geos {
namespace operation {
namespace cluster {
class GEOS_DLL GeometryIntersectsClusterFinder : public AbstractClusterFinder {
protected:
const geom::Envelope& queryEnvelope(const geom::Geometry* a) override {
return *(a->getEnvelopeInternal());
}
bool shouldJoin(const geom::Geometry* a, const geom::Geometry *b) override {
if (m_prep == nullptr || &(m_prep->getGeometry()) != a) {
m_prep = geom::prep::PreparedGeometryFactory::prepare(a);
}
return m_prep->intersects(b);
}
private:
std::unique_ptr<geom::prep::PreparedGeometry> m_prep;
};
}
}
}
geos::geom::Envelope
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
geos::geom::Geometry
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:196
geos::geom::Geometry::getEnvelopeInternal
virtual const Envelope * getEnvelopeInternal() const =0
Returns the minimum and maximum x and y values in this Geometry, or a null Envelope if this Geometry ...
geos::geom::prep::PreparedGeometryFactory::prepare
static std::unique_ptr< PreparedGeometry > prepare(const geom::Geometry *geom)
Definition PreparedGeometryFactory.h:63
geos::operation::cluster::AbstractClusterFinder
Definition AbstractClusterFinder.h:45
geos::operation::cluster::GeometryIntersectsClusterFinder
Definition GeometryIntersectsClusterFinder.h:29
geos::operation::cluster::GeometryIntersectsClusterFinder::shouldJoin
bool shouldJoin(const geom::Geometry *a, const geom::Geometry *b) override
Definition GeometryIntersectsClusterFinder.h:35
geos::operation::cluster::GeometryIntersectsClusterFinder::queryEnvelope
const geom::Envelope & queryEnvelope(const geom::Geometry *a) override
Definition GeometryIntersectsClusterFinder.h:31
geos::operation
Provides classes for implementing operations on geometries.
Definition CleanCoverage.h:34
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38