# LinearComponentExtracter.h

    00001 /**********************************************************************
    00002  * $Id: LinearComponentExtracter.h 1820 2006-09-06 16:54:23Z mloskot $
    00003  *
    00004  * GEOS - Geometry Engine Open Source
    00005  * http://geos.refractions.net
    00006  *
    00007  * Copyright (C) 2001-2002 Vivid Solutions Inc.
    00008  * Copyright (C) 2006 Refractions Research Inc.
    00009  *
    00010  * This is free software; you can redistribute and/or modify it under
    00011  * the terms of the GNU Lesser General Public Licence as published
    00012  * by the Free Software Foundation.
    00013  * See the COPYING file for more information.
    00014  *
    00015  **********************************************************************/
    00016
    00017 #ifndef GEOS_GEOM_UTIL_LINEARCOMPONENTEXTRACTER_H
    00018 #define GEOS_GEOM_UTIL_LINEARCOMPONENTEXTRACTER_H
    00019
    00020 #include <vector>
    00021
    00022 #include <geos/geom/GeometryComponentFilter.h>
    00023 #include <geos/geom/Geometry.h> // to be removed when we have the .inl
    00024 #include <geos/geom/LineString.h> // to be removed when we have the .inl
    00025 //#include <geos/platform.h>
    00026
    00027 namespace geos {
    00028 namespace geom { // geos.geom
    00029 namespace util { // geos.geom.util
    00030
    00034 class LinearComponentExtracter: public GeometryComponentFilter {
    00035
    00036 private:
    00037
    00038         LineString::ConstVect &comps;
    00039
    00040 public:
    00048         static void getLines(const Geometry &geom, std::vector<const LineString*> &ret)
    00049         {
    00050                 LinearComponentExtracter lce(ret);
    00051                 geom.apply_ro(&lce);
    00052         }
    00053
    00058         LinearComponentExtracter(std::vector<const LineString*> &newComps)
    00059                 :
    00060                 comps(newComps)
    00061                 {}
    00062
    00063         void filter_rw(Geometry *geom)
    00064         {
    00065 if ( const LineString *ls=dynamic_cast<const LineString *>(geom) )
    00066                 comps.push_back(ls);
    00067         }
    00068
    00069         void filter_ro(const Geometry *geom)
    00070         {
    00071 if ( const LineString *ls=dynamic_cast<const LineString *>(geom) )
    00072                 comps.push_back(ls);
    00073         }
    00074
    00075 };
    00076
    00077 } // namespace geos.geom.util
    00078 } // namespace geos.geom
    00079 } // namespace geos
    00080
    00081 #endif
    00082
    00083 /**********************************************************************
    00084  * $Log$
    00085  * Revision 1.1  2006/03/09 16:46:49  strk
    00086  * geos::geom namespace definition, first pass at headers split
    00087  *
    00088  **********************************************************************/