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>
44 m_layersInfo(layersInfo)
62 std::string layer, width, height, format;
66 throw Exception(
TE_TR(
"Invalid data set request. Missing the parameter 'LAYER'!"));
68 std::map<std::string, WMSLayerInfo>::const_iterator it = m_layersInfo.find(layer);
69 if(it == m_layersInfo.end())
70 throw Exception(
TE_TR(
"The informed data set could not be found in the data source!"));
73 std::auto_ptr<te::da::DataSetType> type = getDataSetType(layer);
89 std::string layer, width, height, format;
93 throw Exception(
TE_TR(
"Invalid data set request. Missing the parameter 'LAYER'!"));
95 std::map<std::string, WMSLayerInfo>::const_iterator it = m_layersInfo.find(layer);
96 if(it == m_layersInfo.end())
97 throw Exception(
TE_TR(
"The informed data set could not be found in the data source!"));
100 std::auto_ptr<te::da::DataSetType> type = getDataSetType(layer);
109 const std::string& propertyName,
116 return getDataSet(name, propertyName, g->
getMBR(), r, travType, connected, accessPolicy);
125 throw Exception(
TE_TR(
"The ObjectIdSet concept is not supported by the WMS driver!"));
134 throw Exception(
TE_TR(
"Query operations is not supported by the WMS driver!"));
143 throw Exception(
TE_TR(
"Query operations is not supported by the WMS driver!"));
148 std::vector<std::string> names;
150 std::map<std::string, WMSLayerInfo>::const_iterator it;
151 for(it = m_layersInfo.begin(); it != m_layersInfo.end(); ++it)
152 names.push_back(it->second.m_name);
159 return m_layersInfo.size();
164 std::map<std::string, WMSLayerInfo>::const_iterator it = m_layersInfo.find(name);
165 if(it == m_layersInfo.end())
166 throw Exception(
TE_TR(
"The informed data set could not be found in the data source."));
170 GDALDataset* gds =
static_cast<GDALDataset*
>(GDALOpen(info.
m_pseudoGetMapRequest.c_str(), GA_ReadOnly));
172 throw Exception(
TE_TR(
"The data set type could not be retrieved from data source."));
179 std::vector<te::rst::BandProperty*> bandProperties;
185 for(std::size_t i = 0; i < bandProperties.size(); ++i)
186 rp->
add(bandProperties[i]);
192 return std::auto_ptr<te::da::DataSetType>(type);
197 boost::ptr_vector<te::dt::Property> properties;
199 std::auto_ptr<te::da::DataSetType> type = getDataSetType(datasetName);
201 const std::vector<te::dt::Property*>& props = type->getProperties();
202 for(std::size_t i = 0; i < props.size(); ++i)
203 properties.push_back(props[i]->clone());
210 std::auto_ptr<te::da::DataSetType> type = getDataSetType(datasetName);
212 const std::vector<te::dt::Property*>& props = type->getProperties();
213 for(std::size_t i = 0; i < props.size(); ++i)
215 if(props[i]->getName() == name)
216 return std::auto_ptr<te::dt::Property>(props[i]->clone());
219 throw Exception(
TE_TR(
"The informed property name could not be found in the data set."));
224 std::auto_ptr<te::da::DataSetType> type = getDataSetType(datasetName);
226 const std::vector<te::dt::Property*>& props = type->getProperties();
228 if(propertyPos >= props.size())
229 throw Exception(
TE_TR(
"The informed property position could not be found in the data set."));
231 return std::auto_ptr<te::dt::Property>(props[propertyPos]->clone());
236 std::vector<std::string> propertyNames;
238 std::auto_ptr<te::da::DataSetType> type = getDataSetType(datasetName);
240 const std::vector<te::dt::Property*>& props = type->getProperties();
241 for(std::size_t i = 0; i < props.size(); ++i)
242 propertyNames.push_back(props[i]->getName());
244 return propertyNames;
249 return getPropertyNames(datasetName).size();
254 std::vector<std::string> propertyNames = getPropertyNames(datasetName);
256 for(std::size_t i = 0; i < propertyNames.size(); ++i)
257 if(propertyNames[i] == name)
264 const std::string& propertyName)
266 std::auto_ptr<te::da::DataSetType> type = getDataSetType(datasetName);
268 std::auto_ptr<te::dt::Property> prop = getProperty(datasetName, propertyName);
278 std::size_t propertyPos)
280 std::auto_ptr<te::da::DataSetType> type = getDataSetType(datasetName);
282 std::auto_ptr<te::dt::Property> prop = getProperty(datasetName, propertyPos);
298 return !m_layersInfo.empty();
303 return m_layersInfo.find(name) != m_layersInfo.end();
311 throw Exception(
TE_TR(
"The method begin() is not supported by the WMS driver!"));
316 throw Exception(
TE_TR(
"The method commit() is not supported by the WMS driver!"));
321 throw Exception(
TE_TR(
"The method rollBack() is not supported by the WMS driver!"));
326 throw Exception(
TE_TR(
"The method isInTransaction() is not supported by the WMS driver!"));
331 throw Exception(
TE_TR(
"The method execute() is not supported by the WMS driver!"));
336 throw Exception(
TE_TR(
"The method execute() is not supported by the WMS driver!"));
341 throw Exception(
TE_TR(
"The method getPrepared() is not supported by the WMS driver!"));
346 throw Exception(
TE_TR(
"The method getBatchExecutor() is not supported by the WMS driver!"));
351 throw Exception(
TE_TR(
"The method cancel() is not supported by the WMS driver!"));
356 throw Exception(
TE_TR(
"The method getLastGeneratedId() is not supported by the WMS driver!"));
361 throw Exception(
TE_TR(
"The method escape() is not supported by the WMS driver!"));
366 throw Exception(
TE_TR(
"The method isDataSetNameValid() is not supported by the WMS driver!"));
371 throw Exception(
TE_TR(
"The method isPropertyNameValid() is not supported by the WMS driver!"));
376 throw Exception(
TE_TR(
"The method addProperty() is not supported by the WMS driver!"));
381 throw Exception(
TE_TR(
"The method dropProperty() is not supported by the WMS driver!"));
386 throw Exception(
TE_TR(
"The method renameProperty() is not supported by the WMS driver!"));
391 throw Exception(
TE_TR(
"The method getPrimaryKey() is not supported by the WMS driver!"));
396 throw Exception(
TE_TR(
"The method primaryKeyExists() is not supported by the WMS driver!"));
401 throw Exception(
TE_TR(
"The method addPrimaryKey() is not supported by the WMS driver!"));
406 throw Exception(
TE_TR(
"The method dropPrimaryKey() is not supported by the WMS driver!"));
411 throw Exception(
TE_TR(
"The method getForeignKey() is not supported by the WMS driver!"));
416 throw Exception(
TE_TR(
"The method getForeignKeyNames() is not supported by the WMS driver!"));
421 throw Exception(
TE_TR(
"The method foreignKeyExists() is not supported by the WMS driver!"));
426 throw Exception(
TE_TR(
"The method addForeignKey() is not supported by the WMS driver!"));
431 throw Exception(
TE_TR(
"The method dropForeignKey() is not supported by the WMS driver!"));
436 throw Exception(
TE_TR(
"The method getUniqueKey() is not supported by the WMS driver!"));
441 throw Exception(
TE_TR(
"The method getUniqueKeyNames() is not supported by the WMS driver!"));
446 throw Exception(
TE_TR(
"The method uniqueKeyExists() is not supported by the WMS driver!"));
451 throw Exception(
TE_TR(
"The method addUniqueKey() is not supported by the WMS driver!"));
456 throw Exception(
TE_TR(
"The method dropUniqueKey() is not supported by the WMS driver!"));
461 throw Exception(
TE_TR(
"The method getCheckConstraint() is not supported by the WMS driver!"));
466 throw Exception(
TE_TR(
"The method getCheckConstraintNames() is not supported by the WMS driver!"));
471 throw Exception(
TE_TR(
"The method checkConstraintExists() is not supported by the WMS driver!"));
476 throw Exception(
TE_TR(
"The method addCheckConstraint() is not supported by the WMS driver!"));
481 throw Exception(
TE_TR(
"The method dropCheckConstraint() is not supported by the WMS driver!"));
486 throw Exception(
TE_TR(
"The method getIndex() is not supported by the WMS driver!"));
491 throw Exception(
TE_TR(
"The method getIndexNames() is not supported by the WMS driver!"));
496 throw Exception(
TE_TR(
"The method indexExists() is not supported by the WMS driver!"));
501 throw Exception(
TE_TR(
"The method addIndex() is not supported by the WMS driver!"));
506 throw Exception(
TE_TR(
"The method dropIndex() is not supported by the WMS driver!"));
511 throw Exception(
TE_TR(
"The method getSequence() is not supported by the WMS driver!"));
516 throw Exception(
TE_TR(
"The method getSequenceNames() is not supported by the WMS driver!"));
521 throw Exception(
TE_TR(
"The method sequenceExists() is not supported by the WMS driver!"));
526 throw Exception(
TE_TR(
"The method addSequence() is not supported by the WMS driver!"));
531 throw Exception(
TE_TR(
"The method dropSequence() is not supported by the WMS driver!"));
535 const std::map<std::string, std::string>& )
537 throw Exception(
TE_TR(
"The method createDataSet() is not supported by the WMS driver!"));
542 const std::map<std::string, std::string>& )
544 throw Exception(
TE_TR(
"The method cloneDataSet() is not supported by the WMS driver!"));
549 throw Exception(
TE_TR(
"The method dropDataSet() is not supported by the WMS driver!"));
555 throw Exception(
TE_TR(
"The method renameDataSet() is not supported by the WMS driver!"));
560 const std::map<std::string, std::string>& ,
563 throw Exception(
TE_TR(
"The method add() is not supported by the WMS driver!"));
568 throw Exception(
TE_TR(
"The method remove() is not supported by the WMS driver!"));
573 const std::vector<std::size_t>& ,
575 const std::map<std::string, std::string>& ,
578 throw Exception(
TE_TR(
"The method update() is not supported by the WMS driver!"));
583 throw Exception(
TE_TR(
"The method optimize() is not supported by the WMS driver!"));
void dropIndex(const std::string &datasetName, const std::string &idxName)
It removes the index from the dataset schema.
boost::int64_t getLastGeneratedId()
It returns the last id generated by an insertion command.
void remove(const std::string &datasetName, const te::da::ObjectIdSet *oids=0)
It removes all the informed items from the dataset.
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.
bool uniqueKeyExists(const std::string &datasetName, const std::string &name)
It checks if a unique key with the given name exists in the dataset.
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.
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 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...
CharEncoding
Supported charsets (character encoding).
Transactor(const std::string &uri, const std::map< std::string, WMSLayerInfo > &layersInfo)
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::vector< std::string > getIndexNames(const std::string &datasetName)
It gets the index names of the given dataset.
void begin()
NOT SUPPORTED METHODS.
std::vector< std::string > getSequenceNames()
It gets the sequence names available in the data source.
void dropPrimaryKey(const std::string &datasetName)
It removes the primary key constraint from the dataset schema.
void cancel()
It requests that the data source stop the processing of the current command.
std::string m_pseudoGetMapRequest
A class that models the description of a dataset.
Informations about WMS Layers.
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.
void addCheckConstraint(const std::string &datasetName, te::da::CheckConstraint *cc)
It adds a check constraint to the dataset.
void addForeignKey(const std::string &datasetName, te::da::ForeignKey *fk)
It adds a foreign key constraint to a dataset.
const double & getUpperRightX() const
It returns a constant refernce to the x coordinate of the upper right corner.
void addPrimaryKey(const std::string &datasetName, te::da::PrimaryKey *pk)
It adds a primary key constraint to the dataset schema.
const double & getLowerLeftY() const
It returns a constant refernce to the y coordinate of the lower left corner.
SpatialRelation
Spatial relations between geometric objects.
std::string BuildGetMapRequest(const std::string &serverUrl, const WMSLayerInfo &info, const std::string &width, const std::string &height, const std::string &format, const std::string &bbox="")
It describes a sequence (a number generator).
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.
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.
bool dataSetExists(const std::string &name)
It checks if a dataset with the given name exists in the data source.
#define TE_TR(message)
It marks a string in order to get translated.
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.
std::string escape(const std::string &value)
It escapes a string for using in commands and queries.
It models a property definition.
void addUniqueKey(const std::string &datasetName, te::da::UniqueKey *uk)
It adds a unique key constraint to the dataset.
void dropUniqueKey(const std::string &datasetName, const std::string &name)
It removes the unique key constraint from the dataset.
std::string GetBBOX(const te::gm::Envelope &e)
bool hasDataSets()
It checks if the data source has any dataset.
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...
AccessPolicy
Supported data access policies (can be used as bitfield).
TraverseType
A dataset can be traversed in two ways:
std::vector< std::string > getCheckConstraintNames(const std::string &datasetName)
It gets the check constraint names of the given dataset.
bool isPropertyNameValid(const std::string &propertyName)
It checks if the given property name is valid.
std::vector< std::string > getForeignKeyNames(const std::string &datasetName)
It gets the foreign key names of the given dataset.
An exception class for the TerraLib WMS module.
void add(te::rst::BandProperty *b)
It adds a new band information to the property.
void dropSequence(const std::string &name)
It removes the sequence from the data source.
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...
std::auto_ptr< te::da::PrimaryKey > getPrimaryKey(const std::string &datasetName)
It retrieves the primary key of the dataset.
void addProperty(const std::string &datasetName, te::dt::Property *p)
It adds a new property to the dataset schema.
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 ExtractRequestValues(const std::string &request, std::string &layer, std::string &width, std::string &height, std::string &format)
It models a foreign key constraint for a DataSetType.
bool isInTransaction() const
It returns true if a transaction is in progress, otherwise, it returns false.
It describes a unique key (uk) constraint.
std::auto_ptr< te::da::BatchExecutor > getBatchExecutor()
It creates a batch command executor.
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 renameProperty(const std::string &datasetName, const std::string &propertyName, const std::string &newPropertyName)
It renames a property of the given dataset.
void dropProperty(const std::string &datasetName, const std::string &name)
It removes a property from the given 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.
void rollBack()
It aborts the transaction. Any changes will be rolled-back.
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.
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.
std::auto_ptr< te::da::DataSetType > getDataSetType(const std::string &name)
It gets information about the given dataset.
std::vector< std::string > getUniqueKeyNames(const std::string &datasetName)
It gets the unique key names of the given dataset.
bool isDataSetNameValid(const std::string &datasetName)
It returns true if the given string is a valid dataset name.
It describes a primary key (pk) constraint.
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 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.
std::size_t getNumberOfItems(const std::string &datasetName)
It retrieves the number of items of the given dataset.
const double & getLowerLeftX() const
It returns a constant reference to the x coordinate of the lower left corner.
void execute(const te::da::Query &command)
It executes the specified command using a generic query representation.
te::gm::Envelope * getExtent()
Returns the geographic extension of the grid.
bool primaryKeyExists(const std::string &datasetName, const std::string &name)
It checks if a primary key exists in the dataset.
A GDAL data set gives access to a raster file.
void addSequence(te::da::Sequence *sequence)
It creates a new sequence in the data source.
void dropForeignKey(const std::string &datasetName, const std::string &fkName)
It removes the foreign key constraint from the dataset schema.
te::common::CharEncoding getEncoding()
It return the DataSource current encoding.
bool propertyExists(const std::string &datasetName, const std::string &name)
It checks if a property with the given name exists in the dataset.
void dropDataSet(const std::string &name)
It removes the dataset schema from the data source.
std::vector< std::string > getDataSetNames()
It It gets the dataset names available in the data source.
std::vector< std::string > getPropertyNames(const std::string &datasetName)
It gets the property names of the given dataset.
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.
void renameDataSet(const std::string &name, const std::string &newName)
It renames a dataset.
bool indexExists(const std::string &datasetName, const std::string &name)
It checks if an index with the given name exists in the dataset.
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.
bool sequenceExists(const std::string &name)
It checks if a sequence with the given name exists in the data source.
A rectified grid is the spatial support for raster data.
TEGDALEXPORT te::rst::Grid * GetGrid(GDALDataset *gds)
Gets the grid definition from a GDAL 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.
boost::ptr_vector< te::dt::Property > getProperties(const std::string &datasetName)
It retrieves the properties of the dataset.
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.
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 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.
std::auto_ptr< te::da::Sequence > getSequence(const std::string &name)
It gets the sequence with the given name in the data source.
std::size_t getNumberOfProperties(const std::string &datasetName)
It gets the number of properties of the given dataset.
void dropCheckConstraint(const std::string &datasetName, const std::string &name)
It removes the check constraint from the dataset.
void commit()
It commits the transaction.
Implementation of the transactor for the WMS driver.
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.