目录
2 利用AE的SimpleRender进行点线面渲染的通用接口
1 ArcMap的点、线、面渲染操作
1.1 点渲染
修改点符号的类型和颜色
1.2 线渲染
修改线型和颜色
1.3 面渲染
修改填充颜色和边线宽度及颜色
2 利用AE的SimpleRender进行点线面渲染的通用接口
2.1 IGeoFeatureLayer接口
IGeoFeatureLayer接口的成员如下所示:
AllPropertiesMethodsInheritedNon-inherited | Description | |
---|---|---|
![]() | AnnotationProperties | Annotation properties. |
![]() | AnnotationPropertiesID | The UID used for annotation properties. |
![]() | AreaOfInterest | The default area of interest for the layer. |
![]() | Cached | Indicates if the layer needs its own display cache. |
![]() | CurrentMapLevel | Current map level for drawing symbols. |
![]() | DataSourceType | Data source type. |
![]() | DisplayAnnotation | Indicates if the layer displays annotation. |
![]() | DisplayFeatureClass | Feature class used for display operations (may include joined fields). |
![]() | DisplayField | Primary display field. |
![]() | Draw | Draws the layer to the specified display for the given draw phase. |
![]() | ExclusionSet | The set of features that are excluded from drawing. |
![]() | FeatureClass | The layer's feature class. |
![]() | MaximumScale | Maximum scale (representative fraction) at which the layer will display. |
![]() | MinimumScale | Minimum scale (representative fraction) at which the layer will display. |
![]() | Name | Layer name. |
![]() | Renderer | Renderer used to draw the layer. |
![]() | RendererPropertyPageClassID | Class id of the property page for the renderer. |
![]() | ScaleSymbols | Indicates if symbols are scaled for the layer. |
![]() | Search | Creates a cursor based upon the search criteria. |
![]() | SearchDisplayFeatures | Creates a cursor from the display feature class based upon the search criteria. |
![]() | Selectable | Indicates if layer is selectable. |
![]() | ShowTips | Indicates if the layer shows map tips. |
![]() | SpatialReference | Spatial reference for the layer. |
![]() | SupportedDrawPhases | Supported draw phases. |
![]() | TipText | Map tip text at the specified location. |
![]() | Valid | Indicates if the layer is currently valid. |
![]() | Visible | Indicates if the layer is currently visible. |
其中有可读可写的Render属性,用来对图层进行渲染;此外该接口继承自IFeatureLayer接口,可以使用as进行强制类型转换
打开Render属性发现其类型为IFeatureRenderer
2.2 IFeatureRenderer接口
发现对该接口进行实现的SimpleRender类
沿着SimpleRenderer接口继续向上追溯,发现其继承自接口ISimpleRenderer
2.3 ISimpleRenderer接口
ISimpleRenderer中包含可读可写的Symbol属性,类型为ISymbol;
2.4 ISymbol接口
对该接口进行实现的类中找到如下类:
3 点渲染的接口及实现源码
回溯到ISymbol接口发现,ISymbol中被没有任何对属性可供操作,但是SimpleMarkerSymbolClass类对其进行实现,继续追溯。
3.1 SimpleMarkerSymbolClass类
该类同时实现了接口ISymbol和ISimpleMarkerSymbol,利用接口查询技术实现这两个类的跳转;ISimpleMarkerSymbol提供了对对Symbol的操作
3.2 ISimpleMarkerSymbol
3.3 点渲染实现源码
private void 点渲染ToolStripMenuItem_Click(object sender, EventArgs e)
{
IFeatureLayer myfealyer = axMapControl1.get_Layer(0) as IFeatureLayer;//得到当前视图中的第一个图层
IGeoFeatureLayer geofeature = myfealyer as IGeoFeatureLayer;
ISimpleRenderer render = new SimpleRendererClass();//定义渲染器
ISymbol symbol = new SimpleMarkerSymbolClass();//定义渲染符号
ISimpleMarkerSymbol markSymbol = symbol as ISimpleMarkerSymbol;
IColor color = new RgbColor();
color.RGB = 251;
markSymbol.Color = color;//定义标记符号的颜色
markSymbol.Size = 10;//定义标记符号的大小
markSymbol.Style = esriSimpleMarkerStyle.esriSMSX;//定义标记符号的风格
render.Symbol = symbol;
geofeature.Renderer = render as IFeatureRenderer;
axTOCControl1.Update();
axMapControl1.Refresh();
}
4 线渲染代码接口及实现源码
4.1 SimpleLineSymbolClass类
4.2 ISimpleLineSymbol接口
4.3 线渲染实现源码
private void 线渲染ToolStripMenuItem_Click(object sender, EventArgs e)
{
IFeatureLayer myfealyer = axMapControl1.get_Layer(0) as IFeatureLayer;//得到当前视图中的第一个图层
IGeoFeatureLayer geofeature = myfealyer as IGeoFeatureLayer;
ISimpleRenderer render = new SimpleRendererClass();//定义渲染器
ISymbol symbol = new SimpleLineSymbolClass();//定义渲染符号
ISimpleLineSymbol linesymbol = symbol as ISimpleLineSymbol;
IColor color = new RgbColor();
color.RGB = 255;
linesymbol.Color = color;
linesymbol.Style = esriSimpleLineStyle.esriSLSDot;
linesymbol.Width = 3;
render.Symbol = symbol;
geofeature.Renderer = render as IFeatureRenderer;
axMapControl1.Update();
axTOCControl1.Refresh();
}
5 面渲染的实现
5.1 ILineSymbol接口进行线要素的渲染
5.2 ISimpleFillSymbol进行面填充渲染
有三个属性:
color用来设置面填充的颜色;
Ouline是为了设置轮廓线的颜色和线宽,使用线填充是用到的SimpleLineSymbolClass类;
Style设置填充风格
5.3 面渲染实现源码
private void 面渲染ToolStripMenuItem_Click(object sender, EventArgs e)
{
IFeatureLayer myfealyer = axMapControl1.get_Layer(0) as IFeatureLayer;//得到当前视图中的第一个图层
IGeoFeatureLayer geofeature = myfealyer as IGeoFeatureLayer;
ISimpleRenderer render = new SimpleRendererClass();//定义渲染器
ILineSymbol linesymbol = new SimpleLineSymbolClass();
IColor color = new RgbColor();
color.RGB = 255;
linesymbol.Color = color;//线的颜色
linesymbol.Width = 5;//线宽
ISymbol symbol = new SimpleFillSymbolClass();
ISimpleFillSymbol fillSybol = symbol as ISimpleFillSymbol;
fillSybol.Outline = linesymbol;
IColor fillColor = new RgbColor();//设置填充色
fillColor.RGB = 255;
fillSybol.Color = fillColor;
fillSybol.Style = esriSimpleFillStyle.esriSFSVertical;
render.Symbol = symbol;
geofeature.Renderer = render as IFeatureRenderer;
axMapControl1.Update();
axTOCControl1.Refresh();
}
6 总结
在使用AE进行二次开发时,要多多使用官方的帮助文档,训练快速根据帮助文档理顺可用接口及其之间的关系,以实现需要的功能。
在AE中有这样一个命名规律:
对一个类按照单词进行拆解,可依次发现其继承的接口,如下图:
本博文用到的接口和类如下:
接口 | 描述 | 官方描述 |
IFeatureLayer | 矢量图层接口 | Provides access to the properties and methods of a layer based on vector geographic data, which is typically a geodatabase, shapefile, or coverage feature class. |
IGeoFeatureLayer | 矢量图层符号和标记接口 | Provides access to symbolization and labeling properties for layers based on vector geographic data. Also provides a method for returning a read-only feature cursor of layer features that includes joined fields. |
矢量渲染器接口 | All feature renderers implement this interface and it is used by the framework to draw features from a FeatureClass. | |
图层渲染接口 | Provides access to members that control a renderer which draws the same symbol for each feature. | |
ISymbol | 图层符号接口 | Provides access to members that control symbols. |
ISimpleMarkerSymbol | 点符号接口 | Provides access to members that control the simple marker symbol. |
ISimpleLineSymbol | 符号接口 | ISimpleLineSymbol is used to create a line symbol comprised of a predefinded set of styles. The availble styles are provided by the esriSimpleLineStyle enumeration. Use the ILineSymbol interface to set additional properties for ISimpleLineSymbols. |
ISimpleFillSymbol | 面符号接口 | ISimpleFillSymbol is used to create a fill symbol comprised of a predefined set of styles. The available styles are provided by the esriSimpleFillStyle enumeration. Use the IFillSymbol interface to set additional properties for ISimpleFillSymbols. |
更多精彩,欢迎关注个人微信公众帐号“学而立行”