DataAccessExamples.h File Reference

Examples on how to access/manipulate DataSources in TerraLib. More...

#include <terralib_buildconfig.h>
#include <terralib/common.h>
#include <terralib/dataaccess.h>
#include <terralib/datatype_fw.h>
#include <terralib/dataaccess_fw.h>
#include <terralib/dataaccess/datasource/DataSourceFactory.h>
#include <terralib/geometry.h>

Go to the source code of this file.

Functions

void AddingDataSetPropertyValues (te::da::DataSet *ds)
 It adds a new data set property and its values. More...
 
te::da::PrimaryKeyAddPrimaryKey (const std::string &datasetname, te::da::DataSourceTransactor *transactor)
 
te::dt::SimplePropertyAddProperty (const std::string &datasetname, te::da::DataSourceTransactor *transactor)
 
te::da::IndexAddSpatialIndex (const std::string &datasetname, te::da::DataSourceTransactor *transactor)
 
te::da::UniqueKeyAddUniqueKey (const std::string &datasetname, te::da::DataSourceTransactor *transactor)
 
void CopyingData ()
 This example shows how to copy a given dataset from one data source to another one. More...
 
void CopyingDataSetToDataSource (te::da::DataSet *dataSet, const std::string &dsName, std::map< std::string, std::string > &dsInfo)
 It copies a data set to a data source. More...
 
te::da::DataSetTypeCreateDataSetType (const std::string &datasetname, te::da::DataSetType *dt, te::da::DataSourceTransactor *transactor)
 
te::da::DataSetTypeCreateDataSetTypeInMemory (const std::string &datasettypename)
 
te::da::DataSetCreatingDataSetInMemory (const std::string &datasetName)
 It creates a data set in memory. More...
 
te::da::DataSetCreatingDataSetInMemoryGivingDt (te::da::DataSetType *dt)
 
void DataSetAdapter ()
 DataSet Adapter example. More...
 
void DataSetGetExtent (te::da::DataSourceTransactor *transactor)
 An example showing how to retrieve the extent of a DataSet. More...
 
void DroppingDataSetType (const std::string &datasetname, te::da::DataSourceTransactor *trans)
 It removes a data set type from the associated data source. More...
 
void DroppingDataSetTypeProperty (const std::string &datasetname, const std::string &propname, te::da::DataSourceTransactor *trans)
 It removes a property from the data set type and from the associated data source. More...
 
void ExportingOGR ()
 An example using OGR data source driver to export some ;. More...
 
void GDALExample ()
 An example using GDAL data source driver. More...
 
void LoadModules ()
 It loads the data source drivers. More...
 
void MemoryExample ()
 This example shows how to create DataSet and DataSetType in memory. More...
 
void MySQLExample ()
 An example using MySQL data source driver. More...
 
void ObjectId ()
 ObjectId example. More...
 
void ObjectId3 ()
 
void ObjectId_query ()
 
void OGRExampleRead ()
 An example using OGR data source driver to retrieve data from a datafile. More...
 
void ORGExampleWrite ()
 An example using OGR data source driver to persist data to a datafile. More...
 
void PersistenceExample ()
 This example shows how to use the TerraLib Persistence. More...
 
void PostGISExample ()
 An example using PostGIS data source driver. More...
 
void PrintCatalog (te::da::DataSource *ds)
 This example will print to standard output all information about the datasets stored in the data source. More...
 
void PrintDataSet (std::string datasetName, te::da::DataSet *dataset)
 It prints the data in a given dataset. More...
 
void PrintDataSets (te::da::DataSource *ds)
 It prints datasets in a given data source. More...
 
void PrintDataSourceCapabilities (te::da::DataSource *ds)
 It retrieves and prints the capabilities of a given data source. More...
 
void QueryExample ()
 Quering a dataset. More...
 
void QueryInsertExample ()
 Quering Insert clause. More...
 
void RetrieveUsingSpatialFilter (te::da::DataSource *ds)
 An example showing how to retrieve data using a spatial filter. More...
 
