Esempio n. 1
0
        // Methods
        public static IFeatureClass CreateAnnoFeatureClass(string string_0, IFeatureDataset ifeatureDataset_0,
                                                           double double_0)
        {
            IObjectClassDescription  description  = new AnnotationFeatureClassDescription();
            IFeatureClassDescription description2 = (IFeatureClassDescription)description;
            IFields requiredFields               = description.RequiredFields;
            IFeatureWorkspaceAnno workspace      = (IFeatureWorkspaceAnno)ifeatureDataset_0.Workspace;
            IGraphicsLayerScale   referenceScale = new GraphicsLayerScale
            {
                ReferenceScale = double_0,
                Units          = esriUnits.esriMeters
            };
            UID instanceCLSID                  = description.InstanceCLSID;
            UID classExtensionCLSID            = description.ClassExtensionCLSID;
            ISymbolCollection symbolCollection = new SymbolCollection();

            symbolCollection.set_Symbol(0, (ISymbol)MakeTextSymbol("宋体", 3.0));
            symbolCollection.set_Symbol(1, (ISymbol)MakeTextSymbol("宋体", 3.5));
            symbolCollection.set_Symbol(2, (ISymbol)MakeTextSymbol("宋体", 3.0));
            symbolCollection.set_Symbol(3, (ISymbol)MakeTextSymbol("宋体", 2.5));
            symbolCollection.set_Symbol(4, (ISymbol)MakeTextSymbol("黑体", 2.0));
            symbolCollection.set_Symbol(5, (ISymbol)MakeTextSymbol("黑体", 1.5));
            symbolCollection.set_Symbol(6, (ISymbol)MakeTextSymbol("宋体", 1.0));
            symbolCollection.set_Symbol(7, (ISymbol)MakeTextSymbol("宋体", 0.4));
            symbolCollection.set_Symbol(8, (ISymbol)MakeTextSymbol("宋体", 0.3));
            symbolCollection.set_Symbol(9, (ISymbol)MakeTextSymbol("黑体", 1.0));
            symbolCollection.set_Symbol(10, (ISymbol)MakeTextSymbol("宋体", 0.5));
            symbolCollection.set_Symbol(11, (ISymbol)MakeTextSymbol("宋体", 0.6));
            symbolCollection.set_Symbol(12, (ISymbol)MakeTextSymbol("宋体", 0.7));
            symbolCollection.set_Symbol(13, (ISymbol)MakeTextSymbol("宋体", 0.8));
            symbolCollection.set_Symbol(14, (ISymbol)MakeTextSymbol("宋体", 0.9));
            symbolCollection.set_Symbol(15, (ISymbol)MakeTextSymbol("宋体", 1.2));
            return(workspace.CreateAnnotationClass(string_0, requiredFields, instanceCLSID, classExtensionCLSID,
                                                   description2.ShapeFieldName, "", ifeatureDataset_0, null, null, referenceScale, symbolCollection, true));
        }
Esempio n. 2
0
        private IFeatureClass method_2(IFeatureWorkspaceAnno ifeatureWorkspaceAnno_0, IFeatureDataset ifeatureDataset_0,
                                       IFeatureClass ifeatureClass_0, double double_1, esriUnits esriUnits_0,
                                       IAnnotateLayerPropertiesCollection iannotateLayerPropertiesCollection_0,
                                       ISymbolCollection isymbolCollection_0, string string_0)
        {
            IObjectClassDescription description = new AnnotationFeatureClassDescriptionClass();
            IFields requiredFields = description.RequiredFields;
            int     index          = requiredFields.FindField((description as IFeatureClassDescription).ShapeFieldName);

            if (index != -1)
            {
                IField            field            = requiredFields.get_Field(index);
                IGeometryDef      geometryDef      = field.GeometryDef;
                ISpatialReference spatialReference = geometryDef.SpatialReference;
                SpatialReferenctOperator.ChangeCoordinateSystem(ifeatureWorkspaceAnno_0 as IGeodatabaseRelease,
                                                                spatialReference, false);
                (geometryDef as IGeometryDefEdit).SpatialReference_2 = spatialReference;
                (field as IFieldEdit).GeometryDef_2 = geometryDef;
            }
            IFeatureClassDescription description2   = description as IFeatureClassDescription;
            IGraphicsLayerScale      referenceScale = new GraphicsLayerScaleClass
            {
                ReferenceScale = double_1,
                Units          = esriUnits_0
            };
            UID instanceCLSID       = description.InstanceCLSID;
            UID classExtensionCLSID = description.ClassExtensionCLSID;

            return(ifeatureWorkspaceAnno_0.CreateAnnotationClass(string_0, requiredFields, instanceCLSID,
                                                                 classExtensionCLSID, description2.ShapeFieldName, "", ifeatureDataset_0, ifeatureClass_0,
                                                                 iannotateLayerPropertiesCollection_0, referenceScale, isymbolCollection_0, true));
        }
