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海洋

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 云阳县| 陕西省| 辉南县| 东源县| 南昌市| 盐源县| 和顺县| 云霄县| 安泽县| 自治县| 澎湖县| 巴林左旗| 大连市| 南康市| 辽阳市| 介休市| 汉阴县| 桐梓县| 通许县| 广德县| 阿图什市| 顺平县| 大方县| 莱阳市| 台湾省| 楚雄市| 五原县| 中江县| 肥西县| 喀什市| 大洼县| 利津县| 民乐县| 逊克县| 慈利县| 凤冈县| 册亨县| 韩城市| 合江县| 九龙县| 怀化市|