GEOS  3.6.2
IndexedPointInAreaLocator.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 #ifndef GEOS_ALGORITHM_LOCATE_INDEXEDPOINTINAREALOCATOR_H
00017 #define GEOS_ALGORITHM_LOCATE_INDEXEDPOINTINAREALOCATOR_H
00018 
00019 #include <geos/algorithm/locate/PointOnGeometryLocator.h> // inherited
00020 #include <geos/index/ItemVisitor.h> // inherited
00021 
00022 #include <vector> // composition
00023 
00024 namespace geos {
00025         namespace algorithm {
00026                 class RayCrossingCounter;
00027         }
00028         namespace geom {
00029                 class Geometry;
00030                 class Coordinate; 
00031                 class CoordinateSequence; 
00032                 class LineSegment;
00033         }
00034         namespace index {
00035                 namespace intervalrtree {
00036                         class SortedPackedIntervalRTree;
00037                 }
00038         }
00039 }
00040 
00041 namespace geos {
00042 namespace algorithm { // geos::algorithm
00043 namespace locate { // geos::algorithm::locate
00044 
00055 class IndexedPointInAreaLocator : public PointOnGeometryLocator 
00056 {
00057 private:
00058         class IntervalIndexedGeometry
00059         {
00060         private:
00061                 index::intervalrtree::SortedPackedIntervalRTree * index;
00062 
00063                 void init( const geom::Geometry & g);
00064                 void addLine( geom::CoordinateSequence * pts);
00065 
00066                 // To keep track of allocated LineSegments
00067                 std::vector< geom::LineSegment* > allocatedSegments;
00068 
00069         public:
00070                 IntervalIndexedGeometry( const geom::Geometry & g);
00071                 ~IntervalIndexedGeometry();
00072 
00073                 void query(double min, double max, index::ItemVisitor * visitor);
00074         };
00075 
00076 
00077         class SegmentVisitor : public index::ItemVisitor
00078         {
00079         private:
00080                 algorithm::RayCrossingCounter * counter;
00081 
00082         public:
00083                 SegmentVisitor( algorithm::RayCrossingCounter * counter) 
00084                 :       counter( counter)
00085                 { }
00086                 
00087                 ~SegmentVisitor() 
00088                 { }
00089 
00090                 void visitItem( void * item);
00091         };
00092 
00093 
00094         const geom::Geometry & areaGeom;
00095         IntervalIndexedGeometry * index;
00096 
00097         void buildIndex( const geom::Geometry & g);
00098 
00099     // Declare type as noncopyable
00100     IndexedPointInAreaLocator(const IndexedPointInAreaLocator& other);
00101     IndexedPointInAreaLocator& operator=(const IndexedPointInAreaLocator& rhs);
00102 
00103 public:
00108         IndexedPointInAreaLocator( const geom::Geometry & g);
00109 
00110         ~IndexedPointInAreaLocator();
00111     
00118         int locate( const geom::Coordinate * /*const*/ p);
00119 
00120 };
00121 
00122 } // geos::algorithm::locate
00123 } // geos::algorithm
00124 } // geos
00125 
00126 #endif // GEOS_ALGORITHM_LOCATE_INDEXEDPOINTINAREALOCATOR_H