GEOS  3.3.3
IsValidOp.h
1 /**********************************************************************
2  * $Id: IsValidOp.h 3258 2011-03-02 13:13:50Z strk $
3  *
4  * GEOS - Geometry Engine Open Source
5  * http://geos.refractions.net
6  *
7  * Copyright (C) 2010 Sandro Santilli <strk@keybit.net>
8  * Copyright (C) 2005-2006 Refractions Research Inc.
9  * Copyright (C) 2001-2002 Vivid Solutions Inc.
10  *
11  * This is free software; you can redistribute and/or modify it under
12  * the terms of the GNU Lesser General Public Licence as published
13  * by the Free Software Foundation.
14  * See the COPYING file for more information.
15  *
16  **********************************************************************
17  *
18  * Last port: operation/valid/IsValidOp.java r335 (JTS-1.12)
19  *
20  **********************************************************************/
21 
22 #ifndef GEOS_OP_ISVALIDOP_H
23 #define GEOS_OP_ISVALIDOP_H
24 
25 #include <geos/export.h>
26 
27 #include <geos/operation/valid/TopologyValidationError.h> // for inlined destructor
28 
29 // Forward declarations
30 namespace geos {
31  namespace util {
32  class TopologyValidationError;
33  }
34  namespace geom {
35  class CoordinateSequence;
36  class GeometryFactory;
37  class Geometry;
38  class Point;
39  class LinearRing;
40  class LineString;
41  class Polygon;
42  class GeometryCollection;
43  class MultiPolygon;
44  class MultiLineString;
45  }
46  namespace geomgraph {
47  class DirectedEdge;
48  class EdgeIntersectionList;
49  class PlanarGraph;
50  class GeometryGraph;
51  }
52 }
53 
54 namespace geos {
55 namespace operation { // geos::operation
56 namespace valid { // geos::operation::valid
57 
62 class GEOS_DLL IsValidOp {
63 friend class Unload;
64 private:
66  const geom::Geometry *parentGeometry;
67 
68  bool isChecked;
69 
70  // CHECKME: should this really be a pointer ?
71  TopologyValidationError* validErr;
72 
73  // This is the version using 'isChecked' flag
74  void checkValid();
75 
76  void checkValid(const geom::Geometry *g);
77  void checkValid(const geom::Point *g);
78  void checkValid(const geom::LinearRing *g);
79  void checkValid(const geom::LineString *g);
80  void checkValid(const geom::Polygon *g);
81  void checkValid(const geom::MultiPolygon *g);
82  void checkValid(const geom::GeometryCollection *gc);
83  void checkConsistentArea(geomgraph::GeometryGraph *graph);
84 
85 
94  void checkNoSelfIntersectingRings(geomgraph::GeometryGraph *graph);
95 
102  void checkNoSelfIntersectingRing(
104 
105  void checkTooFewPoints(geomgraph::GeometryGraph *graph);
106 
118  void checkHolesInShell(const geom::Polygon *p,
119  geomgraph::GeometryGraph *graph);
120 
133  void checkHolesNotNested(const geom::Polygon *p,
134  geomgraph::GeometryGraph *graph);
135 
150  void checkShellsNotNested(const geom::MultiPolygon *mp,
151  geomgraph::GeometryGraph *graph);
152 
164  void checkShellNotNested(const geom::LinearRing *shell,
165  const geom::Polygon *p,
166  geomgraph::GeometryGraph *graph);
167 
178  const geom::Coordinate *checkShellInsideHole(
179  const geom::LinearRing *shell,
180  const geom::LinearRing *hole,
181  geomgraph::GeometryGraph *graph);
182 
183  void checkConnectedInteriors(geomgraph::GeometryGraph &graph);
184 
185  void checkInvalidCoordinates(const geom::CoordinateSequence *cs);
186 
187  void checkInvalidCoordinates(const geom::Polygon *poly);
188 
189  void checkClosedRings(const geom::Polygon *poly);
190 
191  void checkClosedRing(const geom::LinearRing *ring);
192 
193  bool isSelfTouchingRingFormingHoleValid;
194 
195 public:
202  static const geom::Coordinate *findPtNotNode(
203  const geom::CoordinateSequence *testCoords,
204  const geom::LinearRing *searchRing,
205  geomgraph::GeometryGraph *graph);
206 
215  static bool isValid(const geom::Coordinate &coord);
216 
223  static bool isValid(const geom::Geometry &geom);
224 
225  IsValidOp(const geom::Geometry *geom)
226  :
227  parentGeometry(geom),
228  isChecked(false),
229  validErr(NULL),
230  isSelfTouchingRingFormingHoleValid(false)
231  {}
232 
234  virtual ~IsValidOp() {
235  delete validErr;
236  }
237 
238  bool isValid();
239 
240  TopologyValidationError* getValidationError();
241 
268  void setSelfTouchingRingFormingHoleValid(bool isValid)
269  {
270  isSelfTouchingRingFormingHoleValid = isValid;
271  }
272 
273 };
274 
275 } // namespace geos.operation.valid
276 } // namespace geos.operation
277 } // namespace geos
278 
279 #endif // GEOS_OP_ISVALIDOP_H
280 
281 /**********************************************************************
282  * $Log$
283  * Revision 1.2 2006/03/29 13:53:59 strk
284  * EdgeRing equipped with Invariant testing function and lots of exceptional assertions. Removed useless heap allocations, and pointers usages.
285  *
286  * Revision 1.1 2006/03/20 16:57:44 strk
287  * spatialindex.h and opValid.h headers split
288  *
289  **********************************************************************/
290