GEOS  3.14.0dev
RectangleIntersects.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
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  * Last port: operation/predicate/RectangleIntersects.java r378 (JTS-1.12)
17  *
18  **********************************************************************/
19 
20 #pragma once
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 Polygon;
31 }
32 }
33 
34 namespace geos {
35 namespace operation { // geos::operation
36 namespace predicate { // geos::operation::predicate
37 
51 class GEOS_DLL RectangleIntersects {
52 
53 private:
54 
55  const geom::Polygon& rectangle;
56 
57  const geom::Envelope& rectEnv;
58 
59  // Declare type as noncopyable
60  RectangleIntersects(const RectangleIntersects& other) = delete;
61  RectangleIntersects& operator=(const RectangleIntersects& rhs) = delete;
62 
63 public:
64 
71  :
72  rectangle(newRect),
73  rectEnv(*(newRect.getEnvelopeInternal()))
74  {}
75 
76  bool intersects(const geom::Geometry& geom);
77 
85  static bool
86  intersects(const geom::Polygon& rectangle,
87  const geom::Geometry& b)
88  {
89  RectangleIntersects rp(rectangle);
90  return rp.intersects(b);
91  }
92 
93 };
94 
95 
96 } // namespace geos::operation::predicate
97 } // namespace geos::operation
98 } // namespace geos
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:59
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:197
Represents a linear polygon, which may include holes.
Definition: Polygon.h:61
Optimized implementation of the "intersects" spatial predicate for cases where one Geometry is a rect...
Definition: RectangleIntersects.h:51
RectangleIntersects(const geom::Polygon &newRect)
Create a new intersects computer for a rectangle.
Definition: RectangleIntersects.h:70
static bool intersects(const geom::Polygon &rectangle, const geom::Geometry &b)
Tests whether a rectangle intersects a given geometry.
Definition: RectangleIntersects.h:86
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25