GEOS 3.13.1
GeometryIntersectsClusterFinder.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_GEOMETRYINTERSECTSCLUSTERFINDER
16#define GEOS_OPERATION_CLUSTER_GEOMETRYINTERSECTSCLUSTERFINDER
17
18#include <geos/operation/cluster/AbstractClusterFinder.h>
19#include <geos/geom/Geometry.h>
20#include <geos/geom/prep/PreparedGeometry.h>
21#include <geos/geom/prep/PreparedGeometryFactory.h>
22
23namespace geos {
24namespace operation {
25namespace cluster {
26
31protected:
32 const geom::Envelope& queryEnvelope(const geom::Geometry* a) override {
33 return *(a->getEnvelopeInternal());
34 }
35
36 bool shouldJoin(const geom::Geometry* a, const geom::Geometry *b) override {
37 if (m_prep == nullptr || &(m_prep->getGeometry()) != a) {
38 m_prep = geom::prep::PreparedGeometryFactory::prepare(a);
39 }
40
41 return m_prep->intersects(b);
42 }
43
44private:
45 std::unique_ptr<geom::prep::PreparedGeometry> m_prep;
46};
47
48
49}
50}
51}
52
53#endif
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
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 GeometryIntersectsClusterFinder.h:30
bool shouldJoin(const geom::Geometry *a, const geom::Geometry *b) override
Definition GeometryIntersectsClusterFinder.h:36
const geom::Envelope & queryEnvelope(const geom::Geometry *a) override
Definition GeometryIntersectsClusterFinder.h:32
Basic namespace for all GEOS functionalities.
Definition geos.h:39