Esempio n. 3
0
        /// <summary>
        /// 创建标注
        /// </summary>
        /// <param name="feaName"></param>
        /// <param name="featureDataset"></param>
        /// <param name="feaworkspace"></param>
        /// <param name="fsEditAnno"></param>
        /// <param name="intScale"></param>
        public void createAnnoFeatureClass(string feaName, IFeatureDataset featureDataset, IFeatureWorkspace feaworkspace, IFieldsEdit fsEditAnno, int intScale)
        {
            //创建注记的特殊字段
            try
            {
                //注记的workSpace
                IFeatureWorkspaceAnno pFWSAnno = feaworkspace as IFeatureWorkspaceAnno; //标注操作空间

                IGraphicsLayerScale pGLS = new GraphicsLayerScaleClass();               //图形比例接口
                pGLS.Units          = esriUnits.esriMeters;                             //图形比例设定
                pGLS.ReferenceScale = Convert.ToDouble(intScale);                       //创建注记必须要设置比例尺

                IFormattedTextSymbol myTextSymbol = new TextSymbolClass();              //文本格式接口
                ISymbol pSymbol = (ISymbol)myTextSymbol;                                //标记
                //Anno要素类必须有的缺省符号
                ISymbolCollection2 pSymbolColl = new SymbolCollectionClass();
                ISymbolIdentifier2 pSymID      = new SymbolIdentifierClass();
                pSymbolColl.AddSymbol(pSymbol, "Default", out pSymID);

                //Anno要素类的必要属性
                IAnnotateLayerProperties pAnnoProps = new LabelEngineLayerPropertiesClass();
                pAnnoProps.CreateUnplacedElements = true;
                pAnnoProps.CreateUnplacedElements = true;
                pAnnoProps.DisplayAnnotation      = true;
                pAnnoProps.UseOutput = true;

                ILabelEngineLayerProperties pLELayerProps = (ILabelEngineLayerProperties)pAnnoProps;
                pLELayerProps.Symbol             = pSymbol as ITextSymbol;
                pLELayerProps.SymbolID           = 0;
                pLELayerProps.IsExpressionSimple = true;
                pLELayerProps.Offset             = 0;
                pLELayerProps.SymbolID           = 0;

                IAnnotationExpressionEngine aAnnoVBScriptEngine = new AnnotationVBScriptEngineClass();
                pLELayerProps.ExpressionParser = aAnnoVBScriptEngine;
                pLELayerProps.Expression       = "[DESCRIPTION]";
                IAnnotateLayerTransformationProperties pATP = (IAnnotateLayerTransformationProperties)pAnnoProps;
                pATP.ReferenceScale = pGLS.ReferenceScale;
                pATP.ScaleRatio     = 1;

                IAnnotateLayerPropertiesCollection pAnnoPropsColl = new AnnotateLayerPropertiesCollectionClass();
                pAnnoPropsColl.Add(pAnnoProps);

                IObjectClassDescription pOCDesc = new AnnotationFeatureClassDescription();
                IFields fields = pOCDesc.RequiredFields;
                IFeatureClassDescription pFDesc = pOCDesc as IFeatureClassDescription;

                for (int j = 0; j < pOCDesc.RequiredFields.FieldCount; j++)
                {
                    fsEditAnno.AddField(pOCDesc.RequiredFields.get_Field(j));
                }
                fields = fsEditAnno as IFields;
                pFWSAnno.CreateAnnotationClass(feaName, fields, pOCDesc.InstanceCLSID, pOCDesc.ClassExtensionCLSID, pFDesc.ShapeFieldName, "", featureDataset, null, pAnnoPropsColl, pGLS, pSymbolColl, true);
            }
            catch
            {
            }
        }
Esempio n. 4
0
        private IFeatureClass method_1(IFeatureWorkspace ifeatureWorkspace_0, string string_4, double double_0,
                                       ITextSymbol itextSymbol_0, IFields ifields_0)
        {
            IObjectClassDescription  description  = new AnnotationFeatureClassDescriptionClass();
            IFeatureClassDescription description2 = description as IFeatureClassDescription;
            IClone     requiredFields             = description.RequiredFields as IClone;
            IFields    fields = requiredFields.Clone() as IFields;
            IFieldEdit edit   = null;
            int        index  = fields.FindField(description2.ShapeFieldName);

            edit = fields.get_Field(index) as IFieldEdit;
            IGeometryDefEdit      geometryDef    = edit.GeometryDef as IGeometryDefEdit;
            IFeatureWorkspaceAnno anno           = ifeatureWorkspace_0 as IFeatureWorkspaceAnno;
            IGraphicsLayerScale   referenceScale = new GraphicsLayerScaleClass
            {
                ReferenceScale = double_0,
                Units          = esriUnits.esriMeters
            };
            UID instanceCLSID                  = description.InstanceCLSID;
            UID classExtensionCLSID            = description.ClassExtensionCLSID;
            ISymbolCollection symbolCollection = new SymbolCollectionClass();

            symbolCollection.set_Symbol(0, itextSymbol_0 as ISymbol);
            IAnnotateLayerPropertiesCollection2 annoProperties = new AnnotateLayerPropertiesCollectionClass();
            IAnnotateLayerProperties            item           = new LabelEngineLayerPropertiesClass
            {
                Class         = "要素类 1",
                FeatureLinked = false,
                AddUnplacedToGraphicsContainer = false,
                CreateUnplacedElements         = true,
                DisplayAnnotation = true,
                UseOutput         = true
            };
            ILabelEngineLayerProperties properties2 = item as ILabelEngineLayerProperties;

            properties2.Offset   = 0.0;
            properties2.SymbolID = 0;
            properties2.Symbol   = itextSymbol_0;
            annoProperties.Add(item);
            for (int i = 0; i < ifields_0.FieldCount; i++)
            {
                if (fields.FindField(ifields_0.get_Field(i).Name) == -1)
                {
                    (fields as IFieldsEdit).AddField(ifields_0.get_Field(i));
                }
            }
            try
            {
                return(anno.CreateAnnotationClass(string_4, fields, instanceCLSID, classExtensionCLSID,
                                                  description2.ShapeFieldName, "", null, null, annoProperties, referenceScale, symbolCollection, false));
            }
            catch (Exception exception)
            {
                Logger.Current.Error("", exception, "");
            }
            return(null);
        }
