GEOS: UniqueCoordinateArrayFilter.h Source File

GEOS 3.3.8

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

UniqueCoordinateArrayFilter.h
1 /**********************************************************************
2 * $Id: UniqueCoordinateArrayFilter.h 2958 2010-03-29 11:29:40Z mloskot $
3 *
4 * GEOS - Geometry Engine Open Source
5 * http://geos.refractions.net
6 *
7 * Copyright (C) 2001-2002 Vivid Solutions Inc.
8 * Copyright (C) 2006 Refractions Research Inc.
9 *
10 * This is free software; you can redistribute and/or modify it under
11 * the terms of the GNU Lesser General Public Licence as published
12 * by the Free Software Foundation.
13 * See the COPYING file for more information.
14 *
15 **********************************************************************/
16
17 #ifndef GEOS_UTIL_UNIQUECOORDINATEARRAYFILTER_H
18 #define GEOS_UTIL_UNIQUECOORDINATEARRAYFILTER_H
19
20 #include <geos/export.h>
21 #include <cassert>
22 #include <set>
23 #include <vector>
24
25 #include <geos/geom/CoordinateFilter.h>
26 #include <geos/geom/CoordinateSequence.h>
27 #include <geos/geom/Coordinate.h>
28
29 #ifdef _MSC_VER
30 #pragma warning(push)
31 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
32 #endif
33
34 namespace geos {
35 namespace util { // geos::util
36
37 /*
38 * A CoordinateFilter that fills a vector of Coordinate const pointers.
39 * The set of coordinates contains no duplicate points.
40 *
41 * Last port: util/UniqueCoordinateArrayFilter.java rev. 1.17
42 */
43 class GEOS_DLL UniqueCoordinateArrayFilter: public geom::CoordinateFilter
44 {
45 public:
51 UniqueCoordinateArrayFilter(geom::Coordinate::ConstVect &target)
52 : pts(target)
53 {}
54
61 virtual ~UniqueCoordinateArrayFilter() {}
62
68 virtual void filter_ro(const geom::Coordinate *coord)
69 {
70 if ( uniqPts.insert(coord).second )
71 {
72 pts.push_back(coord);
73 }
74 }
75
76 private:
77 geom::Coordinate::ConstVect &pts; // target set reference
78 geom::Coordinate::ConstSet uniqPts; // unique points set
79
80 // Declare type as noncopyable
81 UniqueCoordinateArrayFilter(const UniqueCoordinateArrayFilter& other);
82 UniqueCoordinateArrayFilter& operator=(const UniqueCoordinateArrayFilter& rhs);
83 };
84
85 } // namespace geos::util
86 } // namespace geos
87
88 #ifdef _MSC_VER
89 #pragma warning(pop)
90 #endif
91
92 #endif // GEOS_UTIL_UNIQUECOORDINATEARRAYFILTER_H
93
94 /**********************************************************************
95 * $Log$
96 * Revision 1.4 2006/06/19 23:33:03 strk
97 * Don't *require* CoordinateFilters to define both read-only and read-write methods.
98 *
99 * Revision 1.3 2006/06/12 10:10:39 strk
100 * Fixed getGeometryN() to take size_t rather then int, changed unsigned int parameters to size_t.
101 *
102 * Revision 1.2 2006/04/10 09:21:23 mloskot
103 * Added new test for UniqueCoordinateArrayFilter class. Small fixes related to signed/unsigned comparison.
104 *
105 * Revision 1.1 2006/03/09 16:46:49 strk
106 * geos::geom namespace definition, first pass at headers split
107 *
108 **********************************************************************/