24 #include "../../../../core/filesystem/FileSystem.h" 25 #include "../../../../core/translator/Translator.h" 26 #include "../../../../dataaccess/query/SQLDialect.h" 29 #include <ogrsf_frmts.h> 31 #include <gdal_priv.h> 36 #include <boost/filesystem/operations.hpp> 81 if(!ds || ds->GetLayerCount() <= 0)
86 OGRLayer* l = ds->GetLayer(0);
126 return std::auto_ptr<te::da::DataSourceTransactor>(
new Transactor(
this));
134 throw Exception(
TE_TR(
"There is no information about the data source"));
137 std::map<std::string, std::string>::const_iterator it;
141 throw(
Exception(
TE_TR(
"Not enough information to open the data source.")));
147 m_ogrDS = (GDALDataset*)GDALOpenEx(path.c_str(), GDAL_OF_UPDATE, NULL, NULL, NULL);
153 m_ogrDS = (GDALDataset*)GDALOpenEx(path.c_str(), GDAL_OF_READONLY, NULL, NULL, NULL);
226 std::map<std::string, std::string>::const_iterator it;
230 throw(
Exception(
TE_TR(
"Not enough information to create data set.")));
233 boost::filesystem::path bpath(path);
234 std::string dir = bpath.parent_path().string();
241 GDALDriverManager* driverManager = GetGDALDriverManager();
246 driver = driverManager->GetDriverByName(it->second.c_str());
248 driver = driverManager->GetDriverByName(
GetDriverName(path).c_str());
256 if (!OGR_Dr_TestCapability(driver, ODrCCreateDataSource))
257 throw(
Exception(
TE_TR(
"The driver has no capability for creating a datasource!")));
259 char** papszOptions = 0;
263 if(it->first ==
"URI" || it->first ==
"SOURCE" || it->first ==
"DRIVER")
268 papszOptions = CSLSetNameValue(papszOptions, it->first.c_str(), it->second.c_str());
273 m_ogrDS = driver->Create(path.c_str(), 0, 0, 0, GDT_Unknown, papszOptions);
276 CSLDestroy(papszOptions);
282 std::auto_ptr<te::da::DataSourceTransactor> t =
getTransactor();
283 return t->createDataSet(dt, options);
288 std::string path = dsInfo.begin()->second;
297 GDALDriverManager* driverManager = GetGDALDriverManager();
298 GDALDriver* driver = driverManager->GetDriverByName(
GetDriverName(path).c_str());
306 if (!OGR_Dr_TestCapability(driver, ODrCDeleteDataSource))
321 std::vector<std::string> names;
323 names.push_back(dsInfo.begin()->second);
330 return std::vector<te::core::EncodingType>();
void setSupportString(const bool &support)
te::da::SQLDialect * dialect
static bool exists(const std::string &path)
Checks if a given path in UTF-8 exists.
GDALDataset * m_ogrDS
A pointer to OGR Data Source.
void createDataSet(te::da::DataSetType *dt, const std::map< std::string, std::string > &options)
It creates the dataset schema definition in the target data source.
~DataSource()
Virtual destructor.
void GetCapabilities(GDALDataset *ds, te::da::DataSourceCapabilities &caps)
const te::da::DataSourceCapabilities & getCapabilities() const
It returns the known capabilities of the data source.
Base exception class for plugin module.
A class that models the description of a dataset.
void addSpatialTopologicOperator(const std::string &op)
static te::da::SQLDialect * sm_myDialect
OGR SQL dialect.
void setSupportGeometry(const bool &support)
const std::map< std::string, std::string > & getConnectionInfo() const
static const std::string m_driverIdentifier
The OGR driver identifier.
void setSupportNumeric(const bool &support)
std::vector< te::core::EncodingType > getEncodings(const std::map< std::string, std::string > &dsInfo)
It represents the SQL query dialect accepted by a given data source.
void addComparsionOperator(const std::string &op)
void setSupportEfficientMove(const bool &support)
DataSource()
Default constructor that can be called by subclasses.
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
void setAccessPolicy(const te::common::AccessPolicy &accessPolicy)
static te::dt::Date ds(2010, 01, 01)
A class that informs what the dataset implementation of a given data source can perform.
GDALDataset * getOGRDataSource()
#define TE_TR(message)
It marks a string in order to get translated.
void drop(const std::map< std::string, std::string > &dsInfo)
void setSupportDouble(const bool &support)
void setConnectionInfo(const std::map< std::string, std::string > &connInfo)
void setQueryCapabilities(const QueryCapabilities &capabilities)
void setSupportByteArray(const bool &support)
std::vector< std::string > getDataSourceNames(const std::map< std::string, std::string > &dsInfo)
void addLogicalOperator(const std::string &op)
bool exists(const std::map< std::string, std::string > &dsInfo)
A class that represents the supported data types of a specific data source.
const te::da::SQLDialect * getDialect() const
It returns the data source SQL dialect, if there is one.
A class that informs the query support of a given data source.
void close()
It closes the data source and clears all the resources used by its internal communication channel...
This file contains include headers for the TerraLib GDAL driver.
static te::dt::TimeDuration dt(20, 30, 50, 11)
bool isOpened() const
It returns true if the data source is opened, otherwise it returns false.
void open()
It opens the data source and makes it ready for using.
std::map< std::string, std::string > m_connectionInfo
Connection information.
void setDataSetCapabilities(const DataSetCapabilities &capabilities)
te::da::DataSourceCapabilities m_capabilities
OGR capabilities.
bool m_isValid
True if this is a valid datasource.
void setSupportInt32(const bool &support)
void setSupportBidirectionalTraversing(const bool &support)
std::string getType() const
It returns the data source type name (in UPPER CASE). Ex: POSTGIS, SQLITE, WFS, WMS, or MYSQL.
static bool createDirectory(const std::string &path)
Creates a directory from a given path in UTF-8.
std::auto_ptr< te::da::DataSourceTransactor > getTransactor()
It returns the set of parameters used to set up the access channel to the underlying repository...
void setSupportRandomTraversing(const bool &support)
void setDataTypeCapabilities(const DataTypeCapabilities &capabilities)
bool isValid() const
It checks if the data source is valid (available for using).
void GetDataSetTypeCapabilities(te::da::DataSourceCapabilities &caps)
std::string GetDriverName(const std::string &path)
It tries extract the driver name used by OGR Library based on the given path.
void create(const std::map< std::string, std::string > &dsInfo)
void setSupportDateTime(const bool &support)
void GetQueryCapabilities(te::da::DataSourceCapabilities &caps)
void setSupportArray(const bool &support)
static void setDialect(te::da::SQLDialect *dialect)
The OGR data source provider.
void setSupportEfficientDataSetSize(const bool &support)