openModeller  Version 1.5.0
OpenModeller Class Reference

#include <OpenModeller.hh>

Collaboration diagram for OpenModeller:
Collaboration graph

Public Member Functions

 OpenModeller ()
 
 ~OpenModeller ()
 
void setLogLevel (Log::Level level)
 
std::string getVersion ()
 
AlgMetadata const ** availableAlgorithms ()
 
AlgMetadata const * algorithmMetadata (char const *algorithm_id)
 
int numAvailableAlgorithms ()
 
EnvironmentPtr getEnvironment ()
 
AlgorithmPtr getAlgorithm ()
 
Model getModel () const
 
const SamplerPtrgetSampler () const
 
int setOccurrences (const OccurrencesPtr &presence, const OccurrencesPtr &absence=OccurrencesPtr())
 
int setAlgorithm (std::string const id, int nparam, AlgParameter const *param)
 
void setEnvironment (std::vector< std::string > categ_map, std::vector< std::string > continuous_map, const std::string &mask)
 
void setSampler (const SamplerPtr &sampler)
 
void setAbortionCallback (AbortionCallback func, void *param=0)
 
void setMapCallback (ModelProjectionCallback func, void *param=0)
 
int createMap (const EnvironmentPtr &env, char const *output_file, MapFormat &format)
 
int createMap (const EnvironmentPtr &env, char const *output_file)
 
int createMap (char const *output_file, MapFormat &format)
 
int createMap (char const *output_file)
 
void setModelCallback (ModelCreationCallback func, void *param=0)
 
int createModel ()
 
int run ()
 
Scalar getValue (const ConstEnvironmentPtr &env, Coord x, Coord y)
 
Scalar getValue (Scalar const *environment_values)
 
char * error ()
 
AreaStatsgetActualAreaStats ()
 
AreaStatsgetEstimatedAreaStats (double proportionAreaToSample=0.01)
 
AreaStatsgetEstimatedAreaStats (const ConstEnvironmentPtr &env, double proportionAreaToSample=0.01)
 
const ConfusionMatrix *const getConfusionMatrix ()
 
RocCurve *const getRocCurve ()
 
ConfigurationPtr getModelConfiguration () const
 
void setModelConfiguration (const ConstConfigurationPtr &)
 
void setProjectionConfiguration (const ConstConfigurationPtr &)
 
void calculateModelStatistics (const ConstConfigurationPtr &)
 

Private Member Functions

bool hasEnvironment ()
 

Private Attributes

SamplerPtr _samp
 
AlgorithmPtr _alg
 
OccurrencesPtr _presence
 
OccurrencesPtr _absence
 
EnvironmentPtr _env
 
CallbackWrapper _callback_wrapper
 
MapFormat _format
 
EnvironmentPtr _projEnv
 
AreaStats_actualAreaStats
 
AreaStats_estimatedAreaStats
 
ConfusionMatrix _confusion_matrix
 
RocCurve _roc_curve
 
char _error [256]
 

Detailed Description

Defines and implements all commands to interface with the model generator.

Definition at line 71 of file OpenModeller.hh.

Constructor & Destructor Documentation

OpenModeller::OpenModeller ( )

Definition at line 76 of file OpenModeller.cpp.

References _actualAreaStats, _error, and _estimatedAreaStats.

OpenModeller::~OpenModeller ( )

Definition at line 90 of file OpenModeller.cpp.

References _actualAreaStats, and _estimatedAreaStats.

Member Function Documentation

AlgMetadata const * OpenModeller::algorithmMetadata ( char const *  algorithm_id)

Returns a specific algorithm metadata

Parameters
algorithm_idIdentifier of the algorithm.
Returns
Algorithm's metadata or zero if the algorithm was not found.

Definition at line 126 of file OpenModeller.cpp.

References AlgorithmFactory::algorithmMetadata().

Referenced by RequestFile::_setAlgorithm().

Here is the call graph for this function:

AlgMetadata const ** OpenModeller::availableAlgorithms ( )

Finds the system available algorithms' metadata.

The pointer returned are copied from an internal storage of algorithms. So they can not be deallocated. Another point is that the AlgMetadata will be reallocated the next time this method is called.

Returns
a null terminated list of available algorithms.

Definition at line 117 of file OpenModeller.cpp.

References AlgorithmFactory::availableAlgorithms().

Referenced by main().

