GEOS  3.4.2
RectangleContains.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/predicate/RectangleContains.java rev 1.5 (JTS-1.10)
16  *
17  **********************************************************************/
18 
19 #ifndef GEOS_OP_PREDICATE_RECTANGLECONTAINS_H
20 #define GEOS_OP_PREDICATE_RECTANGLECONTAINS_H
21 
22 #include <geos/export.h>
23 
24 #include <geos/geom/Polygon.h> // for inlines
25 
26 // Forward declarations
27 namespace geos {
28  namespace geom {
29  class Envelope;
30  class Geometry;
31  class Point;
32  class Coordinate;
33  class LineString;
34  //class Polygon;
35  }
36 }
37 
38 namespace geos {
39 namespace operation { // geos::operation
40 namespace predicate { // geos::operation::predicate
41 
51 class GEOS_DLL RectangleContains {
52 
53 private:
54 
55  const geom::Polygon& rectangle;
56  const geom::Envelope& rectEnv;
57 
58  bool isContainedInBoundary(const geom::Geometry& geom);
59 
60  bool isPointContainedInBoundary(const geom::Point& geom);
61 
69  bool isPointContainedInBoundary(const geom::Coordinate &pt);
70 
78  bool isLineStringContainedInBoundary(const geom::LineString &line);
79 
88  bool isLineSegmentContainedInBoundary(const geom::Coordinate& p0,
89  const geom::Coordinate& p1);
90 
91 public:
92 
93  static bool contains(const geom::Polygon& rect, const geom::Geometry& b)
94  {
95  RectangleContains rc(rect);
96  return rc.contains(b);
97  }
98 
105  :
106  rectangle(rect),
107  rectEnv(*(rect.getEnvelopeInternal()))
108  {}
109 
110  bool contains(const geom::Geometry& geom);
111 
112  // Declare type as noncopyable
113  RectangleContains(const RectangleContains& other);
114  RectangleContains& operator=(const RectangleContains& rhs);
115 };
116 
117 
118 
119 } // namespace geos::operation::predicate
120 } // namespace geos::operation
121 } // namespace geos
122 
123 #endif // ifndef GEOS_OP_PREDICATE_RECTANGLECONTAINS_H
RectangleContains(const geom::Polygon &rect)
Definition: RectangleContains.h:104
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:53
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:167
Definition: LineString.h:70
Represents a linear polygon, which may include holes.
Definition: Polygon.h:66
Optimized implementation of spatial predicate &quot;contains&quot; for cases where the first Geometry is a rect...
Definition: RectangleContains.h:51
Definition: Point.h:67