⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sado_solarradiation.cpp

📁 这是一个GPS相关的程序
💻 CPP
📖 第 1 页 / 共 3 页
字号:

///////////////////////////////////////////////////////////
//                                                       //
//                         SAGA                          //
//                                                       //
//      System for Automated Geoscientific Analyses      //
//                                                       //
//                    Module Library:                    //
//                     ta_lighting                       //
//                                                       //
//-------------------------------------------------------//
//                                                       //
//                SADO_SolarRadiation.cpp                //
//                                                       //
//                 Copyright (C) 2006 by                 //
//                      Olaf Conrad                      //
//                                                       //
//-------------------------------------------------------//
//                                                       //
// This file is part of 'SAGA - System for Automated     //
// Geoscientific Analyses'. SAGA is free software; you   //
// can redistribute it and/or modify it under the terms  //
// of the GNU General Public License as published by the //
// Free Software Foundation; version 2 of the License.   //
//                                                       //
// SAGA is distributed in the hope that it will be       //
// useful, but WITHOUT ANY WARRANTY; without even the    //
// implied warranty of MERCHANTABILITY or FITNESS FOR A  //
// PARTICULAR PURPOSE. See the GNU General Public        //
// License for more details.                             //
//                                                       //
// You should have received a copy of the GNU General    //
// Public License along with this program; if not,       //
// write to the Free Software Foundation, Inc.,          //
// 59 Temple Place - Suite 330, Boston, MA 02111-1307,   //
// USA.                                                  //
//                                                       //
//-------------------------------------------------------//
//                                                       //
//    e-mail:     oconrad@saga-gis.org                   //
//                                                       //
//    contact:    Olaf Conrad                            //
//                Institute of Geography                 //
//                University of Goettingen               //
//                Goldschmidtstr. 5                      //
//                37077 Goettingen                       //
//                Germany                                //
//                                                       //
///////////////////////////////////////////////////////////

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


///////////////////////////////////////////////////////////
//														 //
//														 //
//														 //
///////////////////////////////////////////////////////////

//---------------------------------------------------------
#include "SADO_SolarRadiation.h"


///////////////////////////////////////////////////////////
//														 //
//														 //
//														 //
///////////////////////////////////////////////////////////