Here is the call graph for this function:

int OpenModeller::createMap ( const EnvironmentPtr env,
char const *  output_file,
MapFormat format 
)

Create and save distribution map to disk using the specified projection environment and output format.

Parameters
envPointer to Environment object with the layers to project the model onto.
output_fileOutput file name.
formatGeoreferenced map file which will define cell size, extent, WKT projection, no data value, and file type for the output map.

Definition at line 265 of file OpenModeller.cpp.

References _actualAreaStats, _alg, _callback_wrapper, _format, _projEnv, MapFormat::copyDefaults(), Projector::createMap(), Log::error(), MapFormat::GreyBMP, Log::info(), Log::instance(), RasterFactory::instance(), MapFormat::setFormat(), and Log::warn().

Referenced by createMap(), main(), and RequestFile::makeProjection().

Here is the call graph for this function:

int OpenModeller::createMap ( const EnvironmentPtr env,
char const *  output_file 
)

Create and save distribution map to disk using the specified projection environment. Output format defaults to the output mask format.

Parameters
envPointer to Environment object with the layers to project the model onto.
output_fileOutput file name.

Definition at line 335 of file OpenModeller.cpp.

References _format, and createMap().

Here is the call graph for this function:

int OpenModeller::createMap ( char const *  output_file,
MapFormat format 
)

Create and save distribution map to disk using the specified output format. Projection environment defaults to the same environment used during model creation and previously set by calling the setEnvironment() method.

Parameters
output_fileOutput file name.
formatGeoreferenced map file which will define cell size, extent, WKT projection, no data value, and file type for the output map.

Definition at line 356 of file OpenModeller.cpp.

References _env, _projEnv, and createMap().

Here is the call graph for this function:

int OpenModeller::createMap ( char const *  output_file)

Create and save distribution map to disk. Projection environment defaults to the same environment used during model creation and previously set by calling the setEnvironment() method. Output format defaults to the output mask format.

Parameters
output_fileOutput file name.

Definition at line 343 of file OpenModeller.cpp.

References _env, _format, _projEnv, and createMap().

Here is the call graph for this function:

int OpenModeller::createModel ( )

Run the algorithm to create the model.

Definition at line 231 of file OpenModeller.cpp.

References _alg, _callback_wrapper, _confusion_matrix, _roc_curve, _samp, Log::error(), Log::info(), Log::instance(), ConfusionMatrix::reset(), and RocCurve::reset().

Referenced by main(), and RequestFile::makeModel().

Here is the call graph for this function:

char* OpenModeller::error ( )
inline

Definition at line 304 of file OpenModeller.hh.

Referenced by RequestFile::makeModel().

AreaStats * OpenModeller::getActualAreaStats ( )

Returns a pointer to the model AreaStats object which contains statistics about areas on the map generated by OM. IMPORTANT: you should delete the pointer because it returns a copy of the internal object!

Definition at line 405 of file OpenModeller.cpp.

References _actualAreaStats.

Referenced by main().

AlgorithmPtr OpenModeller::getAlgorithm ( )
inline

Returns the current algorithm setting.

Returns
Pointer to algorithm.

Definition at line 139 of file OpenModeller.hh.

Referenced by main().

const ConfusionMatrix *const OpenModeller::getConfusionMatrix ( )

Returns a pointer to the internal object representing the confusion matrix that was calculated from the last generated model. IMPORTANT: you should NOT delete the returned pointer!

Definition at line 462 of file OpenModeller.cpp.

References _confusion_matrix, ConfusionMatrix::calculate(), getModel(), getSampler(), and ConfusionMatrix::ready().

Referenced by main(), and RequestFile::makeModel().

Here is the call graph for this function:

EnvironmentPtr OpenModeller::getEnvironment ( )
inline

Returns the current environment related to model creation.

Returns
Pointer to environment related to model creation.

Definition at line 133 of file OpenModeller.hh.

Referenced by draw_occur(), and main().

AreaStats * OpenModeller::getEstimatedAreaStats ( double  proportionAreaToSample = 0.01)

Returns a pointer to the model AreaStats object which contains statistics about areas on the map generated by OM. This one uses only a random sample of the data points to estimate prediction areas. IMPORTANT: you should NOT delete the returned pointer!

Parameters
proportionAreaToSampleProportion of the area of interest (mask or intersection of all layers extents) to use as sample size.

