GEOS 3.14.0dev
GeometryLister.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
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 * Last port: geom/util/GeometryExtracter.java r320 (JTS-1.12)
18 *
19 **********************************************************************/
20
21#pragma once
22
23#include <geos/export.h>
24#include <geos/geom/GeometryFilter.h>
25#include <geos/geom/GeometryCollection.h>
26#include <vector>
27
28namespace geos {
29namespace geom { // geos.geom
30namespace util { // geos.geom.util
31
36class GEOS_DLL GeometryLister {
37
38public:
39
49 static void
50 list(const Geometry* geom, std::vector<const Geometry*>& lst)
51 {
52 if(geom->isCollection()) {
53 GeometryLister::Lister lister(lst);
54 geom->apply_ro(&lister);
55 }
56 else {
57 lst.push_back(geom);
58 }
59 }
60
61private:
62
63 struct Lister : public GeometryFilter {
64
70 Lister(std::vector<const Geometry*>& p_geoms) : geoms(p_geoms) {}
71
72 std::vector<const Geometry*>& geoms;
73
74 void
75 filter_ro(const Geometry* geom) override
76 {
77 if(!geom->isCollection()) {
78 geoms.push_back(geom);
79 }
80 }
81
82 // // Declare type as noncopyable
83 // Lister(const Lister& other);
84 // Lister& operator=(const Lister& rhs);
85 };
86};
87
88
89} // namespace geos.geom.util
90} // namespace geos.geom
91} // namespace geos
92
Geometry classes support the concept of applying a Geometry filter to the Geometry.
Definition GeometryFilter.h:45
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:197
Definition GeometryLister.h:36
static void list(const Geometry *geom, std::vector< const Geometry * > &lst)
Definition GeometryLister.h:50
Basic namespace for all GEOS functionalities.
Definition geos.h:39