AnsweredAssumed Answered

Problem with pTraceFlowSolver.FindFlowElements

Question asked by donivip on Feb 11, 2011
Latest reply on Sep 25, 2014 by ciava.at
Dear All,

I have coding snippet for tracing a network,Below this coding snippet :

Public Sub TraceNetworks(ByVal pMap As IMap, ByVal pFlowMethod As ESRI.ArcGIS.NetworkAnalysis.esriFlowMethod, ByVal pFeature As IFeature, ByRef pIEnumJunctionEIDInfo As ESRI.ArcGIS.NetworkAnalysis.IEnumEIDInfo, ByRef pIEnumEdgeEIDInfo As ESRI.ArcGIS.NetworkAnalysis.IEnumEIDInfo)
Dim pNetworkFeature As INetworkFeature
Dim pGeometricNetwork As IGeometricNetwork
Dim pTraceFlowSolver As ESRI.ArcGIS.NetworkAnalysis.ITraceFlowSolver
Dim pNetSolver As ESRI.ArcGIS.NetworkAnalysis.INetSolver
???Dim pNetwork As ESRI.ArcGIS.Geodatabase.INetwork
Dim pFeatureClass As IFeatureClass
Dim pJunctionEIDs As ESRI.ArcGIS.Geodatabase.IEnumNetEID = Nothing
Dim pEdgeEIDs As ESRI.ArcGIS.Geodatabase.IEnumNetEID = Nothing

pNetworkFeature = pFeature
pGeometricNetwork = pNetworkFeature.GeometricNetwork

pTraceFlowSolver = New ESRI.ArcGIS.NetworkAnalysis.TraceFlowSolver

pFeatureClass = pFeature.Table

???Create junction flag from selected feature
If pFeature.FeatureType = ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTComp lexEdge Or pFeature.FeatureType = ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimp leEdge Then
Dim pEdgeFlag As ESRI.ArcGIS.NetworkAnalysis.INetFlag
pEdgeFlag = New ESRI.ArcGIS.NetworkAnalysis.EdgeFlag
pEdgeFlag.UserClassID = pFeatureClass.FeatureClassID
pEdgeFlag.UserID = pFeature.OID
pEdgeFlag.UserSubID = -1
Dim pEdgeFlags(0) As ESRI.ArcGIS.NetworkAnalysis.IEdgeFlag
???Add the flag to the array
pEdgeFlags(0) = pEdgeFlag
pTraceFlowSolver.PutEdgeOrigins(1, pEdgeFlags(0))
ElseIf pFeature.FeatureType = ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimp leJunction Then
Dim pJunctionFlag As ESRI.ArcGIS.NetworkAnalysis.INetFlag
pJunctionFlag = New ESRI.ArcGIS.NetworkAnalysis.JunctionFlag
pJunctionFlag.UserClassID = pFeatureClass.FeatureClassID
pJunctionFlag.UserID = pFeature.OID
pJunctionFlag.UserSubID = 0
Dim pJunctionFlags(0) As ESRI.ArcGIS.NetworkAnalysis.IJunctionFlag
pJunctionFlags(0) = pJunctionFlag
pTraceFlowSolver.PutJunctionOrigins(1, pJunctionFlags(0))
Else
Exit Sub
End If

pTraceFlowSolver.TraceIndeterminateFlow = False

pTraceFlowSolver.FindFlowElements(pFlowMethod, ESRI.ArcGIS.NetworkAnalysis.esriFlowElements.esriF EJunctionsAndEdges, pJunctionEIDs, pEdgeEIDs)

Dim pEIDHelper As ESRI.ArcGIS.NetworkAnalysis.IEIDHelper
pEIDHelper = New ESRI.ArcGIS.NetworkAnalysis.EIDHelper
pEIDHelper.ReturnFeatures = True
pEIDHelper.GeometricNetwork = pGeometricNetwork
pEIDHelper.OutputSpatialReference = pMap.SpatialReference

pIEnumJunctionEIDInfo = pEIDHelper.CreateEnumEIDInfo(pJunctionEIDs)
pIEnumEdgeEIDInfo = pEIDHelper.CreateEnumEIDInfo(pEdgeEIDs)

Dim i As Integer

Dim pEIDInfo As ESRI.ArcGIS.NetworkAnalysis.IEIDInfo
Dim pDataset As IDataset
If pFlowMethod ESRI.ArcGIS.NetworkAnalysis.esriFlowMethod.esriFMC onnected Then
???m_pClearSelectCommand.OnClick()
???SetSelectionSymbol(True, pFlowMethod)
End If

For i = 1 To pIEnumJunctionEIDInfo.Count
pEIDInfo = pIEnumJunctionEIDInfo.Next
pFeature = pEIDInfo.Feature
pDataset = pFeature.Table

If pFlowMethod ESRI.ArcGIS.NetworkAnalysis.esriFlowMethod.esriFMC onnected Then
If Trim(UCase(Split(pDataset.Name, ???.???)(1))) ???ASET_NET_JUNCTIONS??? Then
pMap.SelectFeature(GetLayerByName(pDataset.Name), pFeature)

End If
End If
Next i

For i = 1 To pIEnumEdgeEIDInfo.Count
pEIDInfo = pIEnumEdgeEIDInfo.Next
pFeature = pEIDInfo.Feature
pDataset = pFeature.Table
If pFlowMethod ESRI.ArcGIS.NetworkAnalysis.esriFlowMethod.esriFMC onnected Then
pMap.SelectFeature(GetLayerByName(pDataset.Name), pFeature)

End If
Next i

Map1.Refresh()
End Sub

I have error in statement ???pTraceFlowSolver.FindFlowElements(pFlowMethod, ESRI.ArcGIS.NetworkAnalysis.esriFlowElements.esriF EJunctionsAndEdges, pJunctionEIDs, pEdgeEIDs)???.

Message Error :

???Error HRESULT E_FAIL has been returned from a call to a COM component.???

I hope you can help me solution about problem above . Thank???s before

Regard

-Doni-

Outcomes