void SQLiteExample ()
 An example using SQLite data source driver. More...
 

Detailed Description

Examples on how to access/manipulate DataSources in TerraLib.

Definition in file DataAccessExamples.h.

Function Documentation

void AddingDataSetPropertyValues ( te::da::DataSet ds)

It adds a new data set property and its values.

Parameters
dataSetthe dataSet that will be added.
te::dt::SimpleProperty* AddProperty ( const std::string &  datasetname,
te::da::DataSourceTransactor transactor 
)

Definition at line 4 of file AddingProperty.cpp.

References te::da::DataSourceTransactor::addProperty(), te::dt::INT32_TYPE, and p.

Referenced by PostGISExample().

te::da::Index* AddSpatialIndex ( const std::string &  datasetname,
te::da::DataSourceTransactor transactor 
)
te::da::UniqueKey* AddUniqueKey ( const std::string &  datasetname,
te::da::DataSourceTransactor transactor 
)
void CopyingData ( )
void CopyingDataSetToDataSource ( te::da::DataSet dataSet,
const std::string &  dsName,
std::map< std::string, std::string > &  dsInfo 
)

It copies a data set to a data source.

Parameters
dataSetthe dataSet that will be copied to data source.
dsNamethe data source name
dsInfothe data source info
te::da::DataSetType* CreateDataSetType ( const std::string &  datasetname,
te::da::DataSetType dt,
te::da::DataSourceTransactor transactor 
)
void DataSetAdapter ( )

DataSet Adapter example.

  • Adapting... */

Definition at line 47 of file examples/dataaccess/DataSetAdapter.cpp.

References te::da::DataSourceFactory::make().

Referenced by te::da::CreateAdapter().

void DataSetGetExtent ( te::da::DataSourceTransactor transactor)

An example showing how to retrieve the extent of a DataSet.

Parameters
transactorThe transactor to be used to retrieve the data.

Definition at line 10 of file DataSetGetExtent.cpp.

References te::dt::GEOMETRY_TYPE, te::da::DataSourceTransactor::getDataSet(), te::da::GetFirstPropertyPos(), and te::gm::INTERSECTS.

void DroppingDataSetType ( const std::string &  datasetname,
te::da::DataSourceTransactor trans 
)

It removes a data set type from the associated data source.

Parameters
dtthe dataSetType that will be removed from data source.
transthe transactor to be used in the removing.

Definition at line 11 of file DroppingDataSetType.cpp.

References te::da::DataSourceTransactor::dropDataSet().

Referenced by PostGISExample().

void DroppingDataSetTypeProperty ( const std::string &  datasetname,
const std::string &  propname,
te::da::DataSourceTransactor trans 
)

It removes a property from the data set type and from the associated data source.

Parameters
propthe property that will be removed.
transthe transactor to be used in the removing.

Definition at line 11 of file DroppingDataSetTypeProperty.cpp.

References te::da::DataSourceTransactor::dropProperty().

void ExportingOGR ( )

An example using OGR data source driver to export some ;.

Definition at line 31 of file ExportingOGR.cpp.

References openDirectory(), and saveUsingOGR().

Referenced by main().

void GDALExample ( )

An example using GDAL data source driver.

Definition at line 129 of file GDALExample.cpp.

References DataSourceTransactor(), OpenDirectory(), and OpenFile().

Referenced by main().

void LoadModules ( )

It loads the data source drivers.

It loads the data source drivers.

Load terralib modules.

It loads the data source drivers.

Definition at line 38 of file attic/unittest/dataaccess/LoadModules.h.

void MemoryExample ( )

This example shows how to create DataSet and DataSetType in memory.

Definition at line 11 of file MemoryExample.cpp.

References CreateDataSetTypeInMemory(), CreatingDataSetInMemoryGivingDt(), te::da::DataSourceFactory::make(), and PrintDataSet().

Referenced by main().

void MySQLExample ( )

