- 积分
- 4183
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-27
- 最后登录
- 1970-1-1
|
发表于 2018-8-25 02:50:04
|
显示全部楼层
本帖最后由 孤蓝et 于 2018-8-25 02:51 编辑
大致分析了一下MeteoInfo类库源代码后,测试了几次,找到了精简版的方法,剔除交互界面操作过程以及选取图层过程,直接在绘制layout后添加label。供大家参考,也希望老师指点下@MeteoInfo ,我这样处理的是否正确?
- private void 读取latlon信息ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- //打开latlon数据
- //Create a MeteoDataInfo object
- MeteoDataInfo aDataInfo = new MeteoDataInfo();
- //Open latlon data file
- string aFile = Application.StartupPath + "\\latlon.csv";
- aDataInfo.OpenLonLatData(aFile);
- //Get StationData
- StationInfoData Data = aDataInfo.GetStationInfoData();
- //Create a legend scheme
- LegendScheme aLS = LegendManage.CreateSingleSymbolLegendScheme(ShapeTypes.Point, Color.Red, 6);
- //导入配色方案
- aLS.ImportFromXMLFile("latlon.lgs");
- MapLayer aLayer = new MapLayer();
- if (Data != null)
- {
- aLS.MissingValue = aDataInfo.MissingValue;
- aLayer = DrawMeteoData.CreateSTInfoLayer(Data, aLS, "站点信息信息");
- VectorLayer aLayer2 = (VectorLayer)aLayer;
- aLayer2.RemoveLabels();
- aLayer2.LabelSet.FieldName = "Trkn";
- aLayer2.LabelSet.AvoidCollision = true;
- aLayer2.LabelSet.LabelAlignType = (AlignType)Enum.Parse(typeof(AlignType), "Right", true);
- aLayer2.LabelSet.XOffset = 0;
- aLayer2.LabelSet.YOffset = -5;
- aLayer2.LabelSet.LabelColor = Color.Red;
- aLayer2.LabelSet.DrawLabels = true;
- aLayer2.LabelSet.ColorByLegend = true;
- aLayer2.LabelSet.AutoDecimal = true;
- aLayer2.AddLabels();
- //Add layer
- layersLegend1.ActiveMapFrame.AddLayer(aLayer);
- layersLegend1.ActiveMapFrame.MoveLayer(aLayer.Handle, 0);
- layersLegend1.Refresh();
- }
- }
复制代码
|
|