• 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;
            }
  • 相关阅读:
    当你发现前端传过来的空格是 xa0
    反转义——使从文件读取的失效的转义字符串生效
    openpyxl 读取前端传输的文件,并处理
    django实现下载excel
    IO模块的使用
    pandas 执行sql语句
    近期工作生活小总结
    入职一个月++近期学习++生活总结
    github访问不了
    实现Spring框架(二) SpringMVC框架
  • 原文地址:https://www.cnblogs.com/lauer0246/p/1231141.html
Copyright © 2020-2023  润新知