GEOS  3.14.0dev
BasicPreparedGeometry.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2006 Refractions Research Inc.
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  *
16  * Last port: geom/prep/BasicPreparedGeometry.java rev. 1.5 (JTS-1.10)
17  *
18  **********************************************************************/
19 
20 #pragma once
21 
22 #include <geos/geom/prep/PreparedGeometry.h> // for inheritance
23 #include <geos/geom/Coordinate.h>
24 #include <geos/operation/relateng/RelateNG.h>
25 
26 #include <vector>
27 #include <string>
28 
29 namespace geos {
30 namespace geom {
31 class Geometry;
32 class Coordinate;
33 }
34 }
35 
36 
37 namespace geos {
38 namespace geom { // geos::geom
39 namespace prep { // geos::geom::prep
40 
41 // * \class BasicPreparedGeometry
42 
58 
59 private:
60  const geom::Geometry* baseGeom;
61  std::vector<const CoordinateXY*> representativePts;
62  mutable std::unique_ptr<RelateNG> relate_ng;
63 
64  RelateNG& getRelateNG() const
65  {
66  if (relate_ng == nullptr)
67  relate_ng = RelateNG::prepare(baseGeom);
68 
69  return *relate_ng;
70  }
71 
72 protected:
76  void setGeometry(const geom::Geometry* geom);
77 
85  bool envelopesIntersect(const geom::Geometry* g) const;
86 
95  bool envelopeCovers(const geom::Geometry* g) const;
96 
97 public:
98  BasicPreparedGeometry(const Geometry* geom);
99 
100  ~BasicPreparedGeometry() override = default;
101 
102  const geom::Geometry&
103  getGeometry() const override
104  {
105  return *baseGeom;
106  }
107 
115  const std::vector<const CoordinateXY*>*
117  {
118  return &representativePts;
119  }
120 
129  bool isAnyTargetComponentInTest(const geom::Geometry* testGeom) const;
130 
134  bool within(const geom::Geometry* g) const override;
135 
139  bool contains(const geom::Geometry* g) const override;
140 
144  bool containsProperly(const geom::Geometry* g) const override;
145 
149  bool coveredBy(const geom::Geometry* g) const override;
150 
154  bool covers(const geom::Geometry* g) const override;
155 
159  bool crosses(const geom::Geometry* g) const override;
160 
165  bool disjoint(const geom::Geometry* g) const override;
166 
170  bool intersects(const geom::Geometry* g) const override;
171 
175  bool overlaps(const geom::Geometry* g) const override;
176 
180  bool touches(const geom::Geometry* g) const override;
181 
185  std::unique_ptr<IntersectionMatrix> relate(const geom::Geometry* g) const override;
186 
190  bool relate(const geom::Geometry* g, const std::string& pat) const override;
191 
195  std::unique_ptr<geom::CoordinateSequence> nearestPoints(const geom::Geometry* g) const override;
196 
200  double distance(const geom::Geometry* g) const override;
201 
205  bool isWithinDistance(const geom::Geometry* geom, double dist) const override;
206 
207  std::string toString();
208 
209 };
210 
211 } // namespace geos::geom::prep
212 } // namespace geos::geom
213 } // namespace geos
214 
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:197
A base class for PreparedGeometry subclasses.
Definition: BasicPreparedGeometry.h:56
const geom::Geometry & getGeometry() const override
Gets the original Geometry which has been prepared.
Definition: BasicPreparedGeometry.h:103
bool covers(const geom::Geometry *g) const override
bool envelopeCovers(const geom::Geometry *g) const
const std::vector< const CoordinateXY * > * getRepresentativePoints() const
Definition: BasicPreparedGeometry.h:116
bool relate(const geom::Geometry *g, const std::string &pat) const override
bool coveredBy(const geom::Geometry *g) const override
bool isWithinDistance(const geom::Geometry *geom, double dist) const override
bool intersects(const geom::Geometry *g) const override
bool contains(const geom::Geometry *g) const override
double distance(const geom::Geometry *g) const override
bool isAnyTargetComponentInTest(const geom::Geometry *testGeom) const
std::unique_ptr< geom::CoordinateSequence > nearestPoints(const geom::Geometry *g) const override
bool envelopesIntersect(const geom::Geometry *g) const
bool touches(const geom::Geometry *g) const override
bool crosses(const geom::Geometry *g) const override
bool overlaps(const geom::Geometry *g) const override
void setGeometry(const geom::Geometry *geom)
bool within(const geom::Geometry *g) const override
std::unique_ptr< IntersectionMatrix > relate(const geom::Geometry *g) const override
bool disjoint(const geom::Geometry *g) const override
bool containsProperly(const geom::Geometry *g) const override
An interface for classes which prepare Geometrys in order to optimize the performance of repeated cal...
Definition: PreparedGeometry.h:58
Definition: RelateNG.h:86
static std::unique_ptr< RelateNG > prepare(const Geometry *a)
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25