I am having difficulties creating turn restrictions in ArcObjects. I have found a way to Add a a network turn to restrictions through the
INetworkForwardStarEx.AddTurnRestriction() interface. But how to I create the INetworkTurn that this method takes.
INetworkTurn is a noncreatable object. You can only get it from querying an existing turn element. So if the turn you are trying to query does not yet exist, you will have to first create it.
Once you do have a turn, you will need to use INetworkQuery.QueryTurn and pass in the turn element ID as an argument.
This method will return INetworkTurn for you. You can then pass this value into INetworkForwardStarEx.AddTurnRestriction()
Hope this helps.
My guess is that you have to have to embed the ID for the from and to interior or exterior edges in the arc.object this creates.
I have now identified the answer. You simply create the feature as a conventional feature in the turn featureclass:
A) Create a turn shape as a ratio of the road segments involved. Remember that the roads can be connected in different ways: FromPoint to FromPoint, FromPoint to Topoint, ToPoint to FromPoint or ToPoint to ToPoint. So be careful which segments, you create the turn-shape from.
C) Fill out all attributes. The attributes Edge1FCID and Edge2FCID holds the internal id of featureclass of the roads involved in the turn. These can be found in the table sde.GDB_ITEMS in the geodatabase. The fields Edge1Pos and Edge2Pos indicate how much of each road segments are involved in the turn. This value should match the shape created in A. Again, remember that the roads can be connected in different ways. That should be reflected in the Edge1Pos and Edge2Pos values.
C) Build the network.