GEOS  3.9.1dev
UniqueCoordinateArrayFilter.h
Go to the documentation of this file.
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 
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  */
43 public:
50  : pts(target)
51  {}
52 
60 
66  void
67  filter_ro(const geom::Coordinate* coord) override
68  {
69  if(uniqPts.insert(coord).second) {
70  pts.push_back(coord);
71  }
72  }
73 
74 private:
75  geom::Coordinate::ConstVect& pts; // target set reference
76  geom::Coordinate::ConstSet uniqPts; // unique points set
77 
78  // Declare type as noncopyable
80  UniqueCoordinateArrayFilter& operator=(const UniqueCoordinateArrayFilter& rhs) = delete;
81 };
82 
83 } // namespace geos::util
84 } // namespace geos
85 
86 #ifdef _MSC_VER
87 #pragma warning(pop)
88 #endif
89 
90 #endif // GEOS_UTIL_UNIQUECOORDINATEARRAYFILTER_H
#define GEOS_DLL
Definition: export.h:28
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
std::set< const Coordinate *, CoordinateLessThen > ConstSet
A set of const Coordinate pointers.
Definition: Coordinate.h:68
Geometry classes support the concept of applying a coordinate filter to every coordinate in the Geome...
std::vector< const Coordinate * > ConstVect
A vector of const Coordinate pointers.
Definition: Coordinate.h:71
UniqueCoordinateArrayFilter(geom::Coordinate::ConstVect &target)
Basic namespace for all GEOS functionalities.
void filter_ro(const geom::Coordinate *coord) override