GEOS
3.4.2
|
00001 /********************************************************************** 00002 * 00003 * GEOS - Geometry Engine Open Source 00004 * http://geos.osgeo.org 00005 * 00006 * Copyright (C) 2006 Refractions Research Inc. 00007 * 00008 * This is free software; you can redistribute and/or modify it under 00009 * the terms of the GNU Lesser General Public Licence as published 00010 * by the Free Software Foundation. 00011 * See the COPYING file for more information. 00012 * 00013 ********************************************************************** 00014 * 00015 * Last port: operation/predicate/RectangleContains.java rev 1.5 (JTS-1.10) 00016 * 00017 **********************************************************************/ 00018 00019 #ifndef GEOS_OP_PREDICATE_RECTANGLECONTAINS_H 00020 #define GEOS_OP_PREDICATE_RECTANGLECONTAINS_H 00021 00022 #include <geos/export.h> 00023 00024 #include <geos/geom/Polygon.h> // for inlines 00025 00026 // Forward declarations 00027 namespace geos { 00028 namespace geom { 00029 class Envelope; 00030 class Geometry; 00031 class Point; 00032 class Coordinate; 00033 class LineString; 00034 //class Polygon; 00035 } 00036 } 00037 00038 namespace geos { 00039 namespace operation { // geos::operation 00040 namespace predicate { // geos::operation::predicate 00041 00051 class GEOS_DLL RectangleContains { 00052 00053 private: 00054 00055 const geom::Polygon& rectangle; 00056 const geom::Envelope& rectEnv; 00057 00058 bool isContainedInBoundary(const geom::Geometry& geom); 00059 00060 bool isPointContainedInBoundary(const geom::Point& geom); 00061 00069 bool isPointContainedInBoundary(const geom::Coordinate &pt); 00070 00078 bool isLineStringContainedInBoundary(const geom::LineString &line); 00079 00088 bool isLineSegmentContainedInBoundary(const geom::Coordinate& p0, 00089 const geom::Coordinate& p1); 00090 00091 public: 00092 00093 static bool contains(const geom::Polygon& rect, const geom::Geometry& b) 00094 { 00095 RectangleContains rc(rect); 00096 return rc.contains(b); 00097 } 00098 00104 RectangleContains(const geom::Polygon& rect) 00105 : 00106 rectangle(rect), 00107 rectEnv(*(rect.getEnvelopeInternal())) 00108 {} 00109 00110 bool contains(const geom::Geometry& geom); 00111 00112 // Declare type as noncopyable 00113 RectangleContains(const RectangleContains& other); 00114 RectangleContains& operator=(const RectangleContains& rhs); 00115 }; 00116 00117 00118 00119 } // namespace geos::operation::predicate 00120 } // namespace geos::operation 00121 } // namespace geos 00122 00123 #endif // ifndef GEOS_OP_PREDICATE_RECTANGLECONTAINS_H