18 std::string connInfo(
"file://");
19 std::string data_dir = TERRALIB_DATA_DIR;
22 std::cout <<
"Inform the location of your data source (ENTER to accept default \'" << (data_dir +
"/shape/poligono_unico.shp") <<
"\'): ";
23 std::getline (std::cin, aux);
27 connInfo += data_dir +
"/shape/poligono_unico.shp";
33 std::cout <<
"Datasource is opened? " << std::boolalpha << ds->isOpened() <<
'\n' <<
'\n';
39 std::cout <<
"\nDatasource has " << ds->getNumberOfDataSets() <<
" datasources\n";
40 std::vector<std::string> dsets = ds->getDataSetNames();
41 for (
size_t i=0; i<ds->getNumberOfDataSets(); ++i)
42 std::cout <<
'[' << i+1 <<
"]: " << dsets[i] << std::endl;
47 std::cout <<
"\nSelect a dataset from 1 to " << ds->getNumberOfDataSets() <<
" to see its data (0 to none): ";
50 if (n<1 || n>ds->getNumberOfDataSets())
52 PrintDataSet(dsets[n-1], ds->getDataSet(dsets[n-1]).get());
55 catch(
const std::exception& e)
57 std::cout << std::endl <<
"An exception has occurred in the OGR Example: " << e.what() << std::endl;
61 std::cout << std::endl <<
"An unexpected exception has occurred in the OGR Example!" << std::endl;
72 std::cout <<
"Inform a name to shapefile being created (ENTER to accept default \'soilmeasures\'): ";
73 std::getline (std::cin, aux);
77 dsName =
"soilmeasures";
84 std::string connInfo(
"file://");
85 std::string data_dir = TERRALIB_DATA_DIR;
87 std::cout <<
"Inform a location to write your shapefile (ENTER to accept default \'" << (data_dir +
"/shape") <<
"\'): ";
88 std::getline(std::cin, aux);
93 connInfo += data_dir +
"/shape";
99 std::cout <<
"Datasource is opened? " << std::boolalpha << ds->isOpened() <<
'\n' <<
'\n';
102 std::map<std::string, std::string> options;
103 ds->createDataSet(dType, options);
104 ds->add(dsName,dSet, options);
108 std::cout <<
"Datasource is opened? " << std::boolalpha << ds->isOpened() <<
'\n' <<
'\n';
110 std::cout <<
"Datasource is opened? " << std::boolalpha << ds->isOpened() <<
'\n' <<
'\n';
117 catch(
const std::exception& e)
119 std::cout << std::endl <<
"An exception has occurred in the OGR Example: " << e.what() << std::endl;
123 std::cout << std::endl <<
"An unexpected exception has occurred in the OGR Example!" << std::endl;
static std::unique_ptr< DataSource > make(const std::string &driver, const te::core::URI &connInfo)
A class that models the description of a dataset.
It models a property definition.
te::da::DataSetType * CreateDataSetTypeInMemory(const std::string &datasettypename)
static te::dt::Date ds(2010, 01, 01)
void PrintDataSourceCapabilities(te::da::DataSource *ds)
It retrieves and prints the capabilities of a given data source.
te::da::DataSet * CreatingDataSetInMemoryGivingDt(te::da::DataSetType *dt)
Examples on how to access/manipulate DataSources in TerraLib.
A factory for data sources.
void ORGExampleWrite()
An example using OGR data source driver to persist data to a datafile.
A dataset is the unit of information manipulated by the data access module of TerraLib.
virtual bool moveBeforeFirst()=0
It moves the internal pointer to a position before the first item in the collection.
void OGRExampleRead()
An example using OGR data source driver to retrieve data from a datafile.
This file contains include headers for the Data Access module of TerraLib.
void PrintDataSet(std::string datasetName, te::da::DataSet *dataset)
It prints the data in a given dataset.