Esempio n. 5
0
        private IFeatureClass method_1(string string_0, double double_0, IFields ifields_0,
                                       IFeatureDataset ifeatureDataset_1, IFeatureClass ifeatureClass_0,
                                       IFeatureWorkspaceAnno ifeatureWorkspaceAnno_0, esriUnits esriUnits_0,
                                       IAnnotateLayerPropertiesCollection2 iannotateLayerPropertiesCollection2_0,
                                       ISymbolCollection2 isymbolCollection2_0)
        {
            IObjectClassDescription  description    = new AnnotationFeatureClassDescriptionClass();
            IFeatureClassDescription description2   = description as IFeatureClassDescription;
            IGraphicsLayerScale      referenceScale = new GraphicsLayerScaleClass
            {
                ReferenceScale = double_0,
                Units          = esriUnits_0
            };
            UID instanceCLSID       = description.InstanceCLSID;
            UID classExtensionCLSID = description.ClassExtensionCLSID;

            return(ifeatureWorkspaceAnno_0.CreateAnnotationClass(string_0, ifields_0, instanceCLSID, classExtensionCLSID,
                                                                 description2.ShapeFieldName, "", ifeatureDataset_1, ifeatureClass_0,
                                                                 iannotateLayerPropertiesCollection2_0, referenceScale, isymbolCollection2_0, true));
        }
Esempio n. 6
0
        public static IFeatureClass CreateAnnoFeatureClass(string string_0, IFeatureDataset ifeatureDataset_0,
                                                           double double_0)
        {
            IObjectClassDescription  annotationFeatureClassDescriptionClass = new AnnotationFeatureClassDescription();
            IFeatureClassDescription featureClassDescription =
                (IFeatureClassDescription)annotationFeatureClassDescriptionClass;
            IFields requiredFields          = annotationFeatureClassDescriptionClass.RequiredFields;
            IFeatureWorkspaceAnno workspace = (IFeatureWorkspaceAnno)ifeatureDataset_0.Workspace;
            IGraphicsLayerScale   graphicsLayerScaleClass = new GraphicsLayerScale()
            {
                Units = esriUnits.esriMeters
            };
            UID instanceCLSID       = annotationFeatureClassDescriptionClass.InstanceCLSID;
            UID classExtensionCLSID = annotationFeatureClassDescriptionClass.ClassExtensionCLSID;
            ISymbolCollection symbolCollectionClass = new SymbolCollection();

            symbolCollectionClass.Symbol[0]  = (ISymbol)WorkspaceOperator.MakeTextSymbol("宋体", 3);
            symbolCollectionClass.Symbol[1]  = (ISymbol)WorkspaceOperator.MakeTextSymbol("宋体", 3.5);
            symbolCollectionClass.Symbol[2]  = (ISymbol)WorkspaceOperator.MakeTextSymbol("宋体", 3);
            symbolCollectionClass.Symbol[3]  = (ISymbol)WorkspaceOperator.MakeTextSymbol("宋体", 2.5);
            symbolCollectionClass.Symbol[4]  = (ISymbol)WorkspaceOperator.MakeTextSymbol("黑体", 2);
            symbolCollectionClass.Symbol[5]  = (ISymbol)WorkspaceOperator.MakeTextSymbol("黑体", 1.5);
            symbolCollectionClass.Symbol[6]  = (ISymbol)WorkspaceOperator.MakeTextSymbol("宋体", 1);
            symbolCollectionClass.Symbol[7]  = (ISymbol)WorkspaceOperator.MakeTextSymbol("宋体", 0.4);
            symbolCollectionClass.Symbol[8]  = (ISymbol)WorkspaceOperator.MakeTextSymbol("宋体", 0.3);
            symbolCollectionClass.Symbol[9]  = (ISymbol)WorkspaceOperator.MakeTextSymbol("黑体", 1);
            symbolCollectionClass.Symbol[10] = (ISymbol)WorkspaceOperator.MakeTextSymbol("宋体", 0.5);
            symbolCollectionClass.Symbol[11] = (ISymbol)WorkspaceOperator.MakeTextSymbol("宋体", 0.6);
            symbolCollectionClass.Symbol[12] = (ISymbol)WorkspaceOperator.MakeTextSymbol("宋体", 0.7);
            symbolCollectionClass.Symbol[13] = (ISymbol)WorkspaceOperator.MakeTextSymbol("宋体", 0.8);
            symbolCollectionClass.Symbol[14] = (ISymbol)WorkspaceOperator.MakeTextSymbol("宋体", 0.9);
            symbolCollectionClass.Symbol[15] = (ISymbol)WorkspaceOperator.MakeTextSymbol("宋体", 1.2);
            IFeatureClass featureClass = workspace.CreateAnnotationClass(string_0, requiredFields, instanceCLSID,
                                                                         classExtensionCLSID, featureClassDescription.ShapeFieldName, "", ifeatureDataset_0, null, null,
                                                                         graphicsLayerScaleClass, symbolCollectionClass, true);

            return(featureClass);
        }
