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_UTIL_UNIQUECOORDINATEARRAYFILTER_H 00017 #define GEOS_UTIL_UNIQUECOORDINATEARRAYFILTER_H 00018 00019 #include <geos/export.h> 00020 #include <cassert> 00021 #include <set> 00022 #include <vector> 00023 00024 #include <geos/geom/CoordinateFilter.h> 00025 #include <geos/geom/CoordinateSequence.h> 00026 #include <geos/geom/Coordinate.h> 00027 00028 #ifdef _MSC_VER 00029 #pragma warning(push) 00030 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class 00031 #endif 00032 00033 namespace geos { 00034 namespace util { // geos::util 00035 00036 /* 00037 * A CoordinateFilter that fills a vector of Coordinate const pointers. 00038 * The set of coordinates contains no duplicate points. 00039 * 00040 * Last port: util/UniqueCoordinateArrayFilter.java rev. 1.17 00041 */ 00042 class GEOS_DLL UniqueCoordinateArrayFilter: public geom::CoordinateFilter 00043 { 00044 public: 00050 UniqueCoordinateArrayFilter(geom::Coordinate::ConstVect &target) 00051 : pts(target) 00052 {} 00053 00060 virtual ~UniqueCoordinateArrayFilter() {} 00061 00067 virtual void filter_ro(const geom::Coordinate *coord) 00068 { 00069 if ( uniqPts.insert(coord).second ) 00070 { 00071 pts.push_back(coord); 00072 } 00073 } 00074 00075 private: 00076 geom::Coordinate::ConstVect &pts; // target set reference 00077 geom::Coordinate::ConstSet uniqPts; // unique points set 00078 00079 // Declare type as noncopyable 00080 UniqueCoordinateArrayFilter(const UniqueCoordinateArrayFilter& other); 00081 UniqueCoordinateArrayFilter& operator=(const UniqueCoordinateArrayFilter& rhs); 00082 }; 00083 00084 } // namespace geos::util 00085 } // namespace geos 00086 00087 #ifdef _MSC_VER 00088 #pragma warning(pop) 00089 #endif 00090 00091 #endif // GEOS_UTIL_UNIQUECOORDINATEARRAYFILTER_H