Definition at line 413 of file OpenModeller.cpp.

References _env.

AreaStats * OpenModeller::getEstimatedAreaStats ( const ConstEnvironmentPtr env,
double  proportionAreaToSample = 0.01 
)

Definition at line 421 of file OpenModeller.cpp.

References _alg, _estimatedAreaStats, AreaStats::addPrediction(), and AreaStats::reset().

Here is the call graph for this function:

Model OpenModeller::getModel ( ) const
inline

Returns model created by the algorithm.

Returns
Model object.

Definition at line 145 of file OpenModeller.hh.

Referenced by calculateModelStatistics(), getConfusionMatrix(), getRocCurve(), and main().

ConfigurationPtr OpenModeller::getModelConfiguration ( ) const

Definition at line 492 of file OpenModeller.cpp.

References _alg, _confusion_matrix, _roc_curve, _samp, RocCurve::getConfiguration(), ConfusionMatrix::getConfiguration(), RocCurve::ready(), and ConfusionMatrix::ready().

Referenced by main(), and RequestFile::makeModel().

Here is the call graph for this function:

RocCurve *const OpenModeller::getRocCurve ( )

Returns a pointer to the internal object representing the ROC curve that was calculated from the last generated model. IMPORTANT: you should NOT delete the returned pointer!

Definition at line 476 of file OpenModeller.cpp.

References _roc_curve, RocCurve::calculate(), getModel(), getSampler(), and RocCurve::ready().

Referenced by main(), and RequestFile::makeModel().

Here is the call graph for this function:

const SamplerPtr& OpenModeller::getSampler ( ) const
inline

Returns current sampler setting.

Returns
Pointer to sampler.

Definition at line 151 of file OpenModeller.hh.

Referenced by calculateModelStatistics(), getConfusionMatrix(), getRocCurve(), main(), and RequestFile::makeModel().

Scalar OpenModeller::getValue ( const ConstEnvironmentPtr env,
Coord  x,
Coord  y 
)

Get prediction at a given point.

Parameters
envPointer to Environment class with the layers to get environmental values from.
xX coordinate of point being queried
yY coordinate of point being queried
Returns
Prediction value at the specified point. Valid values range from 0.0 to 1.0. Value -1.0 means there is no prediction for that point (masked or not predicted)

Definition at line 369 of file OpenModeller.cpp.

References _alg, _env, and Sample::size().

Referenced by draw_niche().

Here is the call graph for this function:

Scalar OpenModeller::getValue ( Scalar const *  environment_values)

Get prediction at a given point.

Parameters
environment_valuesVector with environment values.
Returns
Prediction value at the specified point. Valid values range from 0.0 to 1.0. Value -1.0 means there is no prediction for that point (masked or not predicted)

Definition at line 395 of file OpenModeller.cpp.

References _alg, and _env.

std::string OpenModeller::getVersion ( )

Returns the openModeller client interface version in the format "n.m"

Definition at line 109 of file OpenModeller.cpp.

Referenced by main().

bool OpenModeller::hasEnvironment ( )
private

Definition at line 141 of file OpenModeller.cpp.

References _env, and _presence.

Referenced by setAlgorithm().

int OpenModeller::numAvailableAlgorithms ( )

Number of available algorithms. If the algorithms are not already searched in the system, searchs them first.

Returns
Number of available algorithms.

Definition at line 135 of file OpenModeller.cpp.

References AlgorithmFactory::numAvailableAlgorithms().

Here is the call graph for this function:

int OpenModeller::run ( )
inline

Compatibility with old oM client versions.

Definition at line 283 of file OpenModeller.hh.

void OpenModeller::setAbortionCallback ( AbortionCallback  func,
void *  param = 0 
)

Sets a callback function to be called during model creation and map projection to check if the job should be aborted.

Parameters
funcPointer to the callback function.
paramUser parameter to be passed to the callback function.

Definition at line 65 of file OpenModeller.cpp.

References _callback_wrapper, and CallbackWrapper::setAbortionCallback().

Here is the call graph for this function:

int OpenModeller::setAlgorithm ( std::string const  id,
int  nparam,
AlgParameter const *  param 
)

Define algorithm that will be used to generate the model.

Parameters
idAlgorithm's identifier. Must match the Algorithm::getID() returned string.
nparamNumber of parameters.
paramVector with all parameters. The address 'param' points to must exist when the method "run()" is called.
Returns
zero if something goes wrong like the algorithm ID does not exist, use different number of parameters, etc.

