CoordinateFilter.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2005-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.
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <geos/geom/Coordinate.h>
#include <cassert>
namespace geos {
namespace geom { // geos::geom
class GEOS_DLL CoordinateFilter {
public:
virtual
~CoordinateFilter() {}
virtual bool isDone() const
{
return false;
}
virtual void
filter_rw(CoordinateXY* /*coord*/) const
{
assert(0);
}
virtual void
filter_ro(const CoordinateXY* /*coord*/)
{
assert(0);
}
virtual void
filter_rw(Coordinate* c) const
{
filter_rw(static_cast<CoordinateXY*>(c));
}
virtual void
filter_ro(const Coordinate* c)
{
filter_ro(static_cast<const CoordinateXY*>(c));
}
virtual void
filter_rw(CoordinateXYM* c) const
{
filter_rw(static_cast<CoordinateXY*>(c));
}
virtual void
filter_ro(const CoordinateXYM* c)
{
filter_ro(static_cast<const CoordinateXY*>(c));
}
virtual void
filter_rw(CoordinateXYZM* c) const
{
filter_rw(static_cast<Coordinate*>(c));
}
virtual void
filter_ro(const CoordinateXYZM* c)
{
filter_ro(static_cast<const Coordinate*>(c));
}
};
template<class Derived>
class CoordinateInspector : public CoordinateFilter
{
public:
virtual void filter_ro(const CoordinateXY* c) override { static_cast<Derived*>(this)->filter(c); }
virtual void filter_ro(const Coordinate* c) override { static_cast<Derived*>(this)->filter(c); }
virtual void filter_ro(const CoordinateXYM* c) override { static_cast<Derived*>(this)->filter(c); }
virtual void filter_ro(const CoordinateXYZM* c) override { static_cast<Derived*>(this)->filter(c); }
};
template<class Derived>
class CoordinateMutator : public CoordinateFilter
{
public:
virtual void filter_rw(CoordinateXY* c) const override { static_cast<const Derived*>(this)->filter(c); }
virtual void filter_rw(Coordinate* c) const override { static_cast<const Derived*>(this)->filter(c); }
virtual void filter_rw(CoordinateXYM* c) const override { static_cast<const Derived*>(this)->filter(c); }
virtual void filter_rw(CoordinateXYZM* c) const override { static_cast<const Derived*>(this)->filter(c); }
};
} // namespace geos::geom
} // namespace geos
geos::geom::CoordinateFilter
Geometry classes support the concept of applying a coordinate filter to every coordinate in the Geome...
Definition CoordinateFilter.h:43
geos::geom::CoordinateFilter::filter_ro
virtual void filter_ro(const CoordinateXY *)
Performs an operation with coord.
Definition CoordinateFilter.h:70
geos::geom::CoordinateFilter::filter_rw
virtual void filter_rw(CoordinateXY *) const
Performs an operation on coord.
Definition CoordinateFilter.h:59
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
geos::geom
Definition Angle.h:26
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38