GEOS  3.3.3
LinearComponentExtracter.h
1 /**********************************************************************
2  * $Id: LinearComponentExtracter.h 2772 2009-12-03 19:30:54Z 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_GEOM_UTIL_LINEARCOMPONENTEXTRACTER_H
18 #define GEOS_GEOM_UTIL_LINEARCOMPONENTEXTRACTER_H
19 
20 
21 #include <geos/export.h>
22 #include <vector>
23 
24 #include <geos/geom/GeometryComponentFilter.h>
25 #include <geos/geom/Geometry.h> // to be removed when we have the .inl
26 #include <geos/geom/LineString.h> // to be removed when we have the .inl
27 //#include <geos/platform.h>
28 
29 namespace geos {
30 namespace geom { // geos.geom
31 namespace util { // geos.geom.util
32 
37 
38 private:
39 
40  LineString::ConstVect &comps;
41 
42  // Declare type as noncopyable
45 
46 public:
54  static void getLines(const Geometry &geom, std::vector<const LineString*> &ret)
55  {
56  LinearComponentExtracter lce(ret);
57  geom.apply_ro(&lce);
58  }
59 
64  LinearComponentExtracter(std::vector<const LineString*> &newComps)
65  :
66  comps(newComps)
67  {}
68 
69  void filter_rw(Geometry *geom)
70  {
71 if ( const LineString *ls=dynamic_cast<const LineString *>(geom) )
72  comps.push_back(ls);
73  }
74 
75  void filter_ro(const Geometry *geom)
76  {
77 if ( const LineString *ls=dynamic_cast<const LineString *>(geom) )
78  comps.push_back(ls);
79  }
80 
81 };
82 
83 } // namespace geos.geom.util
84 } // namespace geos.geom
85 } // namespace geos
86 
87 #endif
88 
89 /**********************************************************************
90  * $Log$
91  * Revision 1.1 2006/03/09 16:46:49 strk
92  * geos::geom namespace definition, first pass at headers split
93  *
94  **********************************************************************/