阅读:2037回复:1
[求助]AE开发符号化问题?
<P>问题是这样的,我按下面的代码运行发现如果图中只有点,线,面各一个图层则程序没有问题,但是如果有两个以上的图层是点或线或面则程序有错误提示,也就是说点或者线或者面图层只能有一个,超过就会提示错误,这个问题怎么解决?<BR> 第二个问题:符号化后怎么回到符号化前?</P>
<P>下面的为点击符号化按钮后的代码<BR> private void symbol_Click(object sender, EventArgs e)<BR> {<BR> //设置当前工具为空<BR> this.axMapControl1.CurrentTool = null;<BR> mytool = 6;</P> <P> //获得图层的数量i及地图图层<BR> int i;<BR> IMap pmap = axMapControl1.Map;<BR> string symbolname;</P> <P> symbolc mycc = new symbolc();</P> <P> //循环获得每一个图层<BR> for(i=0;i<pmap.LayerCount;i++)<BR> {<BR> ILayer layer = pmap.get_Layer(i);<BR> if (layer == null) return;<BR> IFeatureLayer featureLayer = layer as IFeatureLayer;<BR> if (featureLayer == null) return;<BR> IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer)featureLayer;<BR> <BR> //按照图层的特征分别进行点,线,面符号化<BR> switch (featureLayer.FeatureClass.ShapeType)<BR> {<BR> case esriGeometryType.esriGeometryPoint:<BR> {<BR> symbolname = "Marker Symbols";<BR> mycc.symbol(geoFeatureLayer, symbolname);<BR> this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);<BR> };<BR> break;</P> <P> case esriGeometryType.esriGeometryPolyline:<BR> {<BR> symbolname = "Line Symbols";<BR> mycc.symbol(geoFeatureLayer, symbolname);<BR> this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);<BR> };<BR> break;</P> <P> case esriGeometryType.esriGeometryPolygon:<BR> {<BR> symbolname = "Fill Symbols";<BR> mycc.symbol(geoFeatureLayer, symbolname);<BR> this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);<BR> };<BR> break;<BR> }<BR> <BR> }<BR> <BR> }</P> <P>下面是实现上面代码中的symbolc().symbol功能的<BR>class symbolc<BR> {<BR> public void symbol(IGeoFeatureLayer MGeoFeatureLayer,string MFeatureLei)<BR> {<BR> IUniqueValueRenderer PuniqueValueRenderer=null ;<BR> ISymbol Psym=null ;<BR> ITable Ptable=null;<BR> int FieldNumber ;<BR> IQueryFilter PqueryFilter=null ;<BR> ICursor Pcursor=null ;<BR> IRow PnextRow=null ;<BR> IRowBuffer PnextRowBuffer=null ;<BR> object CodeValue=null ;<BR> IStyleGalleryItem PstyleItem=null ;<BR> String PstylePath=null ;<BR> IEnumStyleGalleryItem Pitems=null ;<BR> IStyleGallery PstyleGallery=null ;<BR> IStyleGalleryStorage Pstylstor=null ;</P> <P><BR> //设置只针对Code属性字段进行独特值符号化<BR> PuniqueValueRenderer = new UniqueValueRendererClass();<BR> Ptable = (ITable)MGeoFeatureLayer;<BR> FieldNumber = Ptable.FindField("Code");<BR> PuniqueValueRenderer.FieldCount = 1;<BR> PuniqueValueRenderer.set_Field(0,"Code");</P> <P><BR> PstyleGallery = new ServerStyleGalleryClass();<BR> Pstylstor = (IStyleGalleryStorage)PstyleGallery;<BR> PstylePath = @"D:\Program Files\ArcGIS\Styles\my\gisdefault.ServerStyle";<BR> Pstylstor.AddFile(PstylePath);<BR> <BR> <BR> //对属性字段进行过滤<BR> PqueryFilter = new QueryFilter();<BR> PqueryFilter.AddField("Code");<BR> Pcursor = Ptable.Search(PqueryFilter,true);</P> <P> //对每个要素进行循环符号化<BR> PnextRow = Pcursor.NextRow();</P> <P><BR> while (PnextRow != null)<BR> {<BR> PnextRowBuffer = PnextRow;<BR> CodeValue = PnextRowBuffer.get_Value(FieldNumber);</P> <P> Pitems = PstyleGallery.get_Items(MFeatureLei, PstylePath, (string)CodeValue);<BR> PstyleItem = Pitems.Next();<BR> Psym = (ISymbol)PstyleItem.Item;<BR> PuniqueValueRenderer.AddValue((string)CodeValue, (string)CodeValue, Psym);<BR> PnextRow = Pcursor.NextRow();<BR> <BR> }<BR> }<BR> }</P> |
|
|
1楼#
发布于:2008-01-28 09:23
自己顶一下
|
|
|