19 const auto & ext = path.extension().string();
22 else if (ext ==
".tif" || ext ==
".tiff") {
25 else if (ext ==
".gpkg") {
40 throw std::invalid_argument(
"Unsupported GISFileType");
53 throw std::invalid_argument(
"File type not supported: "+ path.string());
60 explicit AbstractGISFile(
const std::string& pathName):
pathToFile(pathName){}
65 [[nodiscard]]
const std::filesystem::path &
getPath() const noexcept {
69 operator bool ()const noexcept {
79 [[nodiscard]]
bool exists() const noexcept {
80 return std::filesystem::exists(this->pathToFile);
90 [[nodiscard]]
bool supports(
const std::filesystem::path & path)
const noexcept{
126 virtual
bool remove() const noexcept = 0;
142 return std::filesystem::remove(this->pathToFile);
146 std::filesystem::rename(this->pathToFile, newPath);
147 this->pathToFile = newPath;
152 std::filesystem::copy(this->pathToFile, newPath);
157 return "VectorFile(" + this->pathToFile.string() +
")";
174template<
typename File>
176 {file.move(p)}-> std::same_as<File &>;
177 {constF.copy(p)} -> std::same_as<File>;
186template<
typename File>
196template<
typename File>
Definition GISFile.hpp:47
virtual constexpr GISFileType type() const noexcept=0
Returns the type of GISFile.
bool supports(const std::filesystem::path &path) const noexcept
Checks if the supplied path is supported by the concrete GISFile implementation.
Definition GISFile.hpp:90
bool exists() const noexcept
Tests if the GISFile exists on the filesystem.
Definition GISFile.hpp:79
const std::filesystem::path & getPath() const noexcept
Definition GISFile.hpp:65
void changeFilename(const std::string &filename) noexcept
Modifies the path of the GISFile by changing the filename (extension is preserved).
Definition GISFile.hpp:100
std::filesystem::path pathToFile
Definition GISFile.hpp:49
void supportsOrThrow(const std::filesystem::path &path) const
Definition GISFile.hpp:51
void appendToFilename(const std::string &suffix) noexcept
Appends a suffix to the filename / stem of the GISFile (extension is preserved).
Definition GISFile.hpp:109
virtual bool remove() const noexcept=0
Removes the file from the filesystem.
friend class AbstractVectorFile
Definition GISFile.hpp:62
Definition GISFile.hpp:162
AbstractRasterFile(const std::filesystem::path &pathToFile)
Definition GISFile.hpp:164
virtual ~AbstractRasterFile()=default
AbstractRasterFile(const std::string &pathName)
Definition GISFile.hpp:165
Definition GISFile.hpp:131
AbstractVectorFile(const std::string &pathName)
Definition GISFile.hpp:134
AbstractVectorFile copy(const std::filesystem::path &newPath) const
Definition GISFile.hpp:151
std::string toString() const noexcept
Definition GISFile.hpp:156
AbstractVectorFile(const std::filesystem::path &pathToFile)
Definition GISFile.hpp:133
constexpr GISFileType type() const noexcept override
Returns the type of GISFile.
Definition GISFile.hpp:137
bool remove() const noexcept override
Removes the file from the filesystem.
Definition GISFile.hpp:141
virtual ~AbstractVectorFile()=default
AbstractVectorFile & move(const std::filesystem::path &newPath)
Definition GISFile.hpp:145
static std::filesystem::path changeFilename(const std::filesystem::path &path, std::string_view filename) noexcept
Definition PathHelper.cpp:24
Interface for GISFile types. Implementation have to inherit from AbstractGISFile and have to printabl...
Definition GISFile.hpp:175
Interface for all Raster GISFile types.
Definition GISFile.hpp:197
Interface for all Vector GISFile types.
Definition GISFile.hpp:187
Helper concept which checks whether a class has a toString method.
Definition ObjectConcepts.hpp:12
Definition BFSClustering.hpp:5
static std::array< GISFileType, 4 > SUPPORTED_VECTOR_FORMATS
Definition GISFile.hpp:15
static const char * getExtension(GISFileType type)
Definition GISFile.hpp:31
GISFileType
Definition GISFile.hpp:11
static std::array< GISFileType, 4 > SUPPORTED_RASTER_FORMATS
Definition GISFile.hpp:16
static fishnet::Option< GISFileType > getGISFileType(const std::filesystem::path &path)
Definition GISFile.hpp:18