如何利用C#开发GIS
展开全部
///
/// 单值渲染(单字段)
///
/// 图层名
/// 渲染字段
/// 填充式
/// 字段唯值数
public void createUniqueValueRander(string layerName, string RenderField, esriSimpleFillStyle FillStyle,int valueCount)
{
IGeoFeatureLayer geoFeatureLayer;
geoFeatureLayer = getGeoLayer(layerName); IUniqueValueRenderer uniqueValueRenderer = new UniqueValueRendererClass();
//设置字段
uniqueValueRenderer.FieldCount = 1;//0-3
uniqueValueRenderer.set_Field(0, RenderField);
//简单填充符号
ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
simpleFillSymbol.Style = FillStyle;
IFeatureCursor featureCursor = geoFeatureLayer.FeatureClass.Search(null, false);
IFeature feature;
if (featureCursor != null)
{
IEnumColors enumColors = CreateAlgorithmicColorRamp(valueCount).Colors;
int fieldIndex = geoFeatureLayer.FeatureClass.Fields.FindField(RenderField);
for (int i = 0; i < valueCount; i++)
{
feature = featureCursor.NextFeature();
string nameValue = feature.get_Value(fieldIndex).ToString();
simpleFillSymbol = new SimpleFillSymbolClass();
simpleFillSymbol.Color = enumColors.Next();
uniqueValueRenderer.AddValue(nameValue, RenderField, simpleFillSymbol as ISymbol);
}
}
geoFeatureLayer.Renderer = uniqueValueRenderer as IFeatureRenderer;
}
试试
bar(foo( ));
/// 单值渲染(单字段)
///
/// 图层名
/// 渲染字段
/// 填充式
/// 字段唯值数
public void createUniqueValueRander(string layerName, string RenderField, esriSimpleFillStyle FillStyle,int valueCount)
{
IGeoFeatureLayer geoFeatureLayer;
geoFeatureLayer = getGeoLayer(layerName); IUniqueValueRenderer uniqueValueRenderer = new UniqueValueRendererClass();
//设置字段
uniqueValueRenderer.FieldCount = 1;//0-3
uniqueValueRenderer.set_Field(0, RenderField);
//简单填充符号
ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
simpleFillSymbol.Style = FillStyle;
IFeatureCursor featureCursor = geoFeatureLayer.FeatureClass.Search(null, false);
IFeature feature;
if (featureCursor != null)
{
IEnumColors enumColors = CreateAlgorithmicColorRamp(valueCount).Colors;
int fieldIndex = geoFeatureLayer.FeatureClass.Fields.FindField(RenderField);
for (int i = 0; i < valueCount; i++)
{
feature = featureCursor.NextFeature();
string nameValue = feature.get_Value(fieldIndex).ToString();
simpleFillSymbol = new SimpleFillSymbolClass();
simpleFillSymbol.Color = enumColors.Next();
uniqueValueRenderer.AddValue(nameValue, RenderField, simpleFillSymbol as ISymbol);
}
}
geoFeatureLayer.Renderer = uniqueValueRenderer as IFeatureRenderer;
}
试试
bar(foo( ));
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询