爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 2787|回复: 2

求助 二次开发画等值线时候 提示未将对象引用设置到对象实例

[复制链接]

新浪微博达人勋

发表于 2016-6-28 10:25:33 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

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); 运行这行后就弹出错误提示信息:未将对象引用设置到对象实例
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-6-28 10:48:10 | 显示全部楼层
VectorLayer aLayer = DrawMeteoData.CreateContourLayer(gridData, aLS, shpname, shpfieldnme);
shpname, shpfieldnme 没有看到啊?
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-6-28 10:53:42 | 显示全部楼层
jzd19851102 发表于 2016-6-28 10:48
VectorLayer aLayer = DrawMeteoData.CreateContourLayer(gridData, aLS, shpname, shpfieldnme);
shpname ...

能加你QQ帮我看看吗? 我的QQ270209972
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表