openModeller  Version 1.5.0
EnvironmentImpl Class Reference

#include <Environment.hh>

Inheritance diagram for EnvironmentImpl:
Inheritance graph
Collaboration diagram for EnvironmentImpl:
Collaboration graph

Public Member Functions

 ~EnvironmentImpl ()
 
EnvironmentImplclone () 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
 
MapgetLayer (int index) const
 
int changeMask (const std::string &mask_file)
 
MapgetMask () 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 &)
 
- Public Member Functions inherited from Configurable
virtual ~Configurable ()
 
- Public Member Functions inherited from Normalizable
virtual ~Normalizable ()
 

Private Types

typedef std::pair< std::string,
Map * > 
layer
 
typedef std::vector< layerlayers
 

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 ()
 
- Private Member Functions inherited from ReferenceCountedObject
 ReferenceCountedObject ()
 
virtual ~ReferenceCountedObject ()=0
 

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. More...
 
layer _mask
 Mask (can be 0). More...
 
Coord _xmin
 Intersection of all layers. More...
 
Coord _ymin
 Intersection of all layers. More...
 
Coord _xmax
 Intersection of all layers. More...
 
Coord _ymax
 Intersection of all layers. More...
 
Normalizer_normalizerPtr
 Normalize the environment. More...
 

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 ()
 

Detailed Description

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.

Member Typedef Documentation

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.

Constructor & Destructor Documentation

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.

Parameters
categsCategorical layers (e.g. soil).
mapsContinuous layers (e.g. temperature).
mask_fileMask file.

Definition at line 185 of file Environment.cpp.

References initialize().

Here is the call graph for this function:

EnvironmentImpl::~EnvironmentImpl ( )

Definition at line 208 of file Environment.cpp.

References _normalizerPtr, clearLayers(), and clearMask().

Here is the call graph for this function:

Member Function Documentation

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

ConfigurationPtr EnvironmentImpl::getConfiguration ( ) const
virtual

Implements Configurable.

Definition at line 282 of file Environment.cpp.

References _layers, _mask, and getLayerConfig().

Here is the call graph for this function:

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().

Here is the call graph for this function:

Map* EnvironmentImpl::getLayer ( int  index) const
inline

Definition at line 165 of file Environment.hh.

ConfigurationPtr EnvironmentImpl::getLayerConfig ( const layer l,
bool  basicConfig = false 
)
staticprivate

Definition at line 87 of file Environment.cpp.

References min().

Referenced by getConfiguration().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

int EnvironmentImpl::getRegion ( Coord xmin,
Coord ymin,
Coord xmax,
Coord ymax 
) const

Get rectangle that contain all valid points. If there's a mask, use its rectangle.

Definition at line 777 of file Environment.cpp.

References _xmax, _xmin, _ymax, and _ymin.

Sample EnvironmentImpl::getUnnormalized ( Coord  x,
Coord  y 
) const

Definition at line 662 of file Environment.cpp.

References getUnnormalizedInternal().

Referenced by get().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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 
)
staticprivate

Definition at line 405 of file Environment.cpp.

References RasterException::getCode(), RasterFactory::instance(), and Sleep.

Referenced by changeLayers(), and setConfiguration().

Here is the call graph for this function:

EnvironmentImpl::layer EnvironmentImpl::makeLayer ( const ConstConfigurationPtr config,
Map map 
)
staticprivate

Definition at line 111 of file Environment.cpp.

References min(), and UNUSED.

Referenced by changeLayers(), changeMask(), and setConfiguration().

Here is the call graph for this function:

static layer EnvironmentImpl::makeLayer ( const std::string &  filename,
int  categ 
)
staticprivate
static layer EnvironmentImpl::makeLayer ( const std::string &  filename,
Map map 
)
staticprivate
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().

Here is the call graph for this function:

size_t EnvironmentImpl::numCategoricalLayers ( ) const

Definition at line 547 of file Environment.cpp.

References _layers.

Referenced by getNormalized().

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

Friends And Related Function Documentation

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.

Member Data Documentation

layers EnvironmentImpl::_layers
private
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().


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