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/SpatialReferenceSystemManager.h" 
   34 #include "../srs/Config.h" 
   42 #include <ogrsf_frmts.h> 
   78   : te::da::DataSourceTransactor(),
 
   98   if (!m_ogrDs->getOGRDataSource())
 
  119   if (!m_ogrDs->getOGRDataSource())
 
  120     return std::auto_ptr<te::da::DataSet>();
 
  122   OGRDataSource* ds = OGRSFDriverRegistrar::Open(m_ogrDs->getOGRDataSource()->GetName());
 
  124   std::string sql = 
"SELECT FID, * FROM \'" + name + 
"\'";
 
  125   OGRLayer* layer = ds->ExecuteSQL(sql.c_str(), 0, 0);
 
  128     throw Exception(
TE_TR(
"The informed data set could not be found in the data source."));
 
  130   return std::auto_ptr<te::da::DataSet>(
new DataSet(ds, layer));
 
  141   if (!m_ogrDs->getOGRDataSource())
 
  142     return std::auto_ptr<te::da::DataSet>();
 
  144   OGRDataSource* ds = OGRSFDriverRegistrar::Open(m_ogrDs->getOGRDataSource()->GetName());
 
  146   std::string sql = 
"SELECT FID, * FROM \'" + name + 
"\'";
 
  147   OGRLayer* layer = ds->ExecuteSQL(sql.c_str(), 0, 0);
 
  150     throw Exception(
TE_TR(
"The informed data set could not be found in the data source."));
 
  154   return std::auto_ptr<te::da::DataSet>(
new DataSet(ds, layer));
 
  165   if (!m_ogrDs->getOGRDataSource())
 
  166     return std::auto_ptr<te::da::DataSet>();
 
  168   OGRDataSource* ds = OGRSFDriverRegistrar::Open(m_ogrDs->getOGRDataSource()->GetName());
 
  170   std::string sql = 
"SELECT FID, * FROM \'" + name + 
"\'";
 
  171   OGRLayer* layer = ds->ExecuteSQL(sql.c_str(), 0, 0);
 
  174     throw Exception(
TE_TR(
"The informed data set could not be found in the data source."));
 
  178   layer->SetSpatialFilter(ogrg);
 
  180   OGRGeometryFactory::destroyGeometry(ogrg);
 
  182   return std::auto_ptr<te::da::DataSet>(
new DataSet(ds, layer));
 
  190   if (!m_ogrDs->getOGRDataSource())
 
  191     return std::auto_ptr<te::da::DataSet>();
 
  193   OGRDataSource* ds = OGRSFDriverRegistrar::Open(m_ogrDs->getOGRDataSource()->GetName());
 
  197   SQLVisitor visitor(*m_ogrDs->getDialect(), sql);
 
  203   OGRLayer* layer = ds->ExecuteSQL(sql.c_str(), 0, 0);
 
  206     throw Exception(
TE_TR(
"Could not retrieve the DataSet from data source."));
 
  213   return std::auto_ptr<te::da::DataSet>(
new DataSet(ds, layer));
 
  221   if (!m_ogrDs->getOGRDataSource())
 
  222     return std::auto_ptr<te::da::DataSet>();
 
  224   OGRDataSource* ds = OGRSFDriverRegistrar::Open(m_ogrDs->getOGRDataSource()->GetName());
 
  227   std::string queryCopy = query;
 
  228   std::size_t pos = queryCopy.find(
"*");
 
  229   if(pos != std::string::npos)
 
  231     std::string fid = 