//---------------------------------------------------------
CSADO_SolarRadiation::CSADO_SolarRadiation(void)
{
	CSG_Parameter	*pNode;

	//-----------------------------------------------------
	Set_Name		(_TL("Insolation"));

	Set_Author		(_TL("Copyrights (c) 2006 by Olaf Conrad"));

	Set_Description	(_TW(
		"Calculation of incoming solar radiation (insolation). "
		"Based on the SADO (System for the Analysis of Discrete Surfaces) routines "
		"developed by Boehner & Trachinow. "
		"\n\n"
		"References:\n"
	));

	//-----------------------------------------------------
	Parameters.Add_Grid(
		NULL	, "GRD_DEM"			, _TL("Elevation"),
		_TL(""),
		PARAMETER_INPUT
	);

	Parameters.Add_Grid(
		NULL	, "GRD_VAPOUR"		, _TL("Water Vapour Pressure [mbar]"),
		_TL(""),
		PARAMETER_INPUT_OPTIONAL
	);

	Parameters.Add_Grid(
		NULL	, "GRD_LAT"			, _TL("Latitude [degree]"),
		_TL(""),
		PARAMETER_INPUT_OPTIONAL
	);

	Parameters.Add_Grid(
		NULL	, "GRD_LON"			, _TL("Longitude [degree]"),
		_TL(""),
		PARAMETER_INPUT_OPTIONAL
	);

	Parameters.Add_Grid(
		NULL	, "GRD_DIRECT"		, _TL("Direct Insolation"),
		_TL(""),
		PARAMETER_OUTPUT_OPTIONAL
	);

	Parameters.Add_Grid(
		NULL	, "GRD_DIFFUS"		, _TL("Diffuse Insolation"),
		_TL(""),
		PARAMETER_OUTPUT_OPTIONAL
	);

	Parameters.Add_Grid(
		NULL	, "GRD_TOTAL"		, _TL("Total Insolation"),
		_TL("Total insolation, the sum of direct and diffuse incoming solar radiation."),
		PARAMETER_OUTPUT_OPTIONAL
	);

	//-----------------------------------------------------
	Parameters.Add_Value(
		NULL	, "BHORIZON"		, _TL("Horizontal Projection"),
		_TL(""),
		PARAMETER_TYPE_Bool			, false
	);

	Parameters.Add_Value(
		NULL	, "SOLARCONST"		, _TL("Solar Constant [J]"),
		_TL(""),
		PARAMETER_TYPE_Double		, 8.164, 0.0, true
	);

	Parameters.Add_Value(
		NULL	, "ATMOSPHERE"		, _TL("Height of Atmosphere [m]"),
		_TL(""),
		PARAMETER_TYPE_Double		, 12000.0, 0.0, true
	);

	Parameters.Add_Value(
		NULL	, "VAPOUR"			, _TL("Water Vapour Pressure [mbar]"),
		_TL("This value is used as constant if no vapour pressure grid is given."),
		PARAMETER_TYPE_Double		, 10, 0.0, true
	);

	//-----------------------------------------------------
	pNode	= Parameters.Add_Node(
		NULL	, "NODE_TIME"		, _TL("Time"),
		_TL("")
	);

	Parameters.Add_Choice(
		pNode	, "PERIOD"			, _TL("Time Period"),
		_TL(""),

		CSG_String::Format(SG_T("%s|%s|%s|%s|"),
			_TL("moment"),
			_TL("day"),
			_TL("range of days"),
			_TL("same moment for a range of days")
		), 1
	);

	Parameters.Add_Value(
		pNode	, "DHOUR"			, _TL("Daily Time Resolution [h]"),
		_TL("Time resolution for a day's calculation."),
		PARAMETER_TYPE_Double		, 1.0, 0.0, true, 24.0, true
	);

	Parameters.Add_Value(
		pNode	, "DDAYS"			, _TL("Range of Days Time Resolution [days]"),
		_TL("Time resolution for a range of days calculation."),
		PARAMETER_TYPE_Int			, 1, 1, true
	);

	Parameters.Add_Value(
		pNode	, "DAY_A"			, _TL("Day of Year"),
		_TL(""),
		PARAMETER_TYPE_Int			, 81
	);

	Parameters.Add_Value(
		pNode	, "DAY_B"			, _TL("Day of Year (Range End)"),
		_TL(""),
		PARAMETER_TYPE_Int			, 87
	);

	Parameters.Add_Value(
		pNode	, "MOMENT"			, _TL("Moment [h]"),
		_TL(""),
		PARAMETER_TYPE_Double		, 12.0, 0.0, true, 24.0, true
	);

	//-----------------------------------------------------
	pNode	= Parameters.Add_Node(
		NULL	, "NODE_LOCATION"	, _TL("Location"),
		_TL("")
	);

	Parameters.Add_Value(
		pNode	, "LATITUDE"		, _TL("Latitude"),
		_TL(""),
		PARAMETER_TYPE_Degree		, 53.0, -90.0, true, 90.0, true
	);

	Parameters.Add_Value(
		pNode	, "BENDING"			, _TL("Planetery Bending"),
		_TL(""),
		PARAMETER_TYPE_Bool			, false
	);

	Parameters.Add_Value(
		pNode	, "RADIUS"			, _TL("Planetary Radius"),
		_TL(""),
		PARAMETER_TYPE_Double		, 6366737.96, 0.0, true
	);

	Parameters.Add_Choice(
		pNode	, "LAT_OFFSET"		, _TL("Latitude relates to grid's..."),
		_TL(""),

		CSG_String::Format(SG_T("%s|%s|%s|%s|"),
			_TL("bottom"),
			_TL("center"),
			_TL("top"),
			_TL("user defined reference")
		), 3
	);

	Parameters.Add_Choice(
		pNode	, "LON_OFFSET"		, _TL("Local time relates to grid's..."),
		_TL(""),

		CSG_String::Format(SG_T("%s|%s|%s|%s|"),
			_TL("left"),
			_TL("center"),
			_TL("right"),
			_TL("user defined reference")
		), 1
	);

	Parameters.Add_Value(
		pNode	, "LAT_REF_USER"	, _TL("Latitude (user defined reference)"),
		_TL(""),
		PARAMETER_TYPE_Double		, 0.0
	);

	Parameters.Add_Value(
		pNode	, "LON_REF_USER"	, _TL("Local Time (user defined reference)"),
		_TL(""),
		PARAMETER_TYPE_Double		, 0.0
	);

	//-----------------------------------------------------
	pNode	= Parameters.Add_Node(
		NULL	, "NODE_UPDATEVIEW"	, _TL("Update View"),
		_TL("")
	);

	Parameters.Add_Value(
		pNode	, "UPD_DIRECT"		, _TL("Direct Insolation"),
		_TL(""),
		PARAMETER_TYPE_Bool			, false
	);

	Parameters.Add_Value(
		pNode	, "UPD_DIFFUS"		, _TL("Diffuse Insolation"),
		_TL(""),
		PARAMETER_TYPE_Bool			, false
	);

	Parameters.Add_Value(
		pNode	, "UPD_TOTAL"		, _TL("Total Insolation"),
		_TL(""),
		PARAMETER_TYPE_Bool			, false
	);
}

