Skip to main content
Tweeted twitter.com/#!/StackGIS/status/93524057995218944
tweaked grammar/phrasing
Source Link
djq
  • 16.3k
  • 31
  • 112
  • 182

i want to create Problem creating a point IFeatureClass ? it is my code that doesn't work ;

I'm trying to create a point IFeatureClass, but my code doesn't work.

i want to create a point IFeatureClass ? it is my code that doesn't work ;

Problem creating a point IFeatureClass

I'm trying to create a point IFeatureClass, but my code doesn't work.

made the first 2 lines code sample
Source Link
Jay Cummins
  • 14.7k
  • 8
  • 68
  • 143

Public Function CreatePointFeatureClass(ByVal featureClassName As String, _ ByVal featureWorkspace As IFeatureWorkspace) As IFeatureClass

Public Function CreatePointFeatureClass(ByVal featureClassName As String, _
                                         ByVal featureWorkspace As IFeatureWorkspace) As IFeatureClass

    ' Instantiate a feature class description to get the required fields.
    Dim fcDescription As IFeatureClassDescription = New FeatureClassDescriptionClass()
    Dim ocDescription As IObjectClassDescription = CType(fcDescription, IObjectClassDescription)

    Dim fields As IFields = New FieldsClass
    Dim fieldsEdit As IFieldsEdit = CType(fields, IFieldsEdit)
    Dim fieldUserDefined As IField = New FieldClass
    Dim fieldEdit As IFieldEdit = CType(fieldUserDefined, IFieldEdit)

    ' Set up geometry definition for the Shape field.
    ' You do not have to set the spatial reference, as it is inherited from the feature dataset.
    Dim geometryDef As IGeometryDef = New GeometryDefClass
    Dim geometryDefEdit As IGeometryDefEdit = CType(geometryDef, IGeometryDefEdit)

    ' By setting the grid size to 0, you are allowing ArcGIS to determine the appropriate grid sizes for the feature class. 
    ' If in a personal geodatabase, the grid size is 1,000. If in a file or ArcSDE geodatabase, the grid size
    ' is based on the initial loading or inserting of features.
    geometryDefEdit.GeometryType_2 = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint

    ' Set standard field properties.
    fieldEdit.Name_2 = "SHAPE"
    fieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry
    fieldEdit.GeometryDef_2 = geometryDefEdit
    fieldEdit.IsNullable_2 = True
    fieldEdit.Required_2 = True
    fieldsEdit.AddField(fieldUserDefined)


    ' Add a X Double field to the required fields.
    Dim field1 As IField = New FieldClass()
    Dim fieldEdit1 As IFieldEdit = CType(field1, IFieldEdit)
    fieldEdit1.Name_2 = "X"
    fieldEdit1.Type_2 = esriFieldType.esriFieldTypeDouble
    fieldsEdit.AddField(field1)

    ' Add a Y Double field to the required fields.
    Dim field2 As IField = New FieldClass()
    Dim fieldEdit2 As IFieldEdit = CType(field2, IFieldEdit)
    fieldEdit2.Name_2 = "Y"
    fieldEdit2.Type_2 = esriFieldType.esriFieldTypeDouble
    fieldsEdit.AddField(field2)

    ' Add a Elevation Double field to the required fields.
    Dim field3 As IField = New FieldClass()
    Dim fieldEdit3 As IFieldEdit = CType(field3, IFieldEdit)
    fieldEdit3.Name_2 = "Elevation"
    fieldEdit3.Type_2 = esriFieldType.esriFieldTypeDouble
    fieldsEdit.AddField(field3)




    ' Use IFieldChecker to create a validated fields collection.
    Dim fieldChecker As IFieldChecker = New FieldCheckerClass()
    Dim enumFieldError As IEnumFieldError = Nothing
    Dim validatedFields As IFields = Nothing
    fieldChecker.ValidateWorkspace = CType(featureWorkspace, IWorkspace)
    fieldChecker.Validate(fields, enumFieldError, validatedFields)

    ' The enumFieldError enumerator can be inspected at this point to determine
    ' which fields were modified during validation.
    ' Create the feature class.
    Dim featureClass As IFeatureClass = featureWorkspace.CreateFeatureClass(featureClassName, validatedFields, _
                                    ocDescription.InstanceCLSID, ocDescription.ClassExtensionCLSID, esriFeatureType.esriFTSimple, _
                                    "SHAPE", "")

    Return featureClass

