UniqueCoordinateArrayFilter.h

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

Generated on Fri Mar 27 04:53:04 2009 for GEOS by  doxygen 1.5.4