TsSkeleton.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/unittest/rp/skeleton/TsSkeleton.cpp
22 
23  \brief A test suit for Skeleton interface.
24 */
25 
26 // TerraLib
27 #include "../Config.h"
28 #include <terralib/rp.h>
29 #include <terralib/raster.h>
30 
31 // STL
32 #include <cmath>
33 
34 // Boost
35 #define BOOST_TEST_NO_MAIN
36 #include <boost/test/unit_test.hpp>
37 #include <boost/shared_ptr.hpp>
38 
39 BOOST_AUTO_TEST_SUITE (skeleton_tests)
40 
41 BOOST_AUTO_TEST_CASE(pattern1_test)
42 {
43  /* Opening input raster */
44 
45  std::map<std::string, std::string> auxRasterInfo;
46 
47  auxRasterInfo["URI"] = TERRALIB_DATA_DIR "/geotiff/pattern1.tif";
48  boost::shared_ptr< te::rst::Raster > inputRasterPtrPointer ( te::rst::RasterFactory::open(
49  auxRasterInfo ) );
50  BOOST_CHECK( inputRasterPtrPointer.get() );
51 
52  auxRasterInfo.clear();
53  auxRasterInfo["MEM_SRC_RASTER_DRIVER_TYPE"] = "MEM";
54  auxRasterInfo["FORCE_MEM_DRIVER"] = "TRUE";
55  inputRasterPtrPointer.reset( inputRasterPtrPointer->resample(
56  te::rst::NearestNeighbor, -2, auxRasterInfo ) );
57  BOOST_CHECK( inputRasterPtrPointer.get() );
58 
59  /* Creating the algorithm parameters */
60 
61  te::rp::Skeleton::InputParameters algoInputParams;
62 
63  algoInputParams.m_inputRasterPtr = inputRasterPtrPointer.get();
64  algoInputParams.m_inputRasterBand = 0;
65  algoInputParams.m_inputMaskRasterPtr = 0;
66  algoInputParams.m_diffusionThreshold = 0.5;
67  algoInputParams.m_diffusionRegularization = 0.5;
68  algoInputParams.m_diffusionMaxIterations = 0;
69  algoInputParams.m_enableMultiThread = true;
70  algoInputParams.m_skeletonThreshold = 0.75;
71 
72  te::rp::Skeleton::OutputParameters algoOutputParams;
73 
74  algoOutputParams.m_rInfo["URI"] = "terralib_unittest_rp_skeleton_test1.tif";
75  algoOutputParams.m_rType = "GDAL";
76 
77  /* Executing the algorithm */
78 
79  te::rp::Skeleton algorithmInstance;
80 
81  BOOST_CHECK( algorithmInstance.initialize( algoInputParams ) );
82  BOOST_CHECK( algorithmInstance.execute( algoOutputParams ) );
83 }
84 
85 BOOST_AUTO_TEST_SUITE_END()
Near neighborhood interpolation method.
Skeleton output parameters.
Definition: Skeleton.h:120
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Definition: Skeleton.h:124
bool execute(AlgorithmOutputParameters &outputParams) _NOEXCEPT_OP(false)
Executes the algorithm using the supplied parameters.
Definition: Skeleton.cpp:162
BOOST_AUTO_TEST_SUITE(skeleton_tests) BOOST_AUTO_TEST_CASE(pattern1_test)
Definition: TsSkeleton.cpp:39
This file contains include headers for the TerraLib Raster Processing module.
std::map< std::string, std::string > m_rInfo
The necessary information to create the output rasters (as described in te::raster::RasterFactory).
Definition: Skeleton.h:126
Creation of skeleton images.
Definition: Skeleton.h:70
te::rst::Raster const * m_inputRasterPtr
Input raster.
Definition: Skeleton.h:82
BOOST_AUTO_TEST_CASE(encoding_test_utf8_latin1)
bool initialize(const AlgorithmInputParameters &inputParams) _NOEXCEPT_OP(false)
Initialize the algorithm instance making it ready for execution.
Definition: Skeleton.cpp:370
Skeleton input parameters.
Definition: Skeleton.h:78
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.