End Function

Public Function CreatePointFeatureClass(ByVal featureClassName As String, _ ByVal featureWorkspace As IFeatureWorkspace) As IFeatureClass

    ' Instantiate a feature class description to get the required fields.
    Dim fcDescription As IFeatureClassDescription = New FeatureClassDescriptionClass()
    Dim ocDescription As IObjectClassDescription = CType(fcDescription, IObjectClassDescription)

    Dim fields As IFields = New FieldsClass
    Dim fieldsEdit As IFieldsEdit = CType(fields, IFieldsEdit)
    Dim fieldUserDefined As IField = New FieldClass
    Dim fieldEdit As IFieldEdit = CType(fieldUserDefined, IFieldEdit)

    ' Set up geometry definition for the Shape field.
    ' You do not have to set the spatial reference, as it is inherited from the feature dataset.
    Dim geometryDef As IGeometryDef = New GeometryDefClass
    Dim geometryDefEdit As IGeometryDefEdit = CType(geometryDef, IGeometryDefEdit)

    ' By setting the grid size to 0, you are allowing ArcGIS to determine the appropriate grid sizes for the feature class. 
    ' If in a personal geodatabase, the grid size is 1,000. If in a file or ArcSDE geodatabase, the grid size
    ' is based on the initial loading or inserting of features.
    geometryDefEdit.GeometryType_2 = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint

    ' Set standard field properties.
    fieldEdit.Name_2 = "SHAPE"
    fieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry
    fieldEdit.GeometryDef_2 = geometryDefEdit
    fieldEdit.IsNullable_2 = True
    fieldEdit.Required_2 = True
    fieldsEdit.AddField(fieldUserDefined)


    ' Add a X Double field to the required fields.
    Dim field1 As IField = New FieldClass()
    Dim fieldEdit1 As IFieldEdit = CType(field1, IFieldEdit)
    fieldEdit1.Name_2 = "X"
    fieldEdit1.Type_2 = esriFieldType.esriFieldTypeDouble
    fieldsEdit.AddField(field1)

    ' Add a Y Double field to the required fields.
    Dim field2 As IField = New FieldClass()
    Dim fieldEdit2 As IFieldEdit = CType(field2, IFieldEdit)
    fieldEdit2.Name_2 = "Y"
    fieldEdit2.Type_2 = esriFieldType.esriFieldTypeDouble
    fieldsEdit.AddField(field2)

    ' Add a Elevation Double field to the required fields.
    Dim field3 As IField = New FieldClass()
    Dim fieldEdit3 As IFieldEdit = CType(field3, IFieldEdit)
    fieldEdit3.Name_2 = "Elevation"
    fieldEdit3.Type_2 = esriFieldType.esriFieldTypeDouble
    fieldsEdit.AddField(field3)




    ' Use IFieldChecker to create a validated fields collection.
    Dim fieldChecker As IFieldChecker = New FieldCheckerClass()
    Dim enumFieldError As IEnumFieldError = Nothing
    Dim validatedFields As IFields = Nothing
    fieldChecker.ValidateWorkspace = CType(featureWorkspace, IWorkspace)
    fieldChecker.Validate(fields, enumFieldError, validatedFields)

    ' The enumFieldError enumerator can be inspected at this point to determine
    ' which fields were modified during validation.
    ' Create the feature class.
    Dim featureClass As IFeatureClass = featureWorkspace.CreateFeatureClass(featureClassName, validatedFields, _
                                    ocDescription.InstanceCLSID, ocDescription.ClassExtensionCLSID, esriFeatureType.esriFTSimple, _
                                    "SHAPE", "")

    Return featureClass

