21 #ifndef GEOS_GEOM_UTIL_GEOMETRYEXTRACTER_H
22 #define GEOS_GEOM_UTIL_GEOMETRYEXTRACTER_H
24 #include <geos/export.h>
25 #include <geos/geom/GeometryFilter.h>
26 #include <geos/geom/GeometryCollection.h>
36 class GEOS_DLL GeometryExtracter {
47 template <
class ComponentType,
class TargetContainer>
49 extract(
const Geometry& geom, TargetContainer& lst)
51 if(
const ComponentType* p_c =
dynamic_cast<const ComponentType*
>(&geom)) {
54 else if(
const GeometryCollection* p_c1 =
55 dynamic_cast<const GeometryCollection*
>(&geom)) {
56 GeometryExtracter::Extracter<ComponentType, TargetContainer> extracter(lst);
57 p_c1->apply_ro(&extracter);
63 template <
class ComponentType,
class TargetContainer>
64 struct Extracter:
public GeometryFilter {
71 Extracter(TargetContainer& comps) : comps_(comps) {}
73 TargetContainer& comps_;
76 filter_ro(
const Geometry* geom)
override
78 if(
const ComponentType* c =
dynamic_cast<const ComponentType*
>(geom)) {
84 Extracter(
const Extracter& other);
85 Extracter& operator=(
const Extracter& rhs);
89 GeometryExtracter(
const GeometryExtracter& other) =
delete;