GEOS  3.6.2
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 
00108         static int orientationIndex(const geom::Coordinate& p1,
00109                  const geom::Coordinate& p2,
00110                  const geom::Coordinate& q);
00111 
00112         RayCrossingCounter(const geom::Coordinate& point)
00113         :       point( point),
00114                 crossingCount( 0),
00115                 isPointOnSegment( false)
00116         { }
00117         
00124         void countSegment(const geom::Coordinate& p1,
00125                           const geom::Coordinate& p2);
00126         
00136         bool isOnSegment() 
00137         { 
00138                 return isPointOnSegment; 
00139         }
00140         
00151         int getLocation();
00152     
00163         bool isPointInPolygon();
00164 
00165 };
00166 
00167 } // geos::algorithm
00168 } // geos
00169 
00170 #endif // GEOS_ALGORITHM_RAYCROSSINGCOUNTER_H