GEOS: OverlayOp.h Source File

GEOS 3.5.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

OverlayOp.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 * Last port: operation/overlay/OverlayOp.java r567 (JTS-1.12+)
16 *
17 **********************************************************************/
18
19 #ifndef GEOS_OP_OVERLAY_OVERLAYOP_H
20 #define GEOS_OP_OVERLAY_OVERLAYOP_H
21
22 #include <geos/export.h>
23
24 #include <geos/operation/GeometryGraphOperation.h> // for inheritance
25 #include <geos/geomgraph/EdgeList.h> // for composition
26 #include <geos/algorithm/PointLocator.h> // for composition
27 #include <geos/geomgraph/PlanarGraph.h> // for inline (GeometryGraph->PlanarGraph)
28
29 #include <vector>
30
31 #ifdef _MSC_VER
32 #pragma warning(push)
33 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
34 #endif
35
36 // Forward declarations
37 namespace geos {
38 namespace geom {
39 class Geometry;
40 class Coordinate;
41 class Envelope;
42 class GeometryFactory;
43 class Polygon;
44 class LineString;
45 class Point;
46 }
47 namespace geomgraph {
48 class Label;
49 class Edge;
50 class Node;
51 }
52 namespace operation {
53 namespace overlay {
54 class ElevationMatrix;
55 }
56 }
57 }
58
59 namespace geos {
60 namespace operation { // geos::operation
61 namespace overlay { // geos::operation::overlay
62
64 //
68 class GEOS_DLL OverlayOp: public GeometryGraphOperation {
69
70 public:
71
73 //
77 enum OpCode {
79 opINTERSECTION = 1,
81 opUNION = 2,
83 opDIFFERENCE = 3,
85 opSYMDIFFERENCE = 4
86 };
87
97 static geom::Geometry* overlayOp(const geom::Geometry *geom0,
98 const geom::Geometry *geom1,
99 OpCode opCode);
100 //throw(TopologyException *);
101
114 static bool isResultOfOp(const geomgraph::Label& label, OpCode opCode);
115
117 //
120 static bool isResultOfOp(int loc0, int loc1, OpCode opCode);
121
123 //
127 OverlayOp(const geom::Geometry *g0, const geom::Geometry *g1);
128
129 virtual ~OverlayOp(); // FIXME: virtual ?
130
140 geom::Geometry* getResultGeometry(OpCode overlayOpCode);
141 // throw(TopologyException *);
142
148 geomgraph::PlanarGraph& getGraph() { return graph; }
149
157 bool isCoveredByLA(const geom::Coordinate& coord);
158
165 bool isCoveredByA(const geom::Coordinate& coord);
166
167 /*
168 * @return true if the coord is located in the interior or boundary of
169 * a geometry in the list.
170 */
171
172 protected:
173
182 void insertUniqueEdge(geomgraph::Edge *e);
183
184 private:
185
186 algorithm::PointLocator ptLocator;
187
188 const geom::GeometryFactory *geomFact;
189
190 geom::Geometry *resultGeom;
191
192 geomgraph::PlanarGraph graph;
193
194 geomgraph::EdgeList edgeList;
195
196 std::vector<geom::Polygon*> *resultPolyList;
197
198 std::vector<geom::LineString*> *resultLineList;
199
200 std::vector<geom::Point*> *resultPointList;
201
202 void computeOverlay(OpCode opCode); // throw(TopologyException *);
203
204 void insertUniqueEdges(std::vector<geomgraph::Edge*> *edges, const geom::Envelope *env=0);
205
206 /*
207 * If either of the GeometryLocations for the existing label is
208 * exactly opposite to the one in the labelToMerge,
209 * this indicates a dimensional collapse has happened.
210 * In this case, convert the label for that Geometry to a Line label
211 */
212 //Not needed
213 //void checkDimensionalCollapse(geomgraph::Label labelToMerge, geomgraph::Label existingLabel);
214
226 void computeLabelsFromDepths();
227
232 void replaceCollapsedEdges();
233
244 void copyPoints(int argIndex, const geom::Envelope *env=0);
245
254 void computeLabelling(); // throw(TopologyException *);
255
263 void mergeSymLabels();
264
265 void updateNodeLabelling();
266
284 void labelIncompleteNodes();
285
289 void labelIncompleteNode(geomgraph::Node *n, int targetIndex);
290
302 void findResultAreaEdges(OpCode opCode);
303
308 void cancelDuplicateResultEdges();
309
314 bool isCovered(const geom::Coordinate& coord,
315 std::vector<geom::Geometry*> *geomList);
316
321 bool isCovered(const geom::Coordinate& coord,
322 std::vector<geom::Polygon*> *geomList);
323
328 bool isCovered(const geom::Coordinate& coord,
329 std::vector<geom::LineString*> *geomList);
330
335 geom::Geometry* computeGeometry(
336 std::vector<geom::Point*> *nResultPointList,
337 std::vector<geom::LineString*> *nResultLineList,
338 std::vector<geom::Polygon*> *nResultPolyList);
339
341 std::vector<geomgraph::Edge *>dupEdges;
342
347 int mergeZ(geomgraph::Node *n, const geom::Polygon *poly) const;
348
354 int mergeZ(geomgraph::Node *n, const geom::LineString *line) const;
355
359 double avgz[2];
360 bool avgzcomputed[2];
361
362 double getAverageZ(int targetIndex);
363 static double getAverageZ(const geom::Polygon *poly);
364
365 ElevationMatrix *elevationMatrix;
366
369 void checkObviouslyWrongResult(OpCode opCode);
370
371 };
372
376 struct overlayOp {
377
378 OverlayOp::OpCode opCode;
379
380 overlayOp(OverlayOp::OpCode code)
381 :
382 opCode(code)
383 {}
384
385 geom::Geometry* operator() (const geom::Geometry* g0,
386 const geom::Geometry* g1)
387 {
388 return OverlayOp::overlayOp(g0, g1, opCode);
389 }
390
391 };
392
393 } // namespace geos::operation::overlay
394 } // namespace geos::operation
395 } // namespace geos
396
397 #ifdef _MSC_VER
398 #pragma warning(pop)
399 #endif
400
401 #endif // ndef GEOS_OP_OVERLAY_OVERLAYOP_H
geos::geom::Envelope
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:53
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
geos::operation::overlay::OverlayOp::getGraph
geomgraph::PlanarGraph & getGraph()
Definition: OverlayOp.h:148
geos::geomgraph::PlanarGraph
Represents a directed graph which is embeddable in a planar surface.
Definition: geomgraph/PlanarGraph.h:75
geos::operation::overlay::OverlayOp::OpCode
OpCode
The spatial functions supported by this class.
Definition: OverlayOp.h:77
geos::geomgraph::EdgeList
Definition: EdgeList.h:58
geos::operation::overlay::OverlayOp
Computes the geometric overlay of two Geometry.
Definition: OverlayOp.h:68
geos::algorithm::PointLocator
Computes the topological relationship (Location) of a single point to a Geometry. ...
Definition: PointLocator.h:57
geos::geom::Geometry
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:167
geos::geom::LineString
Definition: LineString.h:70
geos::operation::GeometryGraphOperation
The base class for operations that require GeometryGraph.
Definition: GeometryGraphOperation.h:52
geos::geom::Polygon
Represents a linear polygon, which may include holes.
Definition: Polygon.h:66
geos::geom::GeometryFactory
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:67
geos::operation::overlay::overlayOp
OverlayOp::overlayOp Adapter for use with geom::BinaryOp.
Definition: OverlayOp.h:376
geos::geomgraph::Label
A Label indicates the topological relationship of a component of a topology graph to a given Geometry...
Definition: Label.h:57
geos
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
geos::geomgraph::Node
Definition: geomgraph/Node.h:62
geos::geomgraph::Edge
Definition: geomgraph/Edge.h:66