//对行政略图中的面图层进行唯一值渲染
ipFeaClass = ipTmpFeaCls;
ipGeoFeaLayer = ipTmpGeoFeaLayer;
IQueryFilterPtr ipQueryFilter(__uuidof(QueryFilter));
IFeatureCursorPtr ipcursor;
ipFeaClass->Search(ipQueryFilter, false, &ipcursor);
ISimpleFillSymbolPtr ipsymbol(CLSID_SimpleFillSymbol);
//随机颜色
IRandomColorRampPtr iprx(CLSID_RandomColorRamp);
iprx->put_MinSaturation(20);
iprx->put_MaxSaturation(40);
iprx->put_MinValue(76);
iprx->put_MaxValue(188);
iprx->put_StartHue(0);
iprx->put_EndHue(360);
iprx->put_Size(100);
VARIANT_BOOL btrue = true;
iprx->CreateRamp(&btrue);
IEnumColorsPtr ipnumcolors;
iprx->get_Colors(&ipnumcolors);
if(ipnumcolors == NULL)
return;
ipnumcolors->Reset();
IUniqueValueRendererPtr ipuniqueRnd;
IFeatureRendererPtr ipRnd;
if((ipuniqueRnd = ipRnd) == NULL)
{
hr = ipuniqueRnd.CreateInstance(CLSID_UniqueValueRenderer);
if(FAILED(hr))
return;
ipRnd = ipuniqueRnd;
}
CString fname = _T("FNAME");
BSTR fieldname = fname.AllocSysString();
ipuniqueRnd->put_FieldCount(1);
ipuniqueRnd->put_Field(0, fieldname);
//遍历
IFeaturePtr ipfeat;
ipcursor->NextFeature(&ipfeat);
IFieldsPtr ifields;
long index;
ipfeat->get_Fields(&ifields);
ifields->FindField(fieldname, &index);
ISimpleLineSymbolPtr ipline(CLSID_SimpleLineSymbol);
ipline->put_Width(0.01);
while(ipfeat != NULL)
{
ISimpleFillSymbolPtr ipsymbol(CLSID_SimpleFillSymbol);
IColorPtr ipcolor2;
ipnumcolors->Next(&ipcolor2);
ipsymbol->put_Color(ipcolor2);
ipsymbol->put_Outline(ipline);
VARIANT valuevar;
ipfeat->get_Value(index, &valuevar);
CString valuestr(valuevar);
BSTR valuebstr = valuestr.AllocSysString();
ipuniqueRnd->AddValue(valuebstr, valuebstr, (ISymbolPtr)ipsymbol);
ipcursor->NextFeature(&ipfeat);
}
ipRnd = (IFeatureRendererPtr)ipuniqueRnd;
ipGeoFeaLayer->putref_Renderer(ipRnd);AO+C++实现唯一值渲染
最新推荐文章于 2022-04-25 18:36:18 发布
本文详细介绍了如何使用特定代码片段对行政略图中的面图层进行唯一值渲染,包括初始化类、设置颜色范围、创建渲染器等关键步骤。
1203

被折叠的 条评论
为什么被折叠?



