00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef GEOS_GEOM_UTIL_LINEARCOMPONENTEXTRACTER_H
00017 #define GEOS_GEOM_UTIL_LINEARCOMPONENTEXTRACTER_H
00018
00019
00020 #include <geos/export.h>
00021 #include <vector>
00022
00023 #include <geos/geom/GeometryComponentFilter.h>
00024 #include <geos/geom/Geometry.h>
00025 #include <geos/geom/LineString.h>
00026
00027
00028 namespace geos {
00029 namespace geom {
00030 namespace util {
00031
00035 class GEOS_DLL LinearComponentExtracter: public GeometryComponentFilter {
00036
00037 private:
00038
00039 LineString::ConstVect &comps;
00040
00041
00042 LinearComponentExtracter(const LinearComponentExtracter& other);
00043 LinearComponentExtracter& operator=(const LinearComponentExtracter& rhs);
00044
00045 public:
00053 static void getLines(const Geometry &geom, std::vector<const LineString*> &ret)
00054 {
00055 LinearComponentExtracter lce(ret);
00056 geom.apply_ro(&lce);
00057 }
00058
00063 LinearComponentExtracter(std::vector<const LineString*> &newComps)
00064 :
00065 comps(newComps)
00066 {}
00067
00068 void filter_rw(Geometry *geom)
00069 {
00070 if ( const LineString *ls=dynamic_cast<const LineString *>(geom) )
00071 comps.push_back(ls);
00072 }
00073
00074 void filter_ro(const Geometry *geom)
00075 {
00076 if ( const LineString *ls=dynamic_cast<const LineString *>(geom) )
00077 comps.push_back(ls);
00078 }
00079
00080 };
00081
00082 }
00083 }
00084 }
00085
00086 #endif