21 #include "../common/Translator.h"
22 #include "../dataaccess/dataset/ObjectId.h"
23 #include "../dataaccess/dataset/ObjectIdSet.h"
24 #include "../dataaccess/query/DataSetName.h"
25 #include "../dataaccess/query/Query.h"
26 #include "../dataaccess/query/Select.h"
27 #include "../dataaccess/utils/Utils.h"
28 #include "../datatype/ByteArray.h"
29 #include "../datatype/Date.h"
30 #include "../datatype/TimeInstant.h"
31 #include "../geometry/Envelope.h"
32 #include "../geometry/GeometryProperty.h"
33 #include "../srs/Config.h"
41 #include <ogrsf_frmts.h>
46 std::size_t pos = sql.find(
"AND Intersection");
49 if(pos == std::string::npos)
50 pos = sql.find(
"WHERE Intersection");
52 if(pos == std::string::npos)
57 std::size_t pos2 = sql.find(
"))", pos);
58 newQuery = sql.substr(0, pos);
59 newQuery += sql.substr(pos2 + 2);
65 : te::da::DataSourceTransactor(),
85 if (!m_ogrDs->getOGRDataSource())
106 if (!m_ogrDs->getOGRDataSource())
107 return std::auto_ptr<te::da::DataSet>();
109 OGRDataSource* ds = OGRSFDriverRegistrar::Open(m_ogrDs->getOGRDataSource()->GetName());
111 std::string sql =
"SELECT FID, * FROM \'" + name +
"\'";
112 OGRLayer* layer = ds->ExecuteSQL(sql.c_str(), 0, 0);
115 throw Exception(
TR_OGR(
"The informed data set could not be found in the data source."));
117 return std::auto_ptr<te::da::DataSet>(
new DataSet(ds, layer));
128 if (!m_ogrDs->getOGRDataSource())
129 return std::auto_ptr<te::da::DataSet>();
131 OGRDataSource* ds = OGRSFDriverRegistrar::Open(m_ogrDs->getOGRDataSource()->GetName());
133 std::string sql =
"SELECT FID, * FROM \'" + name +
"\'";
134 OGRLayer* layer = ds->ExecuteSQL(sql.c_str(), 0, 0);
137 throw Exception(
TR_OGR(
"The informed data set could not be found in the data source."));
141 return std::auto_ptr<te::da::DataSet>(
new DataSet(ds, layer));
152 if (!m_ogrDs->getOGRDataSource())
153 return std::auto_ptr<te::da::DataSet>();
155 OGRDataSource* ds = OGRSFDriverRegistrar::Open(m_ogrDs->getOGRDataSource()->GetName());
157 std::string sql =
"SELECT FID, * FROM \'" + name +
"\'";
158 OGRLayer* layer = ds->ExecuteSQL(sql.c_str(), 0, 0);
161 throw Exception(
TR_OGR(
"The informed data set could not be found in the data source."));
165 layer->SetSpatialFilter(ogrg);
167 OGRGeometryFactory::destroyGeometry(ogrg);
169 return std::auto_ptr<te::da::DataSet>(
new DataSet(ds, layer));
177 if (!m_ogrDs->getOGRDataSource())
178 return std::auto_ptr<te::da::DataSet>();
180 OGRDataSource* ds = OGRSFDriverRegistrar::Open(m_ogrDs->getOGRDataSource()->GetName());
184 SQLVisitor visitor(*m_ogrDs->getDialect(), sql);
190 OGRLayer* layer = ds->ExecuteSQL(sql.c_str(), 0, 0);
193 throw Exception(
TR_OGR(
"Could not retrieve the DataSet from data source."));
200 return std::auto_ptr<te::da::DataSet>(
new DataSet(ds, layer));
208 if (!m_ogrDs->getOGRDataSource())
209 return std::auto_ptr<te::da::DataSet>();
211 OGRDataSource* ds = OGRSFDriverRegistrar::Open(m_ogrDs->getOGRDataSource()->GetName());
213 OGRLayer* layer = ds->ExecuteSQL(query.c_str(), 0, 0);
216 throw Exception(
TR_OGR(
"Could not retrieve the DataSet from data source."));
218 return std::auto_ptr<te::da::DataSet>(
new DataSet(ds, layer));
233 if (!m_ogrDs->getOGRDataSource())
236 OGRLayer* layer = m_ogrDs->getOGRDataSource()->ExecuteSQL(command.c_str(), 0,
"");
239 m_ogrDs->getOGRDataSource()->ReleaseResultSet(layer);
244 return std::auto_ptr<te::da::PreparedQuery>(0);
249 return std::auto_ptr<te::da::BatchExecutor>(0);
278 std::vector<std::string> names;
280 if (!m_ogrDs->getOGRDataSource())
283 for(
int i=0; i<m_ogrDs->getOGRDataSource()->GetLayerCount(); i++)
284 names.push_back(m_ogrDs->getOGRDataSource()->GetLayer(i)->GetName());
291 if (!m_ogrDs->getOGRDataSource())
294 return m_ogrDs->getOGRDataSource()->GetLayerCount();
299 if (!m_ogrDs->getOGRDataSource())
300 return std::auto_ptr<te::da::DataSetType>();
302 std::string sql(
"SELECT FID, * FROM \'");
305 OGRLayer* l = m_ogrDs->getOGRDataSource()->ExecuteSQL(sql.c_str(), 0, 0);
308 return std::auto_ptr<te::da::DataSetType>();
310 std::auto_ptr<te::da::DataSetType> type(
Convert2TerraLib(l->GetLayerDefn()));
314 const char* colIdName = l->GetFIDColumn();
316 if(colIdName == 0 || colIdName[0] ==
'\0')
319 int pos = l->GetLayerDefn()->GetFieldIndex(colIdName);
323 pk->
add(type->getProperty(pos));
333 m_ogrDs->getOGRDataSource()->ReleaseResultSet(l);
340 boost::ptr_vector<te::dt::Property> ps;
342 if (!m_ogrDs->getOGRDataSource())
345 std::string sql(
"SELECT FID, * FROM \'");
346 sql += datasetName +
"\'";
348 OGRLayer* l = m_ogrDs->getOGRDataSource()->ExecuteSQL(sql.c_str(), 0, 0);
353 std::auto_ptr<te::da::DataSetType> dt(
Convert2TerraLib(l->GetLayerDefn(),srs));
354 std::vector<te::dt::Property*> props = dt->getProperties();
355 std::vector<te::dt::Property*>::iterator it;
357 for(it=props.begin(); it!=props.end(); ++it)
358 ps.push_back((*it)->clone());
361 m_ogrDs->getOGRDataSource()->ReleaseResultSet(l);
368 if (!m_ogrDs->getOGRDataSource())
369 return std::auto_ptr<te::dt::Property>();
372 std::string sql(
"SELECT FID, * FROM \'");
373 sql += datasetName +
"\'";
375 OGRLayer* l = m_ogrDs->getOGRDataSource()->ExecuteSQL(sql.c_str(), 0, 0);
378 idx = l->GetLayerDefn()->GetFieldIndex(name.c_str());
380 m_ogrDs->getOGRDataSource()->ReleaseResultSet(l);
382 return getProperty(datasetName, idx);
387 OGRDataSource* ogrds = m_ogrDs->getOGRDataSource();
389 return std::auto_ptr<te::dt::Property>();
391 std::auto_ptr<te::dt::Property> res;
392 std::string sql (
"SELECT FID, * FROM \'");
393 sql += datasetName +
"\'";
395 OGRLayer* l = ogrds->ExecuteSQL(sql.c_str(), 0, 0);
399 OGRFeatureDefn* def = l->GetLayerDefn();
400 OGRFieldDefn* fdef = def->GetFieldDefn(propertyPos);
406 m_ogrDs->getOGRDataSource()->ReleaseResultSet(l);
413 OGRDataSource* ogrds = m_ogrDs->getOGRDataSource();
415 return std::vector<std::string>();
417 std::vector<std::string> res;
418 std::string sql (
"SELECT FID, * FROM \'");
419 sql += datasetName +
"\'";
421 OGRLayer* l = ogrds->ExecuteSQL(sql.c_str(), 0, 0);
425 OGRFeatureDefn* def = l->GetLayerDefn();
427 for(
int i=0; i<def->GetFieldCount(); i++)
428 res.push_back(def->GetFieldDefn(i)->GetNameRef());
431 ogrds->ReleaseResultSet(l);
438 OGRDataSource* ogrds = m_ogrDs->getOGRDataSource();
442 std::string sql(
"SELECT FID, * FROM \'");
443 sql += datasetName +
"\'";
445 OGRLayer* l = ogrds->ExecuteSQL(sql.c_str(), 0, 0);
451 res = l->GetLayerDefn()->GetFieldCount();
452 ogrds->ReleaseResultSet(l);
460 OGRDataSource* ogrds = m_ogrDs->getOGRDataSource();
464 std::string sql(
"SELECT FID, * FROM \'");
465 sql += datasetName +
"\'";
468 OGRLayer* l = ogrds->ExecuteSQL(sql.c_str(), 0, 0);
472 res = (l->GetLayerDefn()->GetFieldIndex(name.c_str()) != -1);
473 ogrds->ReleaseResultSet(l);
481 if (!m_ogrDs->getOGRDataSource())
484 OGRLayer* l = m_ogrDs->getOGRDataSource()->GetLayerByName(datasetName.c_str());
494 OGRErr error = l->CreateField(nField);
498 if(error != OGRERR_NONE)
499 throw Exception(
TR_OGR(
"Error when attempting add the property."));
501 error = l->SyncToDisk();
503 if(error != OGRERR_NONE)
504 throw Exception(
TR_OGR(
"Error saving changes on the file."));
511 OGRLayer* l = m_ogrDs->getOGRDataSource()->GetLayerByName(datasetName.c_str());
515 if(!l->TestCapability(OLCDeleteField))
516 throw Exception(
TR_OGR(
"This dataset do not support remove properties operation."));
518 int fPos = l->GetLayerDefn()->GetFieldIndex(name.c_str());
521 throw Exception(
TR_OGR(
"Field not found."));
523 OGRErr error = l->DeleteField(fPos);
525 if(error != OGRERR_NONE)
526 throw Exception(
TR_OGR(
"Error when attempting remove the property."));
528 error = l->SyncToDisk();
530 if(error != OGRERR_NONE)
531 throw Exception(
TR_OGR(
"Error saving changes on the file."));
536 const std::string& propertyName,
537 const std::string& newPropertyName)
539 if (!m_ogrDs->getOGRDataSource())
542 OGRLayer* l = m_ogrDs->getOGRDataSource()->GetLayerByName(datasetName.c_str());
546 int idx = l->GetLayerDefn()->GetFieldIndex(propertyName.c_str());
549 throw Exception(
TR_OGR(
"Field to be renamed does not exists."));
551 OGRFieldDefn* df = l->GetLayerDefn()->GetFieldDefn(idx);
553 df->SetName(newPropertyName.c_str());
559 if (!m_ogrDs->getOGRDataSource())
560 return std::auto_ptr<te::da::PrimaryKey>();
562 std::auto_ptr<te::da::PrimaryKey> res;
563 std::string sql(
"SELECT FID, * FROM \'");
564 sql += datasetName +
"\'";
566 OGRLayer* layer = m_ogrDs->getOGRDataSource()->ExecuteSQL(sql.c_str(), 0, 0);
570 const char* colIdName = layer->GetFIDColumn();
572 if(colIdName == 0 || colIdName[0] ==
'\0')
575 int pos = layer->GetLayerDefn()->GetFieldIndex(colIdName);
580 res->add(getProperty(datasetName, pos).
get());
584 m_ogrDs->getOGRDataSource()->ReleaseResultSet(layer);
604 return std::auto_ptr<te::da::ForeignKey>();
609 return std::vector<std::string>();
627 return std::auto_ptr<te::da::UniqueKey>();
632 return std::vector<std::string>();
650 return std::auto_ptr<te::da::CheckConstraint>();
655 return std::vector<std::string>();
673 return std::auto_ptr<te::da::Index>();
678 return std::vector<std::string>();
687 const std::map<std::string, std::string>& )
697 return std::auto_ptr<te::da::Sequence>();
702 return std::vector<std::string>();
719 const std::string& propertyName)
721 if (!m_ogrDs->getOGRDataSource())
722 return std::auto_ptr<te::gm::Envelope>();
724 std::auto_ptr<te::gm::Envelope> res;
725 std::string sql(
"SELECT ");
726 sql += propertyName +
" FROM \'";
727 sql += datasetName +
"\'";
729 OGRLayer* l = m_ogrDs->getOGRDataSource()->ExecuteSQL(sql.c_str(), 0, 0);
733 std::auto_ptr<OGREnvelope> env(
new OGREnvelope);
735 if(l->GetExtent(env.get()) != OGRERR_NONE)
737 m_ogrDs->getOGRDataSource()->ReleaseResultSet(l);
738 throw Exception(
TR_OGR(
"Error when attempting get extent."));
743 m_ogrDs->getOGRDataSource()->ReleaseResultSet(l);
752 return getExtent(datasetName,
"OGR_GEOMETRY");
757 if (!m_ogrDs->getOGRDataSource())
760 OGRLayer* l = m_ogrDs->getOGRDataSource()->GetLayerByName(datasetName.c_str());
763 return l->GetFeatureCount();
770 if (!m_ogrDs->getOGRDataSource())
773 return (m_ogrDs->getOGRDataSource()->GetLayerCount() > 0);
778 if (!m_ogrDs->getOGRDataSource())
781 return (m_ogrDs->getOGRDataSource()->GetLayerByName(name.c_str()) != 0);
786 if (!m_ogrDs->getOGRDataSource())
789 if(!m_ogrDs->getOGRDataSource()->TestCapability(ODsCCreateLayer))
790 throw Exception(
TR_OGR(
"This driver does not support dataset creation."));
792 OGRwkbGeometryType geomType = wkbUnknown;
793 OGRSpatialReference* srs = 0;
800 srs =
new OGRSpatialReference();
801 srs->importFromEPSG(srid);
805 char** papszOptions = 0;
806 std::map<std::string, std::string>::const_iterator it = m_ogrDs->getConnectionInfo().begin();
807 while(it != m_ogrDs->getConnectionInfo().end())
809 if(it->first ==
"URI" || it->first ==
"SOURCE" || it->first ==
"DRIVER")
814 papszOptions = CSLSetNameValue(papszOptions, it->first.c_str(), it->second.c_str());
818 OGRLayer* newLayer = m_ogrDs->getOGRDataSource()->CreateLayer(dt->
getName().c_str(), srs, geomType, papszOptions);
821 CSLDestroy(papszOptions);
824 throw Exception(
TR_OGR(
"Error when attempting create the dataset type."));
826 dt->
setName(newLayer->GetName());
829 for(
size_t i = 0; i < dt->
size(); ++i)
834 const std::string& cloneName,
835 const std::map<std::string, std::string>& )
837 if (!m_ogrDs->getOGRDataSource())
840 if(!m_ogrDs->getOGRDataSource()->TestCapability(ODsCCreateLayer))
841 throw Exception(
TR_OGR(
"This driver does not support creates a dataset."));
843 OGRLayer* l = m_ogrDs->getOGRDataSource()->GetLayerByName(name.c_str());
846 throw Exception(
TR_OGR(
"Could not retrieve the DataSet from data source."));
848 OGRLayer* cl = m_ogrDs->getOGRDataSource()->CopyLayer(l, cloneName.c_str());
851 throw Exception(
TR_OGR(
"Error when attempting clone the dataset."));
856 if (!m_ogrDs->getOGRDataSource())
859 if(!m_ogrDs->getOGRDataSource()->TestCapability(ODsCDeleteLayer))
860 throw Exception(
TR_OGR(
"This driver does not support remove a dataset."));
864 for(; i<m_ogrDs->getOGRDataSource()->GetLayerCount(); i++)
865 if(name.compare(m_ogrDs->getOGRDataSource()->GetLayer(i)->GetName()) == 0)
868 if(i == m_ogrDs->getOGRDataSource()->GetLayerCount())
869 throw Exception(
TR_OGR(
"Could not retrieve the DataSet from data source."));
871 if(m_ogrDs->getOGRDataSource()->DeleteLayer(i) != OGRERR_NONE)
872 throw Exception(
TR_OGR(
"Error when attempting to remove the dataset."));
881 const std::map<std::string, std::string>& options,
885 limit = std::string::npos;
887 if (!m_ogrDs->getOGRDataSource())
890 OGRLayer* layer = m_ogrDs->getOGRDataSource()->GetLayerByName(datasetName.c_str());
893 throw Exception(
TR_OGR(
"Could not retrieve the DataSet from data source."));
901 std::size_t nProcessedRows = 0;
903 while(d->
moveNext() && (nProcessedRows != limit))
905 OGRFeature* feat = OGRFeature::CreateFeature(layer->GetLayerDefn());
907 std::size_t currfield = 0;
909 for(std::size_t i = 0; i != nproperties; ++i)
922 feat->SetField(currfield, d->
getInt16(i));
927 feat->SetField(currfield, d->
getInt32(i));
932 feat->SetField(currfield, d->
getAsString(i).c_str());
937 feat->SetField(currfield, d->
getDouble(i));
942 feat->SetField(currfield, atof(d->
getNumeric(i).c_str()));
948 std::auto_ptr<te::dt::ByteArray> ba(d->
getByteArray(i));
949 feat->SetField(currfield, ba->bytesUsed(),
reinterpret_cast<unsigned char*
>(ba->getData()));
956 std::auto_ptr<te::dt::DateTime> dtm(d->
getDateTime(i));
962 feat->SetField(currfield,
963 static_cast<int>(dtime->getYear()),
964 static_cast<int>(dtime->getMonth()),
965 static_cast<int>(dtime->getDay()));
974 feat->SetField(currfield, 0, 0, 0,
975 static_cast<int>(tduration->
getHours()),
986 feat->SetField(currfield,
987 static_cast<int>(dtime->getYear()),
988 static_cast<int>(dtime->getMonth()),
989 static_cast<int>(dtime->getDay()),
990 static_cast<int>(tduration->
getHours()),
997 throw Exception (
TR_OGR(
"Unsupported date and time type by OGR."));
1003 std::auto_ptr<te::gm::Geometry> geom(d->
getGeometry(i));
1005 feat->SetGeometryDirectly(OGRgeom);
1010 throw Exception(
TR_OGR(
"Unsupported data type by OGR."));
1014 if(layer->CreateFeature(feat) != OGRERR_NONE)
1016 OGRFeature::DestroyFeature(feat);
1017 throw Exception(
TR_OGR(
"Fail to insert dataset item."));
1020 OGRFeature::DestroyFeature(feat);
1035 if(!m_ogrDs->getOGRDataSource())
1038 OGRLayer* l = m_ogrDs->getOGRDataSource()->GetLayerByName(datasetName.c_str());
1041 throw Exception(
TR_OGR(
"Could not retrieve the DataSet from data source."));
1043 if(!l->TestCapability(OLCDeleteFeature))
1044 throw Exception(
TR_OGR(
"Driver does not support removal of features."));
1046 std::set<te::da::ObjectId*, te::common::LessCmp<te::da::ObjectId*> >::const_iterator it = oids->
begin();
1048 while(it != oids->
end())
1052 if(l->DeleteFeature(atoi((*it)->getValue()[0].toString().c_str())) != OGRERR_NONE)
1055 throw Exception(
TR_OGR(
"Error when attempting to remove the feature."));
1066 const std::vector<std::size_t>& ,
1068 const std::map<std::string, std::string>& ,
virtual double getDouble(std::size_t i) const =0
Method for retrieving a double attribute value.
std::vector< std::string > getSequenceNames()
It gets the sequence names available in the data source.
TEOGREXPORT int Convert2TerraLibProjection(OGRSpatialReference *osrs)
It converts the OGR Projection to TerraLib Projection.
std::string escape(const std::string &value)
It escapes a string for using in commands and queries.
bool primaryKeyExists(const std::string &datasetName, const std::string &name)
It checks if a primary key exists in the dataset.
std::auto_ptr< te::da::DataSetType > getDataSetType(const std::string &name)
It gets information about the given dataset.
It describes an index associated to a DataSetType.
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...
std::size_t getNumberOfItems(const std::string &datasetName)
It retrieves the number of items of the given dataset.
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset.
This class represents a set of unique ids created in the same context. i.e. from the same data set...
bool indexExists(const std::string &datasetName, const std::string &name)
It checks if an index with the given name exists in the dataset.
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.
Property * getProperty(std::size_t i) const
It returns the i-th property.
std::size_t size() const
It returns the number of properties of the CompositeProperty.
bool isDataSetNameValid(const std::string &datasetName)
It returns true if the given string is a valid dataset name.
std::vector< std::string > getDataSetNames()
It It gets the dataset names available in the data source.
std::string RemoveSpatialSql(const std::string &sql)
void dropUniqueKey(const std::string &datasetName, const std::string &name)
It removes the unique key constraint from the dataset.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
bool isPropertyNameValid(const std::string &propertyName)
It checks if the given property name is valid.
virtual std::string getAsString(std::size_t i, int precision=0) const
Method for retrieving a data value as a string plain representation.
void remove(const std::string &datasetName, const te::da::ObjectIdSet *oids=0)
It removes all the informed items from the dataset.
A Select models a query to be used when retrieving data from a DataSource.
int getSRID() const
It returns the spatial reference system identifier associated to this property.
virtual std::auto_ptr< te::dt::DateTime > getDateTime(std::size_t i) const =0
Method for retrieving a date and time attribute value.
void dropProperty(const std::string &datasetName, const std::string &name)
It removes a property from the given dataset.
virtual boost::int32_t getInt32(std::size_t i) const =0
Method for retrieving a 32-bit integer attribute value (4 bytes long).
std::auto_ptr< te::da::ForeignKey > getForeignKey(const std::string &datasetName, const std::string &name)
It retrieves the foreign key from the given dataset.
A class for data providers of OGR.
std::size_t getNumberOfProperties(const std::string &datasetName)
It gets the number of properties of the given dataset.
void addUniqueKey(const std::string &datasetName, te::da::UniqueKey *uk)
It adds a unique key constraint to the dataset.
void begin()
It starts a new transaction.
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection.
It describes a primary key (pk) constraint.
const std::string & getName() const
It returns the property name.
virtual std::string getNumeric(std::size_t i) const =0
Method for retrieving a numeric attribute value.
std::vector< std::string > getPropertyNames(const std::string &datasetName)
It gets the property names of the given 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.
virtual bool isNull(std::size_t i) const =0
It checks if the attribute value is NULL.
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
It describes a sequence (a number generator).
void dropForeignKey(const std::string &datasetName, const std::string &fkName)
It removes the foreign key constraint from the dataset schema.
SpatialRelation
Spatial relations between geometric objects.
It models a foreign key constraint for a DataSetType.
A base class for date data types.
boost::ptr_vector< te::dt::Property > getProperties(const std::string &datasetName)
It retrieves the properties of the dataset.
void setName(const std::string &name)
It sets the property name.
AccessPolicy
Supported data access policies (can be used as bitfield).
bool isInTransaction() const
It returns true if a transaction is in progress, otherwise, it returns false.
void cancel()
It requests that the data source stop the processing of the current command.
void dropDataSet(const std::string &name)
It removes the dataset schema from the data source.
std::size_t getNumberOfDataSets()
It retrieves the number of data sets available in the data source.
virtual boost::int16_t getInt16(std::size_t i) const =0
Method for retrieving a 16-bit integer attribute value (2 bytes long).
double m_lly
Lower left corner y-coordinate.
void rollBack()
It aborts the transaction. Any changes will be rolled-back.
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.
std::auto_ptr< te::da::Sequence > getSequence(const std::string &name)
It gets the sequence with the given name in the data source.
Utility functions for the data access module.
A Query is independent from the data source language/dialect.
boost::int64_t getLastGeneratedId()
It returns the last id generated by an insertion command.
TEOGREXPORT OGRGeometry * Convert2OGR(const te::gm::Geometry *teGeom)
It converts the TerraLib Geometry to OGR Geometry.
bool hasGeom() const
It returns true if the DataSetType has at least one geometry property; otherwise, it returns false...
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.
double m_ury
Upper right corner y-coordinate.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
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::Index > getIndex(const std::string &datasetName, const std::string &name)
It gets the index with the given name from the dataset.
Implementation of a DataSet for OGR data provider.
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos.
std::vector< std::string > getIndexNames(const std::string &datasetName)
It gets the index names of the given dataset.
It describes a unique key (uk) constraint.
virtual std::auto_ptr< te::dt::ByteArray > getByteArray(std::size_t i) const =0
Method for retrieving a byte array.
te::da::DataSource * getDataSource() const
It returns the parent data source of the transactor.
void dropCheckConstraint(const std::string &datasetName, const std::string &name)
It removes the check constraint from the dataset.
long getSeconds() const
It returns the seconds of a minute - from 0 to 59.
void renameDataSet(const std::string &name, const std::string &newName)
It renames a dataset.
#define TR_OGR(message)
It marks a string in order to get translated. This is a special mark used in the DataAccess module of...
double m_urx
Upper right corner x-coordinate.
std::set< ObjectId *, te::common::LessCmp< ObjectId * > >::const_iterator begin() const
Returns an iterator for the object ids in container.
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::set< ObjectId *, te::common::LessCmp< ObjectId * > >::const_iterator end() const
Returns an iterator for the object ids in container.
bool propertyExists(const std::string &datasetName, const std::string &name)
It checks if a property with the given name exists in the dataset.
bool dataSetExists(const std::string &name)
It checks if a dataset with the given name exists in the data source.
TraverseType
A dataset can be traversed in two ways:
The OGR data source provider.
void addForeignKey(const std::string &datasetName, te::da::ForeignKey *fk)
It adds a foreign key constraint to a dataset.
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
long getMinutes() const
It returns the minutes of a hour - from 0 to 59.
void commit()
It commits the transaction.
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 addSequence(te::da::Sequence *sequence)
It creates a new sequence in the data source.
long getHours() const
It returns the hours of a day - from 0 to 23.
A class that models the description of a dataset.
TEOGREXPORT te::gm::Geometry * Convert2TerraLib(OGRGeometry *ogrGeom)
It converts the OGR Geometry to TerraLib Geometry.
std::auto_ptr< te::da::BatchExecutor > getBatchExecutor()
It creates a batch command executor.
bool hasDataSets()
It checks if the data source has any 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.
Transactor(DataSource *ds)
std::vector< std::string > getCheckConstraintNames(const std::string &datasetName)
It gets the check constraint names of the given dataset.
void addProperty(const std::string &datasetName, te::dt::Property *p)
It adds a new property to the dataset schema.
void execute(const te::da::Query &command)
It executes the specified command using a generic query representation.
A class to represent time instant.
void add(te::dt::Property *p)
It adds a property to the list of properties of the primary key.
It models a property definition.
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.
double m_llx
Lower left corner x-coordinate.
virtual ReturnType accept(VisitorType &guest) const =0
It call the visit method from the guest object.
std::vector< std::string > getUniqueKeyNames(const std::string &datasetName)
It gets the unique key names of the given dataset.
int getType() const
It returns the property data type.
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.
A visitor for building an SQL statement using OGR dialect.
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...
virtual std::auto_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
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 setSRID(int srid)
It sets the spatial reference system identifier associated to this property.
A class that describes a check constraint.
An Envelope defines a 2D rectangular region.
void renameProperty(const std::string &datasetName, const std::string &propertyName, const std::string &newPropertyName)
It renames a property of the given 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 addCheckConstraint(const std::string &datasetName, te::da::CheckConstraint *cc)
It adds a check constraint to the dataset.
Implementation of a DataSet for OGR data provider.
void dropIndex(const std::string &datasetName, const std::string &idxName)
It removes the index from the dataset schema.
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.
A dataset is the unit of information manipulated by the data access module of TerraLib.
std::auto_ptr< te::da::PrimaryKey > getPrimaryKey(const std::string &datasetName)
It retrieves the primary key of the dataset.
std::vector< std::string > getForeignKeyNames(const std::string &datasetName)
It gets the foreign key names of the given dataset.
void addPrimaryKey(const std::string &datasetName, te::da::PrimaryKey *pk)
It adds a primary key constraint to the dataset schema.
A class to represent time duration with nano-second/micro-second resolution.
void dropSequence(const std::string &name)
It removes the sequence from the data source.
bool uniqueKeyExists(const std::string &datasetName, const std::string &name)
It checks if a unique key with the given name exists in the dataset.
bool sequenceExists(const std::string &name)
It checks if a sequence with the given name exists in the data source.
void dropPrimaryKey(const std::string &datasetName)
It removes the primary key constraint from the dataset schema.