输入图层 ,咨信网zixin.com.cn" />
收藏 分销(赏)

Arcgis Engine开发分级渲染.doc

上传人:xrp****65 文档编号:8315330 上传时间:2025-02-09 格式:DOC 页数:6 大小:47KB 下载积分:10 金币
下载 相关 举报
Arcgis Engine开发分级渲染.doc_第1页
第1页 / 共6页
Arcgis Engine开发分级渲染.doc_第2页
第2页 / 共6页


点击查看更多>>
资源描述
这是网上找的分级渲染代码 /// <summary> /// 不同颜色生成分级点符号图 /// </summary> /// <param name="mFeatureLayer">输入图层</param> /// <param name="mFieldName">点符号颜色字段</param> /// <param name="iBreakCount">点符号分级数</param> /// <returns>点符号图层</returns> public IFeatureLayer GisChart_ClassBreakColorMaker(IFeatureLayer mFeatureLayer, IServerContext pSOC, string mFieldName, ref int iBreakCount) { IGeoFeatureLayer pGeoFeatureLayer; IFillSymbol pFillSymbol; ISimpleMarkerSymbol pSimpleMarkerS; stdole.StdFont pFontDisp; ITable pTable; IQueryFilter pQueryFilter; ICursor pCursor; IDataStatistics pDataStatistics; IStatisticsResults pStatisticsResult; pGeoFeatureLayer = mFeatureLayer as IGeoFeatureLayer; //计算要素最大最小值 pTable = (ITable)pGeoFeatureLayer; pQueryFilter = new QueryFilterClass(); pQueryFilter.AddField(""); pCursor = pTable.Search(pQueryFilter, true); pDataStatistics = new DataStatisticsClass(); pDataStatistics.Cursor = pCursor; pDataStatistics.Field = mFieldName; pStatisticsResult = pDataStatistics.Statistics; //背景色 pFillSymbol = pSOC.CreateObject("esriDisplay.SimpleFillSymbol") as ISimpleFillSymbol; pFillSymbol.Color = GetColor(233, 255, 190,pSOC); //点符号样式 pSimpleMarkerS = pSOC.CreateObject("esriDisplay.SimpleMarkerSymbol") as ISimpleMarkerSymbol; pFontDisp = new stdole.StdFontClass(); pFontDisp.Name = "ESRI Business"; pFontDisp.Size = 10; pSimpleMarkerS.Outline = true; pSimpleMarkerS.OutlineColor = GetColor(0, 0, 0, pSOC); //分级符号图 //获取统计数据及起频率 ITableHistogram pTableHistogram = pSOC.CreateObject("esriCarto.BasicTableHistogram") as ITableHistogram; pTableHistogram.Field = mFieldName; pTableHistogram.Table = pTable; object dataValues, dataFrequency; IBasicHistogram pHistogram = (IBasicHistogram)pTableHistogram; pHistogram.GetHistogram(out dataValues, out dataFrequency); IClassifyGEN pClassify = new NaturalBreaksClass(); //产生种类 pClassify.Classify(dataValues, dataFrequency, ref iBreakCount); object ob = pClassify.ClassBreaks; double[] Classes = (double[])ob; int ClassesCount = Classes.Length; //定义分类渲染 IClassBreaksRenderer pClassBreaksRenderer = (IClassBreaksRenderer)pSOC.CreateObject("esriCarto.ClassBreaksRenderer"); pClassBreaksRenderer.Field = mFieldName; pClassBreaksRenderer.BreakCount = ClassesCount; pClassBreaksRenderer.SortClassesAscending = true; pClassBreaksRenderer.MinimumBreak = Classes[0]; IColor pColor = GetRGBColor(124, 143, 0, pSOC); //设置要素的填充颜色 for (int i = 0; i < ClassesCount; i ) { ISimpleFillSymbol pFillSymbol1 = new SimpleFillSymbolClass(); pSimpleMarkerS. Color = pColor; pFillSymbol1.Style = esriSimpleFillStyle.esriSFSSolid; pSimpleMarkerS.Size = 4*(i 1); pClassBreaksRenderer.BackgroundSymbol = pFillSymbol; pClassBreaksRenderer.set_Symbol(i, (ISymbol)pSimpleMarkerS); pClassBreaksRenderer.set_Break(i, Classes[i]); } pGeoFeatureLayer.Renderer = (IFeatureRenderer)pClassBreaksRenderer; return (IFeatureLayer)pGeoFeatureLayer; } private static IRgbColor GetRGBColor(int yourRed, int yourGreen, int yourBlue, IServerContext pSOC) { IRgbColor pRGB = (IRgbColor)pSOC.CreateObject("esriDisplay.RgbColor"); pRGB.Red = yourRed; pRGB.Green = yourGreen; pRGB.Blue = yourBlue; pRGB.UseWindowsDithering = true; return pRGB; } /// <summary> /// 颜色设置 /// </summary> /// <param name="red">R</param> /// <param name="green">G</param> /// <param name="blue">B</param> /// <returns>GIS颜色对象</returns> private static IColor GetColor(int red, int green, int blue, IServerContext pSOC) { IRgbColor rgbColor = GetRGBColor(red, green, blue, pSOC); IColor color = rgbColor as IColor; return color; } 这是打开文件菜单的代码,包括打开、新建、保存、另存为、退出 using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.IO; using System.Runtime.InteropServices; using ESRI.ArcGIS.esriSystem; using ESRI.ArcGIS.Carto; using ESRI.ArcGIS.Controls; using ESRI.ArcGIS.ADF; using ESRI.ArcGIS.SystemUI; namespace MapControlApplication1 { public sealed partial class MainForm : Form { #region class private members private IMapControl3 m_mapControl = null; private string m_mapDocumentName = string.Empty; #endregion #region class constructor public MainForm() { InitializeComponent(); } #endregion private void MainForm_Load(object sender, EventArgs e) { //get the MapControl m_mapControl = (IMapControl3)axMapControl1.Object; //disable the Save menu (since there is no document yet) menuSaveDoc.Enabled = false; } #region Main Menu event handlers private void menuNewDoc_Click(object sender, EventArgs e) { //execute New Document command ICommand command = new CreateNewDocument(); command.OnCreate(m_mapControl.Object); command.OnClick(); } private void menuOpenDoc_Click(object sender, EventArgs e) { //execute Open Document command ICommand command = new ControlsOpenDocCommandClass(); command.OnCreate(m_mapControl.Object); command.OnClick(); } private void menuSaveDoc_Click(object sender, EventArgs e) { //execute Save Document command if (m_mapControl.CheckMxFile(m_mapDocumentName)) { //create a new instance of a MapDocument IMapDocument mapDoc = new MapDocumentClass(); mapDoc.Open(m_mapDocumentName, string.Empty); //Make sure that the MapDocument is not readonly if (mapDoc.get_IsReadOnly(m_mapDocumentName)) { MessageBox.Show("Map document is read only!"); mapDoc.Close(); return; } //Replace its contents with the current map mapDoc.ReplaceContents((IMxdContents)m_mapControl.Map); //save the MapDocument in order to persist it mapDoc.Save(mapDoc.UsesRelativePaths, false); //close the MapDocument mapDoc.Close(); } } private void menuSaveAs_Click(object sender, EventArgs e) { //execute SaveAs Document command ICommand command = new ControlsSaveAsDocCommandClass(); command.OnCreate(m_mapControl.Object); command.OnClick(); } private void menuExitApp_Click(object sender, EventArgs e) { //exit the application Application.Exit(); } #endregion //listen to MapReplaced evant in order to update the statusbar and the Save menu private void axMapControl1_OnMapReplaced(object sender, IMapControlEvents2_OnMapReplacedEvent e) { //get the current document name from the MapControl m_mapDocumentName = m_mapControl.DocumentFilename; //if there is no MapDocument, diable the Save menu and clear the statusbar if (m_mapDocumentName == string.Empty) { menuSaveDoc.Enabled = false; statusBarXY.Text = string.Empty; } else { //enable the Save manu and write the doc name to the statusbar menuSaveDoc.Enabled = true; statusBarXY.Text = Path.GetFileName(m_mapDocumentName); } } private void axMapControl1_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e) { statusBarXY.Text = string.Format("{0}, {1} {2}", e.mapX.ToString("#######.##"), e.mapY.ToString("#######.##"), axMapControl1.MapUnits.ToString().Substring(4)); } } }
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 管理财经 > 管理学资料

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服