27 #include "../Config.h" 39 #define BOOST_TEST_NO_MAIN 40 #include <boost/test/unit_test.hpp> 41 #include <boost/shared_ptr.hpp> 42 #include <boost/uuid/random_generator.hpp> 43 #include <boost/uuid/uuid_io.hpp> 49 std::map<std::string, std::string> rasterInfo;
51 rasterInfo[
"URI"] = TERRALIB_DATA_DIR
"/geotiff/Landsat8_22162_07102015_8bits_rec.tif";
54 BOOST_CHECK(cloudRasterPtrPointer.get());
58 BOOST_CHECK(shadowRasterPtrPointer.get());
64 double minCloud = 130;
65 double maxCloud = 255;
67 double maxShadow = 60;
69 std::vector<te::rp::Filter::InputParameters::FilterType> vecFilter;
70 std::vector<int> vecIt;
75 te::rst::Raster* raster = cloudDetection->executeCloudDetection(cloudRasterPtrPointer.get(), shadowRasterPtrPointer.get(), cloudBand, shadowBand,
76 minCloud, maxCloud, minShadow, maxShadow, vecFilter, vecIt);
78 BOOST_CHECK( raster );
81 std::string outputdataset =
"terralib_unittest_rp_clouddetection.shp";
83 BOOST_CHECK(!outputdataset.empty());
85 std::string uriStr = TERRALIB_BUILD_PATH
"/terralib_unittest_rp/" + outputdataset;
90 boost::filesystem::path uri(uriStr);
92 std::size_t idx = outputdataset.find(
".");
93 if (idx != std::string::npos)
94 outputdataset = outputdataset.substr(0, idx);
96 std::string dsinfo(
"file://" + uri.string());
99 boost::uuids::basic_random_generator<boost::mt19937> gen;
100 boost::uuids::uuid u = gen();
101 std::string
id = boost::uuids::to_string(u);
104 ds->setConnInfo(dsinfo);
105 ds->setTitle(uri.stem().string());
106 ds->setAccessDriver(
"OGR");
108 ds->setDescription(
"Test Cloud Detection");
115 std::vector<te::gm::Geometry*> geomVec;
116 std::vector< double > geomsValues;
119 raster->
vectorize(geomVec, 0, 0, &geomsValues);
121 BOOST_CHECK(!geomVec.empty());
127 dsType->add(idProperty);
131 dsType->add(geomProperty);
134 std::string pkName =
"pk_id";
135 pkName +=
"_" + outputdataset;
139 std::unique_ptr<te::mem::DataSet> dataSet(
new te::mem::DataSet(dsType.get()));
141 for (std::size_t t = 0; t < geomVec.size(); ++t)
158 dataSet->moveBeforeFirst();
160 std::map<std::string, std::string> options;
162 dataSource->createDataSet(dsType.get(), options);
164 dataSource->add(outputdataset, dataSet.get(), options);
virtual void vectorize(std::vector< te::gm::Geometry * > &g, std::size_t b, unsigned int mp=0, std::vector< double > *const polygonsValues=0)
Vectorizes a given raster band, using GDALPolygonize function.
void add(te::dt::Property *p)
It adds a property to the list of properties of the primary key.
void setGeometry(std::size_t i, te::gm::Geometry *value)
It sets the value of the i-th property.
An atomic property like an integer or double.
boost::shared_ptr< DataSource > DataSourcePtr
A class that models the description of a dataset.
This is a singleton for managing all data source instances available in the system.
static te::dt::Date ds(2010, 01, 01)
A singleton to keep all the registered data sources.
void setInt32(std::size_t i, boost::int32_t value)
It sets the value of the i-th property.
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
static DataSourceInfoManager & getInstance()
It returns a reference to the singleton instance.
An abstract class for raster data strucutures.
This class provide cloud detection.
A factory for data sources.
This file contains include headers for the TerraLib Raster Processing module.
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
A conteiner class for keeping information about a data source.
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
int getSRID() const
Returns the raster spatial reference system identifier.
BOOST_AUTO_TEST_CASE(cloudDetection_test)
It describes a primary key (pk) constraint.
A class that represents a data source component.
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr
static Raster * open(const std::map< std::string, std::string > &rinfo, te::common::AccessPolicy p=te::common::RAccess)
It opens a raster with the given parameters and default raster driver.