GEOS  3.14.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 #pragma once
16 
17 #include <memory>
18 #include <vector>
19 
20 #include <geos/export.h>
21 #include <geos/index/strtree/TemplateSTRtree.h>
22 #include <geos/operation/cluster/Clusters.h>
23 
24 // Forward declarations
25 namespace geos {
26 namespace geom {
27  class Envelope;
28  class Geometry;
29 }
30 namespace operation {
31 namespace cluster {
32  class UnionFind;
33 }
34 }
35 }
36 
37 namespace geos {
38 namespace operation {
39 namespace cluster {
40 
45 class GEOS_DLL AbstractClusterFinder {
46 
47 public:
54  Clusters cluster(const std::vector<const geom::Geometry*>& g);
55 
65  std::vector<std::unique_ptr<geom::Geometry>> clusterToVector(std::unique_ptr<geom::Geometry> && g);
66 
74  std::vector<std::unique_ptr<geom::Geometry>> clusterToVector(const geom::Geometry& g);
75 
85  std::unique_ptr<geom::Geometry> clusterToCollection(std::unique_ptr<geom::Geometry> && g);
86 
94  std::unique_ptr<geom::Geometry> clusterToCollection(const geom::Geometry & g);
95 
96 protected:
103  virtual bool shouldJoin(const geom::Geometry* a, const geom::Geometry* b) = 0;
104 
111  virtual const geom::Envelope& queryEnvelope(const geom::Geometry* a) = 0;
112 
120  virtual Clusters process(const std::vector<const geom::Geometry*> & components,
121  index::strtree::TemplateSTRtree<std::size_t> & index,
122  UnionFind & uf);
123 
124 private:
125  static std::vector<std::unique_ptr<geom::Geometry>> getComponents(std::unique_ptr<geom::Geometry>&& g);
126 };
127 
128 
129 
130 }
131 }
132 }
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:59
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:197
Definition: AbstractClusterFinder.h:45
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:32
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25