27 #include "../geometry/Envelope.h" 28 #include "../geometry/Polygon.h" 29 #include "../raster/Raster.h" 30 #include "../raster/RasterFactory.h" 31 #include "../raster/Band.h" 32 #include "../raster/BandProperty.h" 33 #include "../raster/Grid.h" 42 : m_classifierStrategyParamsPtr(nullptr)
142 m_outputRasterPtr.reset();
181 "Unable to initialize the classification strategy - " 182 + strategyPtr->getErrorMessage() );
194 "Unable to execute the classification strategy - " +
195 strategyPtr->getErrorMessage() );
199 std::unique_ptr< te::rst::Raster > memOutRasterPtr = strategyPtr->releaseOutputRaster();
202 std::vector<te::rst::BandProperty*> bandsProperties;
204 for(
unsigned int memBandIdx=0; memBandIdx < memOutRasterPtr->getNumberOfBands(); memBandIdx++)
207 *( memOutRasterPtr->getBand( memBandIdx )->getProperty() ) );
215 memOutRasterPtr->getBand( 0 )->getProperty()->m_colorInterp
221 memOutRasterPtr->getBand( 0 )->getProperty()->m_palette.size()
230 bandsProperties.push_back(newbprop);
240 outputParamsPtr->
m_rInfo,
nullptr,
nullptr));
242 "Output raster creation error");
246 const unsigned int nBands =
static_cast<unsigned int>(memOutRasterPtr->getNumberOfBands());
247 const unsigned int nCols = memOutRasterPtr->getNumberOfColumns();
248 const unsigned int nRows = memOutRasterPtr->getNumberOfRows();
249 unsigned int row = 0;
250 unsigned int col = 0;
251 std::complex< double > value;
253 for(
unsigned int bandIdx = 0 ; bandIdx < nBands ; ++bandIdx )
255 const te::rst::Band& inBand = *memOutRasterPtr->getBand( bandIdx );
258 for( row = 0 ; row < nRows ; ++row )
260 for( col = 0 ; col <
nCols ; ++
col )
263 outBand.
setValue( col, row, value );
268 strategyPtr->getMetaData( outputParamsPtr->
m_metadata );
298 "Invalid raster bands number");
303 "Invalid raster bands" );
307 const std::vector< te::gm::Polygon* >& inputPolygons =
311 const std::size_t inputPolygonsSize = inputPolygons.size();
313 for (std::size_t inputPolygonsIdx = 0; inputPolygonsIdx > inputPolygonsSize;
317 "Invalid input polygon pointer");
319 inputPolygons[ inputPolygonsIdx ]->getSRID() ==
320 inputRaster.
getSRID(),
"Invalid input polygon SRID" );
322 inputPolygons[ inputPolygonsIdx ]->getMBR()->within(*inputRaster.
getExtent()),
323 "Raster and Polygons does not fit");
te::gm::Envelope * getExtent()
Returns the geographic extension of the raster data.
Palette indexes color interpretation.
OutputParameters()
Default constructor.
A raster band description.
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
Base exception class for plugin module.
std::unique_ptr< te::rst::Raster > m_outputRasterPtr
A pointer to the generated output raster (label image).
Raster Processing algorithm output parameters base interface.
int m_type
The data type of the elements in the band ( See te::dt namespace basic data types for reference )...
Raster Processing algorithm base interface class.
Classifier output parameters.
te::common::AccessPolicy getAccessPolicy() const
Returns the raster access policy.
unsigned int unsigned int nCols
const Classifier::OutputParameters & operator=(const Classifier::OutputParameters ¶ms)
An abstract class for raster data strucutures.
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
Classifier::InputParameters m_inputParameters
Classifier execution parameters.
A raster band description.
static te::rp::ClassifierStrategy * make(const std::string &factoryKey)
It creates an object with the appropriated factory.
virtual void setValue(unsigned int c, unsigned int r, const double value)=0
Sets the cell attribute value.
Raster classifier strategy factory base class.
Abstract parameters base interface.
int getSRID() const
Returns the raster spatial reference system identifier.
bool m_instanceInitialized
Is this instance already initialized?
te::common::AbstractParameters * clone() const
Create a clone copy of this instance.
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state...
Classifier Strategy Parameters.
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.
static Raster * make()
It creates and returns an empty raster with default raster driver.
Raster classifier strategy base class.
void reset()
Clear all internal allocated objects and reset the algorithm to its initial state.
virtual void reset() _NOEXCEPT_OP(false)
Clear all internal allocated objects and reset the algorithm to its initial state.
std::map< std::string, std::string > m_rInfo
The necessary information to create the raster (as described in te::raster::RasterFactory).
A rectified grid is the spatial support for raster data.
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Configuration flags for the Raster Processing module of TerraLib.
#define TERP_INSTANCE_TRUE_OR_RETURN_FALSE(value, message)
Checks if value is true. For false values a warning message will be logged, the current instance erro...
bool isInitialized() const
Returns true if the algorithm instance is initialized and ready for execution.
virtual AbstractParameters * clone() const =0
Create a clone copy of this instance.
virtual void getValue(unsigned int c, unsigned int r, double &value) const =0
Returns the cell attribute value.
std::map< std::string, std::string > m_metadata
Extra strategy-dependent generated metadata.