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

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

#include "pg_menu_db_soil_salinity_risk.h"
#include "pgsql/pgdatabase.h"
#include "pgsql/pg_menu_db.h"
#include "saga_gui/saga_frame.h"		// location of class Cpgdatabase
										// using global *g_pSAGA_Frame pointer
#include "saga_gui/helper.h"			// using function MSG_General_Add()
#define MSG_ADD(s)	MSG_General_Add(s, true, true);

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

CSoilSalinityRisk::CSoilSalinityRisk()
: Cpg_menu_db_soil_salinity()
{
}
//---------------------------------------------------------------------

CSoilSalinityRisk::~CSoilSalinityRisk()
{
}
//---------------------------------------------------------------------



///////////////////////////////////////////////////////////////////////
//
//	IMPORT FUNCTIONS
//
///////////////////////////////////////////////////////////////////////


void CSoilSalinityRisk::Load_Map()
{
	CSG_Data_Object* pObject = Select_Import_Map();

	if ( pObject != NULL ) {

		Set_Feature_Name(pObject);

		Add_Specific_Fields(pObject);

		g_pData->Add(pObject);
		pObject->asSimpleFeature()->Set_Category(SF_CATEGORY_SoilSalinityRiskMap);
	}
}

//---------------------------------------------------------------------
CSG_String CSoilSalinityRisk::Get_Feature_Name(CSG_Data_Object* pObject)
{
	CSG_String featurename = "ssr_"; // ssr = soil salinity risk
	featurename.Append(pObject->Get_Name());
	return(featurename);
}
//---------------------------------------------------------------------

void CSoilSalinityRisk::Set_Feature_Name(CSG_Data_Object* pObject)
{
	CSG_String featurename = Get_Feature_Name(pObject);
	// Set feature name 'ssa_' + original object name
	pObject->Set_Name(featurename.c_str());
	// Set attribute table name
	pObject->asSimpleFeature()->Get_Table().Set_Name(featurename.c_str());
}
//---------------------------------------------------------------------

void CSoilSalinityRisk::Add_Specific_Fields(CSG_Data_Object* pObject)
{
	// add soil salinity specific columns
	pObject->asSimpleFeature()->Get_Table().Add_Field("MS_HIGH",TABLE_FIELDTYPE_Float,1);
	pObject->asSimpleFeature()->Get_Table().Add_Field("MS_MEDIUM",TABLE_FIELDTYPE_Float,1);
	pObject->asSimpleFeature()->Get_Table().Add_Field("MS_LOW",TABLE_FIELDTYPE_Float,1);
	pObject->asSimpleFeature()->Get_Table().Add_Field("Risk_v",TABLE_FIELDTYPE_Float,1);
	pObject->asSimpleFeature()->Get_Table().Add_Field("Risk",TABLE_FIELDTYPE_String,1);
	pObject->asSimpleFeature()->Get_Table().Add_Field("Season",TABLE_FIELDTYPE_String,1);
	pObject->asSimpleFeature()->Get_Table().Add_Field("Year",TABLE_FIELDTYPE_Int,1);
}
//---------------------------------------------------------------------