End Function
Public Function CreatePointFeatureClass(ByVal featureClassName As String, _
                                         ByVal featureWorkspace As IFeatureWorkspace) As IFeatureClass

    ' Instantiate a feature class description to get the required fields.
    Dim fcDescription As IFeatureClassDescription = New FeatureClassDescriptionClass()
    Dim ocDescription As IObjectClassDescription = CType(fcDescription, IObjectClassDescription)

    Dim fields As IFields = New FieldsClass
    Dim fieldsEdit As IFieldsEdit = CType(fields, IFieldsEdit)
    Dim fieldUserDefined As IField = New FieldClass
    Dim fieldEdit As IFieldEdit = CType(fieldUserDefined, IFieldEdit)

    ' Set up geometry definition for the Shape field.
    ' You do not have to set the spatial reference, as it is inherited from the feature dataset.
    Dim geometryDef As IGeometryDef = New GeometryDefClass
    Dim geometryDefEdit As IGeometryDefEdit = CType(geometryDef, IGeometryDefEdit)

    ' By setting the grid size to 0, you are allowing ArcGIS to determine the appropriate grid sizes for the feature class. 
    ' If in a personal geodatabase, the grid size is 1,000. If in a file or ArcSDE geodatabase, the grid size
    ' is based on the initial loading or inserting of features.
    geometryDefEdit.GeometryType_2 = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint

    ' Set standard field properties.
    fieldEdit.Name_2 = "SHAPE"
    fieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry
    fieldEdit.GeometryDef_2 = geometryDefEdit
    fieldEdit.IsNullable_2 = True
    fieldEdit.Required_2 = True
    fieldsEdit.AddField(fieldUserDefined)


    ' Add a X Double field to the required fields.
    Dim field1 As IField = New FieldClass()
    Dim fieldEdit1 As IFieldEdit = CType(field1, IFieldEdit)
    fieldEdit1.Name_2 = "X"
    fieldEdit1.Type_2 = esriFieldType.esriFieldTypeDouble
    fieldsEdit.AddField(field1)

    ' Add a Y Double field to the required fields.
    Dim field2 As IField = New FieldClass()
    Dim fieldEdit2 As IFieldEdit = CType(field2, IFieldEdit)
    fieldEdit2.Name_2 = "Y"
    fieldEdit2.Type_2 = esriFieldType.esriFieldTypeDouble
    fieldsEdit.AddField(field2)

    ' Add a Elevation Double field to the required fields.
    Dim field3 As IField = New FieldClass()
    Dim fieldEdit3 As IFieldEdit = CType(field3, IFieldEdit)
    fieldEdit3.Name_2 = "Elevation"
    fieldEdit3.Type_2 = esriFieldType.esriFieldTypeDouble
    fieldsEdit.AddField(field3)




    ' Use IFieldChecker to create a validated fields collection.
    Dim fieldChecker As IFieldChecker = New FieldCheckerClass()
    Dim enumFieldError As IEnumFieldError = Nothing
    Dim validatedFields As IFields = Nothing
    fieldChecker.ValidateWorkspace = CType(featureWorkspace, IWorkspace)
    fieldChecker.Validate(fields, enumFieldError, validatedFields)

    ' The enumFieldError enumerator can be inspected at this point to determine
    ' which fields were modified during validation.
    ' Create the feature class.
    Dim featureClass As IFeatureClass = featureWorkspace.CreateFeatureClass(featureClassName, validatedFields, _
                                    ocDescription.InstanceCLSID, ocDescription.ClassExtensionCLSID, esriFeatureType.esriFTSimple, _
                                    "SHAPE", "")

    Return featureClass

End Function
edited tags
Link
patrick
  • 2.7k
  • 26
  • 51
edited tags
Link
patrick
  • 2.7k
  • 26
  • 51
Loading
Source Link
hvaezi
  • 289
  • 2
  • 4
  • 12
Loading