JavaGis

          JavaGis大草原

           

          克隆一個IFeatureLayer

          IFeatureLayerPtr CMapControlView::CloneFeatureLayer(IFeatureLayerPtr aFeatureLayer,CString strLayerName)
          {
          ?IFeatureLayerPtr pFeatureLayer;
          ?IGeoFeatureLayerPtr pGeoLayer;
          ?IFeatureRendererPtr pFRender;
          ?IUIDPtr pUID,pUID2;
          ?IAnnotateLayerPropertiesCollectionPtr pAnnotateLayerPropertiesCollection;
          ?VARIANT_BOOL pDisplayAnnotation,pSelectable,pScale,pVisible,pShow,pCached;
          ?IUniqueValueRendererPtr pURen;
          ?ISimpleRendererPtr pSRen;
          ?ISymbolPtr pSym;
          ?BOOL blnUVR;
          ?BSTR pDSType,pFieldName;
          ?IFeatureIDSetPtr pFeatureIDSet;
          ?IFeatureClassPtr pFeatureClass;
          ?double pMinScale,pMaxScale;
          ?try
          ?{
          ?? //get all
          ?? pGeoLayer = (IGeoFeatureLayerPtr)aFeatureLayer;
          ?? pGeoLayer->get_Renderer(&pFRender);
          ?? pURen = pFRender;
          ?? blnUVR = TRUE;
          ?? if (pURen == NULL)
          ?? {
          ? ??pSRen = pFRender;
          ???blnUVR = FALSE;
          ?? }
          ?? if(blnUVR)
          ?? {
          ???pURen->get_DefaultSymbol(&pSym);
          ?? }
          ?? else
          ?? {
          ???pSRen->get_Symbol(&pSym);
          ?? }
          ??
          ?? pGeoLayer->get_RendererPropertyPageClassID(&pUID2);
          ?? pGeoLayer->get_DisplayAnnotation(&pDisplayAnnotation);
          ?? pGeoLayer->get_AnnotationPropertiesID(&pUID);
          ?? pGeoLayer->get_AnnotationProperties(&pAnnotateLayerPropertiesCollection);
          ?? pGeoLayer->get_ExclusionSet(&pFeatureIDSet);
          ?? pGeoLayer->get_FeatureClass(&pFeatureClass);
          ?? pGeoLayer->get_DataSourceType(&pDSType);
          ?? pGeoLayer->get_DisplayField(&pFieldName);
          ?? pGeoLayer->get_Selectable(&pSelectable);
          ?? pGeoLayer->get_ScaleSymbols(&pScale);
          ?? pGeoLayer->get_MinimumScale(&pMinScale);
          ?? pGeoLayer->get_MaximumScale(&pMaxScale);
          ?? pGeoLayer->get_Visible(&pVisible);
          ?? pGeoLayer->get_ShowTips(&pShow);
          ?? pGeoLayer->get_Cached(&pCached);
          ?? ILayerEffectsPtr pLayerEffects;
          ?? pLayerEffects = pGeoLayer;
          ?? short pTransparency;
          ?? pLayerEffects->get_Transparency(&pTransparency);
          ??
          ?? //set all
          ?? pFeatureLayer.CreateInstance(CLSID_FeatureLayer);
          ?? pGeoLayer = (IGeoFeatureLayerPtr)pFeatureLayer;
          ?? IClonePtr pClone1,pClone2;
          ?? pClone1 = pSym;
          ?? pClone1->Clone(&pClone2);
          ?? pSym = pClone2;
          ?? if(blnUVR)
          ?? {
          ??? pURen.CreateInstance(CLSID_UniqueValueRenderer);??
          ??? pURen->put_DefaultSymbol(pSym);
          ??? pFRender = pURen;
          ?? }
          ?? else
          ?? {
          ??? pSRen.CreateInstance(CLSID_SimpleRenderer);?
          ??? pSRen->putref_Symbol(pSym);
          ??? pFRender = pSRen;
          ?? }
          ?? pGeoLayer->putref_Renderer(pFRender);
          ?? //pGeoLayer->put_RendererPropertyPageClassID(pUID2);
          ?? pGeoLayer->put_DisplayAnnotation(pDisplayAnnotation);
          ?? pGeoLayer->putref_AnnotationPropertiesID(pUID);
          ?? pGeoLayer->put_AnnotationProperties(pAnnotateLayerPropertiesCollection);
          ?? pGeoLayer->putref_ExclusionSet(pFeatureIDSet);
          ?? pGeoLayer->putref_FeatureClass(pFeatureClass);
          ?? pGeoLayer->put_DataSourceType(pDSType);
          ?? pGeoLayer->put_DisplayField(pFieldName);
          ?? pGeoLayer->put_Selectable(pSelectable);
          ?? pGeoLayer->put_ScaleSymbols(pScale);
          ?? pGeoLayer->put_Name(_bstr_t(strLayerName));
          ?? pGeoLayer->put_MinimumScale(pMinScale);
          ?? pGeoLayer->put_MaximumScale(pMaxScale);
          ?? pGeoLayer->put_Visible(pVisible);
          ?? pGeoLayer->put_ShowTips(pShow);
          ?? pGeoLayer->put_Cached(pCached);
          ?? pLayerEffects = pGeoLayer;
          ?? pLayerEffects->put_Transparency(pTransparency);

          ?? IDataLayerPtr pDLayer = pGeoLayer;
          ?? INamePtr pName;
          ?? pDLayer->get_DataSourceName(&pName);
          ????? IDatasetNamePtr pDSName = pName;
          ????? BSTR pFCName;
          ????? pDSName->get_Name(&pFCName);
          ????? CString strName = pFCName;

          ?? CString pDataSourceName = "";
          ?? int N;
          ?? while(strName.Find(".") != -1)
          ?? {
          ??? N = strName.Find(".");
          ??? pDataSourceName = pDataSourceName+strName.Left(N)+'.';
          ??? strName = strName.Right(strName.GetLength()-N-1);
          ?? }

          ?? strName = pDataSourceName+strLayerName;
          ?? pDSName->put_Name(_bstr_t(strName));
          ?? pDLayer->put_DataSourceName((INamePtr)pDSName);

          ?? return pFeatureLayer;
          ?}
          ?catch(...)
          ?{
          ??return NULL;
          ?}
          }

          posted on 2006-09-10 11:15 zdygis 閱讀(678) 評論(0)  編輯  收藏 所屬分類: ArcGis

          導航

          統計

          常用鏈接

          留言簿(1)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          Gis世界

          Java天空

          Oracle海洋

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 巴塘县| 吉木萨尔县| 道真| 南投市| 湾仔区| 墨竹工卡县| 二连浩特市| 赞皇县| 靖边县| 锡林郭勒盟| 深水埗区| 颍上县| 班玛县| 乌兰察布市| 龙海市| 柞水县| 思茅市| 北辰区| 焦作市| 蕉岭县| 庆阳市| 兴业县| 荥经县| 齐河县| 南昌县| 斗六市| 青川县| 安远县| 邮箱| 东兰县| 金湖县| 融水| 岳阳市| 出国| 大余县| 阆中市| 紫阳县| 海林市| 大悟县| 美姑县| 象州县|