An example using MySQL data source driver.

void ObjectId3 ( )
void OGRExampleRead ( )

An example using OGR data source driver to retrieve data from a datafile.

Definition at line 13 of file OGRExample.cpp.

References ds, te::da::DataSourceFactory::make(), PrintDataSet(), and PrintDataSourceCapabilities().

Referenced by main().

void ORGExampleWrite ( )

An example using OGR data source driver to persist data to a datafile.

Definition at line 65 of file OGRExample.cpp.

References CreateDataSetTypeInMemory(), CreatingDataSetInMemoryGivingDt(), ds, te::da::DataSourceFactory::make(), te::da::DataSet::moveBeforeFirst(), and PrintDataSet().

Referenced by main().

void PersistenceExample ( )

This example shows how to use the TerraLib Persistence.

void PrintCatalog ( te::da::DataSource ds)

This example will print to standard output all information about the datasets stored in the data source.

Parameters
dsThe data source used to retrieve information about its datasets.

This example will print to standard output all information about the datasets stored in the data source.

Parameters
dsThe data source used to retrieve information about their datasets.

Definition at line 40 of file PrintCatalog.cpp.

References dt, te::da::DataSource::getDataSetNames(), te::da::DataSource::getDataSetType(), te::da::CheckConstraint::getExpression(), te::da::Constraint::getName(), te::da::Index::getName(), te::da::PrimaryKey::getProperties(), te::da::UniqueKey::getProperties(), te::da::Index::getProperties(), te::da::DataSource::getTransactor(), and te::da::DataSource::isOpened().

void PrintDataSet ( std::string  datasetName,
te::da::DataSet dataset 
)

It prints the data in a given dataset.

Parameters
datasetNamethe dataset name
datasetpointer to a dataset. Do not pass NULL.

This function will move the dataset to the item before first and return it there after printing.

Definition at line 7 of file PrintDataSet.cpp.

References te::da::DataSet::getAsString(), te::da::DataSet::getNumProperties(), te::da::DataSet::getPropertyName(), te::da::DataSet::isNull(), te::da::DataSet::moveBeforeFirst(), and te::da::DataSet::moveNext().

Referenced by DataSourceTransactor(), MemoryExample(), ObjectId(), ObjectId_query(), OGRExampleRead(), ORGExampleWrite(), PostGISExample(), PrintDataSets(), and QueryExample().

void PrintDataSets ( te::da::DataSource ds)

It prints datasets in a given data source.

Parameters
dsThe data source you want to print its data
dsThe data source you want to print its data.

Definition at line 38 of file ado/PrintDataSets.cpp.

References te::da::DataSource::getDataSet(), te::da::DataSource::getDataSetNames(), te::da::DataSource::getTransactor(), te::da::DataSource::isOpened(), PrintDataSet(), PrintDataSetValues(), and te::common::Exception::what().

void PrintDataSourceCapabilities ( te::da::DataSource ds)

It retrieves and prints the capabilities of a given data source.

Parameters
dsA valid data source.

Definition at line 16 of file PrintDataSourceCapabilities.cpp.

