1
/**********************************************************************
2
* $Id: AbstractPreparedPolygonContains.h 2159 2008-08-18 16:27:02Z mloskot $
4
* GEOS - Geometry Engine Open Source
5
* http://geos.refractions.net
7
* Copyright (C) 2006 Refractions Research Inc.
9
* This is free software; you can redistribute and/or modify it under
10
* the terms of the GNU Lesser General Public Licence as published
11
* by the Free Software Foundation.
12
* See the COPYING file for more information.
15
**********************************************************************/
17
#ifndef GEOS_GEOM_PREP_ABSTRACTPREPAREDPOLYGONCONTAINS_H
18
#define GEOS_GEOM_PREP_ABSTRACTPREPAREDPOLYGONCONTAINS_H
20
#include <geos/geom/prep/PreparedPolygonPredicate.h> // inherited
23
// forward declarations
29
class PreparedPolygon;
36
namespace geom { // geos::geom
37
namespace prep { // geos::geom::prep
41
* A base class containing the logic for computes the <tt>contains</tt>
42
* and <tt>covers</tt> spatial relationship predicates
43
* for a {@link PreparedPolygon} relative to all other {@link Geometry} classes.
45
* Uses short-circuit tests and indexing to improve performance.
47
* Contains and covers are very similar, and differ only in how certain
48
* cases along the boundary are handled. These cases require
49
* full topological evaluation to handle, so all the code in
50
* this class is common to both predicates.
52
* It is not possible to short-circuit in all cases, in particular
53
* in the case where line segments of the test geometry touches the polygon linework.
54
* In this case full topology must be computed.
55
* (However, if the test geometry consists of only points, this
56
* <i>can</i> be evaluated in an optimized fashion.
58
* @author Martin Davis
61
class AbstractPreparedPolygonContains : public PreparedPolygonPredicate
64
// information about geometric situation
65
bool hasSegmentIntersection;
66
bool hasProperIntersection;
67
bool hasNonProperIntersection;
69
bool isProperIntersectionImpliesNotContainedSituation( const geom::Geometry * testGeom);
72
* Tests whether a geometry consists of a single polygon with no holes.
74
* @return true if the geometry is a single polygon with no holes
76
bool isSingleShell( const geom::Geometry & geom);
78
void findAndClassifyIntersections( const geom::Geometry * geom);
82
* This flag controls a difference between contains and covers.
84
* For contains the value is true.
85
* For covers the value is false.
87
bool requireSomePointInInterior;
90
* Evaluate the <tt>contains</tt> or <tt>covers</tt> relationship
91
* for the given geometry.
93
* @param geom the test geometry
94
* @return true if the test geometry is contained
96
bool eval( const geom::Geometry * geom);
99
* Computes the full topological predicate.
100
* Used when short-circuit tests are not conclusive.
102
* @param geom the test geometry
103
* @return true if this prepared polygon has the relationship with the test geometry
105
virtual bool fullTopologicalPredicate( const geom::Geometry * geom) =0;
108
AbstractPreparedPolygonContains( const PreparedPolygon * const prepPoly)
109
: PreparedPolygonPredicate( prepPoly),
110
hasSegmentIntersection( false),
111
hasProperIntersection( false),
112
hasNonProperIntersection( false),
113
requireSomePointInInterior(true)
116
AbstractPreparedPolygonContains( const PreparedPolygon * const prepPoly, bool requireSomePointInInterior)
117
: PreparedPolygonPredicate( prepPoly),
118
hasSegmentIntersection( false),
119
hasProperIntersection( false),
120
hasNonProperIntersection( false),
121
requireSomePointInInterior(requireSomePointInInterior)
124
virtual ~AbstractPreparedPolygonContains()
129
} // geos::geom::prep
133
#endif // GEOS_GEOM_PREP_ABSTRACTPREPAREDPOLYGONCONTAINS_H
134
/**********************************************************************
136
**********************************************************************/