zoukankan      html  css  js  c++  java
  • AE指定字段转成注记【2】

    AE指定字段转成注记【2】
    08-06-13 08:33:33 作者:xbt746 出处:xbt746.cnblogs.com

       private bool ConvertToAnnotateByFeature(ILayer pLayer,int fieldnum,ref IAnnotationLayer pAnnoLayer)
            
    {
                IFeatureLayer pFeatlayer 
    = pLayer as IFeatureLayer;
                
    if (pFeatlayer == null)
                    
    return false;
                IFeatureClass pFeatClass 
    = pFeatlayer.FeatureClass;
                IFeatureCursor pFeatCursor 
    = pFeatClass.Search(nullfalse);
                IFeature pFeat 
    = pFeatCursor.NextFeature();

                IFeatureLayer pAnnoFeatLayer
    =pAnnoLayer as IFeatureLayer;
                IAnnotationClassExtension pAnnotateExten 
    = pAnnoFeatLayer.FeatureClass.Extension as IAnnotationClassExtension;
                ISymbol pSymbol 
    = pAnnotateExten.SymbolCollection.get_Symbol(0);
                IGeometry pGeo;
                
    double angle = 0;
                IRgbColor pRGB
    =new RgbColorClass();
                pRGB.Blue
    =255;
                pRGB.Green
    =255;
                pRGB.Red
    =0;
                
    /////判断是不是公路层的Width,特殊处理/////
                string temp_layername = pLayer.Name.ToUpper();
                
    bool bwidth=false;
                
    if(pFeatClass.Fields.get_Field(fieldnum).Name.ToUpper()=="WIDTH")
                
    {
                    
    if (pLayer.Name.ToUpper().Contains("LRDL"))
                        bwidth 
    = true;
                }
       
                IElementCollection pElementColl 
    = new ElementCollectionClass();
                pAnnoLayer.BeginAddElements();
                
    while(pFeat!=null)
                
    {
                    pGeo 
    = pFeat.Shape;
                    IPoint pLabelPoint 
    = null;
                    
    if(pGeo is IPolyline)
                    
    {
                        IPolyline pline
    =pGeo as IPolyline;
                        pLabelPoint 
    = GetLabelPoint(pline);
                    }

                    
    if(pGeo is IPoint)
                    
    {
                        pLabelPoint 
    = pGeo as IPoint;
                    }

                    
    if(pGeo is IPolygon)
                    
    {
                        IPolygon pPolygon 
    = pGeo as IPolygon;
                        IArea pArea 
    = pPolygon as IArea;
                        pLabelPoint 
    = pArea.LabelPoint;
                    }

                    
    object val=pFeat.get_Value(fieldnum);
                    
    string s=val.ToString();
                    
    if (s == null || s.Length == 0)
                    
    {
                        pFeat 
    = pFeatCursor.NextFeature();
                        
    continue;
                    }

                    
    ///对公路的宽度进行特殊处理
                    if(bwidth)
                    
    {
                        
                        
    double width = double.Parse(s);
                        
    int rtegnum = pFeatClass.FindField("RTEG");
                        
    string rteg = pFeat.get_Value(rtegnum).ToString();
                        
    if(rteg=="高速"&&width>55.0)
                        
    {
                            IElement pElement 
    = MakeTextElement(pGeo, angle, s, pRGB, pSymbol);
                            pElementColl.Add(pElement, pFeat.OID);
                        }

                        
    else if(width>40.0)
                        
    {
                            IElement pElement 
    = MakeTextElement(pGeo, angle, s, pRGB, pSymbol);
                            pElementColl.Add(pElement, pFeat.OID);
                        }

                    }

                    
    else if (/*pLabelPoint != null&&*/s.Length>0)
                    
    {
                        IElement pElement 
    = MakeTextElement(pGeo, angle, s, pRGB,pSymbol);                    
                        pElementColl.Add(pElement, pFeat.OID);
                    }

                    pFeat 
    = pFeatCursor.NextFeature();
                }

                pAnnoLayer.EndAddElements();
                pAnnoLayer.BeginAddElements();
                
    if(pElementColl.Count<1)
                
    {
                    pAnnoLayer.EndAddElements();
                    
    return true;
                }

                pAnnoLayer.DoAddElements(pElementColl, 
    0);
             
    /*   pAnnoLayer.SetupAttributeConversion()*/
                pAnnoLayer.EndAddElements();
                
    return true;
            }
  • 相关阅读:
    java——注解Annotation
    java——maven
    sklearn——回归评估指标
    java——单例模式
    java——极简handler机制
    java——为什么要有接口?和抽象类有什么不一样?
    java——cmd命令编译带包名的源程序
    [loj 2478][luogu P4843]「九省联考 2018」林克卡特树
    「线性基」学习小结
    FOI 冬令营 Day6
  • 原文地址:https://www.cnblogs.com/lauer0246/p/1231141.html
Copyright © 2011-2022 走看看