00001 /********************************************************************** 00002 * $Id: ComponentCoordinateExtracter.h 2263 2009-01-29 18:56:00Z mloskot $ 00003 * 00004 * GEOS - Geometry Engine Open Source 00005 * http://geos.refractions.net 00006 * 00007 * Copyright (C) 2001-2002 Vivid Solutions Inc. 00008 * Copyright (C) 2006 Refractions Research Inc. 00009 * 00010 * This is free software; you can redistribute and/or modify it under 00011 * the terms of the GNU Lesser General Public Licence as published 00012 * by the Free Software Foundation. 00013 * See the COPYING file for more information. 00014 * 00015 **********************************************************************/ 00016 00017 #ifndef GEOS_GEOM_UTIL_COMPONENTCOORDINATEEXTRACTER_H 00018 #define GEOS_GEOM_UTIL_COMPONENTCOORDINATEEXTRACTER_H 00019 00020 #include <vector> 00021 00022 #include <geos/geom/GeometryComponentFilter.h> 00023 #include <geos/geom/Geometry.h> // to be removed when we have the .inl 00024 #include <geos/geom/Coordinate.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/geom/Point.h> // to be removed when we have the .inl 00027 //#include <geos/platform.h> 00028 00029 namespace geos { 00030 namespace geom { // geos::geom 00031 namespace util { // geos::geom::util 00032 00039 class ComponentCoordinateExtracter : public GeometryComponentFilter 00040 { 00041 private: 00042 00043 Coordinate::ConstVect &comps; 00044 00045 public: 00053 static void getCoordinates(const Geometry &geom, std::vector<const Coordinate*> &ret) 00054 { 00055 ComponentCoordinateExtracter cce(ret); 00056 geom.apply_ro(&cce); 00057 } 00058 00063 ComponentCoordinateExtracter( std::vector<const Coordinate*> &newComps) 00064 : 00065 comps(newComps) 00066 {} 00067 00068 void filter_rw( Geometry * geom) 00069 { 00070 if ( geom->getGeometryTypeId() == geos::geom::GEOS_LINEARRING 00071 || geom->getGeometryTypeId() == geos::geom::GEOS_LINESTRING 00072 || geom->getGeometryTypeId() == geos::geom::GEOS_POINT ) 00073 comps.push_back( geom->getCoordinate() ); 00074 //if ( typeid( *geom ) == typeid( LineString ) 00075 // || typeid( *geom ) == typeid( Point ) ) 00076 //if ( const Coordinate *ls=dynamic_cast<const Coordinate *>(geom) ) 00077 // comps.push_back(ls); 00078 } 00079 00080 void filter_ro( const Geometry * geom) 00081 { 00082 //if ( typeid( *geom ) == typeid( LineString ) 00083 // || typeid( *geom ) == typeid( Point ) ) 00084 if ( geom->getGeometryTypeId() == geos::geom::GEOS_LINEARRING 00085 || geom->getGeometryTypeId() == geos::geom::GEOS_LINESTRING 00086 || geom->getGeometryTypeId() == geos::geom::GEOS_POINT ) 00087 comps.push_back( geom->getCoordinate() ); 00088 //if ( const Coordinate *ls=dynamic_cast<const Coordinate *>(geom) ) 00089 // comps.push_back(ls); 00090 } 00091 00092 }; 00093 00094 } // namespace geos.geom.util 00095 } // namespace geos.geom 00096 } // namespace geos 00097 00098 #endif //GEOS_GEOM_UTIL_COMPONENTCOORDINATEEXTRACTER_H 00099 00100 /********************************************************************** 00101 * $Log$ 00102 * 00103 **********************************************************************/