GEOS 3.9.1
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
33namespace geos {
34namespace 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 */
42class GEOS_DLL UniqueCoordinateArrayFilter: public geom::CoordinateFilter {
43public:
49 UniqueCoordinateArrayFilter(geom::Coordinate::ConstVect& target)
50 : pts(target)
51 {}
52
59 ~UniqueCoordinateArrayFilter() override {}
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
74private:
75 geom::Coordinate::ConstVect& pts; // target set reference
76 geom::Coordinate::ConstSet uniqPts; // unique points set
77
78 // Declare type as noncopyable
79 UniqueCoordinateArrayFilter(const UniqueCoordinateArrayFilter& other) = delete;
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
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26