GEOS  3.8.0dev
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.
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
94  contains(const geom::Polygon& rect, const geom::Geometry& b)
95  {
96  RectangleContains rc(rect);
97  return rc.contains(b);
98  }
99
106  :
107  rectangle(rect),
108  rectEnv(*(rect.getEnvelopeInternal()))
109  {}
110
111  bool contains(const geom::Geometry& geom);
112
113  // Declare type as noncopyable
114  RectangleContains(const RectangleContains& other) = delete;
115  RectangleContains& operator=(const RectangleContains& rhs) = delete;
116 };
117
118
119
120 } // namespace geos::operation::predicate
121 } // namespace geos::operation
122 } // namespace geos
123
124 #endif // ifndef GEOS_OP_PREDICATE_RECTANGLECONTAINS_H
RectangleContains(const geom::Polygon &rect)
Definition: RectangleContains.h:105
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:59
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:187
Definition: LineString.h:69
Represents a linear polygon, which may include holes.
Definition: Polygon.h:65
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
Optimized implementation of spatial predicate "contains" for cases where the first Geometry is a rect...
Definition: RectangleContains.h:51
Definition: Point.h:66