"FID, *";
 
  232     queryCopy.replace(pos, 1, fid);
 
  235   OGRLayer* layer = ds->ExecuteSQL(queryCopy.c_str(), 0, 0);
 
  238   throw Exception(
TE_TR(
"Could not retrieve the DataSet from data source."));
 
  240   return std::auto_ptr<te::da::DataSet>(
new DataSet(ds, layer));
 
  255   if (!m_ogrDs->getOGRDataSource())
 
  258   OGRLayer* layer = m_ogrDs->getOGRDataSource()->ExecuteSQL(command.c_str(), 0, 
"");
 
  261     m_ogrDs->getOGRDataSource()->ReleaseResultSet(layer);
 
  266   return std::auto_ptr<te::da::PreparedQuery>(0);
 
  271   return std::auto_ptr<te::da::BatchExecutor>(0);
 
  290   std::vector<std::string> names;
 
  292   if (!m_ogrDs->getOGRDataSource())
 
  295   for(
int i=0; i<m_ogrDs->getOGRDataSource()->GetLayerCount(); i++)
 
  296     names.push_back(m_ogrDs->getOGRDataSource()->GetLayer(i)->GetName());
 
  303   if (!m_ogrDs->getOGRDataSource())
 
  306   return m_ogrDs->getOGRDataSource()->GetLayerCount();
 
  311   if (!m_ogrDs->getOGRDataSource())
 
  312     return std::auto_ptr<te::da::DataSetType>();
 
  314   std::string sql(
"SELECT FID, * FROM \'");
 
  317   OGRLayer* l = m_ogrDs->getOGRDataSource()->ExecuteSQL(sql.c_str(), 0, 0);
 
  320     return std::auto_ptr<te::da::DataSetType>();
 
  322   std::auto_ptr<te::da::DataSetType> type(
Convert2TerraLib(l->GetLayerDefn()));
 
  326   const char* colIdName = l->GetFIDColumn();
 
  328   if(colIdName == 0 || colIdName[0] == 
'\0')
 
  331   int pos = l->GetLayerDefn()->GetFieldIndex(colIdName);
 
  335     pk->
add(type->getProperty(pos));
 
  345   m_ogrDs->getOGRDataSource()->ReleaseResultSet(l);
 
  354   OGRLayer* l = m_ogrDs->getOGRDataSource()->GetLayerByName(name.c_str());
 
  358     cap->setSupportAddColumn((l->TestCapability(OLCCreateField) == 0) ? 
false : 
true);
 
  359     cap->setSupportRemoveColumn((l->TestCapability(OLCDeleteField) == 0) ? 
false : 
true);
 
  360     cap->setSupportDataEdition((l->TestCapability(OLCRandomWrite) == 0) ? 
false : 
true);
 
  368   boost::ptr_vector<te::dt::Property> ps;
 
  370   if (!m_ogrDs->getOGRDataSource())
 
  373   std::string sql(
"SELECT FID, * FROM \'");
 
  374   sql += datasetName + 
"\'";
 
  376   OGRLayer* l = m_ogrDs->getOGRDataSource()->ExecuteSQL(sql.c_str(), 0, 0);
 
  381     std::auto_ptr<te::da::DataSetType> dt(
Convert2TerraLib(l->GetLayerDefn(),srs));
 
  382     std::vector<te::dt::Property*> props = dt->getProperties();
 
  383     std::vector<te::dt::Property*>::iterator it;
 
  385     for(it=props.begin(); it!=props.end(); ++it)
 
  386       ps.push_back((*it)->clone());
 
  389   m_ogrDs->getOGRDataSource()->ReleaseResultSet(l);
 
  396   if (!m_ogrDs->getOGRDataSource())
 
  397     return std::auto_ptr<te::dt::Property>();
 
  400   std::string sql(
"SELECT FID, * FROM \'");
 
  401   sql += datasetName + 
"\'";
 
  403   OGRLayer* l = m_ogrDs->getOGRDataSource()->ExecuteSQL(sql.c_str(), 0, 0);
 
  406     idx = l->GetLayerDefn()->GetFieldIndex(name.c_str());
 
  408   m_ogrDs->getOGRDataSource()->ReleaseResultSet(l);
 
  410   return getProperty(datasetName, idx);
 
  415   OGRDataSource* ogrds = m_ogrDs->getOGRDataSource();
 
  417     return std::auto_ptr<te::dt::Property>();
 
  419   std::auto_ptr<te::dt::Property> res;
 
  420   std::string sql (
"SELECT FID, * FROM \'");
 
  421   sql += datasetName + 
"\'";
 
  423   OGRLayer* l = ogrds->ExecuteSQL(sql.c_str(), 0, 0);
 
  427     OGRFeatureDefn* def = l->GetLayerDefn();
 
  428     OGRFieldDefn* fdef = def->GetFieldDefn(propertyPos);
 
  434   m_ogrDs->getOGRDataSource()->ReleaseResultSet(l);
 
  441   OGRDataSource* ogrds = m_ogrDs->getOGRDataSource();
 
  443     return std::vector<std::string>();
 
  445   std::vector<std::string> res;
 
  446   std::string sql (
"SELECT FID, * FROM \'");
 
  447   sql += datasetName + 
