GEOS  3.4.2
PointExtracter.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_GEOM_UTIL_POINTEXTRACTER_H
17 #define GEOS_GEOM_UTIL_POINTEXTRACTER_H
18 
19 #include <geos/export.h>
20 #include <geos/geom/GeometryFilter.h>
21 #include <geos/geom/Point.h>
22 #include <geos/platform.h>
23 #include <vector>
24 
25 namespace geos {
26 namespace geom { // geos.geom
27 namespace util { // geos.geom.util
28 
32 class GEOS_DLL PointExtracter: public GeometryFilter {
33 
34 public:
41  static void getPoints(const Geometry &geom, Point::ConstVect &ret)
42  {
43  PointExtracter pe(ret);
44  geom.apply_ro(&pe);
45  }
46 
52  :
53  comps(newComps)
54  {}
55 
56  void filter_rw(Geometry *geom)
57  {
58 if ( const Point *p=dynamic_cast<const Point *>(geom) )
59  comps.push_back(p);
60  }
61 
62  void filter_ro(const Geometry *geom)
63  {
64 if ( const Point *p=dynamic_cast<const Point *>(geom) )
65  comps.push_back(p);
66  }
67 
68 private:
69 
70  Point::ConstVect& comps;
71 
72  // Declare type as noncopyable
73  PointExtracter(const PointExtracter& other);
74  PointExtracter& operator=(const PointExtracter& rhs);
75 };
76 
77 } // namespace geos.geom.util
78 } // namespace geos.geom
79 } // namespace geos
80 
81 #endif
Geometry classes support the concept of applying a Geometry filter to the Geometry.
Definition: GeometryFilter.h:48
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:167
PointExtracter(Point::ConstVect &newComps)
Definition: PointExtracter.h:51
std::vector< const Point * > ConstVect
A vector of const Point pointers.
Definition: Point.h:75
Definition: PointExtracter.h:32
Definition: Point.h:67
static void getPoints(const Geometry &geom, Point::ConstVect &ret)
Definition: PointExtracter.h:41