Esempio n. 7
0
        public static IFeatureClass CreateAnnoFeatureClass(IFeatureWorkspaceAnno ifeatureWorkspaceAnno_0,
                                                           IFeatureDataset ifeatureDataset_0, IFeatureClass ifeatureClass_0, double double_0, esriUnits esriUnits_0,
                                                           IAnnotateLayerPropertiesCollection iannotateLayerPropertiesCollection_0,
                                                           ISymbolCollection isymbolCollection_0, string string_0)
        {
            IObjectClassDescription annotationFeatureClassDescriptionClass = new AnnotationFeatureClassDescription();
            IFields requiredFields = annotationFeatureClassDescriptionClass.RequiredFields;
            int     num            =
                requiredFields.FindField(
                    (annotationFeatureClassDescriptionClass as IFeatureClassDescription).ShapeFieldName);

            if (num != -1)
            {
                IField            field            = requiredFields.Field[num];
                IGeometryDef      geometryDef      = field.GeometryDef;
                ISpatialReference spatialReference = geometryDef.SpatialReference;
                LayerOp.ChangeCoordinateSystem(ifeatureWorkspaceAnno_0 as IGeodatabaseRelease, spatialReference, false);
                (geometryDef as IGeometryDefEdit).SpatialReference_2 = spatialReference;
                (field as IFieldEdit).GeometryDef_2 = geometryDef;
            }
            IFeatureClassDescription featureClassDescription =
                annotationFeatureClassDescriptionClass as IFeatureClassDescription;
            IGraphicsLayerScale graphicsLayerScaleClass = new GraphicsLayerScale()
            {
                ReferenceScale = double_0,
                Units          = esriUnits_0
            };
            UID           instanceCLSID       = annotationFeatureClassDescriptionClass.InstanceCLSID;
            UID           classExtensionCLSID = annotationFeatureClassDescriptionClass.ClassExtensionCLSID;
            IFeatureClass featureClass        = ifeatureWorkspaceAnno_0.CreateAnnotationClass(string_0, requiredFields,
                                                                                              instanceCLSID, classExtensionCLSID, featureClassDescription.ShapeFieldName, "", ifeatureDataset_0,
                                                                                              ifeatureClass_0, iannotateLayerPropertiesCollection_0, graphicsLayerScaleClass, isymbolCollection_0,
                                                                                              true);

            return(featureClass);
        }
Esempio n. 8
0
        public static IFeatureClass CreateAnnoFeatureClass(string string_0, IFeatureDataset ifeatureDataset_0,
                                                           double double_0, ITextSymbol itextSymbol_0)
        {
            IObjectClassDescription  annotationFeatureClassDescriptionClass = new AnnotationFeatureClassDescription();
            IFeatureClassDescription featureClassDescription =
                annotationFeatureClassDescriptionClass as IFeatureClassDescription;
            IFields field = (annotationFeatureClassDescriptionClass.RequiredFields as IClone).Clone() as IFields;
            IFeatureWorkspaceAnno workspace = ifeatureDataset_0.Workspace as IFeatureWorkspaceAnno;
            IGraphicsLayerScale   graphicsLayerScaleClass = new GraphicsLayerScale()
            {
                ReferenceScale = double_0,
                Units          = esriUnits.esriMeters
            };
            UID instanceCLSID       = annotationFeatureClassDescriptionClass.InstanceCLSID;
            UID classExtensionCLSID = annotationFeatureClassDescriptionClass.ClassExtensionCLSID;
            ISymbolCollection symbolCollectionClass = new SymbolCollection();

            symbolCollectionClass.Symbol[0] = itextSymbol_0 as ISymbol;
            IFeatureClass featureClass = workspace.CreateAnnotationClass(string_0, field, instanceCLSID,
                                                                         classExtensionCLSID, featureClassDescription.ShapeFieldName, "", ifeatureDataset_0, null, null,
                                                                         graphicsLayerScaleClass, symbolCollectionClass, true);

            return(featureClass);
        }
