CreatingDataSetType.cpp
Go to the documentation of this file.
1 // Examples
2 #include "DataAccessExamples.h"
3 
4 // TerraLib
5 #include <terralib/datatype.h>
6 
8 {
9  if(transactor == 0)
10  throw te::common::Exception("You informed a NULL transactor!");
11 
12 // check if dataset with the same name already exists
13 
14  if(transactor->dataSetExists(datasetname)) //("public.our_country1"))
15  {
16  throw te::common::Exception("The table public.our_country1 already exists!");
17  }
18 
19 // mount one in memory...
20  /* te::da::DataSetType* datasetType = new te::da::DataSetType("public.our_country1");
21 
22  dt->add(new te::dt::SimpleProperty("gid", te::dt::INT32_TYPE, true));
23  dt->add(new te::dt::StringProperty("country_name", te::dt::STRING));
24  dt->add(new te::dt::StringProperty("city_name", te::dt::VAR_STRING, 50, true));
25  dt->add(new te::gm::GeometryProperty("spatial_data", 4326, te::gm::GeometryType, true));
26 */
27 
28 // ... and then call persistence API
29  std::map<std::string, std::string> options; //API requires this parameter
30  transactor->createDataSet(dt,options);
31 
32  return dt;
33 }
34 
This file contains include headers for the Data Type module of TerraLib.
A class that models the description of a dataset.
Definition: DataSetType.h:72
virtual void createDataSet(DataSetType *dt, const std::map< std::string, std::string > &options)=0
It creates the dataset schema definition in the target data source.
te::da::DataSetType * CreateDataSetType(const std::string &datasetname, te::da::DataSetType *dt, te::da::DataSourceTransactor *transactor)
virtual bool dataSetExists(const std::string &name)=0
It checks if a dataset with the given name exists in the data source.
Examples on how to access/manipulate DataSources in TerraLib.
static te::dt::TimeDuration dt(20, 30, 50, 11)
A DataSourceTransactor can be viewed as a connection to the data source for reading/writing things in...
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...