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_COMPONENTCOORDINATEEXTRACTER_H 00017 #define GEOS_GEOM_UTIL_COMPONENTCOORDINATEEXTRACTER_H 00018 00019 #include <vector> 00020 00021 #include <geos/geom/GeometryComponentFilter.h> 00022 #include <geos/geom/Geometry.h> // to be removed when we have the .inl 00023 #include <geos/geom/Coordinate.h> // to be removed when we have the .inl 00024 #include <geos/geom/LineString.h> // to be removed when we have the .inl 00025 #include <geos/geom/Point.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 00038 class ComponentCoordinateExtracter : public GeometryComponentFilter 00039 { 00040 public: 00048 static void getCoordinates(const Geometry &geom, std::vector<const Coordinate*> &ret) 00049 { 00050 ComponentCoordinateExtracter cce(ret); 00051 geom.apply_ro(&cce); 00052 } 00053 00058 ComponentCoordinateExtracter( std::vector<const Coordinate*> &newComps) 00059 : 00060 comps(newComps) 00061 {} 00062 00063 void filter_rw( Geometry * geom) 00064 { 00065 if ( geom->getGeometryTypeId() == geos::geom::GEOS_LINEARRING 00066 || geom->getGeometryTypeId() == geos::geom::GEOS_LINESTRING 00067 || geom->getGeometryTypeId() == geos::geom::GEOS_POINT ) 00068 comps.push_back( geom->getCoordinate() ); 00069 //if ( typeid( *geom ) == typeid( LineString ) 00070 // || typeid( *geom ) == typeid( Point ) ) 00071 //if ( const Coordinate *ls=dynamic_cast<const Coordinate *>(geom) ) 00072 // comps.push_back(ls); 00073 } 00074 00075 void filter_ro( const Geometry * geom) 00076 { 00077 //if ( typeid( *geom ) == typeid( LineString ) 00078 // || typeid( *geom ) == typeid( Point ) ) 00079 if ( geom->getGeometryTypeId() == geos::geom::GEOS_LINEARRING 00080 || geom->getGeometryTypeId() == geos::geom::GEOS_LINESTRING 00081 || geom->getGeometryTypeId() == geos::geom::GEOS_POINT ) 00082 comps.push_back( geom->getCoordinate() ); 00083 //if ( const Coordinate *ls=dynamic_cast<const Coordinate *>(geom) ) 00084 // comps.push_back(ls); 00085 } 00086 00087 private: 00088 00089 Coordinate::ConstVect &comps; 00090 00091 // Declare type as noncopyable 00092 ComponentCoordinateExtracter(const ComponentCoordinateExtracter& other); 00093 ComponentCoordinateExtracter& operator=(const ComponentCoordinateExtracter& rhs); 00094 }; 00095 00096 } // namespace geos.geom.util 00097 } // namespace geos.geom 00098 } // namespace geos 00099 00100 #endif //GEOS_GEOM_UTIL_COMPONENTCOORDINATEEXTRACTER_H