GEOS 3.6.2
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
37namespace 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
59namespace geos {
60namespace operation { // geos::operation
61namespace overlay { // geos::operation::overlay
62
64//
68class GEOS_DLL OverlayOp: public GeometryGraphOperation {
69
70public:
71
73 //
87
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 //
128
129 virtual ~OverlayOp(); // FIXME: virtual ?
130
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
172protected:
173
183
184private:
185
186 algorithm::PointLocator ptLocator;
187
188 const geom::GeometryFactory *geomFact;
189
190 geom::Geometry *resultGeom;
191
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
376struct 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
Computes the topological relationship (Location) of a single point to a Geometry.
Definition PointLocator.h:58
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:60
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:53
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:67
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:167
Definition LineString.h:70
Definition Point.h:68
Represents a linear polygon, which may include holes.
Definition Polygon.h:67
Definition EdgeList.h:58
Definition geomgraph/Edge.h:66
A Label indicates the topological relationship of a component of a topology graph to a given Geometry...
Definition Label.h:57
Definition geomgraph/Node.h:62
Represents a directed graph which is embeddable in a planar surface.
Definition geomgraph/PlanarGraph.h:75
static geom::Geometry * overlayOp(const geom::Geometry *geom0, const geom::Geometry *geom1, OpCode opCode)
void insertUniqueEdge(geomgraph::Edge *e)
Insert an edge from one of the noded input graphs.
OpCode
The spatial functions supported by this class.
Definition OverlayOp.h:77
@ opSYMDIFFERENCE
The code for the Symmetric Difference overlay operation.
Definition OverlayOp.h:85
@ opUNION
The code for the Union overlay operation.
Definition OverlayOp.h:81
@ opINTERSECTION
The code for the Intersection overlay operation.
Definition OverlayOp.h:79
@ opDIFFERENCE
The code for the Difference overlay operation.
Definition OverlayOp.h:83
bool isCoveredByLA(const geom::Coordinate &coord)
This method is used to decide if a point node should be included in the result or not.
geom::Geometry * getResultGeometry(OpCode overlayOpCode)
static bool isResultOfOp(int loc0, int loc1, OpCode opCode)
This method will handle arguments of Location.NULL correctly.
OverlayOp(const geom::Geometry *g0, const geom::Geometry *g1)
Construct an OverlayOp with the given Geometry args.
bool isCoveredByA(const geom::Coordinate &coord)
This method is used to decide if an L edge should be included in the result or not.
geomgraph::PlanarGraph & getGraph()
Definition OverlayOp.h:148
static bool isResultOfOp(const geomgraph::Label &label, OpCode opCode)
Contains the Geometry interface hierarchy and supporting classes.
Definition IndexedNestedRingTester.h:26
Contains classes that implement topology graphs.
Definition IndexedNestedRingTester.h:34
Contains classes that perform a topological overlay to compute boolean spatial functions.
Definition BufferBuilder.h:62
Provides classes for implementing operations on geometries.
Definition IndexedNestedRingTester.h:40
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:25