单个要素制图表达的获取及修改
来源:互联网 发布:矩阵特征值 编辑:程序博客网 时间:2024/05/19 14:00
1.获取制图表达
/// <summary> /// 获取图层中某个要素的制图表达 /// </summary> /// <param name="pLyr">图层</param> /// <param name="pActiveView">视图</param> /// <param name="pFea">单个要素</param> /// <returns></returns> public static IRepresentation getRepresentation(ILayer pLyr, IActiveView pActiveView, IFeature pFea) { try { IMapContext pMapContext = new MapContextClass(); pMapContext.InitFromDisplay(pActiveView.ScreenDisplay.DisplayTransformation); IFeatureLayer pFeaLyr = pLyr as IFeatureLayer; IRepresentationRenderer pRepRenderer = (pFeaLyr as IGeoFeatureLayer).Renderer as IRepresentationRenderer; IRepresentation pRepresentation = pRepRenderer.RepresentationClass.GetRepresentation(pFea, pMapContext); return pRepresentation; } catch (Exception ex) { return null; } }
/// <summary> /// 获取地图上要素类图层 /// </summary> /// <param name="pMap"></param> /// <param name="sUID"></param> /// <param name="sLayerName"></param> /// <returns></returns> public static ILayer GetLayer(IMap pMap, string sLayerName) { ILayer pLyr = null; UID uid = new UIDClass(); uid.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}"; IEnumLayer pEnumLayer = pMap.get_Layers(uid, true); try { pEnumLayer.Reset(); ILayer pLayer = null; while ((pLayer = pEnumLayer.Next()) != null) { if (!pLayer.Visible) { continue; } if (!string.IsNullOrEmpty(sLayerName) && sLayerName == ((pLayer as IFeatureLayer).FeatureClass as IDataset).Name) { pLyr = pLayer; } } return pLyr; } catch (Exception ex) { return null; } finally { Marshal.ReleaseComObject(pEnumLayer); } }
3.获取制图表达属性信息并进行更改的操作
private void UpdateRepColor(ILayer pLyr, string JBConde, List<ConvertMappingInfo> plistMappingInfo, ConvertToType convertToType) { IWorkspaceEdit2 pWsEdit = pWs as IWorkspaceEdit2; try { IFeatureCursor pFeaCursor = (pLyr as IFeatureLayer).FeatureClass.Update(null, false); IFeature pFea = null; //开启编辑会话 WorkspaceAPI.StartWorkspaceEdit(pWs); pWsEdit.StartEditOperation(); while ((pFea = pFeaCursor.NextFeature()) != null) { IRepresentation pRepresentation = CommonAPI.getRepresentation(pLyr, ArcMap.Document.ActivatedView, pFea); IRepresentationRule pRepRule = pRepresentation.RepresentationClass.RepresentationRules.get_Rule(pRepresentation.RuleID); string strRuleName = pRepresentation.RepresentationClass.RepresentationRules.get_Name(pRepresentation.RuleID); if (strRuleName != JBConde) { continue; } for (int i = 0; i < pRepRule.LayerCount; i++) { IBasicSymbol pBasicSymbol = pRepRule.get_Layer(i); IGraphicAttributes pGraphicAttributes = null; //IGeometry pRepGeometry = null; if (pBasicSymbol is IBasicMarkerSymbol) { IBasicMarkerSymbol pBasicMarkerSymbol = pBasicSymbol as IBasicMarkerSymbol; //pRepGeometry = pRepresentation.Shape; pGraphicAttributes = pBasicMarkerSymbol as IGraphicAttributes; } if (pBasicSymbol is IBasicLineSymbol) { IBasicLineSymbol pBasicLineSymbol = pBasicSymbol as IBasicLineSymbol; ILineStroke pLineStroke = pBasicLineSymbol.Stroke; //IDrawingOutline pDrawingOutline = pLineStroke as IDrawingOutline; //IGeometry geo = pDrawingOutline.GetAllOutlineParts(feature.Shape, esriOutlineType.esriOutlineExact, esriOutlineOption.esriOutlineConvex, 3.14, null); //pRepGeometry = pRepresentation.Shape; pGraphicAttributes = pLineStroke as IGraphicAttributes; } if (pBasicSymbol is IBasicFillSymbol) { IBasicFillSymbol pBasicFillSymbol = pBasicSymbol as IBasicFillSymbol; IFillPattern pFillPattern = pBasicFillSymbol.FillPattern; //pRepGeometry = pRepresentation.Shape; pGraphicAttributes = pFillPattern as IGraphicAttributes; } for (int N = 0; N < pGraphicAttributes.GraphicAttributeCount; N++) { int iId = pGraphicAttributes.get_ID(N); string name = pGraphicAttributes.get_Name(iId); IGraphicAttributeType pGraphicAttributeType = pGraphicAttributes.get_Type(iId); if (pGraphicAttributeType.Type == esriGraphicAttributeType.esriAttributeTypeColor) { IColor pColor = pRepresentation.get_Value(pGraphicAttributes, iId) as IColor; ICmykColor pCMYKColor = pColor as ICmykColor; if (pCMYKColor==null) { continue; } if (convertToType == ConvertToType.ChuBan) { ConvertMappingInfo pConvertInfo = new ConvertMappingInfo(); pConvertInfo.PC = pCMYKColor.Cyan; pConvertInfo.PM = pCMYKColor.Magenta; pConvertInfo.PY = pCMYKColor.Yellow; pConvertInfo.PK = pCMYKColor.Black; foreach (ConvertMappingInfo c in plistMappingInfo) { if (pConvertInfo.CompareColorValue(c, convertToType)) { pCMYKColor.Cyan = c.CC; pCMYKColor.Magenta = c.CM; pCMYKColor.Yellow = c.CY; pCMYKColor.Black = c.CK; pRepresentation.set_Value(pGraphicAttributes, iId, pCMYKColor); } } } if (convertToType == ConvertToType.PenHui) { ConvertMappingInfo pConvertInfo = new ConvertMappingInfo(); pConvertInfo.CC = pCMYKColor.Cyan; pConvertInfo.CM = pCMYKColor.Magenta; pConvertInfo.CY = pCMYKColor.Yellow; pConvertInfo.CK = pCMYKColor.Black; foreach (ConvertMappingInfo c in plistMappingInfo) { if (pConvertInfo.CompareColorValue(c, convertToType)) { pCMYKColor.Cyan = c.PC; pCMYKColor.Magenta = c.PM; pCMYKColor.Yellow = c.PY; pCMYKColor.Black = c.PK; } } } } } } pRepresentation.UpdateFeature(); pFeaCursor.UpdateFeature(pFea); //关闭编辑会话 pWsEdit.StopEditOperation(); pWsEdit.StopEditing(true); } } catch (Exception ex) { WorkspaceAPI.RollbackWorkspaceEdit(pWsEdit); } finally { } }
阅读全文
0 0
- 单个要素制图表达的获取及修改
- 改变单个制图表达属性
- Arcengine制图表达的一些理解
- ArcEngine中制图表达的相关接口
- ArcGIS制图表达Representation-制图表达介绍
- ArcGIS制图表达Representation-制图表达原理
- 制图表达覆盖
- 创建制图表达规则
- 使用制图表达创建简易的河流渐变效果
- 怎么使用制图表达的高级图层显示
- ArcGIS制图表达Representation-制图表达使用须知
- ArcGIS制图表达Representation实战篇4-自由式制图表达
- Representation(制图表达)在地图制图中的应用
- 使用AE加载带有制图表达(Representation)的图层(Layer)
- 获取独立的要素类
- ArcGIS制图表达—创建天桥
- ArcGIS制图表达—突出实体目标
- ArcGIS制图表达—河流渐变效果
- 模仿微信界面
- CentOS 7 源码安装 mysql5.7
- Android Json转换为Map Json转为List
- 获取多类型文件
- unity中的LOD
- 单个要素制图表达的获取及修改
- bzoj 3238 lcp
- 常见数据结构与算法整理总结(上)
- FFmpeg缩放swscale详解 <转>
- 判断网络是否连接
- 笔试题错误笔记(一)
- jQuery插件开发
- 模仿微信界面之聊天界面
- 随机生成字符串