openModeller
Version 1.4.0
|
#include <Environment.hh>
Public Member Functions | |
~EnvironmentImpl () | |
EnvironmentImpl * | clone () const |
unsigned int | numLayers () const |
size_t | numCategoricalLayers () const |
int | isCategorical (int i) |
void | getMinMax (Sample *min, Sample *max) const |
void | normalize (Normalizer *normalizerPtr) |
void | resetNormalization () |
Sample | get (Coord x, Coord y) const |
Sample | getNormalized (Coord x, Coord y) const |
Sample | getUnnormalized (Coord x, Coord y) const |
Sample | getRandom (Coord *x=0, Coord *y=0) const |
int | checkCoordinates (Coord x, Coord y) const |
int | getRegion (Coord *xmin, Coord *ymin, Coord *xmax, Coord *ymax) const |
int | getExtremes (Sample *min, Sample *max) const |
Map * | getLayer (int index) const |
int | changeMask (const std::string &mask_file) |
Map * | getMask () const |
const std::string & | getLayerPath (int index) const |
const std::string & | getMaskPath () const |
void | removeLayer (unsigned int index) |
virtual ConfigurationPtr | getConfiguration () const |
virtual void | setConfiguration (const ConstConfigurationPtr &) |
Private Types | |
typedef std::pair< std::string, Map * > | layer |
typedef std::vector< layer > | layers |
Private Member Functions | |
EnvironmentImpl () | |
EnvironmentImpl (const std::vector< std::string > &categs, const std::vector< std::string > &maps, const std::string &mask_file="") | |
void | initialize (const std::vector< std::string > &categs, const std::vector< std::string > &maps, const std::string &mask_file="") |
void | getUnnormalizedInternal (Sample *, Coord x, Coord y) const |
void | clearMask () |
void | clearLayers () |
int | changeLayers (const std::vector< std::string > &categs, const std::vector< std::string > &maps) |
void | calcRegion () |
Static Private Member Functions | |
static ConfigurationPtr | getLayerConfig (const layer &l, bool basicConfig=false) |
static void | loadLayers (const std::vector< std::string > &map_ids, std::vector< Map * > &map_refs, int categ=0) |
static layer | makeLayer (const ConstConfigurationPtr &config, Map *map) |
static layer | makeLayer (const std::string &filename, int categ) |
static layer | makeLayer (const std::string &filename, Map *map) |
Private Attributes | |
layers | _layers |
Vector with all layers that describe the variables. | |
layer | _mask |
Mask (can be 0). | |
Coord | _xmin |
Intersection of all layers. | |
Coord | _ymin |
Intersection of all layers. | |
Coord | _xmax |
Intersection of all layers. | |
Coord | _ymax |
Intersection of all layers. | |
Normalizer * | _normalizerPtr |
Normalize the environment. | |
Friends | |
class | ReferenceCountedPointer< EnvironmentImpl > |
class | ReferenceCountedPointer< const EnvironmentImpl > |
EnvironmentPtr dllexp | createEnvironment (const std::vector< std::string > &categs, const std::vector< std::string > &maps, const std::string &mask_file) |
EnvironmentPtr dllexp | createEnvironment (const std::vector< std::string > &categs, const std::vector< std::string > &maps) |
EnvironmentPtr dllexp | createEnvironment (const ConstConfigurationPtr &config) |
EnvironmentPtr dllexp | createEnvironment () |
Allow access to environmental variables by means of vectors gathering data from all layers on the sampled points.
Definition at line 69 of file Environment.hh.
typedef std::pair<std::string, Map*> EnvironmentImpl::layer [private] |
Definition at line 85 of file Environment.hh.
typedef std::vector<layer> EnvironmentImpl::layers [private] |
Definition at line 86 of file Environment.hh.
EnvironmentImpl::EnvironmentImpl | ( | ) | [private] |
Definition at line 174 of file Environment.cpp.
Referenced by clone().
EnvironmentImpl::EnvironmentImpl | ( | const std::vector< std::string > & | categs, |
const std::vector< std::string > & | maps, | ||
const std::string & | mask_file = "" |
||
) | [private] |
Vector with file names that contain the variables to be used and also the mask layer.
categs | Categorical layers (e.g. soil). |
maps | Continuous layers (e.g. temperature). |
mask_file | Mask file. |
Definition at line 185 of file Environment.cpp.
References initialize().
Definition at line 208 of file Environment.cpp.
References _normalizerPtr, clearLayers(), and clearMask().
void EnvironmentImpl::calcRegion | ( | ) | [private] |
Calculate the widest region common to all layers.
Definition at line 817 of file Environment.cpp.
References _layers, _mask, _xmax, _xmin, _ymax, _ymin, Log::instance(), MAXFLOAT, and Log::warn().
Referenced by changeLayers(), changeMask(), removeLayer(), and setConfiguration().
int EnvironmentImpl::changeLayers | ( | const std::vector< std::string > & | categs, |
const std::vector< std::string > & | maps | ||
) | [private] |
Rebuild the layer representation.
Definition at line 450 of file Environment.cpp.
References _layers, calcRegion(), clearLayers(), loadLayers(), and makeLayer().
Referenced by initialize().
int EnvironmentImpl::changeMask | ( | const std::string & | mask_file | ) |
Change the mask.
Definition at line 498 of file Environment.cpp.
References _mask, calcRegion(), clearMask(), RasterException::getCode(), makeLayer(), and Sleep.
Referenced by initialize().
int EnvironmentImpl::checkCoordinates | ( | Coord | x, |
Coord | y | ||
) | const |
Return 0 if (x,y) falls outside the mask. If there's no mask, return != 0 always.
Definition at line 742 of file Environment.cpp.
References _mask, _xmax, _ymax, Log::debug(), and Log::instance().
Referenced by getUnnormalizedInternal().
void EnvironmentImpl::clearLayers | ( | ) | [private] |
Definition at line 257 of file Environment.cpp.
References _layers.
Referenced by changeLayers(), setConfiguration(), and ~EnvironmentImpl().
void EnvironmentImpl::clearMask | ( | ) | [private] |
Definition at line 270 of file Environment.cpp.
References _mask.
Referenced by changeMask(), setConfiguration(), and ~EnvironmentImpl().
EnvironmentImpl * EnvironmentImpl::clone | ( | ) | const |
Deep copy of this.
Definition at line 224 of file Environment.cpp.
References _layers, _mask, _normalizerPtr, EnvironmentImpl(), and normalize().
Sample EnvironmentImpl::get | ( | Coord | x, |
Coord | y | ||
) | const |
Read for vector 'sample' all values of environmental variables of coordinate (x,y). Returns a Sample of dim 0 if environment has a mask and point is outside its borders. If the environment has been normalized, the Sample returned will be normalized.
Definition at line 686 of file Environment.cpp.
References _normalizerPtr, getNormalized(), and getUnnormalized().
ConfigurationPtr EnvironmentImpl::getConfiguration | ( | ) | const [virtual] |
Implements Configurable.
Definition at line 282 of file Environment.cpp.
References _layers, _mask, and getLayerConfig().
int EnvironmentImpl::getExtremes | ( | Sample * | min, |
Sample * | max | ||
) | const |
Returns the minimum and maximum values of each layer. If the environment has been normalized, the values returned are normalized.
Definition at line 788 of file Environment.cpp.
References _layers, _normalizerPtr, Normalizer::normalize(), and Sample::resize().
Map* EnvironmentImpl::getLayer | ( | int | index | ) | const [inline] |
Definition at line 165 of file Environment.hh.
ConfigurationPtr EnvironmentImpl::getLayerConfig | ( | const layer & | l, |
bool | basicConfig = false |
||
) | [static, private] |
Definition at line 87 of file Environment.cpp.
References min().
Referenced by getConfiguration().
const std::string& EnvironmentImpl::getLayerPath | ( | int | index | ) | const [inline] |
Definition at line 172 of file Environment.hh.
Map* EnvironmentImpl::getMask | ( | ) | const [inline] |
Definition at line 170 of file Environment.hh.
const std::string& EnvironmentImpl::getMaskPath | ( | ) | const [inline] |
Definition at line 174 of file Environment.hh.
void EnvironmentImpl::getMinMax | ( | Sample * | min, |
Sample * | max | ||
) | const [virtual] |
Indicate that all non categorical variable layers must be normalized according to the interval [min, max].
Implements Normalizable.
Definition at line 576 of file Environment.cpp.
References _layers, and Map::getMinMax().
Sample EnvironmentImpl::getNormalized | ( | Coord | x, |
Coord | y | ||
) | const |
Definition at line 670 of file Environment.cpp.
References _normalizerPtr, getUnnormalizedInternal(), Normalizer::normalize(), numCategoricalLayers(), and Sample::setCategoricalThreshold().
Referenced by get().
Sample EnvironmentImpl::getRandom | ( | Coord * | x = 0 , |
Coord * | y = 0 |
||
) | const |
Read for 'sample' all values of environmental variables of a valid coordinate (inside the mask) randomly chosen returns coordinates (x,y) through pointer arguments. If the environment has been normalized, the Sample returned will be normalized.
Definition at line 699 of file Environment.cpp.
References _xmax, _xmin, _ymax, _ymin, Log::error(), Log::instance(), and Sample::size().
int EnvironmentImpl::getRegion | ( | Coord * | xmin, |
Coord * | ymin, | ||
Coord * | xmax, | ||
Coord * | ymax | ||
) | const |
Sample EnvironmentImpl::getUnnormalized | ( | Coord | x, |
Coord | y | ||
) | const |
Definition at line 662 of file Environment.cpp.
References getUnnormalizedInternal().
Referenced by get().
void EnvironmentImpl::getUnnormalizedInternal | ( | Sample * | sample, |
Coord | x, | ||
Coord | y | ||
) | const [private] |
Definition at line 629 of file Environment.cpp.
References _layers, Sample::begin(), checkCoordinates(), Log::debug(), Log::instance(), and Sample::resize().
Referenced by getNormalized(), and getUnnormalized().
void EnvironmentImpl::initialize | ( | const std::vector< std::string > & | categs, |
const std::vector< std::string > & | maps, | ||
const std::string & | mask_file = "" |
||
) | [private] |
Definition at line 193 of file Environment.cpp.
References _normalizerPtr, changeLayers(), and changeMask().
Referenced by EnvironmentImpl().
int EnvironmentImpl::isCategorical | ( | int | i | ) |
Returns 1 if the i-th variable is categorical. else returns 0.
Definition at line 567 of file Environment.cpp.
References _layers.
void EnvironmentImpl::loadLayers | ( | const std::vector< std::string > & | map_ids, |
std::vector< Map * > & | map_refs, | ||
int | categ = 0 |
||
) | [static, private] |
Definition at line 405 of file Environment.cpp.
References RasterException::getCode(), RasterFactory::instance(), and Sleep.
Referenced by changeLayers(), and setConfiguration().
EnvironmentImpl::layer EnvironmentImpl::makeLayer | ( | const ConstConfigurationPtr & | config, |
Map * | map | ||
) | [static, private] |
Definition at line 111 of file Environment.cpp.
Referenced by changeLayers(), changeMask(), and setConfiguration().
static layer EnvironmentImpl::makeLayer | ( | const std::string & | filename, |
int | categ | ||
) | [static, private] |
static layer EnvironmentImpl::makeLayer | ( | const std::string & | filename, |
Map * | map | ||
) | [static, private] |
void EnvironmentImpl::normalize | ( | Normalizer * | normalizerPtr | ) | [virtual] |
Set specific normalization parameters
Implements Normalizable.
Definition at line 600 of file Environment.cpp.
References _normalizerPtr, Normalizer::getCopy(), and resetNormalization().
Referenced by clone().
size_t EnvironmentImpl::numCategoricalLayers | ( | ) | const |
unsigned int EnvironmentImpl::numLayers | ( | ) | const [inline] |
Definition at line 108 of file Environment.hh.
Referenced by removeLayer().
void EnvironmentImpl::removeLayer | ( | unsigned int | index | ) |
Definition at line 857 of file Environment.cpp.
References _layers, calcRegion(), and numLayers().
void EnvironmentImpl::resetNormalization | ( | ) |
Reset normalization parameters
Definition at line 616 of file Environment.cpp.
References _normalizerPtr.
Referenced by normalize().
void EnvironmentImpl::setConfiguration | ( | const ConstConfigurationPtr & | config | ) | [virtual] |
Implements Configurable.
Definition at line 310 of file Environment.cpp.
References _layers, _mask, calcRegion(), clearLayers(), clearMask(), loadLayers(), and makeLayer().
EnvironmentPtr dllexp createEnvironment | ( | const std::vector< std::string > & | categs, |
const std::vector< std::string > & | maps, | ||
const std::string & | mask_file | ||
) | [friend] |
Definition at line 55 of file Environment.cpp.
EnvironmentPtr dllexp createEnvironment | ( | const std::vector< std::string > & | categs, |
const std::vector< std::string > & | maps | ||
) | [friend] |
Definition at line 62 of file Environment.cpp.
EnvironmentPtr dllexp createEnvironment | ( | const ConstConfigurationPtr & | config | ) | [friend] |
Definition at line 68 of file Environment.cpp.
EnvironmentPtr dllexp createEnvironment | ( | ) | [friend] |
Definition at line 77 of file Environment.cpp.
friend class ReferenceCountedPointer< const EnvironmentImpl > [friend] |
Definition at line 72 of file Environment.hh.
friend class ReferenceCountedPointer< EnvironmentImpl > [friend] |
Definition at line 71 of file Environment.hh.
layers EnvironmentImpl::_layers [private] |
Vector with all layers that describe the variables.
Definition at line 222 of file Environment.hh.
Referenced by calcRegion(), changeLayers(), clearLayers(), clone(), getConfiguration(), getExtremes(), getMinMax(), getUnnormalizedInternal(), isCategorical(), numCategoricalLayers(), removeLayer(), and setConfiguration().
layer EnvironmentImpl::_mask [private] |
Mask (can be 0).
Definition at line 223 of file Environment.hh.
Referenced by calcRegion(), changeMask(), checkCoordinates(), clearMask(), clone(), getConfiguration(), and setConfiguration().
Normalizer* EnvironmentImpl::_normalizerPtr [private] |
Normalize the environment.
Definition at line 230 of file Environment.hh.
Referenced by clone(), get(), getExtremes(), getNormalized(), initialize(), normalize(), resetNormalization(), and ~EnvironmentImpl().
Coord EnvironmentImpl::_xmax [private] |
Intersection of all layers.
Definition at line 227 of file Environment.hh.
Referenced by calcRegion(), checkCoordinates(), getRandom(), and getRegion().
Coord EnvironmentImpl::_xmin [private] |
Intersection of all layers.
Definition at line 225 of file Environment.hh.
Referenced by calcRegion(), getRandom(), and getRegion().
Coord EnvironmentImpl::_ymax [private] |
Intersection of all layers.
Definition at line 228 of file Environment.hh.
Referenced by calcRegion(), checkCoordinates(), getRandom(), and getRegion().
Coord EnvironmentImpl::_ymin [private] |
Intersection of all layers.
Definition at line 226 of file Environment.hh.
Referenced by calcRegion(), getRandom(), and getRegion().