Esempio n. 9
0
        /// <summary>
        /// 创建注记层
        /// </summary>
        /// <param name="strFeaClsName">注记层名称</param>
        /// <param name="destDataset">待创建的注记层所在的featuredataset</param>
        /// <param name="ipInputFields">注记层字段</param>
        public static IFeatureClass CreateAnnotation(IFeatureClass pInputCls, IFeatureDataset destDataset, IFields ipInputFields)
        {
            try
            {
                //要素类标识信息
                IObjectClassDescription  ipObjectClassDesc = new AnnotationFeatureClassDescription();
                IFeatureClassDescription ipFeatClassDesc   = (IFeatureClassDescription)ipObjectClassDesc;


                IAnnoClass pAnnoClass = pInputCls.Extension as IAnnoClass;
                double     scale      = pAnnoClass.ReferenceScale;


                IUID ipCLSID = ipObjectClassDesc.InstanceCLSID;
                ipCLSID.Value = "esriCore.AnnotationFeature";


                IUID ipExtCLSID = ipObjectClassDesc.ClassExtensionCLSID;
                ipExtCLSID.Value = "esriCore.AnnotationFeatureClassExtension";

                //IField ipField;
                IFields     ipFields     = ipObjectClassDesc.RequiredFields;
                IFieldsEdit ipFieldsEdit = (IFieldsEdit)ipFields;
                int         numFields    = ipInputFields.FieldCount;

                esriFieldType type;
                for (int i = 0; i < numFields; i++)
                {
                    IField ipField = ipInputFields.get_Field(i);
                    type = ipField.Type;
                    if (type != esriFieldType.esriFieldTypeOID && type != esriFieldType.esriFieldTypeGeometry)
                    {
                        string fldName  = ipField.Name;
                        int    fldIndex = ipFields.FindField(fldName);

                        if (fldIndex == -1)
                        {
                            ipFieldsEdit.AddField(ipField);
                        }
                    }
                }

                //工作空间
                IWorkspace            ipWorkspace            = destDataset.Workspace;
                IFeatureWorkspaceAnno ipFeatureWorkspaceAnno = (IFeatureWorkspaceAnno)ipWorkspace;


                //显示比例
                IGraphicsLayerScale ipGraphicsLayerScale = new GraphicsLayerScaleClass();
                ipGraphicsLayerScale.ReferenceScale = scale;
                ipGraphicsLayerScale.Units          = pAnnoClass.ReferenceScaleUnits;

                //符号信息
                //' set up symbol collection
                ISymbolCollection pSymbolColl = new SymbolCollectionClass();

                ITextSymbol myTxtSym = new TextSymbolClass();
                //Set the font for myTxtSym
                stdole.IFontDisp myFont = new stdole.StdFontClass() as stdole.IFontDisp;
                IFont            pFt    = (IFont)myFont;
                pFt.Name = "Courier New";

                myTxtSym.Font = myFont;

                // Set the Color for myTxtSym to be Dark Red
                IRgbColor myColor = new RgbColorClass();
                myColor.Red    = 150;
                myColor.Green  = 0;
                myColor.Blue   = 0;
                myTxtSym.Color = myColor;

                // Set other properties for myTxtSym
                myTxtSym.Angle               = 0;
                myTxtSym.RightToLeft         = false;
                myTxtSym.VerticalAlignment   = esriTextVerticalAlignment.esriTVABaseline;
                myTxtSym.HorizontalAlignment = esriTextHorizontalAlignment.esriTHAFull;
                myTxtSym.Size = 9;

                ISymbol pSymbol = (ISymbol)myTxtSym;
                pSymbolColl.set_Symbol(0, pSymbol);


                //set up the annotation labeling properties including the expression
                IAnnotateLayerProperties pAnnoProps = new LabelEngineLayerPropertiesClass();
                pAnnoProps.FeatureLinked = true;
                pAnnoProps.AddUnplacedToGraphicsContainer = false;
                pAnnoProps.CreateUnplacedElements         = true;
                pAnnoProps.DisplayAnnotation = true;
                pAnnoProps.UseOutput         = true;

                ILabelEngineLayerProperties pLELayerProps       = (ILabelEngineLayerProperties)pAnnoProps;
                IAnnotationExpressionEngine aAnnoVBScriptEngine = new AnnotationVBScriptEngineClass();
                pLELayerProps.ExpressionParser   = aAnnoVBScriptEngine;
                pLELayerProps.Expression         = "[DESCRIPTION]";
                pLELayerProps.IsExpressionSimple = true;
                pLELayerProps.Offset             = 0;
                pLELayerProps.SymbolID           = 0;
                pLELayerProps.Symbol             = myTxtSym;

                IAnnotateLayerTransformationProperties pATP = (IAnnotateLayerTransformationProperties)pAnnoProps;
                double dRefScale = ipGraphicsLayerScale.ReferenceScale;
                pATP.ReferenceScale = dRefScale;
                pATP.Units          = esriUnits.esriMeters;
                pATP.ScaleRatio     = 1;

                IAnnotateLayerPropertiesCollection pAnnoPropsColl = new AnnotateLayerPropertiesCollectionClass();
                pAnnoPropsColl.Add(pAnnoProps);

                //' use the AnnotationFeatureClassDescription co - class to get the list of required fields and the default name of the shape field
                IObjectClassDescription  pOCDesc = new AnnotationFeatureClassDescriptionClass();
                IFeatureClassDescription pFDesc  = (IFeatureClassDescription)pOCDesc;

                IFields pReqFields       = pOCDesc.RequiredFields;
                IUID    pInstCLSID       = pOCDesc.InstanceCLSID;
                IUID    pExtCLSID        = pOCDesc.ClassExtensionCLSID;
                string  bsShapeFieldName = pFDesc.ShapeFieldName;

                IDataset pDs = (IDataset)pInputCls;

                //创建
                string        bstName  = ipFeatClassDesc.ShapeFieldName;
                IFeatureClass pOutFcls =
                    ipFeatureWorkspaceAnno.CreateAnnotationClass(pDs.Name, ipFields, pOCDesc.InstanceCLSID,
                                                                 pOCDesc.ClassExtensionCLSID, pInputCls.ShapeFieldName, "", destDataset, null, pAnnoPropsColl,
                                                                 ipGraphicsLayerScale, pSymbolColl, true);
                return(pOutFcls);
            }
            catch (Exception exp)
            {
                Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString());

                return(null);
            }
            return(null);
        }
