📄 wasp_map.cpp
字号:
///////////////////////////////////////////////////////////
// //
// SAGA //
// //
// System for Automated Geoscientific Analyses //
// //
// Module Library: //
// shapes_tools //
// //
//-------------------------------------------------------//
// //
// WASP_MAP.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 "wasp_map.h"
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
CWASP_MAP_Export::CWASP_MAP_Export(void)
{
Set_Name (_TL("Export WASP terrain map file"));
Set_Author (_TL("Copyrights (c) 2006 by Olaf Conrad"));
Set_Description (_TW(
"Reference:\n"
"<a href=\"http://www.risoe.dk/vea/projects/nimo/WAsPHelp/Wasp8.htm#FileFormatofMAP.htm\" target=\"_blank\">"
"http://www.risoe.dk/vea/projects/nimo/WAsPHelp/Wasp8.htm#FileFormatofMAP.htm</a>"
));
//-----------------------------------------------------
CSG_Parameter *pShapes = Parameters.Add_Shapes(
NULL , "SHAPES" , _TL("Contour Lines"),
_TL(""),
PARAMETER_INPUT , SHAPE_TYPE_Line
);
Parameters.Add_Table_Field(
pShapes , "ELEVATION" , _TL("Map File"),
_TL("")
);
Parameters.Add_FilePath(
NULL , "FILE" , _TL("File Name"),
_TL(""),
CSG_String::Format(SG_T("%s|*.map|%s|*.*"),
_TL("WASP Map Files (*.map)"),
_TL("All Files")
), NULL, true
);
}
//---------------------------------------------------------
CWASP_MAP_Export::~CWASP_MAP_Export(void)
{}
//---------------------------------------------------------
bool CWASP_MAP_Export::On_Execute(void)
{
int zField;
FILE *Stream;
CSG_String fName;
CSG_Shape *pLine;
CSG_Shapes *pLines;
//-----------------------------------------------------
pLines = Parameters("SHAPES") ->asShapes();
zField = Parameters("ELEVATION") ->asInt();
fName = Parameters("FILE") ->asString();
//-----------------------------------------------------
if( pLines && pLines->is_Valid() && (Stream = fopen(fName.b_str(), "w")) != NULL )
{
// 1) Text string identifying the terrain map: + ...
fprintf(Stream, "+ %s\n", pLines->Get_Name());
// 2) Fixed point #1 in user and metric [m] coordinates:
// X1(user) Y1(user) X1(metric) Y1(metric)
fprintf(Stream, "%f %f %f %f\n", 0.0, 0.0, 0.0, 0.0);
// 3) Fixed point #2 in user and metric [m] coordinates:
// X2(user) Y2(user) X2(metric) Y2(metric)
fprintf(Stream, "%f %f %f %f\n", 1.0, 1.0, 1.0, 1.0);
// 4) Scaling factor and offset for height scale (Z):
// Zmetric = {scaling factor}(Zuser + {offset})
fprintf(Stream, "%f %f\n", 1.0, 0.0);
for(int iLine=0; iLine<pLines->Get_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++)
{
pLine = pLines->Get_Shape(iLine);
for(int iPart=0; iPart<pLine->Get_Part_Count(); iPart++)
{
if( pLine->Get_Point_Count(iPart) > 1 )
{
// 5a) Height contour: elevation (Z) and number of points (n) in line:
// Z n
fprintf(Stream, "%f %d\n", pLine->Get_Record()->asDouble(zField), pLine->Get_Point_Count(iPart));
// 5b) Roughness change line:
// roughness lengths to the left (z0l) and right (z0r) side of the line,
// respectively, and number of points:
// z0l z0r n
// 5c) Roughness and contour line:
// roughness lengths to the left and right of the line,
// respectively, elevation and number of points:
// z0l z0r Z n
// 6
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -