23 std::unique_ptr<te::da::DataSourceTransactor> transactor = ds->getTransactor();
54 fields->push_back(f_min);
55 fields->push_back(f_max);
56 fields->push_back(f_count);
57 fields->push_back(f_sum);
58 fields->push_back(f_mean);
59 fields->push_back(f_stddev);
60 fields->push_back(f_variance);
61 fields->push_back(f_amplitude);
69 std::unique_ptr<te::da::DataSet> dataset = transactor->query(select);
70 dataset->moveBeforeFirst();
73 while(dataset->moveNext())
75 std::string min = dataset->getAsString(0);
76 std::cout <<
"Min: " << min <<std::endl;
78 std::string max = dataset->getAsString(1);
79 std::cout <<
"Max: " << max <<std::endl;
81 std::string count = dataset->getAsString(2);
82 std::cout <<
"Count: " << count <<std::endl;
84 std::string sum = dataset->getAsString(3);
85 std::cout <<
"Sum: " << sum <<std::endl;
87 std::string mean = dataset->getAsString(4);
88 std::cout <<
"Mean: " << mean <<std::endl;
90 std::string stddev = dataset->getAsString(5);
91 std::cout <<
"Std_dev: " << stddev <<std::endl;
93 std::string variance = dataset->getAsString(6);
94 std::cout <<
"Variance: " << variance <<std::endl;
96 std::string amplitude = dataset->getAsString(7);
97 std::cout <<
"Amplitude: " << amplitude <<std::endl;
103 std::string sql(
"SELECT * , st_intersects(g1.geom, g2.geom) " 104 "FROM munic_2001 AS g1, munic_2001 AS g2 " 105 "WHERE g1.nome = 'Ouro Preto' " 106 "AND st_intersects(g1.geom, g2.geom) " 109 std::unique_ptr<te::da::DataSet> dataset = transactor->query(sql);
110 PrintDataSet(
"All neighbours of Ouro Preto", dataset.get());
113 bool trans_connected;
114 trans_connected = transactor->isInTransaction();
118 delete transactor.release();
121 catch(
const std::exception& e)
123 std::cout << std::endl <<
"An exception has occurred in QueryExample: " << e.what() << std::endl;
127 std::cout << std::endl <<
"An unexpected exception has occurred in QueryExample!" << std::endl;
An abstract class that models a source of data in a query.
The Field class can be used to model an expression that takes part of the output items of a SELECT...
A class that models the name of a dataset used in a From clause.
void QueryExample()
Quering a dataset.
A class that models the name of any property of an object.
TEMNTEXPORT te::gm::Point Max(te::gm::Point &p1, te::gm::Point &p2)
Count statistical function.
static te::dt::Date ds(2010, 01, 01)
Avg statistical function.
This is an abstract class that models a query expression.
StdDev statistical function.
TESAEXPORT double Sum(te::sa::GeneralizedProximityMatrix *gpm, int attrIdx)
Function used to calculate sum of a specific attribute from a gpm.
Examples on how to access/manipulate DataSources in TerraLib.
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
std::unique_ptr< te::da::DataSource > GetPostGISConnection()
A Select models a query to be used when retrieving data from a DataSource.
boost::ptr_vector< FromItem > From
It models the FROM clause for a query.
The subtraction operator.
Variance statistical function.
TEMNTEXPORT te::gm::Point Min(te::gm::Point &p1, te::gm::Point &p2)
void PrintDataSet(std::string datasetName, te::da::DataSet *dataset)
It prints the data in a given dataset.