GEOS
3.3.1
|
00001 /********************************************************************** 00002 * $Id: UniqueCoordinateArrayFilter.h 2958 2010-03-29 11:29:40Z 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_UTIL_UNIQUECOORDINATEARRAYFILTER_H 00018 #define GEOS_UTIL_UNIQUECOORDINATEARRAYFILTER_H 00019 00020 #include <geos/export.h> 00021 #include <cassert> 00022 #include <set> 00023 #include <vector> 00024 00025 #include <geos/geom/CoordinateFilter.h> 00026 #include <geos/geom/CoordinateSequence.h> 00027 #include <geos/geom/Coordinate.h> 00028 00029 #ifdef _MSC_VER 00030 #pragma warning(push) 00031 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class 00032 #endif 00033 00034 namespace geos { 00035 namespace util { // geos::util 00036 00037 /* 00038 * A CoordinateFilter that fills a vector of Coordinate const pointers. 00039 * The set of coordinates contains no duplicate points. 00040 * 00041 * Last port: util/UniqueCoordinateArrayFilter.java rev. 1.17 00042 */ 00043 class GEOS_DLL UniqueCoordinateArrayFilter: public geom::CoordinateFilter 00044 { 00045 public: 00051 UniqueCoordinateArrayFilter(geom::Coordinate::ConstVect &target) 00052 : pts(target) 00053 {} 00054 00061 virtual ~UniqueCoordinateArrayFilter() {} 00062 00068 virtual void filter_ro(const geom::Coordinate *coord) 00069 { 00070 if ( uniqPts.insert(coord).second ) 00071 { 00072 pts.push_back(coord); 00073 } 00074 } 00075 00076 private: 00077 geom::Coordinate::ConstVect &pts; // target set reference 00078 geom::Coordinate::ConstSet uniqPts; // unique points set 00079 00080 // Declare type as noncopyable 00081 UniqueCoordinateArrayFilter(const UniqueCoordinateArrayFilter& other); 00082 UniqueCoordinateArrayFilter& operator=(const UniqueCoordinateArrayFilter& rhs); 00083 }; 00084 00085 } // namespace geos::util 00086 } // namespace geos 00087 00088 #ifdef _MSC_VER 00089 #pragma warning(pop) 00090 #endif 00091 00092 #endif // GEOS_UTIL_UNIQUECOORDINATEARRAYFILTER_H 00093 00094 /********************************************************************** 00095 * $Log$ 00096 * Revision 1.4 2006/06/19 23:33:03 strk 00097 * Don't *require* CoordinateFilters to define both read-only and read-write methods. 00098 * 00099 * Revision 1.3 2006/06/12 10:10:39 strk 00100 * Fixed getGeometryN() to take size_t rather then int, changed unsigned int parameters to size_t. 00101 * 00102 * Revision 1.2 2006/04/10 09:21:23 mloskot 00103 * Added new test for UniqueCoordinateArrayFilter class. Small fixes related to signed/unsigned comparison. 00104 * 00105 * Revision 1.1 2006/03/09 16:46:49 strk 00106 * geos::geom namespace definition, first pass at headers split 00107 * 00108 **********************************************************************/