From c34eb78818eb0caca3f4621639e190282b825f33 Mon Sep 17 00:00:00 2001 From: strk Date: Tue, 19 Nov 2013 08:26:42 +0000 Subject: [PATCH] Define ComponentCoordinateExtracter classes in .cpp file (#535) This is a workaround for a bug in GCC 4.4 failing to properly encode inheritance info in the shared library when the class is fully inlined. Patch by Daniel Komisar git-svn-id: http://svn.osgeo.org/geos/trunk@3960 5242fede-7e19-0410-aef8-94bd7d2200fb --- include/geos/geom/Geometry.h | 7 +-- .../geos/geom/util/ComponentCoordinateExtracter.h | 35 ++------------ include/geos/geom/util/LinearComponentExtracter.h | 24 ++-------- include/geos/geom/util/PointExtracter.h | 23 ++------- include/geos/geom/util/PolygonExtracter.h | 26 ++-------- src/geom/Geometry.cpp | 5 ++ src/geom/util/ComponentCoordinateExtracter.cpp | 37 ++++++++++++++ src/geom/util/LinearComponentExtracter.cpp | 51 ++++++++++++++++++++ src/geom/util/Makefile.am | 5 +- src/geom/util/PointExtracter.cpp | 56 ++++++++++++++++++++++ src/geom/util/PolygonExtracter.cpp | 54 +++++++++++++++++++++ 11 files changed, 225 insertions(+), 98 deletions(-) create mode 100644 src/geom/util/LinearComponentExtracter.cpp create mode 100644 src/geom/util/PointExtracter.cpp create mode 100644 src/geom/util/PolygonExtracter.cpp diff --git a/include/geos/geom/Geometry.h b/include/geos/geom/Geometry.h index 88eca837..44ec060a 100644 --- a/include/geos/geom/Geometry.h +++ b/include/geos/geom/Geometry.h @@ -832,13 +832,10 @@ private: int getClassSortIndex() const; - class GeometryChangedFilter : public GeometryComponentFilter + class GEOS_DLL GeometryChangedFilter : public GeometryComponentFilter { public: - void filter_rw(Geometry* geom) - { - geom->geometryChangedAction(); - } + void filter_rw(Geometry* geom); }; static GeometryChangedFilter geometryChangedFilter; diff --git a/include/geos/geom/util/ComponentCoordinateExtracter.h b/include/geos/geom/util/ComponentCoordinateExtracter.h index d4880b7c..14a0c0c3 100644 --- a/include/geos/geom/util/ComponentCoordinateExtracter.h +++ b/include/geos/geom/util/ComponentCoordinateExtracter.h @@ -45,44 +45,17 @@ public: * efficient to create a single ComponentCoordinateFilter instance * and pass it to multiple geometries. */ - static void getCoordinates(const Geometry &geom, std::vector &ret) - { - ComponentCoordinateExtracter cce(ret); - geom.apply_ro(&cce); - } + static void getCoordinates(const Geometry &geom, std::vector &ret); /** * Constructs a ComponentCoordinateFilter with a list in which * to store Coordinates found. */ - ComponentCoordinateExtracter( std::vector &newComps) - : - comps(newComps) - {} + ComponentCoordinateExtracter( std::vector &newComps); - void filter_rw( Geometry * geom) - { - if ( geom->getGeometryTypeId() == geos::geom::GEOS_LINEARRING - || geom->getGeometryTypeId() == geos::geom::GEOS_LINESTRING - || geom->getGeometryTypeId() == geos::geom::GEOS_POINT ) - comps.push_back( geom->getCoordinate() ); - //if ( typeid( *geom ) == typeid( LineString ) - // || typeid( *geom ) == typeid( Point ) ) - //if ( const Coordinate *ls=dynamic_cast(geom) ) - // comps.push_back(ls); - } + void filter_rw( Geometry * geom); - void filter_ro( const Geometry * geom) - { - //if ( typeid( *geom ) == typeid( LineString ) - // || typeid( *geom ) == typeid( Point ) ) - if ( geom->getGeometryTypeId() == geos::geom::GEOS_LINEARRING - || geom->getGeometryTypeId() == geos::geom::GEOS_LINESTRING - || geom->getGeometryTypeId() == geos::geom::GEOS_POINT ) - comps.push_back( geom->getCoordinate() ); - //if ( const Coordinate *ls=dynamic_cast(geom) ) - // comps.push_back(ls); - } + void filter_ro( const Geometry * geom); private: diff --git a/include/geos/geom/util/LinearComponentExtracter.h b/include/geos/geom/util/LinearComponentExtracter.h index 19cb4943..260cc0fb 100644 --- a/include/geos/geom/util/LinearComponentExtracter.h +++ b/include/geos/geom/util/LinearComponentExtracter.h @@ -50,32 +50,16 @@ public: * efficient to create a single LinearComponentExtracterFilter instance * and pass it to multiple geometries. */ - static void getLines(const Geometry &geom, std::vector &ret) - { - LinearComponentExtracter lce(ret); - geom.apply_ro(&lce); - } - + static void getLines(const Geometry &geom, std::vector &ret); /** * Constructs a LinearComponentExtracterFilter with a list in which * to store LineStrings found. */ - LinearComponentExtracter(std::vector &newComps) - : - comps(newComps) - {} + LinearComponentExtracter(std::vector &newComps); - void filter_rw(Geometry *geom) - { -if ( const LineString *ls=dynamic_cast(geom) ) - comps.push_back(ls); - } + void filter_rw(Geometry *geom); - void filter_ro(const Geometry *geom) - { -if ( const LineString *ls=dynamic_cast(geom) ) - comps.push_back(ls); - } + void filter_ro(const Geometry *geom); }; diff --git a/include/geos/geom/util/PointExtracter.h b/include/geos/geom/util/PointExtracter.h index b8b36463..150a5c64 100644 --- a/include/geos/geom/util/PointExtracter.h +++ b/include/geos/geom/util/PointExtracter.h @@ -38,32 +38,17 @@ public: * efficient to create a single PointExtracter filter instance * and pass it to multiple geometries. */ - static void getPoints(const Geometry &geom, Point::ConstVect &ret) - { - PointExtracter pe(ret); - geom.apply_ro(&pe); - } + static void getPoints(const Geometry &geom, Point::ConstVect &ret); /** * Constructs a PointExtracterFilter with a list in which * to store Points found. */ - PointExtracter(Point::ConstVect& newComps) - : - comps(newComps) - {} + PointExtracter(Point::ConstVect& newComps); - void filter_rw(Geometry *geom) - { -if ( const Point *p=dynamic_cast(geom) ) - comps.push_back(p); - } + void filter_rw(Geometry *geom); - void filter_ro(const Geometry *geom) - { -if ( const Point *p=dynamic_cast(geom) ) - comps.push_back(p); - } + void filter_ro(const Geometry *geom); private: diff --git a/include/geos/geom/util/PolygonExtracter.h b/include/geos/geom/util/PolygonExtracter.h index c33fec03..53330e16 100644 --- a/include/geos/geom/util/PolygonExtracter.h +++ b/include/geos/geom/util/PolygonExtracter.h @@ -40,35 +40,17 @@ public: * efficient to create a single PolygonExtracterFilter instance * and pass it to multiple geometries. */ - static void getPolygons(const Geometry &geom, std::vector& ret) - { - PolygonExtracter pe(ret); - geom.apply_ro(&pe); - } + static void getPolygons(const Geometry &geom, std::vector& ret); /** * Constructs a PolygonExtracterFilter with a list in which * to store Polygons found. */ - PolygonExtracter(std::vector& newComps) - : - comps(newComps) - {} + PolygonExtracter(std::vector& newComps); - void filter_rw(Geometry *geom) { - if ( const Polygon *p=dynamic_cast(geom) ) - { - comps.push_back(p); - } - } + void filter_rw(Geometry *geom); - void filter_ro(const Geometry *geom) - { - if ( const Polygon *p=dynamic_cast(geom) ) - { - comps.push_back(p); - } - } + void filter_ro(const Geometry *geom); private: diff --git a/src/geom/Geometry.cpp b/src/geom/Geometry.cpp index da61b800..121202af 100644 --- a/src/geom/Geometry.cpp +++ b/src/geom/Geometry.cpp @@ -687,6 +687,11 @@ Geometry::getClassSortIndex() const #endif } +void Geometry::GeometryChangedFilter::filter_rw(Geometry* geom) +{ + geom->geometryChangedAction(); +} + int Geometry::compare(vector a, vector b) const { diff --git a/src/geom/util/ComponentCoordinateExtracter.cpp b/src/geom/util/ComponentCoordinateExtracter.cpp index aff6fc40..88eed361 100644 --- a/src/geom/util/ComponentCoordinateExtracter.cpp +++ b/src/geom/util/ComponentCoordinateExtracter.cpp @@ -20,6 +20,43 @@ namespace geos { namespace geom { // geos.geom namespace util { // geos.geom.util + ComponentCoordinateExtracter::ComponentCoordinateExtracter( std::vector &newComps) + : + comps(newComps) + {} + + void ComponentCoordinateExtracter::filter_rw( Geometry * geom) + { + if ( geom->getGeometryTypeId() == geos::geom::GEOS_LINEARRING + || geom->getGeometryTypeId() == geos::geom::GEOS_LINESTRING + || geom->getGeometryTypeId() == geos::geom::GEOS_POINT ) + comps.push_back( geom->getCoordinate() ); + //if ( typeid( *geom ) == typeid( LineString ) + // || typeid( *geom ) == typeid( Point ) ) + //if ( const Coordinate *ls=dynamic_cast(geom) ) + // comps.push_back(ls); + } + + void ComponentCoordinateExtracter::filter_ro( const Geometry * geom) + { + //if ( typeid( *geom ) == typeid( LineString ) + // || typeid( *geom ) == typeid( Point ) ) + if ( geom->getGeometryTypeId() == geos::geom::GEOS_LINEARRING + || geom->getGeometryTypeId() == geos::geom::GEOS_LINESTRING + || geom->getGeometryTypeId() == geos::geom::GEOS_POINT ) + comps.push_back( geom->getCoordinate() ); + //if ( const Coordinate *ls=dynamic_cast(geom) ) + // comps.push_back(ls); + } + + + void ComponentCoordinateExtracter::getCoordinates(const Geometry &geom, std::vector &ret) + { + ComponentCoordinateExtracter cce(ret); + geom.apply_ro(&cce); + } + } // namespace geos.geom.util } // namespace geos.geom } // namespace geos + diff --git a/src/geom/util/LinearComponentExtracter.cpp b/src/geom/util/LinearComponentExtracter.cpp new file mode 100644 index 00000000..3492cdbb --- /dev/null +++ b/src/geom/util/LinearComponentExtracter.cpp @@ -0,0 +1,51 @@ +/********************************************************************** + * + * GEOS - Geometry Engine Open Source + * http://geos.osgeo.org + * + * Copyright (C) 2001-2002 Vivid Solutions Inc. + * Copyright (C) 2006 Refractions Research Inc. + * + * This is free software; you can redistribute and/or modify it under + * the terms of the GNU Lesser General Public Licence as published + * by the Free Software Foundation. + * See the COPYING file for more information. + * + **********************************************************************/ + +#include +#include + +#include +#include + +namespace geos { + namespace geom { // geos.geom + namespace util { // geos.geom.util + + LinearComponentExtracter::LinearComponentExtracter(std::vector &newComps) + : + comps(newComps) + {} + + void LinearComponentExtracter::getLines(const Geometry &geom, std::vector &ret) + { + LinearComponentExtracter lce(ret); + geom.apply_ro(&lce); + } + + void LinearComponentExtracter::filter_rw(Geometry *geom) + { + if ( const LineString *ls=dynamic_cast(geom) ) + comps.push_back(ls); + } + + void LinearComponentExtracter::filter_ro(const Geometry *geom) + { + if ( const LineString *ls=dynamic_cast(geom) ) + comps.push_back(ls); + } + + } + } +} diff --git a/src/geom/util/Makefile.am b/src/geom/util/Makefile.am index ef74ab82..aa17f35a 100644 --- a/src/geom/util/Makefile.am +++ b/src/geom/util/Makefile.am @@ -12,4 +12,7 @@ libgeomutil_la_SOURCES = \ GeometryTransformer.cpp \ ShortCircuitedGeometryVisitor.cpp \ SineStarFactory.cpp \ - GeometryCombiner.cpp + GeometryCombiner.cpp \ + LinearComponentExtracter.cpp \ + PointExtracter.cpp \ + PolygonExtracter.cpp diff --git a/src/geom/util/PointExtracter.cpp b/src/geom/util/PointExtracter.cpp new file mode 100644 index 00000000..dd892e52 --- /dev/null +++ b/src/geom/util/PointExtracter.cpp @@ -0,0 +1,56 @@ +/********************************************************************** + * + * GEOS - Geometry Engine Open Source + * http://geos.osgeo.org + * + * Copyright (C) 2001-2002 Vivid Solutions Inc. + * Copyright (C) 2006 Refractions Research Inc. + * + * This is free software; you can redistribute and/or modify it under + * the terms of the GNU Lesser General Public Licence as published + * by the Free Software Foundation. + * See the COPYING file for more information. + * + **********************************************************************/ + + +#include +#include + +#include +#include + +namespace geos { + namespace geom { // geos.geom + namespace util { // geos.geom.util + + + void PointExtracter::getPoints(const Geometry &geom, Point::ConstVect &ret) + { + PointExtracter pe(ret); + geom.apply_ro(&pe); + } + + /** + * Constructs a PointExtracterFilter with a list in which + * to store Points found. + */ + PointExtracter::PointExtracter(Point::ConstVect& newComps) + : + comps(newComps) + {} + + void PointExtracter::filter_rw(Geometry *geom) + { + if ( const Point *p=dynamic_cast(geom) ) + comps.push_back(p); + } + + void PointExtracter::filter_ro(const Geometry *geom) + { + if ( const Point *p=dynamic_cast(geom) ) + comps.push_back(p); + } + } + } +} diff --git a/src/geom/util/PolygonExtracter.cpp b/src/geom/util/PolygonExtracter.cpp new file mode 100644 index 00000000..23f33275 --- /dev/null +++ b/src/geom/util/PolygonExtracter.cpp @@ -0,0 +1,54 @@ +/********************************************************************** + * + * GEOS - Geometry Engine Open Source + * http://geos.osgeo.org + * + * Copyright (C) 2001-2002 Vivid Solutions Inc. + * Copyright (C) 2006 Refractions Research Inc. + * + * This is free software; you can redistribute and/or modify it under + * the terms of the GNU Lesser General Public Licence as published + * by the Free Software Foundation. + * See the COPYING file for more information. + * + **********************************************************************/ + + +#include +#include + +#include +#include + +namespace geos { +namespace geom { // geos.geom +namespace util { // geos.geom.util + + void PolygonExtracter::getPolygons(const Geometry &geom, std::vector& ret) + { + PolygonExtracter pe(ret); + geom.apply_ro(&pe); + } + + PolygonExtracter::PolygonExtracter(std::vector& newComps) + : + comps(newComps) + {} + + void PolygonExtracter::filter_rw(Geometry *geom) { + if ( const Polygon *p=dynamic_cast(geom) ) + { + comps.push_back(p); + } + } + + void PolygonExtracter::filter_ro(const Geometry *geom) + { + if ( const Polygon *p=dynamic_cast(geom) ) + { + comps.push_back(p); + } + } +} +} +} -- 2.11.4.GIT