GEOS  3.11.0rc0
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 #pragma once
17 
18 #include <geos/export.h>
19 #include <cassert>
20 #include <set>
21 #include <vector>
22 
23 #include <geos/geom/CoordinateFilter.h>
24 #include <geos/geom/CoordinateSequence.h>
25 #include <geos/geom/Coordinate.h>
26 
27 #ifdef _MSC_VER
28 #pragma warning(push)
29 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
30 #endif
31 
32 namespace geos {
33 namespace util { // geos::util
34 
35 /*
36  * A CoordinateFilter that fills a vector of Coordinate const pointers.
37  * The set of coordinates contains no duplicate points.
38  *
39  * Last port: util/UniqueCoordinateArrayFilter.java rev. 1.17
40  */
41 class GEOS_DLL UniqueCoordinateArrayFilter: public geom::CoordinateFilter {
42 public:
48  UniqueCoordinateArrayFilter(geom::Coordinate::ConstVect& target)
49  : pts(target)
50  {}
51 
58  ~UniqueCoordinateArrayFilter() override {}
59 
65  void
66  filter_ro(const geom::Coordinate* coord) override
67  {
68  if(uniqPts.insert(coord).second) {
69  pts.push_back(coord);
70  }
71  }
72 
73 private:
74  geom::Coordinate::ConstVect& pts; // target set reference
75  geom::Coordinate::ConstSet uniqPts; // unique points set
76 
77  // Declare type as noncopyable
78  UniqueCoordinateArrayFilter(const UniqueCoordinateArrayFilter& other) = delete;
79  UniqueCoordinateArrayFilter& operator=(const UniqueCoordinateArrayFilter& rhs) = delete;
80 };
81 
82 } // namespace geos::util
83 } // namespace geos
84 
85 #ifdef _MSC_VER
86 #pragma warning(pop)
87 #endif
88 
std::vector< const Coordinate * > ConstVect
A vector of const Coordinate pointers.
Definition: Coordinate.h:69
std::set< const Coordinate *, CoordinateLessThen > ConstSet
A set of const Coordinate pointers.
Definition: Coordinate.h:66
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25