Esempio n. 10
0
        //创建featureclass
        private IFeatureClass CreateFeatureClass(string name, IFeatureClass pFeaCls, IFeatureDataset pFeaDataset, IFeatureWorkspace pWks)
        {
            UID uidCLSID  = null;
            UID uidCLSEXT = null;


            try
            {
                IObjectClassDescription pObjCls = null;
                if (uidCLSID == null)
                {
                    //esriGeometryType GeometryType;
                    uidCLSID = new UIDClass();
                    switch (pFeaCls.FeatureType)
                    {
                    case (esriFeatureType.esriFTSimple):
                        uidCLSID.Value = "{52353152-891A-11D0-BEC6-00805F7C4268}";
                        break;

                    case (esriFeatureType.esriFTSimpleJunction):
                        //GeometryType = esriGeometryType.esriGeometryPoint;
                        uidCLSID.Value = "{CEE8D6B8-55FE-11D1-AE55-0000F80372B4}";
                        break;

                    case (esriFeatureType.esriFTComplexJunction):
                        uidCLSID.Value = "{DF9D71F4-DA32-11D1-AEBA-0000F80372B4}";
                        break;

                    case (esriFeatureType.esriFTSimpleEdge):
                        //GeometryType = esriGeometryType.esriGeometryPolyline;
                        uidCLSID.Value = "{E7031C90-55FE-11D1-AE55-0000F80372B4}";
                        break;

                    case (esriFeatureType.esriFTComplexEdge):
                        //GeometryType = esriGeometryType.esriGeometryPolyline;
                        uidCLSID.Value = "{A30E8A2A-C50B-11D1-AEA9-0000F80372B4}";
                        break;

                    case (esriFeatureType.esriFTAnnotation):
                        //GeometryType = esriGeometryType.esriGeometryPolygon;
                        uidCLSID.Value = "{E3676993-C682-11D2-8A2A-006097AFF44E}";
                        break;

                    case (esriFeatureType.esriFTDimension):
                        //GeometryType = esriGeometryType.esriGeometryPolygon;
                        uidCLSID.Value = "{496764FC-E0C9-11D3-80CE-00C04F601565}";
                        break;
                    }
                }

                // 设置 uidCLSEXT (if Null)
                if (uidCLSEXT == null)
                {
                    switch (pFeaCls.FeatureType)
                    {
                    case (esriFeatureType.esriFTAnnotation):
                        uidCLSEXT       = new UIDClass();
                        uidCLSEXT.Value = "{24429589-D711-11D2-9F41-00C04F6BC6A5}";
                        pObjCls         = new AnnotationFeatureClassDescriptionClass();
                        break;

                    case (esriFeatureType.esriFTDimension):
                        uidCLSEXT       = new UIDClass();
                        uidCLSEXT.Value = "{48F935E2-DA66-11D3-80CE-00C04F601565}";
                        break;
                    }
                }
                //IFeatureWorkspace pFeatureWorkspace = (IFeatureWorkspace)pWorkspace;
                IFieldChecker fdCheker = new FieldCheckerClass();//yjl20110804 add
                pEnumFieldError            = null;
                pFixedField                = null;
                fdCheker.ValidateWorkspace = pWks as IWorkspace;
                fdCheker.Validate(pFeaCls.Fields, out pEnumFieldError, out pFixedField);

                //string strShapeFieldName = pfeaturelayer.FeatureClass.ShapeFieldName;//geometry字段名
                //string[] strShapeNames = strShapeFieldName.Split('.');
                //strShapeFieldName = strShapeNames[strShapeNames.GetLength(0) - 1];

                IFields pFields = new FieldsClass();
                if (pObjCls != null)
                {
                    IFeatureClassDescription pClsDes = pObjCls as IFeatureClassDescription;
                    pFields = pObjCls.RequiredFields;
                }

                IFieldsEdit pFieldsEdit = pFields as IFieldsEdit;

                for (int i = 0; i < pFeaCls.Fields.FieldCount; i++)
                {
                    IField   pf            = pFeaCls.Fields.get_Field(i);
                    string   strFieldName  = pf.Name;
                    string[] strFieldNames = strFieldName.Split('.');

                    bool blnfind = false;
                    for (int j = 0; j < pFields.FieldCount; j++)
                    {
                        IField   pf2        = pFields.get_Field(j);
                        string[] strfields2 = pf2.Name.Split('.');
                        if (strfields2[strfields2.GetLength(0) - 1].ToUpper() == strFieldNames[strFieldNames.GetLength(0) - 1].ToUpper())
                        {
                            blnfind = true;
                            break;
                        }
                    }

                    if (blnfind)
                    {
                        continue;
                    }

                    if (pFeaCls.FeatureType == esriFeatureType.esriFTAnnotation)
                    {
                        if (pFeaCls.ShapeFieldName == pf.Name)
                        {
                            continue;
                        }
                    }

                    if (pFeaCls.LengthField != null)
                    {
                        if (pFeaCls.LengthField.Name == pf.Name)
                        {
                            continue;
                        }
                    }
                    if (pFeaCls.AreaField != null)
                    {
                        if (pFeaCls.AreaField.Name == pf.Name)
                        {
                            continue;
                        }
                    }

                    IClone     pClone         = pFeaCls.Fields.get_Field(i) as IClone;
                    IField     pTempField     = pClone.Clone() as IField;
                    IFieldEdit pTempFieldEdit = pTempField as IFieldEdit;

                    if (pFieldsEdit.FindField(strFieldNames[strFieldNames.GetLength(0) - 1]) > -1)
                    {
                        continue;
                    }

                    pTempFieldEdit.Name_2 = strFieldNames[strFieldNames.GetLength(0) - 1];
                    pFieldsEdit.AddField(pTempField);
                }

                string   strShapeFieldName = pFeaCls.ShapeFieldName;
                string[] strShapeNames     = strShapeFieldName.Split('.');
                strShapeFieldName = strShapeNames[strShapeNames.GetLength(0) - 1];

                //修改geometrydef
                IField pFieldShape = pFeaCls.Fields.get_Field(pFeaCls.Fields.FindField(pFeaCls.ShapeFieldName));

                if (pFieldShape != null)
                {
                    IFieldEdit pFieldShapeEdit = pFields.get_Field(pFields.FindField(strShapeFieldName)) as IFieldEdit;
                    pFieldShapeEdit.GeometryDef_2 = pFieldShape.GeometryDef;
                }

                IGeometryDef pGeoDef  = pFieldShape.GeometryDef;
                double       dblIndex = pGeoDef.get_GridSize(0);

                //添加两个字段一个时间 一个名称
                if (pFields.FindField("ImportTime") < 0)
                {
                    IField     pNewField1 = new FieldClass();
                    IFieldEdit pNewEdit1  = pNewField1 as IFieldEdit;
                    pNewEdit1.Name_2      = "ImportTime";
                    pNewEdit1.AliasName_2 = "入库时间";
                    pNewEdit1.Type_2      = esriFieldType.esriFieldTypeDate;
                    pFieldsEdit.AddField(pNewField1);
                }

                if (pFields.FindField("ImportUser") < 0)
                {
                    IField     pNewField2 = new FieldClass();
                    IFieldEdit pNewEdit2  = pNewField2 as IFieldEdit;
                    pNewEdit2.Name_2      = "ImportUser";
                    pNewEdit2.AliasName_2 = "入库人";
                    pNewEdit2.Type_2      = esriFieldType.esriFieldTypeString;
                    pFieldsEdit.AddField(pNewField2);
                }

                IFeatureClass targetFeatureclass = null;


                if (pFeaCls.FeatureType == esriFeatureType.esriFTAnnotation)
                {
                    IAnnoClass pAnno = pFeaCls.Extension as IAnnoClass;

                    IFeatureWorkspaceAnno pWksAnno = pWks as IFeatureWorkspaceAnno;
                    IGraphicsLayerScale   pGl      = new GraphicsLayerScaleClass();
                    pGl.ReferenceScale = pAnno.ReferenceScale;
                    pGl.Units          = pAnno.ReferenceScaleUnits;
                    targetFeatureclass = pWksAnno.CreateAnnotationClass(name, pFields, pFeaCls.CLSID, pFeaCls.EXTCLSID, strShapeFieldName, "", pFeaDataset, null, pAnno.AnnoProperties, pGl, pAnno.SymbolCollection, false);
                }
                else
                {
                    if (pFeaDataset != null)
                    {
                        targetFeatureclass = pFeaDataset.CreateFeatureClass(name, pFixedField, uidCLSID, uidCLSEXT, pFeaCls.FeatureType, strShapeFieldName, "");
                    }
                    else
                    {
                        targetFeatureclass = pWks.CreateFeatureClass(name, pFixedField, uidCLSID, uidCLSEXT, pFeaCls.FeatureType, strShapeFieldName, "");
                    }
                }

                return(targetFeatureclass);
            }
            catch (Exception ex)
            {
                if (ex.Message == "Cannot create a low precision dataset in a high precision database.")
                {
                    MessageBox.Show("数据必须是ArcGis9.2的数据,请将数据处理成ArcGis9.2的数据!");
                }
            }
            IFeatureClass featureclass = null;

            return(featureclass);
        }
