GEOS 3.12.0
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
32namespace geos {
33namespace 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 */
41class GEOS_DLL UniqueCoordinateArrayFilter : public geom::CoordinateInspector<UniqueCoordinateArrayFilter> {
42public:
48 UniqueCoordinateArrayFilter(std::vector<const geom::Coordinate*>& target)
49 : pts(target)
50 {}
51
58 ~UniqueCoordinateArrayFilter() override {}
59
65 template<typename CoordType>
66 void filter(const CoordType* coord)
67 {
68 if(uniqPts.insert(coord).second) {
69 // TODO make `pts` a CoordinateSequence rather than coercing the type
70 pts.push_back(coord);
71 }
72 }
73
74 void filter(const geom::CoordinateXY*) {
75 assert(0); // not supported
76 }
77
78
79 void filter(const geom::CoordinateXYM*) {
80 assert(0); // not supported
81 }
82
83private:
84 std::vector<const geom::Coordinate*>& pts; // target set reference
85 std::set<const geom::CoordinateXY*, geom::CoordinateLessThan> uniqPts; // unique points set
86
87 // Declare type as noncopyable
88 UniqueCoordinateArrayFilter(const UniqueCoordinateArrayFilter& other) = delete;
89 UniqueCoordinateArrayFilter& operator=(const UniqueCoordinateArrayFilter& rhs) = delete;
90};
91
92} // namespace geos::util
93} // namespace geos
94
95#ifdef _MSC_VER
96#pragma warning(pop)
97#endif
98
Basic namespace for all GEOS functionalities.
Definition geos.h:39