27 #include "../common/StringUtils.h" 28 #include "../core/filesystem/FileSystem.h" 29 #include "../core/translator/Translator.h" 30 #include "../core/uri/URI.h" 31 #include "../core/uri/Utils.h" 32 #include "../geometry/Envelope.h" 33 #include "../dataaccess/dataset/DataSetType.h" 34 #include "../raster/Grid.h" 35 #include "../raster/Raster.h" 36 #include "../raster/RasterProperty.h" 45 #include <gdal_priv.h> 48 #include <boost/filesystem.hpp> 49 #include <boost/format.hpp> 50 #include <boost/algorithm/string/replace.hpp> 82 throw Exception((boost::format(
TE_TR(
"Invalid data source connection information"))).str());
91 boost::replace_all(source,
"file://",
"");
99 throw Exception((boost::format(
TE_TR(
"Not enough information to open the data source."))).str());
124 if (scheme ==
"file")
127 boost::replace_all(source,
"file://",
"");
146 GDALDataset* gds =
static_cast<GDALDataset*
>(GDALOpen(source.c_str(), GA_ReadOnly));
167 throw Exception((boost::format(
TE_TR(
"Data source is not open."))).str());
183 throw Exception((boost::format(
TE_TR(
"Invalid data source connection information"))).str());
185 std::string scheme = auxURI.
scheme();
187 if (scheme ==
"file")
191 boost::replace_all(path,
"file://",
"");
201 throw Exception((boost::format(
TE_TR(
"Data source creation is supported only for directory data sources"))).str());
204 catch (
const boost::filesystem::filesystem_error& e)
206 throw Exception((boost::format(
TE_TR(
"Could not create the data source due to the following error: %1%.")) % e.what()).str());
211 throw Exception((boost::format(
TE_TR(
"Empty data source connection information"))).str());
222 throw Exception((boost::format(
TE_TR(
"Empty ou invalid data source connection information"))).str());
226 if (scheme ==
"file")
229 boost::replace_all(path,
"file://",
"");
235 else if (boost::filesystem::exists(path) && boost::filesystem::is_regular_file(path))
239 GDALDataset* gds =
static_cast<GDALDataset*
>(GDALOpen(path.c_str(), GA_ReadOnly));
255 GDALDataset* gds =
static_cast<GDALDataset*
>(GDALOpen(source.c_str(), GA_ReadOnly));
272 std::string scheme = auxURI.
scheme();
274 if (scheme ==
"file")
277 boost::replace_all(path,
"file://",
"");
285 catch (
const boost::filesystem::filesystem_error& )
299 std::string scheme = auxURI.
scheme();
301 std::vector<std::string> dsnames;
303 if (scheme ==
"file")
306 boost::replace_all(path,
"file://",
"");
310 dsnames.push_back(path);
313 throw Exception((boost::format(
TE_TR(
"Empty ou invalid data source connection information"))).str());
319 dsnames.push_back(aux);
The implementation of a DataSource that consists of datasets that can be decoded by the GDAL Library...
std::string path() const
Retrieving the path.
std::string scheme() const
Retrieving the scheme.
static bool exists(const std::string &path)
Checks if a given path in UTF-8 exists.
void drop(const std::string &connInfo)
It removes the data source with the connection information from a driver.
static bool isDirectory(const std::string &path)
Checks if a given path in UTF-8 is a directory.
std::vector< std::string > getDataSourceNames(const std::string &connInfo)
It gets the data source names available in a driver.
Base exception class for plugin module.
void create(const std::string &connInfo)
It creates a new data source.
DataSource(const std::string &connInfo)
static void setCapabilities(const te::da::DataSourceCapabilities &capabilities)
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
bool isValid() const
Return if the given URI is valid or not.
static te::da::DataSourceCapabilities sm_capabilities
#define TE_TR(message)
It marks a string in order to get translated.
~DataSource()
Virtual destructor.
std::unique_ptr< te::da::DataSourceTransactor > getTransactor()
It returns the set of parameters used to set up the access channel to the underlying repository...
A driver to access raster data using the GDAL library.
static bool remove(const std::string &path)
Removes a file or directory from a given path in UTF-8.
std::string MakePGConnectionStr(const te::core::URI &connInfo)
Returns a PostGIS connection string from the URI connection information. The connection string is to ...
bool exists(const std::string &connInfo)
Check the existence of a data source in a driver.
te::da::DataSourceCapabilities capabilities
std::string GetParentDataSetName(const std::string &subDataSetName)
It returns the parent dataset name from a Sub DataSet name.
const std::string & uri() const
Retrieving the full URI.
void close()
It closes the data source and clears all the resources used by its internal communication channel...
A class for representing an Uniform Resource Identifier (URI).
static bool createDirectory(const std::string &path)
Creates a directory from a given path in UTF-8.
bool isValid() const
It checks if the data source is valid (available for using).
bool isOpened() const
It returns true if the data source is opened, otherwise it returns false.
This file contains utility functions used to manipulate data from a URI.
te::core::URI m_uri
The URI used to describe the datasource connection;.
GDAL data set use counter.
std::string getType() const
It returns the data source type name (in UPPER CASE). Ex: POSTGIS, SQLITE, WFS, WMS, or MYSQL.
void open()
It opens the data source and makes it ready for using.
TECOREEXPORT std::string URIDecode(const std::string &srcUri)
Decodes an encoded URI. The algorithm implementation is based on http://www.codeguru.com/cpp/cpp/algorithms/strings/article.php/c12759/URI-Encoding-and-Decoding.htm.
An exception class for the GDAL module.
static bool isRegularFile(const std::string &path)
Checks if a given path in UTF-8 is a regular file.
const te::da::DataSourceCapabilities & getCapabilities() const
It returns the known capabilities of the data source.
#define TE_GDAL_DRIVER_IDENTIFIER