GEOS
3.4.2
|
00001 /********************************************************************** 00002 * 00003 * GEOS - Geometry Engine Open Source 00004 * http://geos.osgeo.org 00005 * 00006 * Copyright (C) 2001-2002 Vivid Solutions Inc. 00007 * Copyright (C) 2006 Refractions Research 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 #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> // to be removed when we have the .inl 00025 #include <geos/geom/LineString.h> // to be removed when we have the .inl 00026 //#include <geos/platform.h> 00027 00028 namespace geos { 00029 namespace geom { // geos.geom 00030 namespace util { // geos.geom.util 00031 00035 class GEOS_DLL LinearComponentExtracter: public GeometryComponentFilter { 00036 00037 private: 00038 00039 LineString::ConstVect &comps; 00040 00041 // Declare type as noncopyable 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 } // namespace geos.geom.util 00083 } // namespace geos.geom 00084 } // namespace geos 00085 00086 #endif