Esempio n. 11
0
        public IFeatureClass CreateStandAloneAnnotationClass(IWorkspace ws, string annoname)
        {
            #region 创建Anno图层
            IFeatureClass featureClass = null;
            try
            {
                //ILayer pLayer = m_pmap.get_Layer(0);
                //IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
                //ILayer pSrcLayer = pLayer;
                //IFeatureClass featureClass = pFeatureLayer.FeatureClass;

                //IDataset dataset = (IDataset)featureClass;//cast for the feature workspace from the workspace
                //IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)dataset.Workspace;
                IFeatureWorkspaceAnno featureWorkspaceAnno = (IFeatureWorkspaceAnno)ws;//set up the reference scale
                ESRI.ArcGIS.Carto.IGraphicsLayerScale graphicLayerScale = new ESRI.ArcGIS.Carto.GraphicsLayerScaleClass();
                //IGeoDataset geoDataset = (IGeoDataset)dataset;
                graphicLayerScale.Units          = ESRI.ArcGIS.esriSystem.esriUnits.esriMeters;
                graphicLayerScale.ReferenceScale = 500;//set up symbol collection
                ESRI.ArcGIS.Display.ISymbolCollection symbolCollection = new ESRI.ArcGIS.Display.SymbolCollectionClass();
                #region "MakeText"
                ESRI.ArcGIS.Display.IFormattedTextSymbol myTextSymbol = new ESRI.ArcGIS.Display.TextSymbolClass();        //set the font for myTextSymbol
                stdole.IFontDisp myFont = new stdole.StdFontClass() as stdole.IFontDisp;
                myFont.Name       = "Courier New";
                myFont.Size       = 9;
                myTextSymbol.Font = myFont;//set the Color for myTextSymbol to be Dark Red
                ESRI.ArcGIS.Display.IRgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColorClass();
                rgbColor.Red                     = 150;
                rgbColor.Green                   = 0;
                rgbColor.Blue                    = 0;
                myTextSymbol.Color               = (ESRI.ArcGIS.Display.IColor)rgbColor;//Set other properties for myTextSymbol
                myTextSymbol.Angle               = 0;
                myTextSymbol.RightToLeft         = false;
                myTextSymbol.VerticalAlignment   = ESRI.ArcGIS.Display.esriTextVerticalAlignment.esriTVABaseline;
                myTextSymbol.HorizontalAlignment = ESRI.ArcGIS.Display.esriTextHorizontalAlignment.esriTHAFull;
                myTextSymbol.CharacterSpacing    = 200;
                myTextSymbol.Case                = ESRI.ArcGIS.Display.esriTextCase.esriTCNormal;
                #endregion
                symbolCollection.set_Symbol(0, (ESRI.ArcGIS.Display.ISymbol)myTextSymbol); //set up the annotation labeling properties including the expression
                ESRI.ArcGIS.Carto.IAnnotateLayerProperties annoProps = new ESRI.ArcGIS.Carto.LabelEngineLayerPropertiesClass();
                annoProps.FeatureLinked = false;                                           //这里控制是不是关联的注记层
                annoProps.AddUnplacedToGraphicsContainer = false;
                annoProps.CreateUnplacedElements         = true;
                annoProps.DisplayAnnotation = true;
                annoProps.UseOutput         = true;
                ESRI.ArcGIS.Carto.ILabelEngineLayerProperties layerEngineLayerProps = (ESRI.ArcGIS.Carto.ILabelEngineLayerProperties)annoProps;
                ESRI.ArcGIS.Carto.IAnnotationExpressionEngine annoExpressionEngine  = new ESRI.ArcGIS.Carto.AnnotationVBScriptEngineClass();
                layerEngineLayerProps.ExpressionParser   = annoExpressionEngine;
                layerEngineLayerProps.Expression         = "[RefName]";
                layerEngineLayerProps.IsExpressionSimple = true;
                layerEngineLayerProps.Offset             = 0;
                layerEngineLayerProps.SymbolID           = 0;
                layerEngineLayerProps.Symbol             = myTextSymbol;
                ESRI.ArcGIS.Carto.IAnnotateLayerTransformationProperties annoLayerTransProp =
                    (ESRI.ArcGIS.Carto.IAnnotateLayerTransformationProperties)annoProps;
                annoLayerTransProp.ReferenceScale = graphicLayerScale.ReferenceScale;
                annoLayerTransProp.Units          = graphicLayerScale.Units;
                annoLayerTransProp.ScaleRatio     = 1;
                ESRI.ArcGIS.Carto.IAnnotateLayerPropertiesCollection annoPropsColl = new ESRI.ArcGIS.Carto.AnnotateLayerPropertiesCollectionClass();
                annoPropsColl.Add(annoProps);//use the AnnotationFeatureClassDescription to get the list of required
                //fields and the default name of the shape field
                IObjectClassDescription  oCDesc = new ESRI.ArcGIS.Carto.AnnotationFeatureClassDescriptionClass();
                IFeatureClassDescription fCDesc = (IFeatureClassDescription)oCDesc;//create the new class

                featureClass = featureWorkspaceAnno.CreateAnnotationClass(annoname, oCDesc.RequiredFields, oCDesc.InstanceCLSID, oCDesc.ClassExtensionCLSID,
                                                                          fCDesc.ShapeFieldName, "", null, null, annoPropsColl, graphicLayerScale, symbolCollection, true);
                //给新建的图层添加子层
                ISubtypes subtypes = (ISubtypes)featureClass;
                subtypes.SubtypeFieldName = "AnnotationClassID";
                subtypes.AddSubtype(1, "GCD");
                subtypes.AddSubtype(2, "DLDW");
                subtypes.AddSubtype(3, "JMD");
                subtypes.AddSubtype(4, "SXSS");
                subtypes.AddSubtype(5, "DLSS");
                subtypes.AddSubtype(6, "ZBTZ");
                subtypes.AddSubtype(7, "TK");
                subtypes.DefaultSubtypeCode = 1;
                return(featureClass);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(featureClass);
            }
            #endregion
        }