Solved! Go to Solution.
Inizialized Flow Direction if you need downstream or upstream
you can use similiar code for find edge in downstream or upstream with your business logic.
INetTopologyEditGEN netTopology = networkElements as INetTopologyEditGEN; int edgeCount = netTopology.GetAdjacentEdgeCount(yourEIDJunction); bool reverseOrientation; int adjacentEdge; for (int i = 0; i < edgeCount; i++) { netTopology.GetAdjacentEdge(yourEIDJunction, i, out adjacentEdge, out reverseOrientation); netTopology.GetFromToJunctionEIDs(adjacentEdge, out fromEIDJunction, out toEIDJunction);
reverseOrientation = true // into Junction -> upstream
reverseOrientation = false // exit Junction -> downstream
Hello,
I have been trying to do the same, and I keep getting the same error.
Did You find a solution to this?
Thanks.
Hi Kromo,
I can see that network is not set for the ITraceFlowSolver. you can doing this by following code. Cast the ITraceFlowSolve to a INetSolver and set the sourceNetwork with INetwork which can get access from IGeometricNetwork::Network. May be this will help.
Dim pNetSolver As ESRI.ArcGIS.NetworkAnalysis.INetSolver
Set pNetSolver = ipTraceFlowSolver
Set ipNetwork = pGeometricNetwork.Network
Set pNetSolver.SourceNetwork = ipNetwork
Here is the documentation on that..
"Use the INetSolver interface to specify which network on which you want to perform an analysis, which elements in the network are barriers, and which element classes are disabled."
"When you create a TraceFlowSolver object, you also get a reference to a NetSolver object, since TraceFlowSolver inhereits from NetSolver."
This helped me:
Now I am trying to get feature class of e.g. junction that was returned to me by the trace.
I got this far:
pTraceFlowSolver.FindFlowElements(strTraceType,esriFlowElements.esriFEJunctionsAndEdges, out pJunctionEIDs, out pEdgeEIDs);
int idJunction = pJunctionEIDs.Next();
while (idJunction != -1)
{
idJunction = pJunctionEIDs.Next();
}
How can I get a layer, or feature class or something that can give me attributes of the returned objects.
All I have is ID of a junction.
Tnx,
Hi Milos,
One can get featureclass id from EID with INetworkElements.QueryIDs interface
Here is some quick sample code
Dim userclassid1 As Long, userid1 As Long, usersubid1 As Long
Dim pNetElements As INetElements
Set pNetElements = pNetwork
pNetElements.QueryIDs EIDp, esriETEdge, userclassid1, userid1, usersubid1
Debug.Print "classid: " & userclassid1 & " userid: " & userid1 & " subid: " & usersubid1
btw pNetwork is INetwork in the above code.
Dim pNetwork As INetwork
Set pNetwork = pGeometricNetwork.Network
Hello Shriram ,
Thnks for helping out.
This works, but I keep getting the Feature for which I did the trace (e.g. I did an upstream trace and in junctions I get ID of the feature which is a consumer, not the ID of a feature that is a source)...
Any ideas what I did wrong?
I copied the code from the link above, and just changed some minor stuff....
Tnx.
Hi Milo,
No sure of the exact problem - seems like a workflow issue. I think that is worth re-looking is. ITraceFlowSolver.PutJunctionOrigins. The documentation says use ITraceFlowSolverGEN::PutJunctionOrigins. from VB.NET.
"
Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.
[C#]
This method is not callable from C#. Please use ITraceFlowSolverGEN::PutJunctionOrigins.
[Visual Basic .NET]
This method is not callable from VB.NET. Please use ITraceFlowSolverGEN::PutJunctionOrigins.
"