Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

UniqueCoordinateArrayFilter.h

00001 /**********************************************************************
00002  * $Id: UniqueCoordinateArrayFilter.h 2556 2009-06-06 22:22:28Z strk $
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 namespace geos {
00030 namespace util { // geos::util
00031 
00032 /*
00033  *  A CoordinateFilter that fills a vector of Coordinate const pointers.
00034  *  The set of coordinates contains no duplicate points.
00035  *
00036  *  Last port: util/UniqueCoordinateArrayFilter.java rev. 1.17
00037  */
00038 class GEOS_DLL UniqueCoordinateArrayFilter: public geom::CoordinateFilter {
00039 
00040 private:
00041         geom::Coordinate::ConstVect &pts;       // target set reference
00042         geom::Coordinate::ConstSet uniqPts;     // unique points set
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 };
00076 
00077 } // namespace geos::util
00078 } // namespace geos
00079 
00080 #endif // GEOS_UTIL_UNIQUECOORDINATEARRAYFILTER_H
00081 
00082 /**********************************************************************
00083  * $Log$
00084  * Revision 1.4  2006/06/19 23:33:03  strk
00085  * Don't *require* CoordinateFilters to define both read-only and read-write methods.
00086  *
00087  * Revision 1.3  2006/06/12 10:10:39  strk
00088  * Fixed getGeometryN() to take size_t rather then int, changed unsigned int parameters to size_t.
00089  *
00090  * Revision 1.2  2006/04/10 09:21:23  mloskot
00091  * Added new test for UniqueCoordinateArrayFilter class. Small fixes related to signed/unsigned comparison.
00092  *
00093  * Revision 1.1  2006/03/09 16:46:49  strk
00094  * geos::geom namespace definition, first pass at headers split
00095  *
00096  **********************************************************************/

Generated on Thu Jun 11 06:17:02 2009 for GEOS by  doxygen 1.4.4