默认头像
路人甲
路人甲
  • 注册日期2005-12-25
  • 发帖数31
  • QQ
  • 铜币122枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1714回复:1

请教:VC+A0用UniqueValueRenderer给美国各州填充颜色代码出错?

楼主#
更多 发布于:2007-04-29 19:46
void CGrapeSysView::OnUniquerender()
{

IActiveViewPtr pActiveView(m_ipMap);
const CString strNameFiled="STATE_NAME";
ILayerPtr ilyr;
IGeoFeatureLayerPtr pGeoLayer;
pGeoLayer=ilyr;
IUniqueValueRendererPtr pUniqueValueRenderer(CLSID_UniqueValueRenderer);
IColorPtr pColor;
IColorPtr pNextUniqueColor;
IEnumColorsPtr pEnumRamp;
ITablePtr pTable;
long fieldNumber;
IRowPtr pNextRow;
IRowBufferPtr pNextRowBuffer;
ICursorPtr pCursor;
IQueryFilterPtr pQueryFilter(CLSID_QueryFilter);
VARIANT codeValue;
VariantInit(;codeValue);
codeValue.vt=VT_BSTR;
pTable=pGeoLayer;
pTable->FindField(_bstr_t(strNameFiled),;fieldNumber);
ASSERT(fieldNumber!=-1);
pUniqueValueRenderer->put_FieldCount(1);
pUniqueValueRenderer->put_Field(0,_bstr_t(strNameFiled));
IRandomColorRampPtr pColorRamp(CLSID_RandomColorRamp);
pColorRamp->put_StartHue(0);
pColorRamp->put_EndHue(360);
pColorRamp->put_MinValue(99);
pColorRamp->put_MinSaturation(15);
pColorRamp->put_MaxValue(100);
pColorRamp->put_MaxSaturation(30);
pColorRamp->put_Size(100);
VARIANT_BOOL bok;
pColorRamp->CreateRamp(;bok);
pColorRamp->get_Colors(;pEnumRamp);
pNextUniqueColor=NULL;
pQueryFilter->AddField(_bstr_t(strNameFiled));
pTable->Search(pQueryFilter,TRUE,;pCursor);
pCursor->NextRow(;pNextRow);
while (pNextRow) {
 pNextRowBuffer=pNextRow;
 pNextRowBuffer->get_Value(fieldNumber,;codeValue);
 pEnumRamp->Next(;pNextUniqueColor);
 if (pNextUniqueColor=NULL) {
  pEnumRamp->Reset();
  pEnumRamp->Next(;pNextUniqueColor);
 }
 ISimpleFillSymbolPtr pFillSym(CLSID_SimpleFillSymbol);
 ISymbolPtr pSym;
 pFillSym->put_Color(pNextUniqueColor);
 pSym=pFillSym;
 pUniqueValueRenderer->AddValue(codeValue.bstrVal,codeValue.bstrVal,pSym);
 pCursor->NextRow(;pNextRow);
}
IFeatureRendererPtr pFeatrenderer;
pFeatrenderer=pUniqueValueRenderer;
pGeoLayer->putref_Renderer(pFeatrenderer);

pActiveView->Refresh();   // 调试运行后, 到这里出错,不知道是怎么会事情

}

我用的是9.0的
喜欢0 评分0
默认头像
路人甲
路人甲
  • 注册日期2006-12-31
  • 发帖数4
  • QQ
  • 铜币130枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2007-08-31 20:04
 IMapPtr pMap;
m_ipMap->get_Map(;pMap);

IActiveViewPtr pActiveView;
pActiveView = pMap;

.......

pActiveView->Refresh();

举报 回复(0) 喜欢(0)     评分
默认头像

返回顶部