GEOS  3.6.1
IsValidOp.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2010 Sandro Santilli <strk@keybit.net>
7  * Copyright (C) 2005-2006 Refractions Research Inc.
8  * Copyright (C) 2001-2002 Vivid Solutions Inc.
9  *
10  * This is free software; you can redistribute and/or modify it under
11  * the terms of the GNU Lesser General Public Licence as published
12  * by the Free Software Foundation.
13  * See the COPYING file for more information.
14  *
15  **********************************************************************
16  *
17  * Last port: operation/valid/IsValidOp.java r335 (JTS-1.12)
18  *
19  **********************************************************************/
20 
21 #ifndef GEOS_OP_ISVALIDOP_H
22 #define GEOS_OP_ISVALIDOP_H
23 
24 #include <geos/export.h>
25 
26 #include <geos/operation/valid/TopologyValidationError.h> // for inlined destructor
27 
28 // Forward declarations
29 namespace geos {
30  namespace util {
31  class TopologyValidationError;
32  }
33  namespace geom {
34  class CoordinateSequence;
35  class GeometryFactory;
36  class Geometry;
37  class Point;
38  class LinearRing;
39  class LineString;
40  class Polygon;
41  class GeometryCollection;
42  class MultiPolygon;
43  class MultiLineString;
44  }
45  namespace geomgraph {
46  class DirectedEdge;
47  class EdgeIntersectionList;
48  class PlanarGraph;
49  class GeometryGraph;
50  }
51 }
52 
53 namespace geos {
54 namespace operation { // geos::operation
55 namespace valid { // geos::operation::valid
56 
61 class GEOS_DLL IsValidOp {
62 friend class Unload;
63 private:
65  const geom::Geometry *parentGeometry;
66 
67  bool isChecked;
68 
69  // CHECKME: should this really be a pointer ?
70  TopologyValidationError* validErr;
71 
72  // This is the version using 'isChecked' flag
73  void checkValid();
74 
75  void checkValid(const geom::Geometry *g);
76  void checkValid(const geom::Point *g);
77  void checkValid(const geom::LinearRing *g);
78  void checkValid(const geom::LineString *g);
79  void checkValid(const geom::Polygon *g);
80  void checkValid(const geom::MultiPolygon *g);
81  void checkValid(const geom::GeometryCollection *gc);
82  void checkConsistentArea(geomgraph::GeometryGraph *graph);
83 
84 
93  void checkNoSelfIntersectingRings(geomgraph::GeometryGraph *graph);
94 
101  void checkNoSelfIntersectingRing(
103 
104  void checkTooFewPoints(geomgraph::GeometryGraph *graph);
105 
117  void checkHolesInShell(const geom::Polygon *p,
118  geomgraph::GeometryGraph *graph);
119 
132  void checkHolesNotNested(const geom::Polygon *p,
133  geomgraph::GeometryGraph *graph);
134 
149  void checkShellsNotNested(const geom::MultiPolygon *mp,
150  geomgraph::GeometryGraph *graph);
151 
163  void checkShellNotNested(const geom::LinearRing *shell,
164  const geom::Polygon *p,
165  geomgraph::GeometryGraph *graph);
166 
177  const geom::Coordinate *checkShellInsideHole(
178  const geom::LinearRing *shell,
179  const geom::LinearRing *hole,
180  geomgraph::GeometryGraph *graph);
181 
182  void checkConnectedInteriors(geomgraph::GeometryGraph &graph);
183 
184  void checkInvalidCoordinates(const geom::CoordinateSequence *cs);
185 
186  void checkInvalidCoordinates(const geom::Polygon *poly);
187 
188  void checkClosedRings(const geom::Polygon *poly);
189 
190  void checkClosedRing(const geom::LinearRing *ring);
191 
192  bool isSelfTouchingRingFormingHoleValid;
193 
194 public:
201  static const geom::Coordinate *findPtNotNode(
202  const geom::CoordinateSequence *testCoords,
203  const geom::LinearRing *searchRing,
204  geomgraph::GeometryGraph *graph);
205 
214  static bool isValid(const geom::Coordinate &coord);
215 
222  static bool isValid(const geom::Geometry &geom);
223 
224  IsValidOp(const geom::Geometry *geom)
225  :
226  parentGeometry(geom),
227  isChecked(false),
228  validErr(NULL),
229  isSelfTouchingRingFormingHoleValid(false)
230  {}
231 
233  virtual ~IsValidOp() {
234  delete validErr;
235  }
236 
237  bool isValid();
238 
239  TopologyValidationError* getValidationError();
240 
268  {
269  isSelfTouchingRingFormingHoleValid = isValid;
270  }
271 
272 };
273 
274 } // namespace geos.operation.valid
275 } // namespace geos.operation
276 } // namespace geos
277 
278 #endif // GEOS_OP_ISVALIDOP_H
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Models a collection of Polygons.
Definition: MultiPolygon.h:60
Definition: GeometryGraph.h:73
Implements the algorithsm required to compute the isValid() method for Geometrys. ...
Definition: IsValidOp.h:61
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:167
Definition: EdgeIntersectionList.h:59
virtual ~IsValidOp()
TODO: validErr can&#39;t be a pointer!
Definition: IsValidOp.h:233
Definition: LineString.h:70
Represents a linear polygon, which may include holes.
Definition: Polygon.h:66
Represents a collection of heterogeneous Geometry objects.
Definition: GeometryCollection.h:56
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
Models an OGC SFS LinearRing.
Definition: LinearRing.h:57
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:59
void setSelfTouchingRingFormingHoleValid(bool isValid)
Sets whether polygons using Self-Touching Rings to form holes are reported as valid.
Definition: IsValidOp.h:267
Definition: Point.h:67
Contains information about the nature and location of a Geometry validation error.
Definition: TopologyValidationError.h:40