"\'";
 
  449   OGRLayer* l = ogrds->ExecuteSQL(sql.c_str(), 0, 0);
 
  453     OGRFeatureDefn* def = l->GetLayerDefn();
 
  455     for(
int i=0; i<def->GetFieldCount(); i++)
 
  456       res.push_back(def->GetFieldDefn(i)->GetNameRef());
 
  459   ogrds->ReleaseResultSet(l);
 
  466   OGRDataSource* ogrds = m_ogrDs->getOGRDataSource();
 
  470   std::string sql(
"SELECT FID, * FROM \'");
 
  471   sql += datasetName + 
"\'";
 
  473   OGRLayer* l = ogrds->ExecuteSQL(sql.c_str(), 0, 0);
 
  479     res = l->GetLayerDefn()->GetFieldCount();
 
  480     ogrds->ReleaseResultSet(l);
 
  488   OGRDataSource* ogrds = m_ogrDs->getOGRDataSource();
 
  492   std::string sql(
"SELECT FID, * FROM \'");
 
  493   sql += datasetName + 
"\'";
 
  496   OGRLayer* l = ogrds->ExecuteSQL(sql.c_str(), 0, 0);
 
  500     res = (l->GetLayerDefn()->GetFieldIndex(name.c_str()) != -1);
 
  501     ogrds->ReleaseResultSet(l);
 
  509   if (!m_ogrDs->getOGRDataSource())
 
  512   OGRLayer* l = m_ogrDs->getOGRDataSource()->GetLayerByName(datasetName.c_str());
 
  522       OGRErr error = l->CreateField(nField);
 
  526       if(error != OGRERR_NONE)
 
  527         throw Exception(
TE_TR(
"Error when attempting add the property: " + p->
getName() + 
"."));
 
  529       error = l->SyncToDisk();
 
  531       if(error != OGRERR_NONE)
 
  532         throw Exception(
TE_TR(
"Error saving changes on the file."));
 
  539   OGRLayer* l = m_ogrDs->getOGRDataSource()->GetLayerByName(datasetName.c_str());
 
  543     if(!l->TestCapability(OLCDeleteField))
 
  544       throw Exception(
TE_TR(
"This dataset do not support remove properties operation."));
 
  546     int fPos = l->GetLayerDefn()->GetFieldIndex(name.c_str());
 
  549       throw Exception(
TE_TR(
"Field not found."));
 
  551     OGRErr error = l->DeleteField(fPos);
 
  553     if(error != OGRERR_NONE)
 
  554       throw Exception(
TE_TR(
"Error when attempting remove the property."));
 
  556     error = l->SyncToDisk();
 
  558     if(error != OGRERR_NONE)
 
  559       throw Exception(
TE_TR(
"Error saving changes on the file."));
 
  564                             const std::string& propertyName,
 
  565                             const std::string& newPropertyName)
 
  567   if (!m_ogrDs->getOGRDataSource())
 
  570   OGRLayer* l = m_ogrDs->getOGRDataSource()->GetLayerByName(datasetName.c_str());
 
  574     int idx = l->GetLayerDefn()->GetFieldIndex(propertyName.c_str());
 
  577       throw Exception(
TE_TR(
"Field to be renamed does not exists."));
 
  579     OGRFieldDefn* df = l->GetLayerDefn()->GetFieldDefn(idx);
 
  581     OGRFieldDefn* dfn = 
new OGRFieldDefn(df);
 
  583     dfn->SetName(newPropertyName.c_str());
 
  585     OGRErr err = l->AlterFieldDefn(idx, dfn, ALTER_NAME_FLAG);
 
  587     if(err != OGRERR_NONE)
 
  588       throw Exception(
TE_TR(
"Fail to rename field."));
 
  594   if (!m_ogrDs->getOGRDataSource())
 
  597   std::auto_ptr<te::dt::Property> p;
 
  601   OGRLayer* l = m_ogrDs->getOGRDataSource()->GetLayerByName(datasetName.c_str());
 
  605     if(!l->TestCapability(OLCAlterFieldDefn))
 
  606       throw Exception(
TE_TR(
"This data source do not support the operation of alter columns type."));
 
  608     int idx = l->GetLayerDefn()->GetFieldIndex(propName.c_str());
 
  611       throw Exception(
TE_TR(
"Field to be renamed does not exists."));
 
  613     OGRFieldDefn* dfn = 
