GEOS 3.13.1
DBSCANClusterFinder.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2020-2021 Daniel Baston
7 *
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Public Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
12 *
13 **********************************************************************/
14
15#ifndef GEOS_OPERATION_CLUSTER_DBSCANCLUSTERFINDER
16#define GEOS_OPERATION_CLUSTER_DBSCANCLUSTERFINDER
17
18#include <geos/operation/cluster/AbstractClusterFinder.h>
19#include <geos/geom/Geometry.h>
20#include <stdexcept>
21
22namespace geos {
23namespace operation {
24namespace cluster {
25
30public:
31 DBSCANClusterFinder(double eps, size_t minPoints) : m_eps(eps), m_minPoints(minPoints) {}
32
33protected:
34
35 const geom::Envelope& queryEnvelope(const geom::Geometry* a) override {
36 m_envelope = *a->getEnvelopeInternal();
37 m_envelope.expandBy(m_eps);
38 return m_envelope;
39 }
40
41 Clusters process(const std::vector<const geom::Geometry*> & components,
42 index::strtree::TemplateSTRtree<std::size_t> & index,
43 UnionFind & uf) override;
44
45 bool shouldJoin(const geom::Geometry*, const geom::Geometry*) override {
46 throw std::runtime_error("Never get here.");
47 }
48
49private:
50 double m_eps;
51 size_t m_minPoints;
52 geom::Envelope m_envelope;
53};
54
55}
56}
57}
58
59#endif
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
void expandBy(double deltaX, double deltaY)
Expands this envelope by a given distance in all directions. Both positive and negative distances are...
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:197
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 ...
Definition AbstractClusterFinder.h:47
Definition DBSCANClusterFinder.h:29
const geom::Envelope & queryEnvelope(const geom::Geometry *a) override
Definition DBSCANClusterFinder.h:35
bool shouldJoin(const geom::Geometry *, const geom::Geometry *) override
Definition DBSCANClusterFinder.h:45
Clusters process(const std::vector< const geom::Geometry * > &components, index::strtree::TemplateSTRtree< std::size_t > &index, UnionFind &uf) override
Definition UnionFind.h:33
Basic namespace for all GEOS functionalities.
Definition geos.h:39