27 #include "../common/Translator.h"
28 #include "../gdal/DataSet.h"
29 #include "../gdal/Utils.h"
30 #include "../geometry/Envelope.h"
31 #include "../raster/Grid.h"
37 #include <gdal_priv.h>
43 : m_serviceURL(serviceURL),
44 m_coverageName(coverageName)
62 if(name != m_coverageName)
63 throw Exception(
TE_TR(
"The informed data set could not be found in the data source!!"));
66 std::auto_ptr<te::da::DataSetType> type = getDataSetType(name);
69 std::string request =
BuildRequest(m_serviceURL, m_coverageName);
82 if(name != m_coverageName)
83 throw Exception(
TE_TR(
"The informed data set could not be found in the data source!"));
86 std::auto_ptr<te::da::DataSetType> type = getDataSetType(name);
89 std::string request =
BuildRequest(m_serviceURL, m_coverageName, e);
95 const std::string& propertyName,
102 return getDataSet(name, propertyName, g->
getMBR(), r, travType, connected, accessPolicy);
111 throw Exception(
TE_TR(
"The ObjectIdSet concept is not supported by the WCS driver!"));
119 throw Exception(
TE_TR(
"Query operations is not supported by the WCS driver!"));
127 throw Exception(
TE_TR(
"Query operations is not supported by the WCS driver!"));
132 std::vector<std::string> names;
133 names.push_back(m_coverageName);
145 if(name != m_coverageName)
146 throw Exception(
TE_TR(
"The informed data set could not be found in the data source."));
149 std::string request =
BuildRequest(m_serviceURL, m_coverageName);
151 GDALDataset* gds =
static_cast<GDALDataset*
>(GDALOpen(request.c_str(), GA_ReadOnly));
153 throw Exception(
TE_TR(
"The data set type could not be retrieved from data source."));
160 std::vector<te::rst::BandProperty*> bandProperties;
166 for(std::size_t i = 0; i < bandProperties.size(); ++i)
167 rp->
add(bandProperties[i]);
173 return std::auto_ptr<te::da::DataSetType>(type);
178 boost::ptr_vector<te::dt::Property> properties;
180 std::auto_ptr<te::da::DataSetType> type = getDataSetType(datasetName);
182 const std::vector<te::dt::Property*>& props = type->getProperties();
183 for(std::size_t i = 0; i < props.size(); ++i)
184 properties.push_back(props[i]->clone());
191 std::auto_ptr<te::da::DataSetType> type = getDataSetType(datasetName);
193 const std::vector<te::dt::Property*>& props = type->getProperties();
194 for(std::size_t i = 0; i < props.size(); ++i)
196 if(props[i]->getName() == name)
197 return std::auto_ptr<te::dt::Property>(props[i]->clone());
200 throw Exception(
TE_TR(
"The informed property name could not be found in the data set."));
205 std::auto_ptr<te::da::DataSetType> type = getDataSetType(datasetName);
207 const std::vector<te::dt::Property*>& props = type->getProperties();
209 if(propertyPos >= props.size())
210 throw Exception(
TE_TR(
"The informed property position could not be found in the data set."));
212 return std::auto_ptr<te::dt::Property>(props[propertyPos]->clone());
217 std::vector<std::string> propertyNames;
219 std::auto_ptr<te::da::DataSetType> type = getDataSetType(datasetName);
221 const std::vector<te::dt::Property*>& props = type->getProperties();
222 for(std::size_t i = 0; i < props.size(); ++i)
223 propertyNames.push_back(props[i]->getName());
225 return propertyNames;
230 return getPropertyNames(datasetName).size();
235 std::vector<std::string> propertyNames = getPropertyNames(datasetName);
237 for(std::size_t i = 0; i < propertyNames.size(); ++i)
238 if(propertyNames[i] == name)
245 const std::string& propertyName)
247 std::auto_ptr<te::da::DataSetType> type = getDataSetType(datasetName);
249 std::auto_ptr<te::dt::Property> prop = getProperty(datasetName, propertyName);
259 std::size_t propertyPos)
261 std::auto_ptr<te::da::DataSetType> type = getDataSetType(datasetName);
263 std::auto_ptr<te::dt::Property> prop = getProperty(datasetName, propertyPos);
279 return !m_coverageName.empty();
284 return name == m_coverageName;
297 throw Exception(
TE_TR(
"The method begin() is not supported by the WCS driver!"));
302 throw Exception(
TE_TR(
"The method commit() is not supported by the WCS driver!"));
307 throw Exception(
TE_TR(
"The method rollBack() is not supported by the WCS driver!"));
312 throw Exception(
TE_TR(
"The method isInTransaction() is not supported by the WCS driver!"));
317 throw Exception(
TE_TR(
"The method execute() is not supported by the WCS driver!"));
322 throw Exception(
TE_TR(
"The method execute() is not supported by the WCS driver!"));
327 throw Exception(
TE_TR(
"The method getPrepared() is not supported by the WCS driver!"));
332 throw Exception(
TE_TR(
"The method getBatchExecutor() is not supported by the WCS driver!"));
337 throw Exception(
TE_TR(
"The method cancel() is not supported by the WCS driver!"));
342 throw Exception(
TE_TR(
"The method getLastGeneratedId() is not supported by the WCS driver!"));
347 throw Exception(
TE_TR(
"The method escape() is not supported by the WCS driver!"));
352 throw Exception(
TE_TR(
"The method isDataSetNameValid() is not supported by the WCS driver!"));
357 throw Exception(
TE_TR(
"The method isPropertyNameValid() is not supported by the WCS driver!"));
362 throw Exception(
TE_TR(
"The method addProperty() is not supported by the WCS driver!"));
367 throw Exception(
TE_TR(
"The method dropProperty() is not supported by the WCS driver!"));
372 throw Exception(
TE_TR(
"The method renameProperty() is not supported by the WCS driver!"));
377 throw Exception(
TE_TR(
"The method getPrimaryKey() is not supported by the WCS driver!"));
382 throw Exception(
TE_TR(
"The method primaryKeyExists() is not supported by the WCS driver!"));
387 throw Exception(
TE_TR(
"The method addPrimaryKey() is not supported by the WCS driver!"));
392 throw Exception(
TE_TR(
"The method dropPrimaryKey() is not supported by the WCS driver!"));
397 throw Exception(
TE_TR(
"The method getForeignKey() is not supported by the WCS driver!"));
402 throw Exception(
TE_TR(
"The method getForeignKeyNames() is not supported by the WCS driver!"));
407 throw Exception(
TE_TR(
"The method foreignKeyExists() is not supported by the WCS driver!"));
412 throw Exception(
TE_TR(
"The method addForeignKey() is not supported by the WCS driver!"));
417 throw Exception(
TE_TR(
"The method dropForeignKey() is not supported by the WCS driver!"));
422 throw Exception(
TE_TR(
"The method getUniqueKey() is not supported by the WCS driver!"));
427 throw Exception(
TE_TR(
"The method getUniqueKeyNames() is not supported by the WCS driver!"));
432 throw Exception(
TE_TR(
"The method uniqueKeyExists() is not supported by the WCS driver!"));
437 throw Exception(
TE_TR(
"The method addUniqueKey() is not supported by the WCS driver!"));
442 throw Exception(
TE_TR(
"The method dropUniqueKey() is not supported by the WCS driver!"));
447 throw Exception(
TE_TR(
"The method getCheckConstraint() is not supported by the WCS driver!"));
452 throw Exception(
TE_TR(
"The method getCheckConstraintNames() is not supported by the WCS driver!"));
457 throw Exception(
TE_TR(
"The method checkConstraintExists() is not supported by the WCS driver!"));
462 throw Exception(
TE_TR(
"The method addCheckConstraint() is not supported by the WCS driver!"));
467 throw Exception(
TE_TR(
"The method dropCheckConstraint() is not supported by the WCS driver!"));
472 throw Exception(
TE_TR(
"The method getIndex() is not supported by the WCS driver!"));
477 throw Exception(
TE_TR(
"The method getIndexNames() is not supported by the WCS driver!"));
482 throw Exception(
TE_TR(
"The method indexExists() is not supported by the WCS driver!"));
487 throw Exception(
TE_TR(
"The method addIndex() is not supported by the WCS driver!"));
492 throw Exception(
TE_TR(
"The method dropIndex() is not supported by the WCS driver!"));
497 throw Exception(
TE_TR(
"The method getSequence() is not supported by the WCS driver!"));
502 throw Exception(
TE_TR(
"The method getSequenceNames() is not supported by the WCS driver!"));
507 throw Exception(
TE_TR(
"The method sequenceExists() is not supported by the WCS driver!"));
512 throw Exception(
TE_TR(
"The method addSequence() is not supported by the WCS driver!"));
517 throw Exception(
TE_TR(
"The method dropSequence() is not supported by the WCS driver!"));
521 const std::map<std::string, std::string>& )
523 throw Exception(
TE_TR(
"The method createDataSet() is not supported by the WCS driver!"));
528 const std::map<std::string, std::string>& )
530 throw Exception(
TE_TR(
"The method cloneDataSet() is not supported by the WCS driver!"));
535 throw Exception(
TE_TR(
"The method dropDataSet() is not supported by the WCS driver!"));
541 throw Exception(
TE_TR(
"The method renameDataSet() is not supported by the WCS driver!"));
546 const std::map<std::string, std::string>& ,
549 throw Exception(
TE_TR(
"The method add() is not supported by the WCS driver!"));
554 throw Exception(
TE_TR(
"The method remove() is not supported by the WCS driver!"));
559 const std::vector<std::size_t>& ,
561 const std::map<std::string, std::string>& ,
564 throw Exception(
TE_TR(
"The method update() is not supported by the WCS driver!"));
569 throw Exception(
TE_TR(
"The method optimize() is not supported by the WCS driver!"));
void setTitle(const std::string &title)
It sets a human descriptive title for the DataSetType.
void set(te::rst::Grid *grid)
Sets the definition of the raster grid support.
std::vector< std::string > getForeignKeyNames(const std::string &datasetName)
It gets the foreign key names of the given dataset.
void renameProperty(const std::string &datasetName, const std::string &propertyName, const std::string &newPropertyName)
It renames a property of the given dataset.
std::auto_ptr< te::gm::Envelope > getExtent(const std::string &datasetName, const std::string &propertyName)
It retrieves the bounding rectangle of the spatial property for the given dataset.
void addProperty(const std::string &datasetName, te::dt::Property *p)
It adds a new property to the dataset schema.
void dropForeignKey(const std::string &datasetName, const std::string &fkName)
It removes the foreign key constraint from the dataset schema.
CharEncoding
Supported charsets (character encoding).
Implementation of the transactor for the WCS driver.
std::auto_ptr< te::da::Index > getIndex(const std::string &datasetName, const std::string &name)
It gets the index with the given name from the dataset.
Utilitary functions to access GDAL and match some of its concepts to TerraLib concepts.
TEGDALEXPORT void GetBandProperties(GDALDataset *gds, std::vector< te::rst::BandProperty * > &bprops)
Gets the list of bands definition from a GDAL dataset.
std::auto_ptr< te::da::DataSet > getDataSet(const std::string &name, te::common::TraverseType travType=te::common::FORWARDONLY, bool connected=false, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It gets the dataset identified by the given name. A dataset can be connected or disconnected. A connected dataset, after its creation through the data source transactor, continues to depend on the connection given by its associated data source. Differently, a disconnected dataset, after its creation, no more depends of the connection given by the data source, and it continues to live after the connection has been released to the data source.
std::auto_ptr< te::da::UniqueKey > getUniqueKey(const std::string &datasetName, const std::string &name)
It gets the unique key in the dataset with the given name.
void dropSequence(const std::string &name)
It removes the sequence from the data source.
void dropPrimaryKey(const std::string &datasetName)
It removes the primary key constraint from the dataset schema.
bool indexExists(const std::string &datasetName, const std::string &name)
It checks if an index with the given name exists in the dataset.
A class that models the description of a dataset.
bool dataSetExists(const std::string &name)
It checks if a dataset with the given name exists in the data source.
An exception class for the TerraLib WCS module.
std::string escape(const std::string &value)
It escapes a string for using in commands and queries.
std::auto_ptr< te::dt::Property > getProperty(const std::string &datasetName, const std::string &name)
It retrieves the property with the given name from the dataset.
const double & getUpperRightX() const
It returns a constant refernce to the x coordinate of the upper right corner.
bool propertyExists(const std::string &datasetName, const std::string &name)
It checks if a property with the given name exists in the dataset.
void cancel()
It requests that the data source stop the processing of the current command.
bool checkConstraintExists(const std::string &datasetName, const std::string &name)
It checks if a check-constraint with the given name exists in the data source.
std::auto_ptr< te::da::PreparedQuery > getPrepared(const std::string &qName=std::string(""))
It creates a prepared query object that may be used for query commands (select, insert, update and delete) that are used repeatedly.
const double & getLowerLeftY() const
It returns a constant refernce to the y coordinate of the lower left corner.
SpatialRelation
Spatial relations between geometric objects.
void update(const std::string &datasetName, te::da::DataSet *dataset, const std::vector< std::size_t > &properties, const te::da::ObjectIdSet *oids, const std::map< std::string, std::string > &options, std::size_t limit=0)
It updates the contents of a dataset for the set of data items.
void addForeignKey(const std::string &datasetName, te::da::ForeignKey *fk)
It adds a foreign key constraint to a dataset.
It describes a sequence (a number generator).
std::auto_ptr< te::da::DataSetType > getDataSetType(const std::string &name)
It gets information about the given dataset.
std::auto_ptr< te::da::PrimaryKey > getPrimaryKey(const std::string &datasetName)
It retrieves the primary key of the dataset.
bool uniqueKeyExists(const std::string &datasetName, const std::string &name)
It checks if a unique key with the given name exists in the dataset.
A class that describes a check constraint.
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
const double & getUpperRightY() const
It returns a constant refernce to the x coordinate of the upper right corner.
#define TE_TR(message)
It marks a string in order to get translated.
It models a property definition.
bool isDataSetNameValid(const std::string &datasetName)
It returns true if the given string is a valid dataset name.
void addCheckConstraint(const std::string &datasetName, te::da::CheckConstraint *cc)
It adds a check constraint to the dataset.
void dropDataSet(const std::string &name)
It removes the dataset schema from the data source.
Transactor(const std::string &serviceURL, const std::string &coverageName)
void cloneDataSet(const std::string &name, const std::string &cloneName, const std::map< std::string, std::string > &options)
It clones the dataset in the data source.
boost::ptr_vector< te::dt::Property > getProperties(const std::string &datasetName)
It retrieves the properties of the dataset.
std::auto_ptr< te::da::Sequence > getSequence(const std::string &name)
It gets the sequence with the given name in the data source.
void addUniqueKey(const std::string &datasetName, te::da::UniqueKey *uk)
It adds a unique key constraint to the dataset.
void dropProperty(const std::string &datasetName, const std::string &name)
It removes a property from the given dataset.
std::size_t getNumberOfDataSets()
It retrieves the number of data sets available in the data source.
te::da::DataSource * getDataSource() const
It returns the parent data source of the transactor.
AccessPolicy
Supported data access policies (can be used as bitfield).
bool primaryKeyExists(const std::string &datasetName, const std::string &name)
It checks if a primary key exists in the dataset.
TraverseType
A dataset can be traversed in two ways:
std::vector< std::string > getIndexNames(const std::string &datasetName)
It gets the index names of the given dataset.
void add(te::rst::BandProperty *b)
It adds a new band information to the property.
bool hasDataSets()
It checks if the data source has any dataset.
void execute(const te::da::Query &command)
It executes the specified command using a generic query representation.
An Envelope defines a 2D rectangular region.
This class represents a set of unique ids created in the same context. i.e. from the same data set...
bool sequenceExists(const std::string &name)
It checks if a sequence with the given name exists in the data source.
std::vector< std::string > getSequenceNames()
It gets the sequence names available in the data source.
std::auto_ptr< te::da::CheckConstraint > getCheckConstraint(const std::string &datasetName, const std::string &name)
It gets the check constraint of the dataset with the given name.
std::vector< std::string > getPropertyNames(const std::string &datasetName)
It gets the property names of the given dataset.
bool isPropertyNameValid(const std::string &propertyName)
It checks if the given property name is valid.
void optimize(const std::map< std::string, std::string > &opInfo)
For some data access drivers, this method will perform some operations to optimize the data storage...
bool isInTransaction() const
It returns true if a transaction is in progress, otherwise, it returns false.
It models a foreign key constraint for a DataSetType.
It describes a unique key (uk) constraint.
te::common::CharEncoding getEncoding()
It return the DataSource current encoding.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
A Select models a query to be used when retrieving data from a DataSource.
void addSequence(te::da::Sequence *sequence)
It creates a new sequence in the data source.
void renameDataSet(const std::string &name, const std::string &newName)
It renames a dataset.
std::string BuildRequest(const std::string &serviceURL, const std::string &coverageName, const te::gm::Envelope *e=0)
void commit()
It commits the transaction.
std::size_t getNumberOfProperties(const std::string &datasetName)
It gets the number of properties of the given dataset.
void remove(const std::string &datasetName, const te::da::ObjectIdSet *oids=0)
It removes all the informed items from the dataset.
void add(Constraint *c)
It adds a new constraint.
te::rst::Grid * getGrid()
Returns the definition of the raster grid support.
A dataset is the unit of information manipulated by the data access module of TerraLib.
std::auto_ptr< te::da::ForeignKey > getForeignKey(const std::string &datasetName, const std::string &name)
It retrieves the foreign key from the given dataset.
void dropCheckConstraint(const std::string &datasetName, const std::string &name)
It removes the check constraint from the dataset.
It describes a primary key (pk) constraint.
const double & getLowerLeftX() const
It returns a constant reference to the x coordinate of the lower left corner.
std::vector< std::string > getUniqueKeyNames(const std::string &datasetName)
It gets the unique key names of the given dataset.
te::gm::Envelope * getExtent()
Returns the geographic extension of the grid.
std::size_t getNumberOfItems(const std::string &datasetName)
It retrieves the number of items of the given dataset.
A GDAL data set gives access to a raster file.
std::auto_ptr< te::da::BatchExecutor > getBatchExecutor()
It creates a batch command executor.
std::auto_ptr< te::da::DataSet > query(const te::da::Select &q, te::common::TraverseType travType=te::common::FORWARDONLY, bool connected=false, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It executes a query that may return some data using a generic query. A dataset can be connected or di...
void dropUniqueKey(const std::string &datasetName, const std::string &name)
It removes the unique key constraint from the dataset.
void rollBack()
It aborts the transaction. Any changes will be rolled-back.
A rectified grid is the spatial support for raster data.
std::vector< std::string > getDataSetNames()
It It gets the dataset names available in the data source.
void add(const std::string &datasetName, te::da::DataSet *d, const std::map< std::string, std::string > &options, std::size_t limit=0)
It adds data items to the dataset in the data source.
TEGDALEXPORT te::rst::Grid * GetGrid(GDALDataset *gds)
Gets the grid definition from a GDAL dataset.
bool foreignKeyExists(const std::string &datasetName, const std::string &name)
It checks if a foreign key with the given name exists in the data source.
void addIndex(const std::string &datasetName, te::da::Index *idx, const std::map< std::string, std::string > &options)
It adds an index to the dataset.
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.
void dropIndex(const std::string &datasetName, const std::string &idxName)
It removes the index from the dataset schema.
void addPrimaryKey(const std::string &datasetName, te::da::PrimaryKey *pk)
It adds a primary key constraint to the dataset schema.
std::vector< std::string > getCheckConstraintNames(const std::string &datasetName)
It gets the check constraint names of the given dataset.
void begin()
NOT SUPPORTED METHODS.
const Envelope * getMBR() const
It returns the minimum bounding rectangle for the geometry in an internal representation.
A Query is independent from the data source language/dialect.
It describes an index associated to a DataSetType.
boost::int64_t getLastGeneratedId()
It returns the last id generated by an insertion command.