//---------------------------------------------------------
CSADO_SolarRadiation::~CSADO_SolarRadiation(void)
{}


///////////////////////////////////////////////////////////
//														 //
//														 //
//														 //
///////////////////////////////////////////////////////////

//---------------------------------------------------------
bool CSADO_SolarRadiation::On_Execute(void)
{
	//-----------------------------------------------------
	m_pDEM			= Parameters("GRD_DEM")		->asGrid();
	m_pVP			= Parameters("GRD_VAPOUR")	->asGrid();

	m_pSumDirect	= Parameters("GRD_DIRECT")	->asGrid();
	m_bUpdateDirect	= Parameters("UPD_DIRECT")	->asBool() && m_pSumDirect;
	m_pSumDiffus	= Parameters("GRD_DIFFUS")	->asGrid();
	m_bUpdateDiffus	= Parameters("UPD_DIFFUS")	->asBool() && m_pSumDiffus;
	m_pSumTotal		= Parameters("GRD_TOTAL")	->asGrid();
	m_bUpdateTotal	= Parameters("UPD_TOTAL")	->asBool() && m_pSumTotal;

	m_Solar_Const	= Parameters("SOLARCONST")	->asDouble();
	m_Atmosphere	= Parameters("ATMOSPHERE")	->asDouble();
	m_VP			= Parameters("VAPOUR")		->asDouble();
	m_bHorizon		= Parameters("BHORIZON")	->asBool();

	m_Latitude		= Parameters("LATITUDE")	->asDouble() * M_DEG_TO_RAD;
	m_bBending		= Parameters("BENDING")		->asBool();

	m_Hour			= Parameters("MOMENT")		->asDouble();
	m_dHour			= Parameters("DHOUR")		->asDouble();
	m_dDays			= Parameters("DDAYS")		->asInt();
	m_Day_A			= Parameters("DAY_A")		->asInt();
	m_Day_B			= Parameters("DAY_B")		->asInt();

	switch( Parameters("PERIOD")->asInt() )
	{
	case 0:	// moment
		m_bMoment		= true;
		m_bUpdateDirect	= m_bUpdateDiffus	= m_bUpdateTotal	= false;
		break;

	case 1:	// day
		m_bMoment		= false;
		m_Day_B			= m_Day_A;
		m_Hour			= 0.0;
		break;

	case 2:	// range of days
		m_bMoment		= false;
		m_Hour			= 0.0;
		break;

	case 3:	// same moment for a range of days
		m_bMoment		= false;
		m_dHour			= 24.0;
		break;
	}

	//-----------------------------------------------------
	if( !m_pSumDirect && !m_pSumDiffus && !m_pSumTotal )
	{
		Message_Dlg(_TL("No output grid has been choosen."), Get_Name());
	}
	else if( m_pSumDirect == m_pDEM || m_pSumDiffus == m_pDEM || m_pSumTotal == m_pDEM )
	{
		Message_Dlg(_TL("Output must not overwrite elevation grid."), Get_Name());
	}
	else
	{
		return( Get_Insolation() );
	}

	//-----------------------------------------------------
	return( false );
}


///////////////////////////////////////////////////////////
//														 //
//														 //
//														 //
///////////////////////////////////////////////////////////

//---------------------------------------------------------
bool CSADO_SolarRadiation::Initialise(void)
{
	int		x, y;

	Process_Set_Text(_TL("initialising..."));

	//-----------------------------------------------------
	CSG_Colors	c(100, SG_COLORS_YELLOW_RED, true);

	c.Set_Ramp(SG_GET_RGB(  0,   0,  64), SG_GET_RGB(255, 159,   0),  0, 50);
	c.Set_Ramp(SG_GET_RGB(255, 159,   0), SG_GET_RGB(255, 255, 255), 50, 99);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -