Forum Index Home
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help: Update function with a feature class is not working!!

Post new topic   Reply to topic     Forum Index -> Geographic Information System (GIS) forum
View previous topic :: View next topic  
Author Message

Joined: 25 Sep 2007
Posts: 29

PostPosted: Tue Nov 06, 2007 6:30 pm    Post subject: Help: Update function with a feature class is not working!! Reply with quote


may someone help me?

I have a problem with code writting.

A feature class has to be called meny times in a loop. This feature class has to be updated. The update function works only with first step of the loop, then it is stoped at the next step.

the error message says that the index table from this feature class is blocked and I am not allowed to access into it.

The code is as follows:

Private Sub Run1()

'feature classes

Dim pFact As IWorkspaceFactory
Dim pFeatws As IFeatureWorkspace

pFact = New AccessWorkspaceFactory

pFeatws = pFact.OpenFromFile(FGW_Sohle_WS_Name, 0)
Sohle_pFeatcls = pFeatws.OpenFeatureClass(FGW_Sohle_FCS_Name)
Gelli_pFeatcls = pFeatws.OpenFeatureClass(FGW_Gelli_FCS_Name)
Gelre_pFeatcls = pFeatws.OpenFeatureClass(FGW_Gelre_FCS_Name)

Dim i, j, k, RID As Integer
Dim CS_pFeatclsCopy As IFeatureClass

REM test
Me.MakeCopy(CS_pFeatcls, F_C_Name)
Dim pFacttest As IWorkspaceFactory
Dim pFeatwstest As IFeatureWorkspace
pFacttest = New AccessWorkspaceFactory
pFeatwstest = pFacttest.OpenFromFile(Save_Path, 0)

REM pFact = New AccessWorkspaceFactory

REM CS_pFeatclsCopy = Me.MakeCopy(CS_pFeatcls, F_C_Name)

For k = 0 To Select_Sohle_State_List.Count - 1
If Select_Sohle_State_List(k) = 1 Then
CS_pFeatclsCopy = pFeatwstest.OpenFeatureClass(F_C_Name)
Dim Plus_Step, ContourValue As Double
Plus_Step = 0.001

RID = Me.Select_Sohle_ID_List(k)

Dim Route As IFeature = Me.GetFeature(Sohle_pFeatcls, RID)
Dim Max As Double = GetMaxSubsidance(Route.Shape)
If Max = 0 Then Exit Sub

'MakeCopy of Crossection Feature Class
'CS_pFeatclsCopy = Me.MakeCopy(CS_pFeatcls, F_C_Name)

'Get Gelli with Route_ID=104
Dim GelLiFeat As IFeature = Me.GetFeature(Gelli_pFeatcls, RID, "D_ROUTE_ID")

'Get Gelre with Route_ID=104
Dim GelReFeat As IFeature = Me.GetFeature(Gelre_pFeatcls, RID, "D_ROUTE_ID")

'Get crossections with subsidance rate > 20cm
Dim CSList As New ArrayList

CSList = Me.GetCrossections(CS_pFeatclsCopy, Route.Shape, GelLiFeat.Shape, GelReFeat.Shape, RID)

'extend crossections from the list
Dim tempCSList As New ArrayList
Dim strWhereClause As String = ""
For i = 0 To CSList.Count - 1
If i = 0 Then
strWhereClause = CS_pFeatclsCopy.OIDFieldName & "=" & CSList(i).OID
strWhereClause = strWhereClause & " OR " & CS_pFeatclsCopy.OIDFieldName & "=" & CSList(i).OID
End If

'start editing
Dim pWorkspaceEdit As IWorkspaceEdit
Dim pDataset As IDataset = CS_pFeatclsCopy
pWorkspaceEdit = pDataset.Workspace

Dim OutCSList As New ArrayList

// The problem is here, with the function ExtendCrossection
Me.ExtendCrossection(CS_pFeatclsCopy, strWhereClause, CSList, Max, RID, Route)
Me.CheckIfCrossectionIntersect(CS_pFeatclsCopy, Gelli_pFeatcls, Gelre_pFeatcls, RID, tempCSList, OutCSList)

If OutCSList.Count > 0 Then
Me.SetNewGeometry(CS_pFeatclsCopy, OutCSList)
End If


End If

'Add layer to ArcMap
Me.AddLayer(CS_pFeatclsCopy, m_app)

End Sub

Public Sub ExtendCrossection(ByVal FeatureClass As IFeatureClass, ByVal WhereClause As String, ByVal CSList As ArrayList, ByVal Max As Double, ByVal RID As Integer, ByVal Route As IFeature)
Dim i As Integer = 0
Dim pCS As IFeature
Dim Qf As New QueryFilter
Qf.WhereClause = WhereClause

Dim pUpdateFeatureCursor As IFeatureCursor
Dim NewFeatureCount As Integer = 0

//The problem is here, with update
pUpdateFeatureCursor = FeatureClass.Update(Qf, False)

Dim pGS As IGeoDataset = FeatureClass
Dim ContourValue As Double
Dim OID As Integer
Dim IP As IPoint
pCS = pUpdateFeatureCursor.NextFeature
Do While Not pCS Is Nothing
'Update feature
ContourValue = Me.GetContourValue(CSList, pCS.OID, Max)
ContourValue = Format(ContourValue, "F")
IP = Me.GetIPoint(CSList, pCS.OID)
pCS = ExtendLine(pCS, pGS.Extent.Envelope, ContourValue, Route, IP)
If i = 100 Then
i = 0
End If
i += 1
pCS = pUpdateFeatureCursor.NextFeature


Catch ex As Exception
End Try
End Sub
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Geographic Information System (GIS) forum All times are GMT + 2 Hours
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group