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_POINTEXTRACTER_H 00017 #define GEOS_GEOM_UTIL_POINTEXTRACTER_H 00018 00019 #include <geos/export.h> 00020 #include <geos/geom/GeometryFilter.h> 00021 #include <geos/geom/Point.h> 00022 #include <geos/platform.h> 00023 #include <vector> 00024 00025 namespace geos { 00026 namespace geom { // geos.geom 00027 namespace util { // geos.geom.util 00028 00032 class GEOS_DLL PointExtracter: public GeometryFilter { 00033 00034 public: 00041 static void getPoints(const Geometry &geom, Point::ConstVect &ret) 00042 { 00043 PointExtracter pe(ret); 00044 geom.apply_ro(&pe); 00045 } 00046 00051 PointExtracter(Point::ConstVect& newComps) 00052 : 00053 comps(newComps) 00054 {} 00055 00056 void filter_rw(Geometry *geom) 00057 { 00058 if ( const Point *p=dynamic_cast<const Point *>(geom) ) 00059 comps.push_back(p); 00060 } 00061 00062 void filter_ro(const Geometry *geom) 00063 { 00064 if ( const Point *p=dynamic_cast<const Point *>(geom) ) 00065 comps.push_back(p); 00066 } 00067 00068 private: 00069 00070 Point::ConstVect& comps; 00071 00072 // Declare type as noncopyable 00073 PointExtracter(const PointExtracter& other); 00074 PointExtracter& operator=(const PointExtracter& rhs); 00075 }; 00076 00077 } // namespace geos.geom.util 00078 } // namespace geos.geom 00079 } // namespace geos 00080 00081 #endif