47 _nonNativeProjection( false ),
48 _projectionCategoricalMap(),
56 _spatiallyUnique( false ),
57 _environmentallyUnique( false ),
58 _calcConfusionMatrix( true ),
72 std::string input_file( request_file );
81 std::string spatially_unique = fp.
get(
"Spatially unique" );
83 if ( spatially_unique ==
"true" ) {
88 std::string environmentally_unique = fp.
get(
"Environmentally unique" );
90 if ( environmentally_unique ==
"true" ) {
96 std::string confusion_matrix = fp.
get(
"Confusion matrix" );
98 if ( confusion_matrix ==
"false" ) {
103 std::string auc = fp.
get(
"AUC" );
105 if ( auc ==
"false" ) {
128 std::string oc_cs = fp.
get(
"WKT coord system" );
131 std::string oc_file = fp.
get(
"Occurrences source" );
133 if ( oc_file.empty() ) {
135 oc_file = fp.
get(
"Species file" );
139 std::string oc_name = fp.
get(
"Occurrences group" );
141 if ( oc_name.empty() ) {
143 oc_name = fp.
get(
"Species" );
150 if ( ! oc_cs.empty() )
151 Log::instance()->
warn(
"'WKT coord system' will be ignored since 'Input model' has been specified...\n" );
153 if ( ! oc_file.empty() )
154 Log::instance()->
warn(
"'Occurrences source'/'Species file' will be ignored since 'Input model' has been specified...\n" );
156 if ( ! oc_name.empty() )
157 Log::instance()->
warn(
"'Occurrences group'/'Species' will be ignored since 'Input model' has been specified...\n" );
164 if ( oc_cs.empty() ) {
165 Log::instance()->
error(
"'WKT coord system' keyword was not specified in the request file!\n" );
169 if ( oc_file.empty() ) {
171 Log::instance()->
error(
"'Occurrences source' keyword was not specified in the request file!\n" );
215 std::vector<std::string> cat = fp.
getAll(
"Categorical map" );
216 std::vector<std::string> map = fp.
getAll(
"Map" );
223 Log::instance()->
warn(
"'Mask' will be ignored since 'Input model' has been specified...\n" );
225 if ( cat.size() > 0 )
226 Log::instance()->
warn(
"'Categorical map' will be ignored since 'Input model' has been specified...\n" );
228 if ( map.size() > 0 )
229 Log::instance()->
warn(
"'Map' will be ignored since 'Input model' has been specified...\n" );
235 if ( ! (cat.size() + map.size()) ) {
237 Log::instance()->
error(
"At least one 'Map' or 'Categorical map' needs to be specified!\n" );
284 Log::instance()->
error(
"At least one 'Output map' or 'Categorical output map' needs to be specified!\n" );
293 Log::instance()->
info(
"Projection not set: using training Environment for projection\n");
312 std::string format = fp.
get(
"Output format" );
314 if ( ! format.empty() ) {
320 std::string fileType = fp.
get(
"Output file type" );
322 if ( ! fileType.empty() ) {
352 std::string alg_id = fp.
get(
"Algorithm" );
357 if ( ! alg_id.empty() )
358 Log::instance()->
warn(
"'Algorithm' will be ignored since 'Input model' has been specified...\n" );
365 if ( alg_id.empty() )
377 Log::instance()->
error(
"Algorithm '%s' specified in the request file was not found\n",
384 std::vector<std::string> req_param = fp.
getAll(
"Parameter" );
387 int nparam = metadata->
nparam;
415 Log::instance()->
error(
"Could not read occurrences from request file. Make sure 'Occurrences source' has been specified.\n" );
435 std::vector<std::string> str_param )
441 for ( ; param < end; param++, result++ ) {
467 std::vector<std::string> vet )
469 int length = name.length();
470 std::vector<std::string>::iterator it = vet.begin();
471 std::vector<std::string>::iterator end = vet.end();
473 while ( it != end ) {
475 if ( name == (*it).substr( 0, length ) ) {
477 std::string value = (*it).substr( length );
480 std::string::size_type pos = value.find_first_not_of(
' ');
482 if ( pos != std::string::npos ) {
484 value.erase( 0, pos );
519 sampler->spatiallyUnique();
523 Log::instance()->
warn(
"Cannot set spatially unique filter: no sampler available\n" );
533 sampler->environmentallyUnique();
537 Log::instance()->
warn(
"Cannot set environmentally unique filter: no sampler available\n" );
598 Log::instance()->
error(
"Error during projection: Request not properly initialized\n" );
int configure(OpenModeller *om, char *request_file)
void warn(const char *format,...)
'Warn' level.
static ConfigurationPtr readXml(char const *filename)
bool calcConfusionMatrix()
std::string _outputModelFile
const ConfusionMatrix *const getConfusionMatrix()
void setValue(std::string const val)
static Log * instance()
Returns the instance pointer, creating the object on the first call.
std::string _projectionFile
static OccurrencesFactory & instance()
A common interface to rasters.
ConfigurationPtr getModelConfiguration() const
virtual OccurrencesPtr getAbsences(const char *groupId)
EnvironmentPtr createEnvironment(const std::vector< std::string > &categs, const std::vector< std::string > &maps, const std::string &mask_file)
int _setEnvironment(OpenModeller *om, FileParser &fp)
void makeModel(OpenModeller *om)
int createMap(const EnvironmentPtr &env, char const *output_file, MapFormat &format)
void error(const char *format,...)
'Error' level.
OccurrencesPtr _presences
bool _calcConfusionMatrix
bool _environmentallyUnique
virtual OccurrencesPtr getPresences(const char *groupId)
int setOccurrences(const OccurrencesPtr &presence, const OccurrencesPtr &absence=OccurrencesPtr())
AlgMetadata const * algorithmMetadata(char const *algorithm_id)
int _readParameters(AlgParameter *result, AlgMetadata const *metadata, std::vector< std::string > str_param)
int _setOccurrences(OpenModeller *om, FileParser &fp)
static void writeXml(const ConstConfigurationPtr &config, char const *fileaname)
OccurrencesPtr getAbsences()
std::vector< std::string > getAll(const std::string &key) const
std::string _inputModelFile
static RasterFactory & instance()
int setAlgorithm(std::string const id, int nparam, AlgParameter const *param)
int _setAlgorithm(OpenModeller *om, FileParser &fp)
std::string const id() const
std::vector< std::string > _projectionMap
OccurrencesPtr getPresences()
bool _nonNativeProjection
int _setProjection(OpenModeller *om, FileParser &fp)
void setId(std::string const id)
void info(const char *format,...)
'Info' level.
void setEnvironment(std::vector< std::string > categ_map, std::vector< std::string > continuous_map, const std::string &mask)
Raster * create(const string &source, int categ=0)
const SamplerPtr & getSampler() const
bool requestedProjection()
std::string extractParameter(std::string const name, std::vector< std::string > vet)
std::vector< std::string > _projectionCategoricalMap
void makeProjection(OpenModeller *om)
RocCurve *const getRocCurve()
OccurrencesPtr _presences
std::string get(const std::string &key) const
void setModelConfiguration(const ConstConfigurationPtr &)
OccurrencesReader * create(const char *source, const char *coordSystem)