# RectangleContains.h

    00001 /**********************************************************************
    00002  * $Id: RectangleContains.h 1820 2006-09-06 16:54:23Z mloskot $
    00003  *
    00004  * GEOS - Geometry Engine Open Source
    00005  * http://geos.refractions.net
    00006  *
    00007  * Copyright (C) 2006 Refractions Research Inc.
    00008  *
    00009  * This is free software; you can redistribute and/or modify it under
    00010  * the terms of the GNU Lesser General Public Licence as published
    00011  * by the Free Software Foundation.
    00012  * See the COPYING file for more information.
    00013  *
    00014  **********************************************************************/
    00015
    00016 #ifndef GEOS_OP_PREDICATE_RECTANGLECONTAINS_H
    00017 #define GEOS_OP_PREDICATE_RECTANGLECONTAINS_H
    00018
    00019 #include <geos/geom/Polygon.h> // for inlines
    00020
    00021 // Forward declarations
    00022 namespace geos {
    00023         namespace geom {
    00024                 class Envelope;
    00025                 class Geometry;
    00026                 class Point;
    00027                 class Coordinate;
    00028                 class LineString;
    00029                 //class Polygon;
    00030         }
    00031 }
    00032
    00033 namespace geos {
    00034 namespace operation { // geos::operation
    00035 namespace predicate { // geos::operation::predicate
    00036
    00047 class RectangleContains {
    00048
    00049 private:
    00050
    00051         const geom::Polygon& rectangle;
    00052         const geom::Envelope& rectEnv;
    00053
    00054         bool isContainedInBoundary(const geom::Geometry& geom);
    00055         bool isPointContainedInBoundary(const geom::Point& geom);
    00056         bool isPointContainedInBoundary(const geom::Coordinate &coord);
    00057         bool isLineStringContainedInBoundary(const geom::LineString &line);
    00058         bool isLineSegmentContainedInBoundary(const geom::Coordinate& p0,
    00059                         const geom::Coordinate& p1);
    00060
    00061 public:
    00062
    00063         static bool contains(const geom::Polygon& rect, const geom::Geometry& b)
    00064         {
    00065                 RectangleContains rc(rect);
    00066                 return rc.contains(b);
    00067         }
    00068
    00074         RectangleContains(const geom::Polygon& rect)
    00075                 :
    00076                 rectangle(rect),
    00077                 rectEnv(*(rect.getEnvelopeInternal()))
    00078                 {}
    00079
    00080         bool contains(const geom::Geometry& geom);
    00081
    00082
    00083 };
    00084
    00085
    00086
    00087 } // namespace geos::operation::predicate
    00088 } // namespace geos::operation
    00089 } // namespace geos
    00090
    00091 #endif // ifndef GEOS_OP_PREDICATE_RECTANGLECONTAINS_H