new OGRFieldDefn(l->GetLayerDefn()->GetFieldDefn(idx));
 
  617     OGRErr err = l->AlterFieldDefn(idx, dfn, ALTER_TYPE_FLAG);
 
  619     if(err != OGRERR_NONE)
 
  620       throw Exception(
TE_TR(
"Fail to to change field type."));
 
  622     std::string name = m_ogrDs->getOGRDataSource()->GetName();
 
  624     err = l->SyncToDisk();
 
  630   if (!m_ogrDs->getOGRDataSource())
 
  631     return std::auto_ptr<te::da::PrimaryKey>();
 
  633   std::auto_ptr<te::da::PrimaryKey> res;
 
  634   std::string sql(
"SELECT FID, * FROM \'");
 
  635   sql += datasetName + 
"\'";
 
  637   OGRLayer* layer = m_ogrDs->getOGRDataSource()->ExecuteSQL(sql.c_str(), 0, 0);
 
  641     const char* colIdName = layer->GetFIDColumn();
 
  643     if(colIdName == 0 || colIdName[0] == 
'\0')
 
  646     int pos = layer->GetLayerDefn()->GetFieldIndex(colIdName);
 
  651       res->add(getProperty(datasetName, pos).
get());
 
  655   m_ogrDs->getOGRDataSource()->ReleaseResultSet(layer);
 
  675   return std::auto_ptr<te::da::ForeignKey>();
 
  680   return std::vector<std::string>();
 
  698   return std::auto_ptr<te::da::UniqueKey>();
 
  703   return std::vector<std::string>();
 
  721   return std::auto_ptr<te::da::CheckConstraint>();
 
  726   return std::vector<std::string>();
 
  744   return std::auto_ptr<te::da::Index>();
 
  749   return std::vector<std::string>();
 
  758                       const std::map<std::string, std::string>& )
 
  768   return std::auto_ptr<te::da::Sequence>();
 
  773   return std::vector<std::string>();
 
  790                                                   const std::string& propertyName)
 
  792   if (!m_ogrDs->getOGRDataSource())
 
  793     return std::auto_ptr<te::gm::Envelope>();
 
  795   std::auto_ptr<te::gm::Envelope> res;
 
  796   std::string sql(
"SELECT ");
 
  797   sql += propertyName + 
" FROM \'";
 
  798   sql += datasetName + 
"\'";
 
  800   OGRLayer* l = m_ogrDs->getOGRDataSource()->ExecuteSQL(sql.c_str(), 0, 0);
 
  804     std::auto_ptr<OGREnvelope> env(
new OGREnvelope);
 
  806     if(l->GetExtent(env.get()) != OGRERR_NONE)
 
  808       m_ogrDs->getOGRDataSource()->ReleaseResultSet(l);
 
  809       throw Exception(
TE_TR(
"Error when attempting get extent."));
 
  814     m_ogrDs->getOGRDataSource()->ReleaseResultSet(l);
 
  823   return getExtent(datasetName, 
"OGR_GEOMETRY");
 
  828   if (!m_ogrDs->getOGRDataSource())
 
  831   OGRLayer* l = m_ogrDs->getOGRDataSource()->GetLayerByName(datasetName.c_str());
 
  834     return l->GetFeatureCount();
 
  841   if (!m_ogrDs->getOGRDataSource())
 
  844   return (m_ogrDs->getOGRDataSource()->GetLayerCount() > 0);
 
  849   if (!m_ogrDs->getOGRDataSource())
 
  852   return (m_ogrDs->getOGRDataSource()->GetLayerByName(name.c_str()) != 0);
 
  857   if (!m_ogrDs->getOGRDataSource())
 
  860   if(!m_ogrDs->getOGRDataSource()->TestCapability(ODsCCreateLayer))
 
  861     throw Exception(
TE_TR(
"This driver does not support dataset creation."));
 
  863   OGRwkbGeometryType geomType = wkbUnknown;
 
  864   OGRSpatialReference* srs = 0;
 
  875   char** papszOptions = 0;
 
  876   std::map<std::string, std::string>::const_iterator it = m_ogrDs->getConnectionInfo().begin();
 
  877   while(it != m_ogrDs->getConnectionInfo().end())
 
  879     if(it->first == 
"URI" || it->first == 
"SOURCE" || it->first == 
"DRIVER")
 
  884     papszOptions = CSLSetNameValue(papszOptions, it->first.c_str(), it->second.c_str());
 
  888   OGRLayer* newLayer = m_ogrDs->getOGRDataSource()->CreateLayer(dt->
getName().c_str(), srs, geomType, papszOptions);
 
  891     CSLDestroy(papszOptions);
 
  894     throw Exception(
TE_TR(
"Error when attempting create the dataset type."));
 
  896   dt->
