GEOS  3.13.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.
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 #pragma once
20 
21 #include <geos/export.h>
22 
23 #include <geos/geom/Polygon.h> // for inlines
24 
25 // Forward declarations
26 namespace geos {
27 namespace geom {
28 class Envelope;
29 class Geometry;
30 class Point;
31 class Coordinate;
32 class LineString;
33 //class Polygon;
34 }
35 }
36 
37 namespace geos {
38 namespace operation { // geos::operation
39 namespace predicate { // geos::operation::predicate
40 
50 class GEOS_DLL RectangleContains {
51 
52 private:
53 
54  const geom::Envelope& rectEnv;
55 
56  bool isContainedInBoundary(const geom::Geometry& geom);
57 
58  bool isPointContainedInBoundary(const geom::Point& geom);
59 
67  bool isPointContainedInBoundary(const geom::CoordinateXY& pt);
68 
76  bool isLineStringContainedInBoundary(const geom::LineString& line);
77 
86  bool isLineSegmentContainedInBoundary(const geom::Coordinate& p0,
87  const geom::Coordinate& p1);
88 
89 public:
90 
91  static bool
92  contains(const geom::Polygon& rect, const geom::Geometry& b)
93  {
94  RectangleContains rc(rect);
95  return rc.contains(b);
96  }
97 
104  :
105  rectEnv(*(rect.getEnvelopeInternal()))
106  {}
107 
108  bool contains(const geom::Geometry& geom);
109 
110  // Declare type as noncopyable
111  RectangleContains(const RectangleContains& other) = delete;
112  RectangleContains& operator=(const RectangleContains& rhs) = delete;
113 };
114 
115 
116 
117 } // namespace geos::operation::predicate
118 } // namespace geos::operation
119 } // namespace geos
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:216
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:58
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:186
Definition: LineString.h:65
Definition: Point.h:61
Represents a linear polygon, which may include holes.
Definition: Polygon.h:60
Optimized implementation of spatial predicate "contains" for cases where the first Geometry is a rect...
Definition: RectangleContains.h:50
RectangleContains(const geom::Polygon &rect)
Definition: RectangleContains.h:103
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25