/********************************************************************** * * GEOS - Geometry Engine Open Source * http://geos.osgeo.org * * Copyright (C) 2019 Daniel Baston * * 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. * **********************************************************************/ #ifndef GEOS_GEOM_DEFAULTCOORDINATESEQUENCEFACTORY_H #define GEOS_GEOM_DEFAULTCOORDINATESEQUENCEFACTORY_H #include #include #include namespace geos { namespace geom { class GEOS_DLL DefaultCoordinateSequenceFactory : public CoordinateSequenceFactory { public: std::unique_ptr create() const final override { return detail::make_unique(); } std::unique_ptr create(std::vector *coords, std::size_t dims = 0) const final override { return detail::make_unique(coords, dims); } std::unique_ptr create(std::vector &&coords, std::size_t dims = 0) const final override { return detail::make_unique(std::move(coords), dims); } std::unique_ptr create(std::size_t size, std::size_t dims = 0) const final override { switch(size) { case 5: return detail::make_unique>(dims); case 4: return detail::make_unique>(dims); case 3: return detail::make_unique>(dims); case 2: return detail::make_unique>(dims); case 1: return detail::make_unique>(dims); default: return detail::make_unique(size, dims); } } std::unique_ptr create(const CoordinateSequence &coordSeq) const final override { auto cs = create(coordSeq.size(), coordSeq.getDimension()); for (std::size_t i = 0; i < cs->size(); i++) { cs->setAt(coordSeq[i], i); } return cs; } static const CoordinateSequenceFactory *instance(); }; } } #endif //GEOS_DEFAULTCOORDINATESEQUENCEFACTORY_H