Arcengine Creating a Feature class

Source: Internet
Author: User

         PublicESRI. ArcGIS.Geodatabase.IFeatureClass Createfeatureclass (ESRI. ArcGIS.Geodatabase.IWorkspace2 workspace, ESRI. ArcGIS.Geodatabase.IFeatureDataset Featuredataset, System.String featureclassname) {ESRI. ArcGIS.esriSystem.UID CLSID=NULL; ESRI. ArcGIS.esriSystem.UID Clsext=NULL; System.String Strconfigkeyword=NULL; if(Featureclassname = ="")return NULL;//name is not passed inESRI.            ArcGIS.Geodatabase.IFeatureClass Featureclass; ESRI. ArcGIS.Geodatabase.IFeatureWorkspace Featureworkspace= (ESRI. ArcGIS.Geodatabase.IFeatureWorkspace) Workspace;//Explicit Cast            if(Workspace.get_nameexists (ESRI. ArcGIS.Geodatabase.esriDatasetType.esriDTFeatureClass, Featureclassname))//feature class with that name already exists{Featureclass=Featureworkspace.openfeatureclass (featureclassname); returnFeatureclass; }            //assign the class ID value if not assigned            if(CLSID = =NULL) {CLSID=NewESRI.                ArcGIS.esriSystem.UIDClass (); Clsid. Value="esrigeodatabase.feature"; } ESRI. ArcGIS.Geodatabase.IObjectClassDescription objectclassdescription=NewESRI.            ArcGIS.Geodatabase.FeatureClassDescriptionClass (); ESRI. ArcGIS.Geodatabase.IFields Fields=NULL; //if a Fields collection are not passed and then supply our own            if(Fields = =NULL)            {                //Create The fields using the required fields methodFields =Objectclassdescription.requiredfields; ESRI. ArcGIS.Geodatabase.IFieldsEdit Fieldsedit= (ESRI. ArcGIS.Geodatabase.IFieldsEdit) fields;//Explicit CastESRI. ArcGIS.Geodatabase.IField field =NewESRI.                ArcGIS.Geodatabase.FieldClass (); //Create a User defined text fieldESRI. ArcGIS.Geodatabase.IFieldEdit Fieldedit = (ESRI. ArcGIS.Geodatabase.IFieldEdit) field;//Explicit Cast//setup Field Propertiesfieldedit.name_2 ="Zbdid"; Fieldedit.type_2=ESRI.                ArcGIS.Geodatabase.esriFieldType.esriFieldTypeString; Fieldedit.isnullable_2=true; Fieldedit.aliasname_2="Coordinate number"; Fieldedit.defaultvalue_2="0"; Fieldedit.editable_2=true; Fieldedit.length_2= -; //add field to field collectionFieldsedit.addfield (field); fields= (ESRI. ArcGIS.Geodatabase.IFields) Fieldsedit;//Explicit Cast} System.String Strshapefield=""; //Locate the Shape field             for(intj =0; J < fields. FieldCount; J + +)            {                if(Fields.get_field (j). Type = =ESRI. ArcGIS.Geodatabase.esriFieldType.esriFieldTypeGeometry) {Strshapefield=Fields.get_field (j).                Name; }            }            //Use Ifieldchecker to create a validated the Fields collection.ESRI. ArcGIS.Geodatabase.IFieldChecker Fieldchecker =NewESRI.            ArcGIS.Geodatabase.FieldCheckerClass (); ESRI. ArcGIS.Geodatabase.IEnumFieldError Enumfielderror=NULL; ESRI. ArcGIS.Geodatabase.IFields Validatedfields=NULL; Fieldchecker.validateworkspace=(ESRI.            ArcGIS.Geodatabase.IWorkspace) Workspace; Fieldchecker.validate (Fields, outEnumfielderror, outvalidatedfields); //The Enumfielderror Enumerator can be inspected at the-point to determine//which fields were modified during validation. //finally create and return the feature class            if(Featuredataset = =NULL)//if no feature dataset passed in, create at the workspace level{Featureclass=Featureworkspace.createfeatureclass (Featureclassname, Validatedfields, CLSID, Clsext, ESRI.            ArcGIS.Geodatabase.esriFeatureType.esriFTSimple, Strshapefield, Strconfigkeyword); }            Else{Featureclass=Featuredataset.createfeatureclass (Featureclassname, Validatedfields, CLSID, Clsext, ESRI.            ArcGIS.Geodatabase.esriFeatureType.esriFTSimple, Strshapefield, Strconfigkeyword); }            returnFeatureclass; }

Arcengine Creating a Feature class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.