GEOS  3.4.2
UniqueCoordinateArrayFilter.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2001-2002 Vivid Solutions Inc.
7  * Copyright (C) 2006 Refractions Research Inc.
8  *
9  * This is free software; you can redistribute and/or modify it under
10  * the terms of the GNU Lesser General Public Licence as published
11  * by the Free Software Foundation.
12  * See the COPYING file for more information.
13  *
14  **********************************************************************/
15 
16 #ifndef GEOS_UTIL_UNIQUECOORDINATEARRAYFILTER_H
17 #define GEOS_UTIL_UNIQUECOORDINATEARRAYFILTER_H
18 
19 #include <geos/export.h>
20 #include <cassert>
21 #include <set>
22 #include <vector>
23 
24 #include <geos/geom/CoordinateFilter.h>
25 #include <geos/geom/CoordinateSequence.h>
26 #include <geos/geom/Coordinate.h>
27 
28 #ifdef _MSC_VER
29 #pragma warning(push)
30 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
31 #endif
32 
33 namespace geos {
34 namespace util { // geos::util
35 
36 /*
37  * A CoordinateFilter that fills a vector of Coordinate const pointers.
38  * The set of coordinates contains no duplicate points.
39  *
40  * Last port: util/UniqueCoordinateArrayFilter.java rev. 1.17
41  */
42 class GEOS_DLL UniqueCoordinateArrayFilter: public geom::CoordinateFilter
43 {
44 public:
50  UniqueCoordinateArrayFilter(geom::Coordinate::ConstVect &target)
51  : pts(target)
52  {}
53 
60  virtual ~UniqueCoordinateArrayFilter() {}
61 
67  virtual void filter_ro(const geom::Coordinate *coord)
68  {
69  if ( uniqPts.insert(coord).second )
70  {
71  pts.push_back(coord);
72  }
73  }
74 
75 private:
76  geom::Coordinate::ConstVect &pts; // target set reference
77  geom::Coordinate::ConstSet uniqPts; // unique points set
78 
79  // Declare type as noncopyable
80  UniqueCoordinateArrayFilter(const UniqueCoordinateArrayFilter& other);
81  UniqueCoordinateArrayFilter& operator=(const UniqueCoordinateArrayFilter& rhs);
82 };
83 
84 } // namespace geos::util
85 } // namespace geos
86 
87 #ifdef _MSC_VER
88 #pragma warning(pop)
89 #endif
90 
91 #endif // GEOS_UTIL_UNIQUECOORDINATEARRAYFILTER_H
std::vector< const Coordinate * > ConstVect
A vector of const Coordinate pointers.
Definition: Coordinate.h:71
std::set< const Coordinate *, CoordinateLessThen > ConstSet
A set of const Coordinate pointers.
Definition: Coordinate.h:68