1 /********************************************************************** 2 * 3 * GEOS - Geometry Engine Open Source 4 * http://geos.osgeo.org 5 * 6 * Copyright (C) 2009 Sandro Santilli <strk@kbt.io> 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: algorithm/BoundaryNodeRule.java rev 1.4 (JTS-1.10) 16 * 17 **********************************************************************/ 18 19 #ifndef GEOS_ALGORITHM_BOUNDARYNODERULE_H 20 #define GEOS_ALGORITHM_BOUNDARYNODERULE_H 21 22 #include <geos/export.h> 23 24 // Forward declarations 25 // ... 26 27 namespace geos { 28 namespace algorithm { // geos::algorithm 29 30 31 /** \brief 32 * An interface for rules which determine whether node points which are 33 * in boundaries of lineal geometry components 34 * are in the boundary of the parent geometry collection. 35 * 36 * The SFS specifies a single kind of boundary node rule, 37 * the `Mod2BoundaryNodeRule` rule. 38 * However, other kinds of Boundary Node Rules are appropriate 39 * in specific situations (for instance, linear network topology 40 * usually follows the `EndPointBoundaryNodeRule`.) 41 * Some JTS operations allow the BoundaryNodeRule to be specified, 42 * and respect this rule when computing the results of the operation. 43 * 44 * @author Martin Davis 45 * @version 1.7 46 * 47 * @see operation::relate::RelateOp 48 * @see operation::IsSimpleOp 49 * @see algorithm::PointLocator 50 */ 51 class GEOS_DLL BoundaryNodeRule { 52 53 public: 54 55 // virtual classes should always have a virtual destructor.. 56 virtual ~BoundaryNodeRule()57 ~BoundaryNodeRule() {} 58 59 /** \brief 60 * Tests whether a point that lies in `boundaryCount` 61 * geometry component boundaries is considered to form part of 62 * the boundary of the parent geometry. 63 * 64 * @param boundaryCount the number of component boundaries that 65 * this point occurs in 66 * @return `true` if points in this number of boundaries lie in 67 * the parent boundary 68 */ 69 virtual bool isInBoundary(int boundaryCount) const = 0; 70 71 /** \brief 72 * The Mod-2 Boundary Node Rule (which is the rule specified 73 * in the OGC SFS). 74 * 75 * A BoundaryNodeRule specifies that points are in the boundary of 76 * a lineal geometry iff the point lies on the boundary of an odd number 77 * of components. Under this rule LinearRings and closed LineStrings have 78 * an empty boundary. 79 * 80 * This is the rule specified by the OGC SFS, and is the default 81 * rule used in JTS. 82 */ 83 //static const BoundaryNodeRule& MOD2_BOUNDARY_RULE; 84 static const BoundaryNodeRule& getBoundaryRuleMod2(); 85 86 /** \brief 87 * The Endpoint Boundary Node Rule. 88 * 89 * A BoundaryNodeRule which specifies that any points which are endpoints 90 * of lineal components are in the boundary of the parent geometry. This 91 * corresponds to the "intuitive" topological definition of boundary. Under 92 * this rule LinearRings have a non-empty boundary (the common endpoint 93 * of the underlying LineString). 94 * 95 * This rule is useful when dealing with linear networks. For example, 96 * it can be used to check whether linear networks are correctly noded. 97 * The usual network topology constraint is that linear segments may 98 * touch only at endpoints. In the case of a segment touching a closed 99 * segment (ring) at one point, the Mod2 rule cannot distinguish between 100 * the permitted case of touching at the node point and the invalid case 101 * of touching at some other interior (non-node) point. The EndPoint rule 102 * does distinguish between these cases, so is more appropriate for use. 103 */ 104 //static const BoundaryNodeRule& ENDPOINT_BOUNDARY_RULE; 105 static const BoundaryNodeRule& getBoundaryEndPoint(); 106 107 /** \brief 108 * The MultiValent Endpoint Boundary Node Rule. 109 * 110 * A BoundaryNodeRule which determines that only endpoints with valency 111 * greater than 1 are on the boundary. This corresponds to the boundary 112 * of a MultiLineString being all the "attached" endpoints, but not 113 * the "unattached" ones. 114 */ 115 //static const BoundaryNodeRule& MULTIVALENT_ENDPOINT_BOUNDARY_RULE; 116 static const BoundaryNodeRule& getBoundaryMultivalentEndPoint(); 117 118 /** \brief 119 * The Monovalent Endpoint Boundary Node Rule. 120 * 121 * A BoundaryNodeRule which determines that only endpoints with valency of 122 * exactly 1 are on the boundary. This corresponds to the boundary of 123 * a MultiLineString being all the "unattached" endpoints. 124 */ 125 //static const BoundaryNodeRule& MONOVALENT_ENDPOINT_BOUNDARY_RULE; 126 static const BoundaryNodeRule& getBoundaryMonovalentEndPoint(); 127 128 /** \brief 129 * The Boundary Node Rule specified by the OGC Simple Features 130 * Specification, which is the same as the Mod-2 rule. 131 * 132 * A BoundaryNodeRule which determines that only endpoints with valency 133 * greater than 1 are on the boundary. This corresponds to the boundary 134 * of a MultiLineString being all the "attached" endpoints, but not the 135 * "unattached" ones. 136 */ 137 //static const BoundaryNodeRule& OGC_SFS_BOUNDARY_RULE; 138 static const BoundaryNodeRule& getBoundaryOGCSFS(); 139 }; 140 141 } // namespace geos::algorithm 142 } // namespace geos 143 144 #endif // GEOS_ALGORITHM_BOUNDARYNODERULE_H 145 146