- 积分
- 10
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2015-7-16
- 最后登录
- 1970-1-1
|
发表于 2015-8-4 08:43:02
|
显示全部楼层
public bool ht(string picname)
{
bool success = false;
Surfer.Application app = new Surfer.Application();
try
{
// 调用Surfer画等值线
app.Visible = SufBool;
app.Caption = strName;// @"区域自动站雨量等值线图";
// Type.Missing为缺省参数
app.GridData(strDataPath + @"\Data1.txt", 2, 3, 4, Type.Missing, //5
Type.Missing, Type.Missing, Type.Missing, 200, 200, //10
minLon, maxLon, minLat, maxLat, Type.Missing, //15
false, Type.Missing, Type.Missing, Type.Missing, Type.Missing, //20
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, //25
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, //30
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, //35
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, //40
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, //45
Type.Missing, Type.Missing, Type.Missing, Type.Missing, strDataPath + @"data1.grd", //50
SrfGridFormat.srfGridFmtAscii, Type.Missing, Type.Missing, Type.Missing, Type.Missing, //55
Type.Missing, Type.Missing
);
app.GridBlank(strDataPath + @"data1.grd", strMapPath, strDataPath + @"out1.grd", SrfGridFormat.srfGridFmtAscii);
Surfer.IDocuments Docs = app.Documents;// = new Surfer.IDocuments();
Surfer.IPlotDocument PlotDoc = (Surfer.IPlotDocument)Docs.Add(SrfDocTypes.srfDocPlot);
Surfer.IMapFrame MapF = PlotDoc.Shapes.AddContourMap(strDataPath + @"out1.grd");
PlotDoc.Shapes.AddBaseMap(strMapPath, "");
IPostMap PostMap = (IPostMap)PlotDoc.Shapes.AddPostMap(strDataPath + @"Data1.txt", 2, 3, 1, 0, 1).Overlays.Item(1);
IPostMap PostMap1 = (IPostMap)PlotDoc.Shapes.AddPostMap(strDataPath + @"Data1.txt", 2, 3, 4, 0, 0).Overlays.Item(1);
//PlotDoc1.Shapes.AddText().
// 数据和站点显示
PostMap.LabelPos = SrfPostPosType.srfPostPosBelow;
PostMap.LabelFont.Face = @"宋体";
PostMap.LabelFont.Size = 10;
PostMap.LabelFont.Bold = true;
PostMap.Symbol.Index = 11;
PostMap.Symbol.Color = srfColor.srfColorBlue;
PostMap.Symbol.Size = 0.04;
PostMap1.LabelPos = SrfPostPosType.srfPostPosAbove;
PostMap1.LabelFont.Face = @"宋体";
PostMap1.LabelFont.Bold = true;
PostMap1.LabelFont.Size = 10;
PostMap1.Symbol.Index = 11;
PostMap1.Symbol.Color = srfColor.srfColorBlue;
PostMap1.Symbol.Size = 0.04;
//等值线填充
Surfer.IContourMap ContourMap = (Surfer.IContourMap)MapF.Overlays.Item(1);
ContourMap.FillContours = true; //添加颜色填充
ContourMap.ShowColorScale = true; // 显示对应色柱
ContourMap.SmoothContours = SrfConSmoothType.srfConSmoothHigh;
ContourMap.Levels.LoadFile(XGlobal.str雨量等值线色标 + colorfile);
for (int i = 0; i < ContourMap.Levels.Count; i++)
{
ContourMap.Levels.Item(i + 1).ShowLabel = true; //显示等值线上的数值
ContourMap.Levels.Item(i + 1).ShowHach = false; //
ContourMap.Levels.Item(i + 1).Line.Style = "Invisible"; //不显示线
}
ContourMap.SmoothContours = SrfConSmoothType.srfConSmoothNone; //平滑等值线边界当前设置不平滑
ContourMap.ColorScale.Height = 1.4;
ContourMap.ColorScale.Width = 0.3;
double x = ContourMap.Left + 1.4;
double y = ContourMap.Top -ContourMap.Height -0.5 ;
IText Itext = PlotDoc.Shapes.AddText(x, y, strName);//2.5,2.6
Itext.Font.Bold = true;
Itext.Font.Size = 14;
Itext.Font.Face = @"宋体";
//覆盖所有地图
PlotDoc.Shapes.SelectAll();
Surfer.IMapFrame MapFrame = PlotDoc.Selection.OverlayMaps();
MapFrame.Axes.Item(1).Visible = true;
MapFrame.Axes.Item(2).Visible = true;
MapFrame.Axes.Item(3).Visible = true;
MapFrame.Axes.Item(4).Visible = true;
PlotDoc.SaveAs(strDataPath + @"Data1.srf", "", SrfSaveFormat.srfSaveFormatDat);
mapw = pictureBox11.Width;
maph = pictureBox11.Height;
string strWidthHeight = string.Format("width={0:f0},height={1:f0}", mapw, maph);
PlotDoc.Export(XGlobal.str雨量等值线基图 + picname, true, strWidthHeight);
if (SufBool == false)
{
app.Quit();
}
pictureBox11.Image = Bitmap.FromFile(XGlobal.str雨量等值线基图 + picname);
success = true;
}
catch (Exception E)
{
MessageBox.Show(E.Message.ToString());
success = false;
}
finally
{
;
}
return success ;
} |
|