setName(newLayer->GetName());
 
  899   for(
size_t i = 0; i < dt->
size(); ++i)
 
  904                           const std::string& cloneName,
 
  905                           const std::map<std::string, std::string>& )
 
  907   if (!m_ogrDs->getOGRDataSource())
 
  910   if(!m_ogrDs->getOGRDataSource()->TestCapability(ODsCCreateLayer))
 
  911     throw Exception(
TE_TR(
"This driver does not support creates a dataset."));
 
  913   OGRLayer* l = m_ogrDs->getOGRDataSource()->GetLayerByName(name.c_str());
 
  916     throw Exception(
TE_TR(
"Could not retrieve the DataSet from data source."));
 
  918   OGRLayer* cl = m_ogrDs->getOGRDataSource()->CopyLayer(l, cloneName.c_str());
 
  921     throw Exception(
TE_TR(
"Error when attempting clone the dataset."));
 
  926   if (!m_ogrDs->getOGRDataSource())
 
  929   if(!m_ogrDs->getOGRDataSource()->TestCapability(ODsCDeleteLayer))
 
  930     throw Exception(
TE_TR(
"This driver does not support remove a dataset."));
 
  934   for(; i<m_ogrDs->getOGRDataSource()->GetLayerCount(); i++)
 
  935     if(name.compare(m_ogrDs->getOGRDataSource()->GetLayer(i)->GetName()) == 0)
 
  938   if(i == m_ogrDs->getOGRDataSource()->GetLayerCount())
 
  939     throw Exception(
TE_TR(
"Could not retrieve the DataSet from data source."));
 
  941   if(m_ogrDs->getOGRDataSource()->DeleteLayer(i) != OGRERR_NONE)
 
  942     throw Exception(
TE_TR(
"Error when attempting to remove the dataset."));
 
  951                   const std::map<std::string, std::string>& options,
 
  955     limit = std::string::npos;
 
  957   if (!m_ogrDs->getOGRDataSource())
 
  960   OGRLayer* layer = m_ogrDs->getOGRDataSource()->GetLayerByName(datasetName.c_str());
 
  963     throw Exception(
TE_TR(
"Could not retrieve the DataSet from data source."));
 
  971     std::size_t nProcessedRows = 0;
 
  973     while(d->
moveNext() && (nProcessedRows != limit))
 
  975       OGRFeature* feat = OGRFeature::CreateFeature(layer->GetLayerDefn());
 
  977       std::size_t currfield = 0;
 
  979       for(std::size_t i = 0; i != nproperties; ++i)
 
  992             feat->SetField(currfield, d->
getInt16(i));
 
  997             feat->SetField(currfield, d->
getInt32(i));
 
 1002             feat->SetField(currfield, d->
getAsString(i).c_str());
 
 1007             feat->SetField(currfield, d->
getDouble(i));
 
 1012             feat->SetField(currfield, atof(d->
getNumeric(i).c_str()));
 
 1018               std::auto_ptr<te::dt::ByteArray> ba(d->
getByteArray(i));
 
 1019               feat->SetField(currfield, ba->bytesUsed(), 
reinterpret_cast<unsigned char*
>(ba->getData()));
 
 1026               std::auto_ptr<te::dt::DateTime> dtm(d->
getDateTime(i));
 
 1032                 feat->SetField(currfield,
 
 1033                                static_cast<int>(dtime->getYear()),
 
 1034                                static_cast<int>(dtime->getMonth()),
 
 1035                                static_cast<int>(dtime->getDay()));
 
 1044                 feat->SetField(currfield, 0, 0, 0,
 
 1045                                static_cast<int>(tduration->
getHours()),
 
 1056                 feat->SetField(currfield,
 
 1057                                static_cast<int>(dtime->getYear()),
 
 1058                                static_cast<int>(dtime->getMonth()),
 
 1059                                static_cast<int>(dtime->getDay()),
 
 1060                                static_cast<int>(tduration->
getHours()),
 
 1067               throw Exception (
TE_TR(
"Unsupported date and time type by OGR."));
 
 1073               std::auto_ptr<te::gm::Geometry> geom(d->
getGeometry(i));
 
 1075               feat->SetGeometryDirectly(OGRgeom);
 
 1080             throw Exception(
TE_TR(
"Unsupported data type by OGR."));
 
 1084       if(layer->CreateFeature(feat) != OGRERR_NONE)
 
 1086         OGRFeature::DestroyFeature(feat);
 
 1087         throw Exception(
TE_TR(
"Fail to insert dataset item."));
 
 1090       OGRFeature::DestroyFeature(feat);
 
 1105   if(!m_ogrDs->getOGRDataSource())
 
 1108   OGRLayer* l = m_ogrDs->getOGRDataSource()->GetLayerByName(datasetName.c_str());
 
 1111     throw Exception(
TE_TR(
"Could not retrieve the DataSet from data source."));
 
 1113   if(!l->TestCapability(OLCDeleteFeature))
 
 1114     throw Exception(
TE_TR(
"Driver does not support removal of features."));
 
 1116   std::set<te::da::ObjectId*, te::common::LessCmp<te::da::ObjectId*> >::const_iterator it = oids->
begin();
 
 1118   while(it != oids->
end())
 
 1122     if(l->DeleteFeature(atoi((*it)->getValue()[0].toString().c_str())) != OGRERR_NONE)
 
 1125       throw Exception(
TE_TR(
"Error when attempting to remove the feature."));
 
 1137                     const std::vector<std::size_t>& properties,
 
 1139                     const std::map<std::string, std::string>& ,
 
 1145                                  const std::vector<size_t>& ids)
 
 1147   if(m_ogrDs->getOGRDataSource() == 0)
 
 1148     throw Exception(
TE_TR(
"Data source failure"));
 
 1150   OGRLayer* l = m_ogrDs->getOGRDataSource()->GetLayerByName(datasetName.c_str());
 
 1153     throw Exception(
TE_TR(
"Could not retrieve dataset"));
 
 1160     size_t id_pos = ids[0];
 
 1161     int id = dataset->
getInt32(id_pos);
 
 1163     OGRFeature* feat = l->GetFeature(
id)->Clone();
 
 1165     std::set<int> ls = properties[i];
 
 1166     std::set<int>::iterator it;
 
 1168     for(it = ls.begin(); it != ls.end(); ++it)
 
 1171       int fpos_o = fpos - 1;
 
 1176           feat->SetField(fpos_o, dataset->
getInt32(fpos));
 
 1181           feat->SetField(fpos_o, dataset->
getDouble(fpos));
 
 1185           feat->SetField(fpos_o, dataset->
getString(fpos).c_str());
 
 1190           std::auto_ptr<te::gm::Geometry> gm = dataset->
getGeometry(fpos);
 
 1196     l->SetFeature(feat);
 
Property * getProperty(std::size_t i) const 
It returns the i-th property. 
 
std::vector< std::string > getUniqueKeyNames(const std::string &datasetName)
It gets the unique key names of the given dataset. 
 
te::common::CharEncoding getEncoding()
It return the DataSource current encoding. 
 
void dropProperty(const std::string &datasetName, const std::string &name)
It removes a property from the given dataset. 
 
virtual std::auto_ptr< te::dt::DateTime > getDateTime(std::size_t i) const =0
Method for retrieving a date and time attribute value. 
 
virtual boost::int16_t getInt16(std::size_t i) const =0
Method for retrieving a 16-bit integer attribute value (2 bytes long). 
 
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 add(te::dt::Property *p)
It adds a property to the list of properties of the primary key. 
 
void addForeignKey(const std::string &datasetName, te::da::ForeignKey *fk)
It adds a foreign key constraint to a dataset. 
 
Utility functions for the data access module. 
 
void dropCheckConstraint(const std::string &datasetName, const std::string &name)
It removes the check constraint from the dataset. 
 
boost::int64_t getLastGeneratedId()
It returns the last id generated by an insertion command. 
 
A class that informs what kind of constraint and index is supported by a given data source...
 
TEOGREXPORT OGRGeometry * Convert2OGR(const te::gm::Geometry *teGeom)
It converts the TerraLib Geometry to OGR Geometry. 
 
void setSRID(int srid)
It sets the spatial reference system identifier associated to this property. 
 
virtual boost::int32_t getInt32(std::size_t i) const =0
Method for retrieving a 32-bit integer attribute value (4 bytes long). 
 
CharEncoding
Supported charsets (character encoding). 
 
A class for data providers of OGR. 
 
bool isInTransaction() const 
It returns true if a transaction is in progress, otherwise, it returns false. 
 
void commit()
It commits the transaction. 
 
bool hasGeom() const 
It returns true if the DataSetType has at least one geometry property; otherwise, it returns false...
 
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. 
 
std::auto_ptr< te::da::DataSetTypeCapabilities > getCapabilities(const std::string &name)
It gets capabilities about a data set. 
 
bool sequenceExists(const std::string &name)
It checks if a sequence with the given name exists in the data source. 
 
te::da::DataSource * getDataSource() const 
It returns the parent data source of the transactor. 
 
A class that models the description of a dataset. 
 
void addProperty(const std::string &datasetName, te::dt::Property *p)
It adds a new property to the dataset schema. 
 
long getSeconds() const 
It returns the seconds of a minute - from 0 to 59. 
 
std::size_t getNumberOfProperties(const std::string &datasetName)
It gets the number of properties of the given 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. 
 
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. 
 
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. 
 
void dropForeignKey(const std::string &datasetName, const std::string &fkName)
It removes the foreign key constraint from the dataset schema. 
 
virtual std::auto_ptr< te::dt::ByteArray > getByteArray(std::size_t i) const =0
Method for retrieving a byte array. 
 
bool indexExists(const std::string &datasetName, const std::string &name)
It checks if an index with the given name exists in the dataset. 
 
double m_urx
Upper right corner x-coordinate. 
 
void renameDataSet(const std::string &name, const std::string &newName)
It renames a dataset. 
 
SpatialRelation
Spatial relations between geometric objects. 
 
It describes a sequence (a number generator). 
 
std::auto_ptr< te::da::PrimaryKey > getPrimaryKey(const std::string &datasetName)
It retrieves the primary key of the dataset. 
 
bool dataSetExists(const std::string &name)
It checks if a dataset with the given name exists 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. 
 
Transactor(DataSource *ds)
 
A class that describes a check constraint. 
 
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
 
virtual std::string getNumeric(std::size_t i) const =0
Method for retrieving a numeric attribute value. 
 
#define TE_TR(message)
It marks a string in order to get translated. 
 
TEOGREXPORT std::string RemoveSpatialSql(const std::string &sql)
 
std::auto_ptr< te::da::BatchExecutor > getBatchExecutor()
It creates a batch command executor. 
 
void dropUniqueKey(const std::string &datasetName, const std::string &name)
It removes the unique key constraint from the dataset. 
 
void dropDataSet(const std::string &name)
It removes the dataset schema from the data source. 
 
Implementation of a DataSet for OGR data provider. 
 
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. 
 
It models a property definition. 
 
void cancel()
It requests that the data source stop the processing of the current command. 
 
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 remove(const std::string &datasetName, const te::da::ObjectIdSet *oids=0)
It removes all the informed items from the dataset. 
 
virtual double getDouble(std::size_t i) const =0
Method for retrieving a double attribute value. 
 
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...
 
A class to represent time instant. 
 
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. 
 
bool primaryKeyExists(const std::string &datasetName, const std::string &name)
It checks if a primary key exists in the dataset. 
 
void begin()
It starts a new transaction. 
 
std::size_t getNumberOfDataSets()
It retrieves the number of data sets available in the data source. 
 
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection. 
 
AccessPolicy
Supported data access policies (can be used as bitfield). 
 
TraverseType
A dataset can be traversed in two ways: 
 
void addCheckConstraint(const std::string &datasetName, te::da::CheckConstraint *cc)
It adds a check constraint to the dataset. 
 
void setName(const std::string &name)
It sets the property name. 
 
double m_llx
Lower left corner x-coordinate. 
 
int getSRID() const 
It returns the spatial reference system identifier associated to this property. 
 
An Envelope defines a 2D rectangular region. 
 
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib. 
 
A base class for date data types. 
 
This class represents a set of unique ids created in the same context. i.e. from the same data set...
 
virtual bool isNull(std::size_t i) const =0
It checks if the attribute value is NULL. 
 
void changePropertyDefinition(const std::string &datasetName, const std::string &propName, te::dt::Property *newProp)
 
TEOGREXPORT te::gm::Geometry * Convert2TerraLib(OGRGeometry *ogrGeom)
It converts the OGR Geometry to TerraLib Geometry. 
 
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. 
 
A visitor for building an SQL statement using OGR dialect. 
 
It models a foreign key constraint for a DataSetType. 
 
virtual std::string getAsString(std::size_t i, int precision=0) const 
Method for retrieving a data value as a string plain representation. 
 
It describes a unique key (uk) constraint. 
 
std::size_t size() const 
It returns the number of properties of the CompositeProperty. 
 
std::auto_ptr< te::da::ForeignKey > getForeignKey(const std::string &datasetName, const std::string &name)
It retrieves the foreign key from the given dataset. 
 
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset. 
 
std::vector< std::string > getDataSetNames()
It It gets the dataset names available in the data source. 
 
The OGR data source provider. 
 
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards. 
 
void dropPrimaryKey(const std::string &datasetName)
It removes the primary key constraint from the dataset schema. 
 
A Select models a query to be used when retrieving data from a DataSource. 
 
virtual std::auto_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value. 
 
void dropSequence(const std::string &name)
It removes the sequence from the data source. 
 
double m_lly
Lower left corner y-coordinate. 
 
void execute(const te::da::Query &command)
It executes the specified command using a generic query representation. 
 
void dropIndex(const std::string &datasetName, const std::string &idxName)
It removes the index from the dataset schema. 
 
int getType() const 
It returns the property data type. 
 
A dataset is the unit of information manipulated by the data access module of TerraLib. 
 
std::string escape(const std::string &value)
It escapes a string for using in commands and queries. 
 
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. 
 
double m_ury
Upper right corner y-coordinate. 
 
virtual ReturnType accept(VisitorType &guest) const =0
It call the visit method from the guest object. 
 
std::set< ObjectId *, te::common::LessCmp< ObjectId * > >::const_iterator end() const 
Returns an iterator for the object ids in container. 
 
A class to represent time duration with nano-second/micro-second resolution. 
 
void addSequence(te::da::Sequence *sequence)
It creates a new sequence in the data source. 
 
It describes a primary key (pk) constraint. 
 
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::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...
 
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. 
 
Implementation of a DataSet for OGR data provider. 
 
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. 
 
void rollBack()
It aborts the transaction. Any changes will be rolled-back. 
 
std::auto_ptr< te::da::DataSetType > getDataSetType(const std::string &name)
It gets information about the given dataset. 
 
virtual std::string getString(std::size_t i) const =0
Method for retrieving a string value attribute. 
 
std::vector< std::string > getPropertyNames(const std::string &datasetName)
It gets the property names of the given dataset. 
 
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. 
 
long getMinutes() const 
It returns the minutes of a hour - from 0 to 59. 
 
std::vector< std::string > getForeignKeyNames(const std::string &datasetName)
It gets the foreign key names of the given dataset. 
 
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
 
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos. 
 
void addUniqueKey(const std::string &datasetName, te::da::UniqueKey *uk)
It adds a unique key constraint to the dataset. 
 
OGRFieldType GetOGRType(int te_type)
 
std::set< ObjectId *, te::common::LessCmp< ObjectId * > >::const_iterator begin() const 
Returns an iterator for the object ids in container. 
 
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. 
 
std::vector< std::string > getSequenceNames()
It gets the sequence names available in the data source. 
 
virtual bool moveFirst()=0
It moves the internal pointer to the first item in the collection. 
 
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. 
 
bool propertyExists(const std::string &datasetName, const std::string &name)
It checks if a property with the given name exists in the dataset. 
 
TEOGREXPORT OGRSpatialReference * Convert2OGRProjection(int srid)
It converts the TerraLib Projection to OGR Projection. 
 
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 Query is independent from the data source language/dialect. 
 
It describes an index associated to a DataSetType. 
 
long getHours() const 
It returns the hours of a day - from 0 to 23. 
 
TEOGREXPORT int Convert2TerraLibProjection(OGRSpatialReference *osrs)
It converts the OGR Projection to TerraLib Projection. 
 
std::size_t getNumberOfItems(const std::string &datasetName)
It retrieves the number of items of the given dataset. 
 
const std::string & getName() const 
It returns the property name. 
 
std::vector< std::string > getIndexNames(const std::string &datasetName)
It gets the index names of the given dataset. 
 
bool hasDataSets()
It checks if the data source has any dataset.