GEOS  3.6.2
PointLocator.h
00001 /**********************************************************************
00002  *
00003  * GEOS - Geometry Engine Open Source
00004  * http://geos.osgeo.org
00005  *
00006  * Copyright (C) 2005-2011 Refractions Research Inc.
00007  * Copyright (C) 2001-2002 Vivid Solutions 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  * Last port: algorithm/PointLocator.java r320 (JTS-1.12)
00017  *
00018  **********************************************************************/
00019 
00020 #ifndef GEOS_ALGORITHM_POINTLOCATOR_H
00021 #define GEOS_ALGORITHM_POINTLOCATOR_H
00022 
00023 #include <geos/export.h>
00024 #include <geos/geom/Location.h> // for inlines
00025 
00026 // Forward declarations
00027 namespace geos {
00028         namespace geom {
00029                 class Coordinate;
00030                 class Geometry;
00031                 class LinearRing;
00032                 class LineString;
00033                 class Polygon;
00034                 class Point;
00035         }
00036 }
00037 
00038 namespace geos {
00039 namespace algorithm { // geos::algorithm
00040 
00058 class GEOS_DLL PointLocator {
00059 public:
00060         PointLocator() {}
00061         ~PointLocator() {}
00062 
00073         int locate(const geom::Coordinate& p, const geom::Geometry *geom);
00074 
00083         bool intersects(const geom::Coordinate& p, const geom::Geometry *geom) {
00084                 return locate(p, geom) != geom::Location::EXTERIOR;
00085         }
00086 
00087 private:
00088 
00089         bool isIn;         // true if the point lies in or on any Geometry element
00090 
00091         int numBoundaries;    // the number of sub-elements whose boundaries the point lies in
00092 
00093         void computeLocation(const geom::Coordinate& p, const geom::Geometry *geom);
00094 
00095         void updateLocationInfo(int loc);
00096 
00097         int locate(const geom::Coordinate& p, const geom::Point *pt);
00098 
00099         int locate(const geom::Coordinate& p, const geom::LineString *l);
00100 
00101         int locateInPolygonRing(const geom::Coordinate& p, const geom::LinearRing *ring);
00102 
00103         int locate(const geom::Coordinate& p, const geom::Polygon *poly);
00104 
00105 };
00106 
00107 } // namespace geos::algorithm
00108 } // namespace geos
00109 
00110 
00111 #endif // GEOS_ALGORITHM_POINTLOCATOR_H
00112