///////////////////////////////////////////////////////////
// Author:			Stefan Liersch
// Contact:			stefan.liersch@googlemail.com,
//					stefan.liersch@ufz.de
//
// Date:			2008-09-24
// last modified:	2008-09-24
//
//---------------------------------------------------------
// DESCRIPTION
//---------------------------------------------------------
//
//---------------------------------------------------------
// ToDo
//---------------------------------------------------------
//
///////////////////////////////////////////////////////////


#ifndef HEADER_INCLUDED__SOIL_SALINITY_MAP_H__
#define HEADER_INCLUDED__SOIL_SALINITY_MAP_H__

//---------------------------------------------------------------------

//#include "saga_api/saga_api.h"
#include "saga_api/simplefeature_api.h"

#include <vector>
typedef std::vector<int> vector_i;
//---------------------------------------------------------------------

class CParmWeights
{
public:
	// These are the default settings for
	// parameter weights.
	// The weights or importance, respectively,
	// were defined during a workshop in Urgensh (Uzbekistan)
	// in the year 2008.
	// The values can range between 1 and 10,
	// where 1 = low importance and 10 = high importance.
	static const int SoilColourLocal	= 5;
	static const int nLeaching			= 10;
	static const int WQ_Leaching		= 10;
	static const int WQ_Irrigation		= 10;
	static const int WVolumeIrrigation	= 5;
	static const int Evenness			= 10;
	static const int Morphology			= 10;
	static const int SoilTexture		= 5;
	static const int PlantGrowth		= 1;
	static const int GWSalinity			= 5;
	static const int GWLevel			= 10;
	static const int nChannels			= 5;
	static const int Distance			= 10;
	static const int Maintanance		= 10;
};
//---------------------------------------------------------------------

class CSoilSalinityMap
{
public:
	// use this constructor to load a soil salinity map
	CSoilSalinityMap(CSG_SimpleFeature* pSimpleFeature);
	
	// use this constructor to create a soil salinity map
	// on the basis of a shapefile
	CSoilSalinityMap(CSG_Shapes* pShapes);

	~CSoilSalinityMap();
	//---------------------------------------------------------------------

	CSG_SimpleFeature*	Get_SimpleFeature()		{ return(m_pSimpleFeature); }

	CSG_String			Get_MapName()			{ return(m_MapName); }
	CSG_String			Get_AttributeTableName(){ return(m_AttributeTableName); }
	CSG_String			Get_SettingsTableName()	{ return(m_SettingsTableName); }
	CSG_String			Get_WeightsTableName()	{ return(m_WeightsTableName); }

	int					Get_NumberSSVariables()	{ return(m_nSoilSalinityVariables); }

	vector_i			Get_Weights()			{ return(m_v_weights);	}
	int					Get_Weight(int i)		{ return(m_v_weights[i]); }
	bool				Set_Default_Weights();
	bool				Update_Weights(vector_i v_weights);

private:

	CParmWeights		m_Default_Weights;

	CSG_SimpleFeature*	m_pSimpleFeature;

	CSG_String			m_MapName;
	CSG_String			m_AttributeTableName;
	CSG_String			m_SettingsTableName;
	CSG_String			m_WeightsTableName;

	CSG_String			m_PK_colname;

	int					m_nSoilSalinityVariables;
	vector_i			m_v_weights;
	void				_Resize_Weights(int size);
	bool				_Load_Weights();
	bool				_Delete_TableContent_Weights();

	//---------------------------------------------------------------------
	//	CREATE SALINITY MAP (SimpleFeature) FUNCTIONS
	//---------------------------------------------------------------------
	bool				_Export_Shape_As_SoilSalinityMap(CSG_Shapes* pShapes);

	void				_Create_External_Attributes();

	void				_Assign_TableNames(CSG_String m_MapName);

	void				_Add_Specific_Attributes(CSG_Shapes* pShapesOut);

	void				_Add_IDs_To_PK_Field(CSG_Shapes* pShapesOut);

	void				_Create_AttributeTable();

	void				_Create_SettingsTable();

	void				_Create_WeightsTable();

	void				_Insert_DefaultWeights();
	//---------------------------------------------------------------------

};

#endif /* HEADER_INCLUDED__SOIL_SALINITY_MAP_H__ */