References capabilities, dataSetCapabilities, dataSetTypeCapabilities, dataTypeCapabilities, te::da::DataSourceCapabilities::getAccessPolicy(), te::da::DataSource::getCapabilities(), te::da::DataSourceCapabilities::getDataSetCapabilities(), te::da::DataSourceCapabilities::getDataSetTypeCapabilities(), te::da::DataSourceCapabilities::getDataTypeCapabilities(), te::da::DataSourceCapabilities::getQueryCapabilities(), te::common::NoAccess, PrintHelper(), queryCapabilities, te::common::RAccess, te::common::RWAccess, te::da::QueryCapabilities::supportsAlter(), te::da::DataTypeCapabilities::supportsArray(), te::da::DataSourceCapabilities::supportsBatchExecutorAPI(), te::da::DataSetCapabilities::supportsBidirectionalTraversing(), te::da::DataTypeCapabilities::supportsBit(), te::da::DataTypeCapabilities::supportsBoolean(), te::da::DataSetTypeCapabilities::supportsBTreeIndex(), te::da::DataTypeCapabilities::supportsByteArray(), te::da::DataTypeCapabilities::supportsCDouble(), te::da::DataTypeCapabilities::supportsCFloat(), te::da::DataTypeCapabilities::supportsChar(), te::da::DataSetTypeCapabilities::supportsCheckConstraints(), te::da::DataTypeCapabilities::supportsCInt16(), te::da::DataTypeCapabilities::supportsCInt32(), te::da::DataTypeCapabilities::supportsComposite(), te::da::QueryCapabilities::supportsCreate(), te::da::DataTypeCapabilities::supportsDataset(), te::da::DataSourceCapabilities::supportsDataSetPesistenceAPI(), te::da::DataSourceCapabilities::supportsDataSetTypePesistenceAPI(), te::da::DataTypeCapabilities::supportsDateTime(), te::da::QueryCapabilities::supportsDelete(), te::da::DataTypeCapabilities::supportsDouble(), te::da::QueryCapabilities::supportsDrop(), te::da::DataSetCapabilities::supportsEfficientDataSetSize(), te::da::DataSetCapabilities::supportsEfficientMove(), te::da::DataSetCapabilities::supportsEfficientMoveAfterLast(), te::da::DataSetCapabilities::supportsEfficientMoveBeforeFirst(), te::da::DataSetCapabilities::supportsEfficientMoveLast(), te::da::DataSetCapabilities::supportsEfficientMovePrevious(), te::da::DataTypeCapabilities::supportsFloat(), te::da::DataSetTypeCapabilities::supportsForeignKey(), te::da::DataTypeCapabilities::supportsGeometry(), te::da::DataSetTypeCapabilities::supportsHashIndex(), te::da::DataSetTypeCapabilities::supportsIndex(), te::da::DataSetCapabilities::supportsIndexedTraversing(), te::da::QueryCapabilities::supportsInsert(), te::da::DataTypeCapabilities::supportsInt16(), te::da::DataTypeCapabilities::supportsInt32(), te::da::DataTypeCapabilities::supportsInt64(), te::da::DataTypeCapabilities::supportsNumeric(), te::da::DataTypeCapabilities::supportsPolymorphic(), te::da::DataSourceCapabilities::supportsPreparedQueryAPI(), te::da::DataSetTypeCapabilities::supportsPrimaryKey(), te::da::DataSetTypeCapabilities::supportsQuadTreeIndex(), te::da::DataSetCapabilities::supportsRandomTraversing(), te::da::DataTypeCapabilities::supportsRaster(), te::da::DataSetTypeCapabilities::supportsRTreeIndex(), te::da::QueryCapabilities::supportsSelect(), te::da::QueryCapabilities::supportsSelectInto(), te::da::DataSetTypeCapabilities::supportsSequence(), te::da::QueryCapabilities::supportsSQLDialect(), te::da::DataTypeCapabilities::supportsString(), te::da::DataSourceCapabilities::supportsTransactions(), te::da::DataTypeCapabilities::supportsUChar(), te::da::DataTypeCapabilities::supportsUInt16(), te::da::DataTypeCapabilities::supportsUInt32(), te::da::DataTypeCapabilities::supportsUInt64(), te::da::DataSetTypeCapabilities::supportsUniqueKey(), te::da::QueryCapabilities::supportsUpdate(), te::da::DataTypeCapabilities::supportsXML(), and te::common::WAccess.

Referenced by OGRExampleRead(), and PostGISExample().

void QueryExample ( )

Quering a dataset.

Definition at line 12 of file QueryExample_2.cpp.

References ds, GetPostGISConnection(), te::mnt::Max(), te::mnt::Min(), PrintDataSet(), and te::sa::Sum().

Referenced by main().

void SQLiteExample ( )

An example using SQLite data source driver.