19 std::string connInfo(
"file://");
20 std::string data_dir = TERRALIB_DATA_DIR;
23 std::cout <<
"Inform the location of your shapefile (ENTER to accept default \'" << (data_dir +
"/shape/munic_2001.shp") <<
"\'): ";
24 std::getline (std::cin, aux);
28 connInfo += data_dir +
"/shape/munic_2001.shp";
33 if (!dsOrigin->isValid())
35 std::cout <<
"Can not access the shapefile.\n";
40 std::unique_ptr<te::da::DataSourceTransactor> tOrigin = dsOrigin->getTransactor();
42 std::vector<std::string> datasets = tOrigin->getDataSetNames();
43 std::unique_ptr<te::da::DataSet> datasetOrigin = tOrigin->getDataSet(datasets[0]);
44 std::unique_ptr<te::da::DataSetType> dtOrigin = tOrigin->getDataSetType(datasets[0]);
47 if (!dsDestination.get())
50 dsDestination->open();
53 std::unique_ptr<te::da::DataSourceTransactor> tDestination = dsDestination->getTransactor();
57 newDataSet->
setName(
"public.munic_2001_from_shp_to_pgis");
61 std::cout << std::endl <<
"starting copy..." << std::endl;
62 std::map<std::string, std::string> options;
63 if (tDestination->dataSetExists(
"public.munic_2001_from_shp_to_pgis"))
65 tDestination->dropDataSet(
"public.munic_2001_from_shp_to_pgis");
67 tDestination->begin();
68 tDestination->createDataSet(newDataSet,options);
69 tDestination->add(newDataSet->
getName(), datasetOrigin.get(),options);
70 tDestination->commit();
71 std::cout << std::endl <<
"Copy finished..." << std::endl;
73 catch(
const std::exception& e)
75 std::cout << std::endl <<
"An exception has occurred in the Copy Example: " << e.what() << std::endl;
79 std::cout << std::endl <<
"An unexpected exception has occurred in the Copy Example!" << std::endl;
static std::unique_ptr< DataSource > make(const std::string &driver, const te::core::URI &connInfo)
void setSRID(int srid)
It sets the spatial reference system identifier associated to this property.
void setGeometryType(GeomType t)
It sets the geometry subtype.
A class that models the description of a dataset.
std::unique_ptr< te::da::DataSource > GetPostGISConnection()
void setName(const std::string &name)
It sets the property name.
void CopyingData()
This example shows how to copy a given dataset from one data source to another one.
Examples on how to access/manipulate DataSources in TerraLib.
This file contains include headers for the Vector Geometry model of TerraLib.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
This file contains include headers for the Data Access module of TerraLib.
const std::string & getName() const
It returns the property name.