GEOS  3.14.0dev
CoordinateFilter.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2005-2006 Refractions Research Inc.
7  *
8  * This is free software; you can redistribute and/or modify it under
9  * the terms of the GNU Lesser General Public Licence as published
10  * by the Free Software Foundation.
11  * See the COPYING file for more information.
12  *
13  **********************************************************************/
14 
15 #pragma once
16 
17 #include <geos/export.h>
18 #include <geos/geom/Coordinate.h>
19 
20 #include <cassert>
21 
22 namespace geos {
23 namespace geom { // geos::geom
24 
43 class GEOS_DLL CoordinateFilter {
44 public:
45  virtual
46  ~CoordinateFilter() {}
47 
48  virtual bool isDone() const
49  {
50  return false;
51  }
52 
58  virtual void
59  filter_rw(CoordinateXY* /*coord*/) const
60  {
61  assert(0);
62  }
63 
69  virtual void
70  filter_ro(const CoordinateXY* /*coord*/)
71  {
72  assert(0);
73  }
74 
75  virtual void
76  filter_rw(Coordinate* c) const
77  {
78  filter_rw(static_cast<CoordinateXY*>(c));
79  }
80 
81  virtual void
82  filter_ro(const Coordinate* c)
83  {
84  filter_ro(static_cast<const CoordinateXY*>(c));
85  }
86 
87  virtual void
88  filter_rw(CoordinateXYM* c) const
89  {
90  filter_rw(static_cast<CoordinateXY*>(c));
91  }
92 
93  virtual void
94  filter_ro(const CoordinateXYM* c)
95  {
96  filter_ro(static_cast<const CoordinateXY*>(c));
97  }
98 
99  virtual void
100  filter_rw(CoordinateXYZM* c) const
101  {
102  filter_rw(static_cast<Coordinate*>(c));
103  }
104 
105  virtual void
106  filter_ro(const CoordinateXYZM* c)
107  {
108  filter_ro(static_cast<const Coordinate*>(c));
109  }
110 };
111 
112 template<class Derived>
113 class CoordinateInspector : public CoordinateFilter
114 {
115 public:
116  virtual void filter_ro(const CoordinateXY* c) override { static_cast<Derived*>(this)->filter(c); }
117  virtual void filter_ro(const Coordinate* c) override { static_cast<Derived*>(this)->filter(c); }
118  virtual void filter_ro(const CoordinateXYM* c) override { static_cast<Derived*>(this)->filter(c); }
119  virtual void filter_ro(const CoordinateXYZM* c) override { static_cast<Derived*>(this)->filter(c); }
120 };
121 
122 template<class Derived>
123 class CoordinateMutator : public CoordinateFilter
124 {
125 public:
126  virtual void filter_rw(CoordinateXY* c) const override { static_cast<const Derived*>(this)->filter(c); }
127  virtual void filter_rw(Coordinate* c) const override { static_cast<const Derived*>(this)->filter(c); }
128  virtual void filter_rw(CoordinateXYM* c) const override { static_cast<const Derived*>(this)->filter(c); }
129  virtual void filter_rw(CoordinateXYZM* c) const override { static_cast<const Derived*>(this)->filter(c); }
130 };
131 
132 } // namespace geos::geom
133 } // namespace geos
134 
Geometry classes support the concept of applying a coordinate filter to every coordinate in the Geome...
Definition: CoordinateFilter.h:43
virtual void filter_ro(const CoordinateXY *)
Performs an operation with coord.
Definition: CoordinateFilter.h:70
virtual void filter_rw(CoordinateXY *) const
Performs an operation on coord.
Definition: CoordinateFilter.h:59
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:217
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25