EnvelopeDistanceClusterFinder.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/Envelope.h>
namespace geos {
namespace operation {
namespace cluster {
class GEOS_DLL EnvelopeDistanceClusterFinder : public AbstractClusterFinder {
public:
explicit EnvelopeDistanceClusterFinder(double d) : m_distance(d), m_distance_squared(d*d) {}
protected:
const geom::Envelope& queryEnvelope(const geom::Geometry* a) override {
m_envelope = *a->getEnvelopeInternal();
m_envelope.expandBy(m_distance);
return m_envelope;
}
bool shouldJoin(const geom::Geometry* a, const geom::Geometry *b) override {
return a->getEnvelopeInternal()->distanceSquared(*b->getEnvelopeInternal()) <= m_distance_squared;
}
private:
geom::Envelope m_envelope;
double m_distance;
double m_distance_squared;
};
}
}
}
geos::geom::Envelope
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
geos::geom::Envelope::distanceSquared
double distanceSquared(const Envelope &env) const
Computes the square of the distance between this and another Envelope.
Definition Envelope.h:717
geos::geom::Envelope::expandBy
void expandBy(double deltaX, double deltaY)
Expands this envelope by a given distance in all directions. Both positive and negative distances are...
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::operation::cluster::AbstractClusterFinder
Definition AbstractClusterFinder.h:45
geos::operation::cluster::EnvelopeDistanceClusterFinder::queryEnvelope
const geom::Envelope & queryEnvelope(const geom::Geometry *a) override
Definition EnvelopeDistanceClusterFinder.h:32
geos::operation::cluster::EnvelopeDistanceClusterFinder::shouldJoin
bool shouldJoin(const geom::Geometry *a, const geom::Geometry *b) override
Definition EnvelopeDistanceClusterFinder.h:38
geos::operation
Provides classes for implementing operations on geometries.
Definition CleanCoverage.h:34
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38