/********************************************************************** * * GEOS - Geometry Engine Open Source * http://geos.osgeo.org * * Copyright (C) 2023 ISciences, LLC * * 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 #include namespace geos { namespace geom { /// /// \brief The CoordinateSequences class provides utility methods to operate /// on CoordinateSequences. Methods that do not benefit from access to the /// CoordinateSequence internals can be placed here. /// class CoordinateSequences { private: template static constexpr int type_pair(const CoordinateType& typ1, const CoordinateType& typ2) { return (static_cast(typ1) << 4) | static_cast(typ2); } public: /// /// \brief binaryDispatch calls a functor template, explicitly providing the backing types of two CoordinateSequences. The /// CoordinateSequences are not provided to the functor as arguments but can be provided along with any other arugments /// through the `args` argument. template static void binaryDispatch(const CoordinateSequence& seq1, const CoordinateSequence& seq2, F& fun, Args... args) { using CoordinateXYZ = Coordinate; auto typ1 = seq1.getCoordinateType(); auto typ2 = seq2.getCoordinateType(); switch(type_pair(typ1, typ2)) { case type_pair(CoordinateType::XY, CoordinateType::XY): fun.template operator()(args...); break; case type_pair(CoordinateType::XY, CoordinateType::XYZ): fun.template operator()(args...); break; case type_pair(CoordinateType::XY, CoordinateType::XYM): fun.template operator()(args...); break; case type_pair(CoordinateType::XY, CoordinateType::XYZM): fun.template operator()(args...); break; case type_pair(CoordinateType::XYZ, CoordinateType::XY): fun.template operator()(args...); break; case type_pair(CoordinateType::XYZ, CoordinateType::XYZ): fun.template operator()(args...); break; case type_pair(CoordinateType::XYZ, CoordinateType::XYM): fun.template operator()(args...); break; case type_pair(CoordinateType::XYZ, CoordinateType::XYZM): fun.template operator()(args...); break; case type_pair(CoordinateType::XYM, CoordinateType::XY): fun.template operator()(args...); break; case type_pair(CoordinateType::XYM, CoordinateType::XYZ): fun.template operator()(args...); break; case type_pair(CoordinateType::XYM, CoordinateType::XYM): fun.template operator()(args...); break; case type_pair(CoordinateType::XYM, CoordinateType::XYZM): fun.template operator()(args...); break; case type_pair(CoordinateType::XYZM, CoordinateType::XY): fun.template operator()(args...); break; case type_pair(CoordinateType::XYZM, CoordinateType::XYZ): fun.template operator()(args...); break; case type_pair(CoordinateType::XYZM, CoordinateType::XYM): fun.template operator()(args...); break; case type_pair(CoordinateType::XYZM, CoordinateType::XYZM): fun.template operator()(args...); break; } } }; } }