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/relate/RelateOp.java rev. 1.19 (JTS-1.10)
16  *
17  **********************************************************************/
18 
19 #ifndef GEOS_OP_RELATE_RELATEOP_H
20 #define GEOS_OP_RELATE_RELATEOP_H
21 
22 #include <geos/export.h>
23 
24 #include <geos/geom/IntersectionMatrix.h>
25 #include <geos/operation/GeometryGraphOperation.h> // for inheritance
26 #include <geos/operation/relate/RelateComputer.h> // for composition
27 
28 // Forward declarations
29 namespace geos {
30 namespace algorithm {
31 class BoundaryNodeRule;
32 }
33 namespace geom {
34 class Geometry;
35 }
36 }
37 
38 
39 namespace geos {
40 namespace operation { // geos::operation
41 namespace relate { // geos::operation::relate
42 
43 /** \brief
44  * Implements the SFS `relate()` operation on two
45  * geom::Geometry objects.
46  *
47  * This class supports specifying a custom algorithm::BoundaryNodeRule
48  * to be used during the relate computation.
49  *
50  * @note Custom Boundary Node Rules do not (currently)
51  * affect the results of other Geometry methods (such
52  * as [Geometry::getBoundary()](@ref geom::Geometry::getBoundary() const)).
53  * The results of these methods may not be consistent with the relationship
54  * computed by a custom Boundary Node Rule.
55  *
56  */
57 class GEOS_DLL RelateOp: public GeometryGraphOperation {
58 
59 public:
60 
61     /** \brief
62      * Computes the geom::IntersectionMatrix for the spatial relationship
63      * between two geom::Geometry objects, using the default (OGC SFS)
64      * Boundary Node Rule
65      *
66      * @param a a Geometry to test. Ownership left to caller.
67      * @param b a Geometry to test. Ownership left to caller.
68      *
69      * @return the IntersectonMatrix for the spatial relationship
70      *         between the geometries. Ownership transferred.
71      */
72     static std::unique_ptr<geom::IntersectionMatrix> relate(
73         const geom::Geometry* a,
74         const geom::Geometry* b);
75 
76     /** \brief
77      * Computes the geom::IntersectionMatrix for the spatial relationship
78      * between two geom::Geometry objects, using a specified
79      * Boundary Node Rule.
80      *
81      * @param a a Geometry to test. Ownership left to caller.
82      * @param b a Geometry to test. Ownership left to caller.
83      * @param boundaryNodeRule the Boundary Node Rule to use.
84      *
85      * @return the IntersectonMatrix for the spatial relationship
86      *         between the geometries. Ownership transferred.
87      */
88     static std::unique_ptr<geom::IntersectionMatrix> relate(
89         const geom::Geometry* a,
90         const geom::Geometry* b,
91         const algorithm::BoundaryNodeRule& boundaryNodeRule);
92 
93     /** \brief
94      * Creates a new Relate operation, using the default (OGC SFS)
95      * Boundary Node Rule.
96      *
97      * @param g0 a Geometry to relate. Ownership left to caller.
98      * @param g1 another Geometry to relate. Ownership to caller.
99      */
100     RelateOp(const geom::Geometry* g0,
101              const geom::Geometry* g1);
102 
103     /** \brief
104      * Creates a new Relate operation with a specified
105      * Boundary Node Rule.
106      *
107      * @param g0 a Geometry to relate. Ownership left to caller.
108      * @param g1 another Geometry to relate. Ownership to caller.
109      * @param boundaryNodeRule the Boundary Node Rule to use
110      */
111     RelateOp(const geom::Geometry* g0,
112              const geom::Geometry* g1,
113              const algorithm::BoundaryNodeRule& boundaryNodeRule);
114 
115     ~RelateOp() override = default;
116 
117     /** \brief
118      * Gets the IntersectionMatrix for the spatial relationship
119      * between the input geometries.
120      *
121      * @return the geom::IntersectionMatrix for the spatial
122      *         relationship between the input geometries.
123      *         Ownership transferred.
124      */
125     std::unique_ptr<geom::IntersectionMatrix> getIntersectionMatrix();
126 
127 private:
128 
129     RelateComputer relateComp;
130 };
131 
132 
133 } // namespace geos:operation:relate
134 } // namespace geos:operation
135 } // namespace geos
136 
137 #endif // GEOS_OP_RELATE_RELATEOP_H
138