- 积分
- 410
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-11-18
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 sskkyy2008 于 2016-6-28 10:28 编辑
在用站点图画等值线时候 遇到错误:未将对象引用设置到对象实例
代码如下:
if (dianxianmian == "等值线")//等值线
{
StationData stationData = openinfo.GetStationData("Value");
MeteoInfoC.Data.MeteoData.GridDataSetting aGDP = new GridDataSetting();
// aGDP.DataExtent
aGDP.DataExtent.minX = 106;
aGDP.DataExtent.maxX = 109;
aGDP.DataExtent.minY = 30;
aGDP.DataExtent.maxY = 33;
aGDP.XNum = 50;
aGDP.YNum = 50;
// MeteoInfoC.Data.MeteoData.InterpolationSetting ttt = new GRIBParameterTable();
MeteoInfoC.Data.MeteoData.InterpolationSetting gridInterp = new InterpolationSetting();
gridInterp.GridDataSet = aGDP;
// gridInterp.GridDataParaV = aGDP;
gridInterp.InterpolationMethod = MeteoInfoC.Data.MeteoData.InterpolationMethods.IDW_Radius;
// gridInterp.GridInterMethodV = GridInterMethod.Cressman;
gridInterp.Radius = 0.2;//搜索半径
gridInterp.MinPointNum = 1;
double[] X = new double[1];
double[] Y = new double[1];
// ContourDraw.CreateGridXY(gridInterp.GridDataParaV, ref X, ref Y);
ContourDraw.CreateGridXY(gridInterp.GridDataSet, ref X, ref Y);
double[,] S = stationData.Data;
GridData gridData = ContourDraw.InterpolateDiscreteData_Radius(S,
X, Y, gridInterp.MinPointNum, gridInterp.Radius, stationData.MissingValue);
LegendScheme aLS2 = new LegendScheme(ShapeTypes.Polyline);
//aLS2.ImportFromXMLFile(Application.StartupPath + @"\lgs\" + lgs);
bool hasUndefData = false;
LegendScheme aLS = LegendManage.CreateLegendSchemeFromGridData(gridData, LegendType.UniqueValue, ShapeTypes.Polyline, ref hasUndefData);
aLS.ImportFromXMLFile(Application.StartupPath + @"\lgs\count.lgs");
VectorLayer aLayer = DrawMeteoData.CreateContourLayer(gridData, aLS, shpname, shpfieldnme);
aLayer.IsMaskout = true;
layersLegend1.ActiveMapFrame.AddLayer(aLayer);
layersLegend1.ActiveMapFrame.MoveLayer(aLayer.Handle, 1);
layersLegend1.Refresh();
//设置掩膜
layersLegend1.ActiveMapFrame.MapView.MaskOut.SetMaskLayer = true;
// layersLegend1.ActiveMapFrame.MapView.MaskOut.MaskLayer = Application.StartupPath + @"\map\dazhoumask.shp";
MapLayer maskLayer = MapDataManage.OpenLayer(Application.StartupPath + @"\map\" + masktu);
layersLegend1.ActiveMapFrame.MapView.MaskOut.MaskLayer = maskLayer.LayerName;
maskLayer.LegendScheme.LegendBreaks[0].DrawShape = false;
layersLegend1.ActiveMapFrame.AddLayer(maskLayer);
layersLegend1.ActiveMapFrame.MoveLayer(maskLayer.Handle, 2);
layersLegend1.ActiveMapFrame.MapView.PaintLayers();
layersLegend1.Refresh();
// LayoutGraphic title = mapLayout1.AddText(Title, mapLayout1.Width / 2, 20, 12);//maplayout加标题
//Change title of the layout
LayoutGraphic aTitle = mapLayout1.GetTexts()[0];
aTitle.SetFont("宋体", 12);
aTitle.SetLabelText(Title);
aTitle.Top = 80;
aTitle.Left = 200;
aTitle.ForeColor = Color.Blue;
//布局
this.Cursor = Cursors.Default;
// mapLayout1.SetPaperSize(600,450);
// SetPaperSize
mapLayout1.ActiveLayoutMap.Width = 550;
mapLayout1.ActiveLayoutMap.Height = 400;
mapLayout1.Refresh();
mapLayout1.PaintGraphics();
mapLayout1.Refresh();
layersLegend1.Refresh();
MeteoInfoC.Global.Extent aExtent = mapView1.Extent;
mapView1.ZoomToExtent(aExtent);
}
调试时候 在 VectorLayer aLayer = DrawMeteoData.CreateContourLayer(gridData, aLS, shpname, shpfieldnme); 运行这行后就弹出错误提示信息:未将对象引用设置到对象实例
|
|