GEOS 3.4.2

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

- File List

ComponentCoordinateExtracter.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_COMPONENTCOORDINATEEXTRACTER_H
17 #define GEOS_GEOM_UTIL_COMPONENTCOORDINATEEXTRACTER_H
18
19 #include <vector>
20
21 #include <geos/geom/GeometryComponentFilter.h>
22 #include <geos/geom/Geometry.h> // to be removed when we have the .inl
23 #include <geos/geom/Coordinate.h> // to be removed when we have the .inl
24 #include <geos/geom/LineString.h> // to be removed when we have the .inl
25 #include <geos/geom/Point.h> // to be removed when we have the .inl
26 //#include <geos/platform.h>
27
28 namespace geos {
29 namespace geom { // geos::geom
30 namespace util { // geos::geom::util
31
38 class ComponentCoordinateExtracter : public GeometryComponentFilter
39 {
40 public:
48 static void getCoordinates(const Geometry &geom, std::vector<const Coordinate*> &ret)
49 {
50 ComponentCoordinateExtracter cce(ret);
51 geom.apply_ro(&cce);
52 }
53
58 ComponentCoordinateExtracter( std::vector<const Coordinate*> &newComps)
59 :
60 comps(newComps)
61 {}
62
63 void filter_rw( Geometry * geom)
64 {
65 if ( geom->getGeometryTypeId() == geos::geom::GEOS_LINEARRING
66 || geom->getGeometryTypeId() == geos::geom::GEOS_LINESTRING
67 || geom->getGeometryTypeId() == geos::geom::GEOS_POINT )
68 comps.push_back( geom->getCoordinate() );
69 //if ( typeid( *geom ) == typeid( LineString )
70 // || typeid( *geom ) == typeid( Point ) )
71 //if ( const Coordinate *ls=dynamic_cast<const Coordinate *>(geom) )
72 // comps.push_back(ls);
73 }
74
75 void filter_ro( const Geometry * geom)
76 {
77 //if ( typeid( *geom ) == typeid( LineString )
78 // || typeid( *geom ) == typeid( Point ) )
79 if ( geom->getGeometryTypeId() == geos::geom::GEOS_LINEARRING
80 || geom->getGeometryTypeId() == geos::geom::GEOS_LINESTRING
81 || geom->getGeometryTypeId() == geos::geom::GEOS_POINT )
82 comps.push_back( geom->getCoordinate() );
83 //if ( const Coordinate *ls=dynamic_cast<const Coordinate *>(geom) )
84 // comps.push_back(ls);
85 }
86
87 private:
88
89 Coordinate::ConstVect &comps;
90
91 // Declare type as noncopyable
92 ComponentCoordinateExtracter(const ComponentCoordinateExtracter& other);
93 ComponentCoordinateExtracter& operator=(const ComponentCoordinateExtracter& rhs);
94 };
95
96 } // namespace geos.geom.util
97 } // namespace geos.geom
98 } // namespace geos
99
100 #endif //GEOS_GEOM_UTIL_COMPONENTCOORDINATEEXTRACTER_H