- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

# UniqueCoordinateArrayFilter.h

    00001 /**********************************************************************
    00002  * $Id: UniqueCoordinateArrayFilter.h 2786 2009-12-03 19:57:24Z 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 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 public:
    00046         UniqueCoordinateArrayFilter(geom::Coordinate::ConstVect &target)
    00047                 : pts(target)
    00048         {}
    00049
    00056         virtual ~UniqueCoordinateArrayFilter() {}
    00057
    00063         virtual void filter_ro(const geom::Coordinate *coord)
    00064         {
    00065                 if ( uniqPts.insert(coord).second )
    00066                 {
    00067                         pts.push_back(coord);
    00068                 }
    00069     }
    00070
    00071 private:
    00072         geom::Coordinate::ConstVect &pts;       // target set reference
    00073         geom::Coordinate::ConstSet uniqPts;     // unique points set
    00074
    00075     // Declare type as noncopyable
    00076     UniqueCoordinateArrayFilter(const UniqueCoordinateArrayFilter& other);
    00077     UniqueCoordinateArrayFilter& operator=(const UniqueCoordinateArrayFilter& rhs);
    00078 };
    00079
    00080 } // namespace geos::util
    00081 } // namespace geos
    00082
    00083 #endif // GEOS_UTIL_UNIQUECOORDINATEARRAYFILTER_H
    00084
    00085 /**********************************************************************
    00086  * $Log$
    00087  * Revision 1.4  2006/06/19 23:33:03  strk
    00088  * Don't *require* CoordinateFilters to define both read-only and read-write methods.
    00089  *
    00090  * Revision 1.3  2006/06/12 10:10:39  strk
    00091  * Fixed getGeometryN() to take size_t rather then int, changed unsigned int parameters to size_t.
    00092  *
    00093  * Revision 1.2  2006/04/10 09:21:23  mloskot
    00094  * Added new test for UniqueCoordinateArrayFilter class. Small fixes related to signed/unsigned comparison.
    00095  *
    00096  * Revision 1.1  2006/03/09 16:46:49  strk
    00097  * geos::geom namespace definition, first pass at headers split
    00098  *
    00099  **********************************************************************/