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

- File List

# ComponentCoordinateExtracter.h

    00001 /**********************************************************************
    00002  * $Id: ComponentCoordinateExtracter.h 2772 2009-12-03 19:30:54Z 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_COMPONENTCOORDINATEEXTRACTER_H
    00018 #define GEOS_GEOM_UTIL_COMPONENTCOORDINATEEXTRACTER_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/Coordinate.h> // to be removed when we have the .inl
    00025 #include <geos/geom/LineString.h> // to be removed when we have the .inl
    00026 #include <geos/geom/Point.h> // to be removed when we have the .inl
    00027 //#include <geos/platform.h>
    00028
    00029 namespace geos {
    00030 namespace geom { // geos::geom
    00031 namespace util { // geos::geom::util
    00032
    00039 class ComponentCoordinateExtracter : public GeometryComponentFilter
    00040 {
    00041 public:
    00049         static void getCoordinates(const Geometry &geom, std::vector<const Coordinate*> &ret)
    00050         {
    00051                 ComponentCoordinateExtracter cce(ret);
    00052                 geom.apply_ro(&cce);
    00053         }
    00054
    00059         ComponentCoordinateExtracter( std::vector<const Coordinate*> &newComps)
    00060                 :
    00061                 comps(newComps)
    00062                 {}
    00063
    00064         void filter_rw( Geometry * geom)
    00065         {
    00066                 if (    geom->getGeometryTypeId() == geos::geom::GEOS_LINEARRING
    00067                         ||      geom->getGeometryTypeId() == geos::geom::GEOS_LINESTRING
    00068                         ||      geom->getGeometryTypeId() == geos::geom::GEOS_POINT )
    00069                         comps.push_back( geom->getCoordinate() );
    00070                 //if (  typeid( *geom ) == typeid( LineString )
    00071                 //      ||      typeid( *geom ) == typeid( Point ) )
    00072                 //if ( const Coordinate *ls=dynamic_cast<const Coordinate *>(geom) )
    00073                 //      comps.push_back(ls);
    00074         }
    00075
    00076         void filter_ro( const Geometry * geom)
    00077         {
    00078                 //if (  typeid( *geom ) == typeid( LineString )
    00079                 //      ||      typeid( *geom ) == typeid( Point ) )
    00080                 if (    geom->getGeometryTypeId() == geos::geom::GEOS_LINEARRING
    00081                         ||      geom->getGeometryTypeId() == geos::geom::GEOS_LINESTRING
    00082                         ||      geom->getGeometryTypeId() == geos::geom::GEOS_POINT )
    00083                         comps.push_back( geom->getCoordinate() );
    00084                 //if ( const Coordinate *ls=dynamic_cast<const Coordinate *>(geom) )
    00085                 //      comps.push_back(ls);
    00086         }
    00087
    00088 private:
    00089
    00090         Coordinate::ConstVect &comps;
    00091
    00092     // Declare type as noncopyable
    00093     ComponentCoordinateExtracter(const ComponentCoordinateExtracter& other);
    00094     ComponentCoordinateExtracter& operator=(const ComponentCoordinateExtracter& rhs);
    00095 };
    00096
    00097 } // namespace geos.geom.util
    00098 } // namespace geos.geom
    00099 } // namespace geos
    00100
    00101 #endif //GEOS_GEOM_UTIL_COMPONENTCOORDINATEEXTRACTER_H
    00102
    00103 /**********************************************************************
    00104  * $Log$
    00105  *
    00106  **********************************************************************/