示例#1
0
void CSG_Doc_SVG::Draw_Text(double x, 
						 double y, 
						 const SG_Char *Text, 
						 int Color, 
						 const SG_Char* Font, 
						 double dSize,
						 TSG_SVG_Alignment iAlignment)
{

	CSG_String sAlignments[] = {SG_T(""), SG_T("middle"), SG_T("end")};
	CSG_String sSize;
	
	sSize.Append(SG_Get_String(dSize,2));
	sSize.Append(g_Unit);
	
	m_sSVGCode.Append(SG_T("<text "));
	_AddAttribute(SG_T("x"), x);	
	_AddAttribute(SG_T("y"), y);
	_AddAttribute(SG_T("font-family"), Font);
	_AddAttribute(SG_T("fill"), _Get_SVGColor(Color));
	_AddAttribute(SG_T("font-size"), sSize);
	_AddAttribute(SG_T("text-anchor"), sAlignments[iAlignment]);
	m_sSVGCode.Append(SG_T(">\n"));
	m_sSVGCode.Append(Text);
	m_sSVGCode.Append(SG_T("</text>"));

}
示例#2
0
void CSG_Doc_SVG::Draw_LinkedCircle(double x, 
								 double y, 
								 double Radius, 
								 const SG_Char *Link,
								 int Fill_Color, 
								 int Line_Color, 
								 double Line_Width)
{
	
	CSG_String sWidth;
	CSG_String sLink;

	m_sSVGCode.Append(SG_T("<circle "));
	_AddAttribute(SG_T("cx"), x);
	_AddAttribute(SG_T("cy"), y);
	_AddAttribute(SG_T("r"), Radius);
	sWidth.Append(SG_Get_String(Line_Width,2));
	sWidth.Append(g_Unit);
	_AddAttribute(SG_T("stroke-width"), sWidth);
	_AddAttribute(SG_T("stroke"), _Get_SVGColor(Line_Color));
	_AddAttribute(SG_T("fill"), _Get_SVGColor(Fill_Color));
	sLink = SG_T("window.open('");
	sLink.Append(Link);
	sLink.Append(SG_T("')"));
	_AddAttribute(SG_T("onclick"), sLink);
	m_sSVGCode.Append(SG_T("/>\n"));

}
示例#3
0
//---------------------------------------------------------
CSG_String CSG_Module_Library::Get_Menu(int i)
{
	CSG_String	sMenu;

	if( Get_Module(i) != NULL )
	{
		bool		bAbsolute	= false;
		const SG_Char	*sModule	= Get_Module(i)->Get_MenuPath();

		if( sModule && *sModule && *(sModule + 1) == ':' )
		{
			bAbsolute	= sModule[0] == SG_T('A') || sModule[0] == SG_T('a');
			sModule		+= 2;
		}

		if( bAbsolute )	// menu path is relative to top menu...
		{
			if( sModule && *sModule )
			{
				sMenu.Printf(SG_T("%s"), sModule);
			}
		}
		else			// menu path is relative to library menu...
		{
			const SG_Char	*sLibrary	= Get_Info(MLB_INFO_Menu_Path);

			if( sModule && *sModule )
			{
				if( sLibrary && *sLibrary )
				{
					sMenu.Printf(SG_T("%s|%s"), sLibrary, sModule);
				}
				else
				{
					sMenu.Printf(SG_T("%s"), sModule);
				}
			}
			else if( sLibrary && *sLibrary )
			{
				sMenu.Printf(SG_T("%s"), sLibrary);
			}
		}

		if( sMenu.Length() > 0 )
		{
			sMenu.Append(SG_T("|"));
		}

		sMenu.Append(Get_Info(MLB_INFO_Name));
	}

	return( sMenu );
}
示例#4
0
//---------------------------------------------------------
int CTL_Extract::Read_Text(const SG_Char *String, CSG_String &Text)
{
	int			n, Level;

	Text.Clear();

	for(n=0, Level=-1; String[n]!='\0' && Level<2; n++)
	{
		if( Level < 0 )
		{
			if( String[n] == '(' )
			{
				Level	= 0;
			}
			else if( isspace(String[n]) )
			{
				Level	= 2;	// exit !
			}
		}
		else if( Level == 0 )
		{
			switch( String[n] )
			{
			case '\"':
				Level	= 1;
				break;

			case ')':
				Level	= 2;
				break;
			}
		}
		else switch( String[n] )
		{
		case '\"':
			Level	= 0;
			break;

		case '\\':
			Text.Append(String[n++]);
			Text.Append(String[n]);
			break;

		default:
			Text.Append(String[n]);
			break;
		}
	}

	return( n );
}
//---------------------------------------------------------
void CPC_Cluster_Analysis::Write_Result(CSG_Table *pTable, long nElements, int nCluster, double SP)
{
	CSG_String			s;
	CSG_Table_Record	*pRecord;

	pTable->Destroy();
	s	= CSG_String::Format(_TL("Cluster Analysis PC"));
	s	+= CSG_String::Format(SG_T("_%s"), pInput->Get_Name());
	pTable->Set_Name(s);

	pTable->Add_Field(_TL("ClusterID")	, SG_DATATYPE_Int);
	pTable->Add_Field(_TL("Elements")	, SG_DATATYPE_Int);
	pTable->Add_Field(_TL("Variance")	, SG_DATATYPE_Double);

	s.Printf(SG_T("\n%s:\t%ld \n%s:\t%d \n%s:\t%d \n%s:\t%f"),
		_TL("Number of Elements")			, nElements,
		_TL("\nNumber of Variables")		, m_nFeatures,
		_TL("\nNumber of Clusters")			, nCluster,
		_TL("\nValue of Target Function")	, SP
	);

	s.Append(CSG_String::Format(SG_T("%s\t%s\t%s"), _TL("Cluster"), _TL("Elements"), _TL("Variance")));

	for( int j=0; j<m_nFeatures; j++ )
	{
		s.Append(CSG_String::Format(SG_T("\t%02d_%s"), j + 1, pInput->Get_Field_Name(m_Features[j])));
		pTable->Add_Field(pInput->Get_Field_Name(m_Features[j]), SG_DATATYPE_Double);
	}

	Message_Add(s);

	for( int i=0; i<nCluster; i++ )
	{
		s.Printf(SG_T("%d\t%d\t%f"), i, nMembers[i], Variances[i]);

		pRecord	= pTable->Add_Record();
		pRecord->Set_Value(0, i);
		pRecord->Set_Value(1, nMembers[i]);
		pRecord->Set_Value(2, Variances[i]);

		for( int j=0; j<m_nFeatures; j++ )
		{
			s.Append(CSG_String::Format(SG_T("\t%f"), Centroids[i][j]));

			pRecord->Set_Value(j + 3, Centroids[i][j]);
		}

		Message_Add(s);
	}
}
示例#6
0
void CSG_Doc_SVG::Draw_LinkedPolygon(CSG_Points &Points, 
							  const SG_Char* Link,
							  int Fill_Color, 
							  int Line_Color, 
							  double Line_Width)
{
	if( Points.Get_Count() > 2 )
	{
		int i;
		CSG_String sPoints;
		CSG_String sWidth;
		CSG_String sLink;
		
		for (i = 0; i < Points.Get_Count(); i++)
		{
			sPoints.Append(SG_Get_String(Points.Get_X(i),2));
			sPoints.Append(SG_T(","));
			sPoints.Append(SG_Get_String(Points.Get_Y(i),2));
			sPoints.Append(SG_T(" "));
		}
		m_sSVGCode.Append(SG_T("<polygon "));
		_AddAttribute(SG_T("points"), sPoints);
		sWidth.Append(SG_Get_String(Line_Width,2));
		sWidth.Append(g_Unit);
		_AddAttribute(SG_T("stroke-width"), sWidth);				
		_AddAttribute(SG_T("stroke"), _Get_SVGColor(Line_Color));
		_AddAttribute(SG_T("fill"), _Get_SVGColor(Fill_Color));
		sLink = SG_T("window.open('");
		sLink.Append(Link);
		sLink.Append(SG_T("')"));
		_AddAttribute(SG_T("onclick"), sLink);
		m_sSVGCode.Append(SG_T("/>\n"));
	}
}
示例#7
0
//---------------------------------------------------------
CSG_String CSG_Module_Library::Get_Summary(bool bHTML)
{
	CSG_String	s;

	if( bHTML )
	{
		s.Printf(
			SG_T("%s: <b>%s</b><br>%s: <i>%s</i><br>%s: <i>%s</i><br>%s: <i>%s</i><hr>%s"),
			LNG("[CAP] Module Library")	, Get_Info(MLB_INFO_Name),
			LNG("[CAP] Author")			, Get_Info(MLB_INFO_Author),
			LNG("[CAP] Version")		, Get_Info(MLB_INFO_Version),
			LNG("[CAP] File")			, Get_File_Name().c_str(),
			Get_Info(MLB_INFO_Description)
		);

		s.Append(CSG_String::Format(SG_T("<hr><b>%s:<ul>"), LNG("[CAP] Modules")));

		for(int i=0; i<Get_Count(); i++)
		{
			s.Append(CSG_String::Format(SG_T("<li>%s</li>"), Get_Module(i)->Get_Name()));
		}

		s.Append(SG_T("</ul>"));

		s.Replace(SG_T("\n"), SG_T("<br>"));
	}
	else
	{
		s.Printf(
			SG_T("%s: %s\n%s: %s\n%s: %s\n%s: %s\n\n%s"),
			LNG("[CAP] Module Library")	, Get_Info(MLB_INFO_Name),
			LNG("[CAP] Author")			, Get_Info(MLB_INFO_Author),
			LNG("[CAP] Version")		, Get_Info(MLB_INFO_Version),
			LNG("[CAP] File")			, Get_File_Name().c_str(),
			Get_Info(MLB_INFO_Description)
		);

		s.Append(CSG_String::Format(SG_T("\n\n%s:\n"), LNG("[CAP] Modules")));

		for(int i=0; i<Get_Count(); i++)
		{
			s.Append(CSG_String::Format(SG_T("- %s\n"), Get_Module(i)->Get_Name()));
		}
	}

	return( s );
}
示例#8
0
//---------------------------------------------------------
CSG_String		SG_Get_CurrentTimeStr(bool bWithDate)
{
	CSG_String	s;
	wxDateTime	t;

	t.SetToCurrent();

	if( bWithDate )
	{
		s.Append(t.FormatISODate().wc_str());
		s.Append(SG_T("/"));
	}

	s.Append(t.FormatISOTime().wc_str());

	return( s );
}
示例#9
0
void CSG_Doc_SVG::Draw_Line(double xa, 
						   double ya, 
						   double xb, 
						   double yb, 
						   double Width, 
						   int Color)
{

	CSG_String sWidth;

	m_sSVGCode.Append(SG_T("<line "));
	_AddAttribute(SG_T("x1"), xa);
	_AddAttribute(SG_T("x2"), xb);
	_AddAttribute(SG_T("y1"), ya);
	_AddAttribute(SG_T("y2"), yb);
	sWidth.Append(SG_Get_String(Width,2));
	sWidth.Append(g_Unit);
	_AddAttribute(SG_T("stroke-width"), sWidth);	_AddAttribute(SG_T("stroke"), _Get_SVGColor(Color));
	m_sSVGCode.Append(SG_T("/>\n"));

}
示例#10
0
void CSG_Doc_SVG::Draw_Polygon(CSG_Points &Points, 
							  int Fill_Color, 
							  int Line_Color, 
							  double Line_Width)
{
	if( Points.Get_Count() > 2 )
	{
		int i;
		CSG_String sPoints;
		CSG_String sWidth;
		
		for (i = 0; i < Points.Get_Count(); i++)
		{
			sPoints.Append(SG_Get_String(Points.Get_X(i),2));
			sPoints.Append(SG_T(","));
			sPoints.Append(SG_Get_String(Points.Get_Y(i),2));
			sPoints.Append(SG_T(" "));
		}
		m_sSVGCode.Append(SG_T("<polygon "));
		_AddAttribute(SG_T("points"), sPoints);
		sWidth.Append(SG_Get_String(Line_Width,2));
		sWidth.Append(g_Unit);
		_AddAttribute(SG_T("stroke-width"), sWidth);				
		_AddAttribute(SG_T("stroke"), _Get_SVGColor(Line_Color));
		_AddAttribute(SG_T("fill"), _Get_SVGColor(Fill_Color));
		m_sSVGCode.Append(SG_T("/>\n"));
	}
}
示例#11
0
void CSG_Doc_SVG::Draw_Line(CSG_Points &Points, 
						   double Width, 
						   int Color)
{
	int i;
	CSG_String sPoints;
	CSG_String sWidth;
	
	for (i = 0; i < Points.Get_Count(); i++)
	{
		sPoints.Append(SG_Get_String(Points.Get_X(i),2));
		sPoints.Append(SG_T(","));
		sPoints.Append(SG_Get_String(Points.Get_Y(i),2));
		sPoints.Append(SG_T(" "));
	}
	m_sSVGCode.Append(SG_T("<polyline "));
	_AddAttribute(SG_T("points"), sPoints);	
	sWidth.Append(SG_Get_String(Width,2));
	sWidth.Append(g_Unit);
	_AddAttribute(SG_T("stroke-width"), sWidth);
	_AddAttribute(SG_T("stroke"), _Get_SVGColor(Color));
	_AddAttribute(SG_T("fill"), SG_T("none"));
	m_sSVGCode.Append(SG_T("/>\n"));

}
示例#12
0
void CSG_Doc_SVG::Draw_Circle(double x, 
							 double y, 
							 double Radius, 
							 int Fill_Color, 
							 int Line_Color, 
							 double Line_Width)
{
	
	CSG_String sWidth;

	m_sSVGCode.Append(SG_T("<circle "));
	_AddAttribute(SG_T("cx"), x);
	_AddAttribute(SG_T("cy"), y);
	_AddAttribute(SG_T("r"), Radius);
	sWidth.Append(SG_Get_String(Line_Width,2));
	sWidth.Append(g_Unit);
	_AddAttribute(SG_T("stroke-width"), sWidth);
	_AddAttribute(SG_T("stroke"), _Get_SVGColor(Line_Color));
	_AddAttribute(SG_T("fill"), _Get_SVGColor(Fill_Color));
	m_sSVGCode.Append(SG_T("/>\n"));

}
示例#13
0
//---------------------------------------------------------
const SG_Char * CSG_Formula::Get_Used_Variables(void)
{
	static CSG_String	ret;

	ret.Clear();

	for(int i=0; i<'z'-'a'; i++)
	{
		if( m_Vars_Used[i] == true )
		{
			ret.Append((SG_Char)(i + 'a'));
		}
	}

	return( ret );
}
示例#14
0
//---------------------------------------------------------
bool			SG_Read_Line(FILE *Stream, CSG_String &Line)
{
	char	c;

	if( Stream && !feof(Stream) )
	{
		Line.Clear();

		while( !feof(Stream) && (c = fgetc(Stream)) != 0x0A && c != 0x0D )
		{
			Line.Append(c);
		}

		return( true );
	}

	return( false );
}
示例#15
0
//---------------------------------------------------------
bool CSG_File::Read_Line(CSG_String &sLine)	const
{
	int		c;

	if( m_pStream && !feof(m_pStream) )
	{
		sLine.Clear();

		while( !feof(m_pStream) && (c = fgetc(m_pStream)) != 0x0A && c != EOF )
		{
			if( c != 0x0D )
			{
				sLine.Append(SG_STR_MBTOSG(c));
			}
		}

		return( true );
	}

	return( false );
}
//---------------------------------------------------------
void CVIEW_ScatterPlot::_On_Construction(void)
{
	SYS_Set_Color_BG_Window(this);

	//-----------------------------------------------------
	if( m_pGrid )
	{
		m_Parameters.Add_Grid("",
			"GRID"		, _TL("Grid"),
			_TL(""),
			PARAMETER_INPUT, false
		);

		m_Parameters.Add_Shapes("",
			"POINTS"	, _TL("Points"),
			_TL(""),
			PARAMETER_INPUT, SHAPE_TYPE_Point
		);

		m_Parameters.Add_Table_Field("POINTS",
			"FIELD"		, _TL("Attribute"),
			_TL("")
		);

		m_Parameters.Add_Choice("",
			"CMP_WITH"	, _TL("Compare with..."),
			_TL(""),
			CSG_String::Format("%s|%s|",
				_TL("another grid"),
				_TL("points")
			), 0
		);

		m_Parameters.Add_Choice("POINTS",
			"RESAMPLING", _TL("Resampling"),
			_TL(""),
			CSG_String::Format("%s|%s|%s|%s",
				_TL("Nearest Neighbour"),
				_TL("Bilinear Interpolation"),
				_TL("Bicubic Spline Interpolation"),
				_TL("B-Spline Interpolation")
			), 3
		);
	}
	else if( m_pGrids )
	{
		CSG_String	sChoices;

		for(int i=0; i<m_pGrids->Get_Grid_Count(); i++)
		{
			sChoices.Append(m_pGrids->Get_Grid_Name(i, SG_GRIDS_NAME_GRID) + "|");
		}

		m_Parameters.Add_Choice("", "BAND_X", "X", _TL(""), sChoices, 0);
		m_Parameters.Add_Choice("", "BAND_Y", "Y", _TL(""), sChoices, 1);
	}
	else if( m_pTable )
	{
		CSG_String	sChoices;

		for(int i=0; i<m_pTable->Get_Field_Count(); i++)
		{
			sChoices.Append(CSG_String::Format("%s|", m_pTable->Get_Field_Name(i)));
		}

		m_Parameters.Add_Choice("", "FIELD_X", "X", _TL(""), sChoices, 0);
		m_Parameters.Add_Choice("", "FIELD_Y", "Y", _TL(""), sChoices, 1);
	}

	//-----------------------------------------------------
//	m_Parameters.Add_Parameters("", "OPTIONS", _TL("Options"), _TL(""));

	m_Options.Add_Int("",
		"SAMPLES_MAX", _TL("Maximimum Number of Samples"),
		_TL(""),
		100000, 0, true
	);

	m_Options.Add_Bool("",
		"REG_SHOW"	, _TL("Show Regression"),
		_TL(""),
		true
	);

	m_Options.Add_String("REG_SHOW",
		"REG_FORMULA", _TL("Regression Formula"),
		_TL(""),
		"a + b * x"
	);

	m_Options.Add_Color("REG_SHOW",
		"REG_COLOR"	, _TL("Line Colour"),
		_TL(""),
		SG_COLOR_RED
	);

	m_Options.Add_Int("REG_SHOW",
		"REG_SIZE"	, _TL("Line Size"),
		_TL(""),
		0, 0, true
	);

	m_Options.Add_Info_String("REG_SHOW",
		"REG_INFO"	, _TL("Regression Details"),
		_TL(""),
		_TL(""), true
	);

	m_Options.Add_Choice("",
		"DISPLAY"	, _TL("Display Type"),
		_TL(""),
		CSG_String::Format("%s|%s",
			_TL("Points"),
			_TL("Density")
		), m_pGrid || m_pGrids ? 1 : 0
	);

	m_Options.Add_Int("DISPLAY",
		"DENSITY_RES"	, _TL("Display Resolution"),
		_TL(""),
		50, 10, true
	);

	CSG_Colors	Colors(7, SG_COLORS_RAINBOW);

	Colors.Set_Color(0, 255, 255, 255);
	Colors.Set_Count(100);

	m_Options.Add_Colors("DISPLAY",
		"DENSITY_PAL"	, _TL("Colors"),
		_TL(""),
		&Colors
	);

	m_Options.Add_Bool("DISPLAY",
		"DENSITY_LEG"	, _TL("Show Legend"),
		_TL(""),
		true
	);

	//-----------------------------------------------------
	m_Parameters.Set_Callback_On_Parameter_Changed(&Scatter_Plot_On_Parameter_Changed);
}
//---------------------------------------------------------
void CVIEW_Table_Control::On_Field_Add(wxCommandEvent &event)
{
	int				i;
	CSG_String		sFields;
	CSG_Parameters	P;

	//-----------------------------------------------------
	for(i=0; i<m_pTable->Get_Field_Count(); i++)
	{
		sFields.Append(m_pTable->Get_Field_Name(i));	sFields.Append(wxT('|'));
	}

	//-----------------------------------------------------
	P.Set_Name(_TL("Add Field"));

	P.Add_String(
		NULL	, "NAME"	, _TL("Name"),
		_TL(""),
		_TL("Field")
	);

	P.Add_Choice(
		NULL	, "TYPE"	, _TL("Field Type"),
		_TL(""),
		CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|"),
			SG_Data_Type_Get_Name(SG_DATATYPE_String).c_str(),
			SG_Data_Type_Get_Name(SG_DATATYPE_Date  ).c_str(),
			SG_Data_Type_Get_Name(SG_DATATYPE_Color ).c_str(),
			SG_Data_Type_Get_Name(SG_DATATYPE_Byte  ).c_str(),
			SG_Data_Type_Get_Name(SG_DATATYPE_Char  ).c_str(),
			SG_Data_Type_Get_Name(SG_DATATYPE_Word  ).c_str(),
			SG_Data_Type_Get_Name(SG_DATATYPE_Short ).c_str(),
			SG_Data_Type_Get_Name(SG_DATATYPE_DWord ).c_str(),
			SG_Data_Type_Get_Name(SG_DATATYPE_Int   ).c_str(),
			SG_Data_Type_Get_Name(SG_DATATYPE_ULong ).c_str(),
			SG_Data_Type_Get_Name(SG_DATATYPE_Long  ).c_str(),
			SG_Data_Type_Get_Name(SG_DATATYPE_Float ).c_str(),
			SG_Data_Type_Get_Name(SG_DATATYPE_Double).c_str(),
			SG_Data_Type_Get_Name(SG_DATATYPE_Binary).c_str()
		), 0
	);

	P.Add_Choice(
		NULL	, "FIELD"	, _TL("Insert Position"),
		_TL(""),
		sFields, m_pTable->Get_Field_Count() - 1
	);

	P.Add_Choice(
		NULL	, "INSERT"	, _TL("Insert Method"),
		_TL(""),
		CSG_String::Format(SG_T("%s|%s|"),
			_TL("before"),
			_TL("after")
		), 1
	);

	//-----------------------------------------------------
	if( DLG_Parameters(&P) )
	{
		int				Position;
		TSG_Data_Type	Type;

		switch( P("TYPE")->asInt() )
		{
		default:
		case  0:	Type	= SG_DATATYPE_String;	break;
		case  1:	Type	= SG_DATATYPE_Date;		break;
		case  2:	Type	= SG_DATATYPE_Color;	break;
		case  3:	Type	= SG_DATATYPE_Byte;		break;
		case  4:	Type	= SG_DATATYPE_Char;		break;
		case  5:	Type	= SG_DATATYPE_Word;		break;
		case  6:	Type	= SG_DATATYPE_Short;	break;
		case  7:	Type	= SG_DATATYPE_DWord;	break;
		case  8:	Type	= SG_DATATYPE_Int;		break;
		case  9:	Type	= SG_DATATYPE_ULong;	break;
		case 10:	Type	= SG_DATATYPE_Long;		break;
		case 11:	Type	= SG_DATATYPE_Float;	break;
		case 12:	Type	= SG_DATATYPE_Double;	break;
		case 13:	Type	= SG_DATATYPE_Binary;	break;
		}

		Position	= P("FIELD")->asInt() + P("INSERT")->asInt();

		m_pTable->Add_Field(P("NAME")->asString(), Type, Position);

		g_pData->Update(m_pTable, NULL);
	}
}
示例#18
0
CSG_String CSG_Doc_SVG::_Get_SVGColor(int iColor)
{

	CSG_String s;

	if (iColor == SG_COLOR_NONE)
	{
		return SG_T("none");
	}
	else if (iColor == SG_COLOR_RANDOM)
	{
		s.Append(SG_T("rgb("));
		s.Append(SG_Get_String((int)(255.0 * (double)rand() / (double)RAND_MAX),0));
		s.Append(SG_T(","));
		s.Append(SG_Get_String((int)(255.0 * (double)rand() / (double)RAND_MAX),0));
		s.Append(SG_T(","));
		s.Append(SG_Get_String((int)(255.0 * (double)rand() / (double)RAND_MAX),0));
		s.Append(SG_T(")"));

		return s;
	}
	else
	{
		s.Append(SG_T("rgb("));
		s.Append(SG_Get_String(SG_GET_R(iColor),0));
		s.Append(SG_T(","));
		s.Append(SG_Get_String(SG_GET_G(iColor),0));
		s.Append(SG_T(","));
		s.Append(SG_Get_String(SG_GET_B(iColor),0));
		s.Append(SG_T(")"));

		return s;
	}

}
//---------------------------------------------------------
CSG_Grid * CLandsat_Import::Get_Band(const CSG_String &File)
{
	CSG_Data_Manager	tmpMgr;

	if( !tmpMgr.Add(File) || !tmpMgr.Get_Grid_System(0) || !tmpMgr.Get_Grid_System(0)->Get(0) )
	{
		Error_Set(CSG_String::Format(SG_T("%s: %s"), _TL("could not load file"), File.c_str()));

		return( NULL );
	}

	tmpMgr.Get_Grid_System(0)->Get(0)->Set_NoData_Value(0);	// landsat 8 pretends to use a value of 65535 (2^16 - 1)

	CSG_Grid	*pBand	= NULL;

	//-----------------------------------------------------
	if( !tmpMgr.Get_Grid_System(0)->Get(0)->Get_Projection().is_Okay() )
	{
		// undefined coordinate system, nothing to do be done further...
	}

	//-----------------------------------------------------
	else if( Parameters("PROJECTION")->asInt() == 2 )	// Geographic Coordinates
	{
		pBand	= Get_Projection((CSG_Grid *)tmpMgr.Get_Grid_System(0)->Get(0), "+proj=longlat +ellps=WGS84 +datum=WGS84");
	}

	//-----------------------------------------------------
	else												// UTM
	{
		CSG_Grid	*pTmp	= (CSG_Grid *)tmpMgr.Get_Grid_System(0)->Get(0);

		CSG_String	Projection	= pTmp->Get_Projection().Get_Proj4();

		if( Projection.Find("+proj=utm") >= 0
		&&  (  (Projection.Find("+south") >= 0 && Parameters("PROJECTION")->asInt() == 0)
		    || (Projection.Find("+south") <  0 && Parameters("PROJECTION")->asInt() == 1))
		&&  (pBand = SG_Create_Grid(pTmp->Get_Type(), pTmp->Get_NX(), pTmp->Get_NY(), pTmp->Get_Cellsize(),
				pTmp->Get_XMin(), pTmp->Get_YMin() + (Parameters("PROJECTION")->asInt() == 1 ? 10000000 : -10000000)
			)) != NULL )
		{
			if( Parameters("PROJECTION")->asInt() == 1 )
				Projection.Append (" +south");
			else
				Projection.Replace(" +south", "");

			pBand->Get_Projection().Create(Projection, SG_PROJ_FMT_Proj4);

			pBand->Set_Name              (pTmp->Get_Name());
			pBand->Set_Description       (pTmp->Get_Description());
			pBand->Set_NoData_Value_Range(pTmp->Get_NoData_Value(), pTmp->Get_NoData_hiValue());
			pBand->Set_Scaling           (pTmp->Get_Scaling(), pTmp->Get_Offset());

			#pragma omp parallel for
			for(int y=0; y<pBand->Get_NY(); y++)
			{
				for(int x=0; x<pBand->Get_NX(); x++)
				{
					pBand->Set_Value(x, y, pTmp->asDouble(x, y));
				}
			}
		}
	}

	//-----------------------------------------------------
	if( !pBand )
	{
		pBand	= (CSG_Grid *)tmpMgr.Get_Grid_System(0)->Get(0);

		tmpMgr.Delete(tmpMgr.Get_Grid_System(0)->Get(0), true);	// make permanent, detach from temporary data manager
	}

	return( pBand );
}