21 #include "../common/progress/TaskProgress.h" 22 #include "../common/StringUtils.h" 23 #include "../core/translator/Translator.h" 24 #include "../core/uri/URI.h" 25 #include "../core/uri/Utils.h" 26 #include "../dataaccess/dataset/ObjectId.h" 27 #include "../dataaccess/dataset/ObjectIdSet.h" 28 #include "../dataaccess/query/DataSetName.h" 29 #include "../dataaccess/query/Query.h" 30 #include "../dataaccess/query/Select.h" 31 #include "../dataaccess/utils/Utils.h" 32 #include "../datatype/ByteArray.h" 33 #include "../datatype/Date.h" 34 #include "../datatype/TimeInstant.h" 35 #include "../geometry/Envelope.h" 36 #include "../geometry/GeometryProperty.h" 37 #include "../srs/SpatialReferenceSystemManager.h" 38 #include "../srs/Config.h" 46 #include <boost/thread/locks.hpp> 49 #include <ogrsf_frmts.h> 125 return std::unique_ptr<te::da::DataSet>(
nullptr);
131 GDALDataset*
ds =
static_cast<GDALDataset*
>(GDALOpenEx(
m_ogrDs->
getOGRDataSource()->GetDescription(), ogropenflags,
nullptr,
nullptr,
nullptr));
135 return std::unique_ptr<te::da::DataSet>(
nullptr);
138 std::string sql =
"SELECT FID, * FROM \"" + name +
"\"";
139 OGRLayer* layer = ds->ExecuteSQL(sql.c_str(),
nullptr,
nullptr);
147 throw Exception(
TE_TR(
"The informed data set could not be found in the data source."));
149 return std::unique_ptr<te::da::DataSet>(
new DataSet(ds, layer));
166 return std::unique_ptr<te::da::DataSet>(
nullptr);
172 GDALDataset*
ds =
static_cast<GDALDataset*
>(GDALOpenEx(
m_ogrDs->
getOGRDataSource()->GetDescription(), ogropenflags,
nullptr,
nullptr,
nullptr));
176 return std::unique_ptr<te::da::DataSet>(
nullptr);
179 std::string sql =
"SELECT FID, * FROM \"" + name +
"\"";
180 OGRLayer* layer = ds->ExecuteSQL(sql.c_str(),
nullptr,
nullptr);
188 throw Exception(
TE_TR(
"The informed data set could not be found in the data source."));
192 return std::unique_ptr<te::da::DataSet>(
new DataSet(ds, layer));
209 return std::unique_ptr<te::da::DataSet>(
nullptr);
215 GDALDataset*
ds =
static_cast<GDALDataset*
>(GDALOpenEx(
m_ogrDs->
getOGRDataSource()->GetDescription(), ogropenflags,
nullptr,
nullptr,
nullptr));
219 return std::unique_ptr<te::da::DataSet>(
nullptr);
222 std::string sql =
"SELECT FID, * FROM \"" + name +
"\"";
223 OGRLayer* layer = ds->ExecuteSQL(sql.c_str(),
nullptr,
nullptr);
231 throw Exception(
TE_TR(
"The informed data set could not be found in the data source."));
235 layer->SetSpatialFilter(ogrg);
237 OGRGeometryFactory::destroyGeometry(ogrg);
239 return std::unique_ptr<te::da::DataSet>(
new DataSet(ds, layer));
253 return std::unique_ptr<te::da::DataSet>(
nullptr);
259 GDALDataset*
ds =
static_cast<GDALDataset*
>(GDALOpenEx(
m_ogrDs->
getOGRDataSource()->GetDescription(), ogropenflags,
nullptr,
nullptr,
nullptr));
263 return std::unique_ptr<te::da::DataSet>();
274 OGRLayer* layer = ds->ExecuteSQL(sql.c_str(),
nullptr,
nullptr);
282 throw Exception(
TE_TR(
"Could not retrieve the DataSet from data source."));
284 CPLSetConfigOption(
"SHAPE_ENCODING",
"UTF-8");
291 return std::unique_ptr<te::da::DataSet>(
new DataSet(ds, layer));
305 return std::unique_ptr<te::da::DataSet>();
311 GDALDataset*
ds =
static_cast<GDALDataset*
>(GDALOpenEx(
m_ogrDs->
getOGRDataSource()->GetDescription(), ogropenflags,
nullptr,
nullptr,
nullptr));
315 return std::unique_ptr<te::da::DataSet>();
319 std::string queryCopy =
query;
320 std::size_t pos = queryCopy.find(
"*");
321 if(pos != std::string::npos)
323 std::string fid =
"FID, *";
324 queryCopy.replace(pos, 1, fid);
327 OGRLayer* layer = ds->ExecuteSQL(queryCopy.c_str(),
nullptr,
nullptr);
335 throw Exception(
TE_TR(
"Could not retrieve the DataSet from data source."));
337 return std::unique_ptr<te::da::DataSet>(
new DataSet(ds, layer));
363 return std::unique_ptr<te::da::PreparedQuery>();
368 return std::unique_ptr<te::da::BatchExecutor>();
387 std::vector<std::string> names;
409 return std::unique_ptr<te::da::DataSetType>();
411 std::string sql(
"SELECT FID, * FROM \"");
417 return std::unique_ptr<te::da::DataSetType>();
419 std::unique_ptr<te::da::DataSetType> type(
Convert2TerraLib(l->GetLayerDefn()));
423 const char* colIdName = l->GetFIDColumn();
425 if (colIdName ==
nullptr || colIdName[0] ==
'\0')
428 int pos = l->GetLayerDefn()->GetFieldIndex(colIdName);
432 pk->
add(type->getProperty(static_cast<size_t>(pos)));
446 OGR_L_ResetReading(lh);
448 OGRFeatureH nextFeature = OGR_L_GetNextFeature(lh);
451 OGRGeometryH geometry = OGR_F_GetGeometryRef(nextFeature);
458 gp->setGeometryType(geomType);
463 OGR_L_ResetReading(lh);
479 cap->setSupportAddColumn((l->TestCapability(OLCCreateField) == 0) ?
false :
true);
480 cap->setSupportRemoveColumn((l->TestCapability(OLCDeleteField) == 0) ?
false :
true);
481 cap->setSupportDataEdition((l->TestCapability(OLCRandomWrite) == 0) ?
false :
true);
489 boost::ptr_vector<te::dt::Property> ps;
494 std::string sql(
"SELECT FID, * FROM \"");
495 sql += datasetName +
"\"";
503 std::vector<te::dt::Property*> props = dt->getProperties();
504 std::vector<te::dt::Property*>::iterator it;
506 for(it=props.begin(); it!=props.end(); ++it)
507 ps.push_back((*it)->clone());
518 return std::unique_ptr<te::dt::Property>();
521 std::string sql(
"SELECT FID, * FROM \"");
522 sql += datasetName +
"\"";
527 idx = l->GetLayerDefn()->GetFieldIndex(name.c_str());
531 return getProperty(datasetName, static_cast<size_t>(idx));
538 return std::unique_ptr<te::dt::Property>();
540 std::unique_ptr<te::dt::Property> res;
541 std::string sql (
"SELECT FID, * FROM \"");
542 sql += datasetName +
"\"";
544 OGRLayer* l = ogrds->ExecuteSQL(sql.c_str(),
nullptr,
nullptr);
548 OGRFeatureDefn* def = l->GetLayerDefn();
549 OGRFieldDefn* fdef = def->GetFieldDefn(static_cast<int>(propertyPos));
564 return std::vector<std::string>();
566 std::vector<std::string> res;
567 std::string sql (
"SELECT FID, * FROM \"");
568 sql += datasetName +
"\"";
570 OGRLayer* l = ogrds->ExecuteSQL(sql.c_str(),
nullptr,
nullptr);
574 OGRFeatureDefn* def = l->GetLayerDefn();
576 for(
int i=0; i<def->GetFieldCount(); i++)
577 res.push_back(def->GetFieldDefn(i)->GetNameRef());
580 ogrds->ReleaseResultSet(l);
591 std::string sql(
"SELECT FID, * FROM \"");
592 sql += datasetName +
"\"";
594 OGRLayer* l = ogrds->ExecuteSQL(sql.c_str(),
nullptr,
nullptr);
600 res = l->GetLayerDefn()->GetFieldCount();
601 ogrds->ReleaseResultSet(l);
604 return static_cast<size_t>(res);
613 std::string sql(
"SELECT FID, * FROM \"");
614 sql += datasetName +
"\"";
617 OGRLayer* l = ogrds->ExecuteSQL(sql.c_str(),
nullptr,
nullptr);
621 res = (l->GetLayerDefn()->GetFieldIndex(name.c_str()) != -1);
622 ogrds->ReleaseResultSet(l);
640 OGRErr error = l->CreateField(nField);
644 if(error != OGRERR_NONE)
647 error = l->SyncToDisk();
649 if(error != OGRERR_NONE)
661 if(!l->TestCapability(OLCDeleteField))
662 throw Exception(
TE_TR(
"This dataset do not support remove properties operation."));
664 int fPos = l->GetLayerDefn()->GetFieldIndex(name.c_str());
669 OGRErr error = l->DeleteField(fPos);
671 if(error != OGRERR_NONE)
672 throw Exception(
TE_TR(
"Error when attempting remove the property."));
674 error = l->SyncToDisk();
676 if(error != OGRERR_NONE)
682 const std::string& propertyName,
683 const std::string& newPropertyName)
692 int idx = l->GetLayerDefn()->GetFieldIndex(propertyName.c_str());
697 OGRFieldDefn* df = l->GetLayerDefn()->GetFieldDefn(idx);
699 OGRFieldDefn* dfn =
new OGRFieldDefn(df);
701 dfn->SetName(newPropertyName.c_str());
703 OGRErr err = l->AlterFieldDefn(idx, dfn, ALTER_NAME_FLAG);
705 if(err != OGRERR_NONE)
715 std::unique_ptr<te::dt::Property>
p;
723 if(!l->TestCapability(OLCAlterFieldDefn))
724 throw Exception(
TE_TR(
"This data source do not support the operation of alter columns type."));
726 int idx = l->GetLayerDefn()->GetFieldIndex(propName.c_str());
731 OGRFieldDefn* dfn =
new OGRFieldDefn(l->GetLayerDefn()->GetFieldDefn(idx));
735 OGRErr err = l->AlterFieldDefn(idx, dfn, ALTER_TYPE_FLAG);
737 if(err != OGRERR_NONE)
742 err = l->SyncToDisk();
749 return std::unique_ptr<te::da::PrimaryKey>();
751 std::unique_ptr<te::da::PrimaryKey> res;
752 std::string sql(
"SELECT FID, * FROM \"");
753 sql += datasetName +
"\"";
759 const char* colIdName = layer->GetFIDColumn();
761 if(colIdName ==
nullptr || colIdName[0] ==
'\0')
764 int pos = layer->GetLayerDefn()->GetFieldIndex(colIdName);
769 res->add(
getProperty(datasetName, static_cast<size_t>(pos)).
get());
793 return std::unique_ptr<te::da::ForeignKey>();
798 return std::vector<std::string>();
816 return std::unique_ptr<te::da::UniqueKey>();
821 return std::vector<std::string>();
839 return std::unique_ptr<te::da::CheckConstraint>();
844 return std::vector<std::string>();
862 return std::unique_ptr<te::da::Index>();
867 return std::vector<std::string>();
876 const std::map<std::string, std::string>& )
886 return std::unique_ptr<te::da::Sequence>();
891 return std::vector<std::string>();
908 const std::string& propertyName)
911 return std::unique_ptr<te::gm::Envelope>();
913 std::unique_ptr<te::gm::Envelope> res;
914 std::string sql(
"SELECT ");
915 sql += propertyName +
" FROM \"";
916 sql += datasetName +
"\"";
922 std::unique_ptr<OGREnvelope> env(
new OGREnvelope);
924 if(l->GetExtent(env.get()) != OGRERR_NONE)
941 return getExtent(datasetName,
"OGR_GEOMETRY");
952 return static_cast<size_t>(l->GetFeatureCount());
984 throw Exception(
TE_TR(
"This driver does not support dataset creation."));
986 OGRwkbGeometryType geomType = wkbUnknown;
987 OGRSpatialReference* srs =
nullptr;
998 char** papszOptions =
nullptr;
1001 std::map<std::string, std::string>::const_iterator it = kvp.begin();
1002 while(it != kvp.end())
1004 papszOptions = CSLSetNameValue(papszOptions, it->first.c_str(), it->second.c_str());
1014 CSLDestroy(papszOptions);
1016 if(newLayer ==
nullptr)
1017 throw Exception(
TE_TR(
"Error when attempting create the dataset type."));
1019 dt->
setName(newLayer->GetName());
1022 for (
size_t i = 0; i < dt->
size(); ++i)
1034 const std::string& cloneName,
1035 const std::map<std::string, std::string>& )
1041 throw Exception(
TE_TR(
"This driver does not support creates a dataset."));
1046 throw Exception(
TE_TR(
"Could not retrieve the DataSet from data source."));
1051 throw Exception(
TE_TR(
"Error when attempting clone the dataset."));
1060 throw Exception(
TE_TR(
"This driver does not support remove a dataset."));
1069 throw Exception(
TE_TR(
"Could not retrieve the DataSet from data source."));
1072 throw Exception(
TE_TR(
"Error when attempting to remove the dataset."));
1081 const std::map<std::string, std::string>&,
1083 bool enableProgress)
1086 limit = std::string::npos;
1093 if(layer ==
nullptr)
1094 throw Exception(
TE_TR(
"Could not retrieve the DataSet from data source."));
1097 OGRSpatialReference* srs =
nullptr;
1105 std::size_t nProcessedRows = 0;
1107 std::unique_ptr< te::common::TaskProgress > progressPtr;
1108 if(enableProgress ==
true)
1111 progressPtr->setTotalSteps(1 + static_cast<int>(d->
size()));
1112 progressPtr->setMessage(
"Saving...");
1113 progressPtr->useTimer(
true);
1114 progressPtr->pulse();
1117 while(d->
moveNext() && (nProcessedRows != limit))
1119 OGRFeature* feat = OGRFeature::CreateFeature(layer->GetLayerDefn());
1121 std::size_t currfield = 0;
1123 for(std::size_t i = 0; i != nproperties; ++i)
1139 feat->SetField(static_cast<int>(currfield), d->
getInt16(i));
1144 feat->SetField(static_cast<int>(currfield), d->
getInt32(i));
1149 feat->SetField(static_cast<int>(currfield), static_cast<GIntBig>(d->
getInt64(i)));
1154 feat->SetField(static_cast<int>(currfield), d->
getAsString(i).c_str());
1159 feat->SetField(static_cast<int>(currfield), d->
getDouble(i));
1164 feat->SetField(static_cast<int>(currfield), atof(d->
getNumeric(i).c_str()));
1170 std::unique_ptr<te::dt::ByteArray> ba(d->
getByteArray(i));
1171 feat->SetField(static_cast<int>(currfield), static_cast<int>(ba->bytesUsed()), reinterpret_cast<unsigned char*>(ba->getData()));
1178 std::unique_ptr<te::dt::DateTime> dtm(d->
getDateTime(i));
1184 feat->SetField(static_cast<int>(currfield),
1185 static_cast<int>(dtime->getYear()),
1186 static_cast<int>(dtime->getMonth()),
1187 static_cast<int>(dtime->getDay()));
1196 feat->SetField(static_cast<int>(currfield), 0, 0, 0,
1197 static_cast<int>(tduration->
getHours()),
1199 static_cast<float>(tduration->
getSeconds()));
1208 feat->SetField(static_cast<int>(currfield),
1219 throw Exception (
TE_TR(
"Unsupported date and time type by OGR."));
1224 std::unique_ptr<te::gm::Geometry> geom(d->
getGeometry(i));
1229 OGRGeometry* OGRgeom =
Convert2OGR(geom.get(), srs);
1230 feat->SetGeometryDirectly(OGRgeom);
1239 if(layer->CreateFeature(feat) != OGRERR_NONE)
1241 OGRFeature::DestroyFeature(feat);
1245 m_fid =
static_cast<long>(feat->GetFID());
1247 OGRFeature::DestroyFeature(feat);
1250 if(progressPtr.get())
1252 progressPtr->pulse();
1254 if(progressPtr->isActive() ==
false)
1282 throw Exception(
TE_TR(
"Could not retrieve the DataSet from data source."));
1284 if(!l->TestCapability(OLCDeleteFeature))
1285 throw Exception(
TE_TR(
"Driver does not support removal of features."));
1287 std::vector<GIntBig> oidsInt;
1291 std::set<te::da::ObjectId*, te::common::LessCmp<te::da::ObjectId*> >::const_iterator it = oids->
begin();
1293 while (it != oids->
end())
1295 std::string
id = (*it)->getValueAsString();
1297 char* endptr =
nullptr;
1299 GIntBig idLongLong = strtoll(
id.c_str(), &endptr, 10);
1301 oidsInt.push_back(idLongLong);
1308 GIntBig count = l->GetFeatureCount();
1310 for (GIntBig i = 0; i < count; ++i)
1312 oidsInt.push_back(i);
1319 GIntBig s =
static_cast<GIntBig
>(oidsInt.size());
1321 for (GIntBig i = 0; i < s; ++i)
1323 if (l->DeleteFeature(oidsInt[i]) != OGRERR_NONE)
1326 throw Exception(
TE_TR(
"Error when attempting to remove the feature."));
1340 const std::vector<std::size_t>&,
1342 const std::map<std::string, std::string>& ,
1348 const std::vector<size_t>& ids)
1363 size_t id_pos = ids[0];
1379 id =
static_cast<int>(dataset->
getInt64(id_pos));
1386 OGRFeature* feat = l->GetFeature(
id)->Clone();
1388 std::set<int> ls = properties[
static_cast<size_t>(i)];
1389 std::set<int>::iterator it;
1391 for(it = ls.begin(); it != ls.end(); ++it)
1394 int fpos_o = fpos - 1;
1399 feat->SetField(fpos_o, dataset->
getInt32(static_cast<size_t>(fpos)));
1404 feat->SetField(fpos_o, dataset->
getDouble(static_cast<size_t>(fpos)));
1408 feat->SetField(fpos_o, dataset->
getString(static_cast<size_t>(fpos)).c_str());
1413 std::unique_ptr<te::gm::Geometry> gm = dataset->
getGeometry(static_cast<size_t>(fpos));
1419 OGRErr error = l->SetFeature(feat);
1421 if(error != OGRERR_NONE)
virtual std::unique_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
Property * getProperty(std::size_t i) const
It returns the i-th property.
std::unique_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 add(const std::string &datasetName, te::da::DataSet *d, const std::map< std::string, std::string > &options, std::size_t limit=0, bool enableProgress=true)
It adds data items to the dataset in the data source.
std::vector< std::string > getUniqueKeyNames(const std::string &datasetName)
It gets the unique key names of the given dataset.
void dropProperty(const std::string &datasetName, const std::string &name)
It removes a property from the given dataset.
void add(te::dt::Property *p)
It adds a property to the list of properties of the primary key.
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
void addForeignKey(const std::string &datasetName, te::da::ForeignKey *fk)
It adds a foreign key constraint to a dataset.
virtual double getDouble(std::size_t i) const =0
Method for retrieving a double attribute value.
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 std::unique_ptr< te::dt::ByteArray > getByteArray(std::size_t i) const =0
Method for retrieving a byte array.
A visitor for building an SQL statement using OGR dialect.
bool isInTransaction() const
It returns true if a transaction is in progress, otherwise, it returns false.
void commit()
It commits the transaction.
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
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.
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.
Base exception class for plugin module.
A class that models the description of a dataset.
virtual std::string getNumeric(std::size_t i) const =0
Method for retrieving a numeric attribute value.
te::core::EncodingType getEncoding()
It return the DataSource current encoding.
std::unique_ptr< te::da::Sequence > getSequence(const std::string &name)
It gets the sequence with the given name in the data source.
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::unique_ptr< te::da::ForeignKey > getForeignKey(const std::string &datasetName, const std::string &name)
It retrieves the foreign key from the given dataset.
TEOGREXPORT boost::mutex & getStaticMutex()
Returns a reference to a static mutex initialized when this module is initialized.
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.
This class can be used to inform the progress of a task.
boost::gregorian::greg_year getYear() const
It returns the gregorian year.
std::unique_ptr< te::da::BatchExecutor > getBatchExecutor()
It creates a batch command executor.
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.
std::string Convert2UCase(const std::string &value)
It converts a string to upper case.
void createOGRDataSource()
SpatialRelation
Spatial relations between geometric objects.
boost::gregorian::greg_day getDay() const
It returns the gregorian day - from 1 to 31.
It describes a sequence (a number generator).
bool dataSetExists(const std::string &name)
It checks if a dataset with the given name exists in the data source.
virtual ReturnType accept(VisitorType &guest) const =0
It call the visit method from the guest object.
static te::dt::Date ds(2010, 01, 01)
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. ...
#define TE_TR(message)
It marks a string in order to get translated.
TEOGREXPORT 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.
void dropDataSet(const std::string &name)
It removes the dataset schema from the data source.
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.
std::unique_ptr< te::da::DataSetTypeCapabilities > getCapabilities(const std::string &name)
It gets capabilities about a data set.
std::string query() const
Retrieving the query.
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.
virtual std::size_t size() const =0
It returns the collection size, if it is known.
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:
std::unique_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 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.
static std::string getEncodingName(EncodingType et)
Retrive a string from a given character encoding type enum.
double m_llx
Lower left corner x-coordinate.
std::unique_ptr< te::dt::Property > getProperty(const std::string &datasetName, const std::string &name)
It retrieves the property with the given name from the dataset.
std::unique_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.
virtual boost::int16_t getInt16(std::size_t i) const =0
Method for retrieving a 16-bit integer attribute value (2 bytes long).
Date getDate() const
It returns the date associated to time instant.
int getSRID() const
It returns the spatial reference system identifier associated to this property.
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos.
An Envelope defines a 2D rectangular region.
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...
std::unique_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 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.
virtual boost::int32_t getInt32(std::size_t i) const =0
Method for retrieving a 32-bit integer attribute value (4 bytes long).
static te::dt::DateTime d(2010, 8, 9, 15, 58, 39)
static te::dt::TimeDuration dt(20, 30, 50, 11)
std::unique_ptr< te::da::DataSetType > getDataSetType(const std::string &name)
It gets information about the given dataset.
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.
std::unique_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...
It describes a unique key (uk) constraint.
std::size_t size() const
It returns the number of properties of the CompositeProperty.
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.
std::unique_ptr< te::da::PrimaryKey > getPrimaryKey(const std::string &datasetName)
It retrieves the primary key of the dataset.
void dropSequence(const std::string &name)
It removes the sequence from the data source.
OGRFieldType GetOGRType(int te_type)
GDALDataset * getOGRDataSource()
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.
virtual std::unique_ptr< te::dt::DateTime > getDateTime(std::size_t i) const =0
Method for retrieving a date and time attribute value.
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.
This file contains utility functions used to manipulate data from a URI.
double m_ury
Upper right corner y-coordinate.
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.
A class for data providers of OGR.
It describes a primary key (pk) constraint.
const te::core::URI & getConnectionInfo() const
An Uniform Resource Identifier used to describe the datasource connection.
void renameProperty(const std::string &datasetName, const std::string &propertyName, const std::string &newPropertyName)
It renames a property of the given dataset.
TECOREEXPORT std::map< std::string, std::string > Expand(const std::string &query_str)
Split a query string into its components.
TimeDuration getTime() const
It returns the time duration associated to time instant.
Implementation of a DataSet for OGR data provider.
void rollBack()
It aborts the transaction. Any changes will be rolled-back.
virtual bool isNull(std::size_t i) const =0
It checks if the attribute value is NULL.
virtual boost::int64_t getInt64(std::size_t i) const =0
Method for retrieving a 64-bit integer attribute value (8 bytes long).
std::vector< std::string > getPropertyNames(const std::string &datasetName)
It gets the property names of the given dataset.
const te::da::SQLDialect * getDialect() const
It returns the data source SQL dialect, if there is one.
long getMinutes() const
It returns the minutes of a hour - from 0 to 59.
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset.
virtual std::string getPropertyName(std::size_t i) const =0
It returns the property name at position pos.
std::unique_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::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)
std::unique_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 addUniqueKey(const std::string &datasetName, te::da::UniqueKey *uk)
It adds a unique key constraint to the dataset.
std::set< ObjectId *, te::common::LessCmp< ObjectId * > >::const_iterator begin() const
Returns an iterator for the object ids in container.
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.
boost::gregorian::greg_month getMonth() const
It returns the gregorian month - from 1 to 12.
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.
virtual std::string getString(std::size_t i) const =0
Method for retrieving a string value attribute.
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.