阅读:1962回复:3
c#,分类渲染,IClassBreaksRenderer,报错,内有代码
<P>public static void Render(IFeatureLayer Layer, string FiledName)<BR> {</P>
<P> ITable pTable ; <BR> IClassify pClassify ; <BR> ITableHistogram pTableHistogram ; <BR> IHistogram pHistogram ; <BR> object dataFrequency ; <BR> object dataValues ; <BR> IGeoFeatureLayer pGeoFeatureLayer = Layer as IGeoFeatureLayer; <BR> pTable = pGeoFeatureLayer as ITable;<BR> pTableHistogram = new TableHistogram() as ITableHistogram;<BR> pHistogram = pTableHistogram as IHistogram;</P> <P> pTableHistogram.Field = FiledName;<BR> pTableHistogram.Table = pTable;<BR> pHistogram.GetHistogram(out dataValues, out dataFrequency);</P> <P> pClassify = new EqualInterval() as IClassify;<BR> pClassify.SetHistogramData(dataValues, dataFrequency);</P> <P> Double[] Classes ; <BR> long ClassesCount ; <BR> int numDesiredClasses = 9; <BR> pClassify.Classify(ref numDesiredClasses); <BR> Classes = pClassify.ClassBreaks as double[];<BR> ClassesCount = Classes.Length;</P> <P> IClassBreaksRenderer pClassBreaksRenderer ; </P> <P> pClassBreaksRenderer = new ClassBreaksRenderer();<BR> pClassBreaksRenderer.Field = FiledName;<BR> pClassBreaksRenderer.BreakCount = (int)ClassesCount;<BR> pClassBreaksRenderer.SortClassesAscending = true;<BR> <BR> IColor pFromColor = new RgbColor();<BR> pFromColor.RGB = 255;</P> <P> IColor pToColor ; <BR> pToColor = new RgbColor();<BR> pToColor.RGB = 200;</P> <P> IAlgorithmicColorRamp pRamp ; <BR> IEnumColors pEnumColors ; <BR> bool ok ;</P> <P> pRamp = new AlgorithmicColorRamp();<BR> pRamp.Algorithm = ESRI.ArcGIS.Display.esriColorRampAlgorithm.esriHSVAlgorithm;<BR> pRamp.FromColor = pFromColor;<BR> pRamp.ToColor = pToColor;<BR> pRamp.Size = (int)ClassesCount;<BR> pRamp.CreateRamp(out ok);<BR> pEnumColors = pRamp.Colors;</P> <P> IColor pColor ; <BR> ISimpleFillSymbol pFillSymbol ; <BR> long breakIndex ;</P> <P> for( breakIndex = 0 ; breakIndex < ClassesCount;breakIndex++)<BR> {</P> <P> pColor = pEnumColors.Next();<BR> pFillSymbol = new SimpleFillSymbol();<BR> pFillSymbol.Color = pColor;<BR> pClassBreaksRenderer.set_Symbol((int)breakIndex, pFillSymbol as ISymbol);<BR> double d =Classes[breakIndex];<BR> pClassBreaksRenderer.set_Break((int)breakIndex,d);</P> <P> }</P> <P> pGeoFeatureLayer.Renderer = pClassBreaksRenderer as IFeatureRenderer;<BR> }<BR> </P> <P> public static void SetLabel(IFeatureLayer pFeatureLayer,string FieldName) <BR> { <BR> IGeoFeatureLayer pLayer = pFeatureLayer as IGeoFeatureLayer; <BR> pLayer.DisplayField = "YaLi"; <BR> pLayer.ShowTips = true ;<BR> IRgbColor pColorFont = new RgbColor();<BR> pColorFont.Red = 255; <BR> pColorFont.Green = 100;<BR> pColorFont.Blue = 100;<BR> IFormattedTextSymbol pText ; <BR> pText = new TextSymbol() ;<BR> pText.Color = pColorFont ;<BR> IAnnotateLayerPropertiesCollection pAnnoPropsCollection = new AnnotateLayerPropertiesCollection ();<BR> pAnnoPropsCollection.Clear();<BR> ILabelEngineLayerProperties pLabelEngine = new LabelEngineLayerProperties() as ILabelEngineLayerProperties;<BR> pLabelEngine.Expression = "["+FieldName+"]";<BR> pLabelEngine.Symbol = pText ;<BR> IAnnotateLayerProperties pAnnoLayerProps = pLabelEngine as IAnnotateLayerProperties;<BR> // pAnnoLayerProps.WhereClause = "(YaLi > 0)" ;<BR> pAnnoPropsCollection.Add(pAnnoLayerProps);<BR> pLayer.AnnotationProperties = pAnnoPropsCollection ;<BR> pLayer.DisplayAnnotation = true ;</P> <P> } </P> <P>pClassify.Classify(ref numDesiredClasses); </P> <P>Classes = pClassify.ClassBreaks as double[];</P> <P>报错<BR></P> |
|
1楼#
发布于:2006-08-24 20:44
<P>希望高手能够进来看看这个 帮忙解决 我也正在做有关这个的现在~~~~~~~~~~~~</P>
|
|
2楼#
发布于:2006-09-01 11:47
帮助里有一个VB的 不知道你看过没呢??
|
|
3楼#
发布于:2006-09-15 14:31
<P>.NET不支持IClassify,改为IClassifyGEN即可!</P>
<P><a href="mailtmawzh@tom.com" target="_blank" >mawzh@tom.com</A></P> |
|