~sharpie/geos/3.3.2

« back to all changes in this revision

Viewing changes to source/headers/geos/geom/prep/AbstractPreparedPolygonContains.h

  • Committer: Bazaar Package Importer
  • Author(s): Fabio Tranchitella
  • Date: 2009-03-27 15:54:54 UTC
  • mfrom: (1.2.1 upstream) (5.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20090327155454-o3u9j86rzrtcp5vl
Tags: 3.1.0-1
* New upstream release.
* This version includes also a missing header inclusion, which caused FTBFS
  on armel. (Closes: #520447)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**********************************************************************
 
2
 * $Id: AbstractPreparedPolygonContains.h 2159 2008-08-18 16:27:02Z mloskot $
 
3
 *
 
4
 * GEOS - Geometry Engine Open Source
 
5
 * http://geos.refractions.net
 
6
 *
 
7
 * Copyright (C) 2006 Refractions Research Inc.
 
8
 *
 
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.
 
13
 *
 
14
 *
 
15
 **********************************************************************/
 
16
 
 
17
#ifndef GEOS_GEOM_PREP_ABSTRACTPREPAREDPOLYGONCONTAINS_H
 
18
#define GEOS_GEOM_PREP_ABSTRACTPREPAREDPOLYGONCONTAINS_H
 
19
 
 
20
#include <geos/geom/prep/PreparedPolygonPredicate.h> // inherited
 
21
 
 
22
 
 
23
// forward declarations
 
24
namespace geos {
 
25
        namespace geom { 
 
26
                class Geometry;
 
27
 
 
28
                namespace prep { 
 
29
                        class PreparedPolygon;
 
30
                }
 
31
        }
 
32
}
 
33
 
 
34
 
 
35
namespace geos {
 
36
namespace geom { // geos::geom
 
37
namespace prep { // geos::geom::prep
 
38
 
 
39
/**
 
40
 * \brief
 
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.
 
44
 *
 
45
 * Uses short-circuit tests and indexing to improve performance. 
 
46
 * 
 
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.
 
51
 * 
 
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.
 
57
 * 
 
58
 * @author Martin Davis
 
59
 *
 
60
 */
 
61
class AbstractPreparedPolygonContains : public PreparedPolygonPredicate 
 
62
{
 
63
private:
 
64
        // information about geometric situation
 
65
        bool hasSegmentIntersection;
 
66
        bool hasProperIntersection;
 
67
        bool hasNonProperIntersection;
 
68
 
 
69
        bool isProperIntersectionImpliesNotContainedSituation( const geom::Geometry * testGeom);
 
70
 
 
71
        /**
 
72
         * Tests whether a geometry consists of a single polygon with no holes.
 
73
         *  
 
74
         * @return true if the geometry is a single polygon with no holes
 
75
         */
 
76
        bool isSingleShell( const geom::Geometry & geom);
 
77
        
 
78
        void findAndClassifyIntersections( const geom::Geometry * geom);
 
79
 
 
80
protected:
 
81
        /**
 
82
         * This flag controls a difference between contains and covers.
 
83
         * 
 
84
         * For contains the value is true.
 
85
         * For covers the value is false.
 
86
         */
 
87
        bool requireSomePointInInterior;
 
88
 
 
89
        /**
 
90
         * Evaluate the <tt>contains</tt> or <tt>covers</tt> relationship
 
91
         * for the given geometry.
 
92
         * 
 
93
         * @param geom the test geometry
 
94
         * @return true if the test geometry is contained
 
95
         */
 
96
        bool eval( const geom::Geometry * geom);
 
97
 
 
98
        /**
 
99
         * Computes the full topological predicate.
 
100
         * Used when short-circuit tests are not conclusive.
 
101
         * 
 
102
         * @param geom the test geometry
 
103
         * @return true if this prepared polygon has the relationship with the test geometry
 
104
         */
 
105
        virtual bool fullTopologicalPredicate( const geom::Geometry * geom) =0;
 
106
 
 
107
public:
 
108
        AbstractPreparedPolygonContains( const PreparedPolygon * const prepPoly) 
 
109
        :       PreparedPolygonPredicate( prepPoly),
 
110
                hasSegmentIntersection( false),
 
111
                hasProperIntersection( false),
 
112
                hasNonProperIntersection( false),
 
113
                requireSomePointInInterior(true)
 
114
        { }
 
115
 
 
116
        AbstractPreparedPolygonContains( const PreparedPolygon * const prepPoly, bool requireSomePointInInterior) 
 
117
        :       PreparedPolygonPredicate( prepPoly),
 
118
                hasSegmentIntersection( false),
 
119
                hasProperIntersection( false),
 
120
                hasNonProperIntersection( false),
 
121
                requireSomePointInInterior(requireSomePointInInterior)
 
122
        { }
 
123
 
 
124
        virtual ~AbstractPreparedPolygonContains()
 
125
        { }
 
126
 
 
127
};
 
128
 
 
129
} // geos::geom::prep
 
130
} // geos::geom
 
131
} // geos
 
132
 
 
133
#endif // GEOS_GEOM_PREP_ABSTRACTPREPAREDPOLYGONCONTAINS_H
 
134
/**********************************************************************
 
135
 * $Log$
 
136
 **********************************************************************/
 
137