DBSCANClusterFinder.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 <stdexcept>
namespace geos {
namespace operation {
namespace cluster {
class GEOS_DLL DBSCANClusterFinder : public AbstractClusterFinder {
public:
DBSCANClusterFinder(double eps, size_t minPoints) : m_eps(eps), m_minPoints(minPoints) {}
protected:
const geom::Envelope& queryEnvelope(const geom::Geometry* a) override {
m_envelope = *a->getEnvelopeInternal();
m_envelope.expandBy(m_eps);
return m_envelope;
}
Clusters process(const std::vector<const geom::Geometry*> & components,
index::strtree::TemplateSTRtree<std::size_t> & index,
UnionFind & uf) override;
bool shouldJoin(const geom::Geometry*, const geom::Geometry*) override {
throw std::runtime_error("Never get here.");
}
private:
double m_eps;
size_t m_minPoints;
geom::Envelope m_envelope;
};
}
}
}
geos::geom::Envelope
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
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::DBSCANClusterFinder::queryEnvelope
const geom::Envelope & queryEnvelope(const geom::Geometry *a) override
Definition DBSCANClusterFinder.h:34
geos::operation::cluster::DBSCANClusterFinder::shouldJoin
bool shouldJoin(const geom::Geometry *, const geom::Geometry *) override
Definition DBSCANClusterFinder.h:44
geos::operation::cluster::DBSCANClusterFinder::process
Clusters process(const std::vector< const geom::Geometry * > &components, index::strtree::TemplateSTRtree< std::size_t > &index, UnionFind &uf) override
geos::operation::cluster::UnionFind
Definition UnionFind.h:32
geos::index
Provides classes for various kinds of spatial indexes.
Definition CleanCoverage.h:39
geos::operation
Provides classes for implementing operations on geometries.
Definition CleanCoverage.h:34
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38