Definition at line 185 of file OpenModeller.cpp.

References _absence, _alg, _env, _error, _presence, _samp, createSampler(), Log::error(), hasEnvironment(), Log::instance(), AlgorithmFactory::newAlgorithm(), setSampler(), and Log::warn().

Referenced by RequestFile::_setAlgorithm(), and main().

Here is the call graph for this function:

void OpenModeller::setEnvironment ( std::vector< std::string >  categ_map,
std::vector< std::string >  continuous_map,
const std::string &  mask 
)

Defines environmental layers and the mask using STL arguments. Also creates the Environment object used for native range projection.

Parameters
categ_mapVector of strings containing the file names of categorical map layers.
continuous_mapVector of strings containing the file names of continuous map layers.
maskFile name of the mask map layer.

Definition at line 167 of file OpenModeller.cpp.

References _env, and createEnvironment().

Referenced by RequestFile::_setEnvironment().

Here is the call graph for this function:

void OpenModeller::setLogLevel ( Log::Level  level)

Sets the log level on the global Log g_log object.

Note: We need to add control over the log file and prefix as well.

Definition at line 100 of file OpenModeller.cpp.

References Log::instance(), and Log::setLevel().

Here is the call graph for this function:

void OpenModeller::setMapCallback ( ModelProjectionCallback  func,
void *  param = 0 
)

Sets a callback function to be called after each map distribution line generation.

Parameters
funcPointer to the callback function.
paramUser parameter to be passed to the callback function.

Definition at line 60 of file OpenModeller.cpp.

References _callback_wrapper, and CallbackWrapper::setModelProjectionCallback().

Referenced by main().

Here is the call graph for this function:

void OpenModeller::setModelCallback ( ModelCreationCallback  func,
void *  param = 0 
)

Sets a callback function to be called after each iteration of the model creation.

Parameters
funcPointer to the callback function.
paramUser parameter to be passed to the callback function.

Definition at line 55 of file OpenModeller.cpp.

References _callback_wrapper, and CallbackWrapper::setModelCreationCallback().

Referenced by main().

Here is the call graph for this function:

void OpenModeller::setModelConfiguration ( const ConstConfigurationPtr config)
int OpenModeller::setOccurrences ( const OccurrencesPtr presence,
const OccurrencesPtr absence = OccurrencesPtr() 
)

Define occurrence points to be used.

Parameters
presenceOccurrence points which the abundance attribute is not zero.
absenceOccurrence points which the abundance attribute is zero.

Definition at line 149 of file OpenModeller.cpp.

References _absence, _presence, Log::error(), and Log::instance().

Referenced by RequestFile::_setOccurrences().

Here is the call graph for this function:

void OpenModeller::setProjectionConfiguration ( const ConstConfigurationPtr config)
void OpenModeller::setSampler ( const SamplerPtr sampler)

Defines sampler to be used for modeling.

Parameters
samplerSampler object to be used for modeling

Definition at line 177 of file OpenModeller.cpp.

References _samp.

Referenced by setAlgorithm().

Member Data Documentation

OccurrencesPtr OpenModeller::_absence
private

Definition at line 376 of file OpenModeller.hh.

Referenced by setAlgorithm(), setModelConfiguration(), and setOccurrences().

AreaStats* OpenModeller::_actualAreaStats
private
CallbackWrapper OpenModeller::_callback_wrapper
private
ConfusionMatrix OpenModeller::_confusion_matrix
private
char OpenModeller::_error[256]
private

Definition at line 400 of file OpenModeller.hh.

Referenced by OpenModeller(), and setAlgorithm().

AreaStats* OpenModeller::_estimatedAreaStats
private

Definition at line 392 of file OpenModeller.hh.

Referenced by getEstimatedAreaStats(), OpenModeller(), and ~OpenModeller().

MapFormat OpenModeller::_format
private

Definition at line 385 of file OpenModeller.hh.

Referenced by createMap(), and setProjectionConfiguration().

OccurrencesPtr OpenModeller::_presence
private
EnvironmentPtr OpenModeller::_projEnv
private

Definition at line 388 of file OpenModeller.hh.

Referenced by createMap(), and setProjectionConfiguration().

RocCurve OpenModeller::_roc_curve
private

The documentation for this class was generated from the following files: