GEOS  3.13.0dev
AbstractClusterFinder.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2020-2022 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_ABSTRACTCLUSTERFINDER
16 #define GEOS_OPERATION_CLUSTER_ABSTRACTCLUSTERFINDER
17 
18 #include <functional>
19 #include <memory>
20 #include <vector>
21 
22 #include <geos/export.h>
23 #include <geos/index/strtree/TemplateSTRtree.h>
24 #include <geos/operation/cluster/Clusters.h>
25 
26 // Forward declarations
27 namespace geos {
28 namespace geom {
29  class Envelope;
30  class Geometry;
31 }
32 namespace operation {
33 namespace cluster {
34  class UnionFind;
35 }
36 }
37 }
38 
39 namespace geos {
40 namespace operation {
41 namespace cluster {
42 
47 class GEOS_DLL AbstractClusterFinder {
48 
49 public:
56  Clusters cluster(const std::vector<const geom::Geometry*>& g);
57 
67  std::vector<std::unique_ptr<geom::Geometry>> clusterToVector(std::unique_ptr<geom::Geometry> && g);
68 
76  std::vector<std::unique_ptr<geom::Geometry>> clusterToVector(const geom::Geometry& g);
77 
87  std::unique_ptr<geom::Geometry> clusterToCollection(std::unique_ptr<geom::Geometry> && g);
88 
96  std::unique_ptr<geom::Geometry> clusterToCollection(const geom::Geometry & g);
97 
98 protected:
105  virtual bool shouldJoin(const geom::Geometry* a, const geom::Geometry* b) = 0;
106 
113  virtual const geom::Envelope& queryEnvelope(const geom::Geometry* a) = 0;
114 
122  virtual Clusters process(const std::vector<const geom::Geometry*> & components,
123  index::strtree::TemplateSTRtree<std::size_t> & index,
124  UnionFind & uf);
125 
126 private:
127  static std::vector<std::unique_ptr<geom::Geometry>> getComponents(std::unique_ptr<geom::Geometry>&& g);
128 };
129 
130 
131 
132 }
133 }
134 }
135 
136 #endif
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:58
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:186
Definition: AbstractClusterFinder.h:47
std::unique_ptr< geom::Geometry > clusterToCollection(const geom::Geometry &g)
virtual Clusters process(const std::vector< const geom::Geometry * > &components, index::strtree::TemplateSTRtree< std::size_t > &index, UnionFind &uf)
virtual bool shouldJoin(const geom::Geometry *a, const geom::Geometry *b)=0
std::vector< std::unique_ptr< geom::Geometry > > clusterToVector(std::unique_ptr< geom::Geometry > &&g)
Clusters cluster(const std::vector< const geom::Geometry * > &g)
std::vector< std::unique_ptr< geom::Geometry > > clusterToVector(const geom::Geometry &g)
std::unique_ptr< geom::Geometry > clusterToCollection(std::unique_ptr< geom::Geometry > &&g)
virtual const geom::Envelope & queryEnvelope(const geom::Geometry *a)=0
Definition: UnionFind.h:33
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25