RayCrossingCounter.h

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  *
00016  * Last port: algorithm/RayCrossingCounter.java rev. 1.2 (JTS-1.9)
00017  *
00018  **********************************************************************/
00019 
00020 #ifndef GEOS_ALGORITHM_RAYCROSSINGCOUNTER_H
00021 #define GEOS_ALGORITHM_RAYCROSSINGCOUNTER_H
00022 
00023 #include <geos/export.h>
00024 
00025 #include <vector>
00026 
00027 // forward declarations
00028 namespace geos {
00029         namespace geom {
00030                 class Coordinate;
00031                 class CoordinateSequence;
00032         }
00033 }
00034 
00035 
00036 namespace geos {
00037 namespace algorithm {
00038 
00066 class GEOS_DLL RayCrossingCounter 
00067 {
00068 private:
00069         const geom::Coordinate& point;
00070         
00071         int crossingCount;
00072         
00073         // true if the test point lies on an input segment
00074     bool isPointOnSegment;
00075 
00076     // Declare type as noncopyable
00077     RayCrossingCounter(const RayCrossingCounter& other);
00078     RayCrossingCounter& operator=(const RayCrossingCounter& rhs);
00079 
00080 public:
00089         static int locatePointInRing(const geom::Coordinate& p,
00090                                      const geom::CoordinateSequence& ring);
00091 
00093         static int locatePointInRing(const geom::Coordinate& p,
00094                  const std::vector<const geom::Coordinate*>& ring);
00095 
00096         RayCrossingCounter(const geom::Coordinate& point)
00097         :       point( point),
00098                 crossingCount( 0),
00099                 isPointOnSegment( false)
00100         { }
00101         
00108         void countSegment(const geom::Coordinate& p1,
00109                           const geom::Coordinate& p2);
00110         
00120         bool isOnSegment() 
00121         { 
00122                 return isPointOnSegment; 
00123         }
00124         
00135         int getLocation();
00136     
00147         bool isPointInPolygon();
00148 
00149 };
00150 
00151 } // geos::algorithm
00152 } // geos
00153 
00154 #endif // GEOS_ALGORITHM_RAYCROSSINGCOUNTER_H

Generated on 15 May 2014 for GEOS by  doxygen 1.4.7