- 积分
- 104
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2015-11-9
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
求助:
用C#调用meteoinfo画风向标图总是报错,不知何原因,以下是核心代码,因条件有限,只能用csv文件生成。
public void TSMI_GrADSBarb()
{
string datfullpath = GetDatFileData(_interfaceName);
_datfullpath = datfullpath;
string file = @"D:\RegionRending\" + _time.Remove(8, 6) + "000000" + @"\" + _featureName + @"\" + _regionName + @"\" + DateTime.Now.ToString("yyyyMMddHH") + "0000" + ".png";
MeteoDataInfo aDataInfo = new MeteoDataInfo();
aDataInfo.OpenLonLatData(_datfullpath);
StationData stationData = aDataInfo.GetStationData("VR");
StationData stationData1 = aDataInfo.GetStationData("VS");
GridDataSetting aGDP = new GridDataSetting();
aGDP.DataExtent.minX = _xMin;
aGDP.DataExtent.maxX = _xMax;
aGDP.DataExtent.minY = _yMin;
aGDP.DataExtent.maxY = _yMax;
aGDP.XNum = 15;
aGDP.YNum = 15;
InterpolationSetting gridInterp = new InterpolationSetting();
gridInterp.GridDataSet = aGDP;
gridInterp.InterpolationMethod = InterpolationMethods.Cressman;
gridInterp.Radius = 2;
gridInterp.MinPointNum = 1;
List<double> t = new List<double>();
t.Add(10);
t.Add(7);
t.Add(4);
t.Add(2);
t.Add(1);
gridInterp.RadList = t;
double[] X = new double[1];
double[] Y = new double[1];
MeteoInfoC.Drawing.ContourDraw.CreateGridXY(gridInterp.GridDataSet, ref X, ref Y);
double[,] S = stationData.Data;
double[,] S1 = stationData1.Data;
S = MeteoInfoC.Drawing.ContourDraw.FilterDiscreteData_Radius(S, gridInterp.Radius,
gridInterp.GridDataSet.DataExtent, stationData.UNDEF);
S1 = MeteoInfoC.Drawing.ContourDraw.FilterDiscreteData_Radius(S1, gridInterp.Radius,
gridInterp.GridDataSet.DataExtent, stationData1.UNDEF);
GridData ugridData = MeteoInfoC.Drawing.ContourDraw.InterpolateDiscreteData_Cressman(S,
X, Y, stationData.UNDEF, gridInterp.RadList);
GridData vgridData = MeteoInfoC.Drawing.ContourDraw.InterpolateDiscreteData_Cressman(S1,
X, Y, stationData1.UNDEF, gridInterp.RadList);
LegendScheme aLS = LegendManage.CreateSingleSymbolLegendScheme(ShapeTypes.Point, Color.Blue, 10);
VectorLayer aLayer = DrawMeteoData.CreateGridBarbLayer(ugridData, vgridData, ugridData, aLS, false, "Barb_UV", true);
LayersLegend layersLegend1 = new LayersLegend();
layersLegend1.ActiveMapFrame.AddLayer(aLayer);
string time2 = DateTime.Now.ToString("yyyyMMddHH") + "0000";
string startTime = string.Empty;
string endTime = string.Empty;
string name = string.Empty;
string dt = time2.Substring(0, 4) + "-" + time2.Substring(4, 2) +
"-" + time2.Substring(6, 2) + " " + time2.Substring(8, 2) + ":" + time2.Substring(10, 2) + ":" + time2.Substring(12, 2);
switch (_isHourOrDay)
{
case "h":
startTime = Convert.ToDateTime(dt).AddHours(-1).ToString("yyyy年MM月dd日HH时");
endTime = Convert.ToDateTime(dt).ToString("yyyy年MM月dd日HH时");
name = " " + _mapName + "\n" + startTime + " - " + endTime;
break;
case "d":
startTime = Convert.ToDateTime(dt).AddDays(-1).ToString("yyyy年MM月dd日");
endTime = Convert.ToDateTime(dt).ToString("yyyy年MM月dd日");
name = " " + _mapName + "\n" + startTime + " - " + endTime;
break;
case "y":
startTime = Convert.ToDateTime(dt).ToString("yyyy年");
name = " " + startTime + _mapName;
break;
case "m":
startTime = Convert.ToDateTime(dt).ToString("yyyy年MM月");
endTime = Convert.ToDateTime(dt).ToString("yyyy年MM月");
name = " " + startTime + _mapName;
break;
case "cj":
startTime = Convert.ToDateTime(dt).ToString("yyyy年") + "03月";
endTime = Convert.ToDateTime(dt).ToString("yyyy年") + "05月";
name = " " + _mapName + "\n" + startTime + " - " + endTime;
break;
case "xj":
startTime = Convert.ToDateTime(dt).ToString("yyyy年") + "06月";
endTime = Convert.ToDateTime(dt).ToString("yyyy年") + "08月";
name = " " + _mapName + "\n" + startTime + " - " + endTime;
break;
case "qj":
startTime = Convert.ToDateTime(dt).ToString("yyyy年") + "9月";
endTime = Convert.ToDateTime(dt).ToString("yyyy年") + "11月";
name = " " + _mapName + "\n" + startTime + " - " + endTime;
break;
case "dj":
startTime = Convert.ToDateTime(dt).ToString("yyyy年") + "12月";
endTime = Convert.ToDateTime(dt).ToString("yyyy年") + "2月";
name = " " + _mapName + "\n" + startTime + " - " + endTime;
break;
case "sx":
startTime = Convert.ToDateTime(dt).ToString("yyyy年MM月") + "上旬";
endTime = Convert.ToDateTime(dt).ToString("yyyy年MM月") + "上旬";
name = " " + startTime + _mapName;
break;
case "zx":
startTime = Convert.ToDateTime(dt).ToString("yyyy年MM月") + "中旬";
endTime = Convert.ToDateTime(dt).ToString("yyyy年MM月") + "中旬";
name = " " + startTime + _mapName;
break;
case "xx":
startTime = Convert.ToDateTime(dt).ToString("yyyy年MM月") + "下旬";
endTime = Convert.ToDateTime(dt).ToString("yyyy年MM月") + "下旬";
name = " " + startTime + _mapName;
break;
}
MapLayout mapLayout1 = new MapLayout();
LayoutGraphic aTitle = mapLayout1.GetTexts()[0];
aTitle.SetLabelText(name);
aTitle.Left = 140;
aTitle.Top = 50;
mapLayout1.ExportToPicture(file);
}
|
|