Hello,
We use TeleAtlas's maps for Brazil and I receive in shapefile(ESRI) format. The turn restriction table is separate file that contains list of pairs of dynamapids which each line represents a single turn restriction. Our current software, in order to compile a network you need to associate to turn restriction file.
From what I noticed MapSuite Routing Explorer just asks for a shapefile in other to create the index file.
How do I integrate the turn restrictions?
Thank you.
Rodrigo Ludwig
Turn Restriction Table / TeleAtlas
Rodrigo,
The Routing Explorer just can process the normal GIS data. You need to write custom code if some special parameter exists.
Note: The code below is based on the lasted code, and please ask for support@thinkgeo.com for a temporary RoutingExtension DLL package.
You can manage it in two ways. The first one is that you can interrogate the data to loop the dynamapids of restriction and then leave off the adjacent roads that is restricted using BuildingRoutingData Event while building the routing index file. The second way is very similar to the first but that happens during finding path in real-time using FindingPath event. Both are very similar except you are doing it during runtime or during building index file. Each has its advantage.Doing it during the index build means faster route times as it is pre-determined. Doing the restriction during runtime is slower but allows for dynamic changes. If for example you want to add a turn restriction on the fly this would be the way to handle it. You could also do a combination of both. I am posting some sample code below to show you both.
- Using the BuildingRoutingData event when generate routing data.
private void RtgRoutingSource_BuildingRoadData(object sender, BuildingRoutingDataRtgRoutingSourceEventArgs e)
{
// Anssume that dynamapids stores the restriction angle uniqued by feature id
Dictionary<string, double> dynamapids = GetRestrictions();
featureSource.Open();
Feature feature = featureSource.GetFeatureById(e.LineShape.Id, ReturningColumnsType.NoColumns);
double turnRestrictionAngle = dynamapids[feature.Id];
// Get the angle between current line and adjacent lines
Dictionary<string, double> angles = new Dictionary<string, double>();
foreach (string item in e.RouteSegment.EndPointAdjacentIds)
{
Feature tempFeature = featureSource.GetFeatureById(item, ReturningColumnsType.NoColumns);
LineShape toLine = GetLineShape(tempFeature);
angles.Add(item, routingEngine.GetAngleBetweenTwoLines(e.LineShape, toLine));
}
foreach (KeyValuePair<string,double> angle in angles)
{
if (angle.Value > turnRestrictionAngle)
{
e.RouteSegment.EndPointAdjacentIds.Remove(angle.Key);
}
}
}
- Using the FindingRoute event during finding route.
private void Algorithm_FindingPath(object sender, FindingRouteRoutingAlgorithmEventArgs e)
{
// Anssume that dynamapids stores the restriction angle uniqued by feature id
Dictionary<string, double> dynamapids = GetRestrictions();
featureSource.Open();
Feature feature = featureSource.GetFeatureById(e.RouteSegment.FeatureId, ReturningColumnsType.NoColumns);
double turnRestrictionAngle = dynamapids[feature.Id];
// Get the angle between current line and adjacent lines
Dictionary<string, double> angles = new Dictionary<string, double>();
foreach (string item in e.RouteSegment.EndPointAdjacentIds)
{
Feature tempFeature = featureSource.GetFeatureById(item, ReturningColumnsType.NoColumns);
LineShape toLine = GetLineShape(tempFeature);
angles.Add(item, routingEngine.GetAngleBetweenTwoLines(e.LineShape, toLine));
}
foreach (KeyValuePair<string, double> angle in angles)
{
if (angle.Value > turnRestrictionAngle)
{
e.RouteSegment.EndPointAdjacentIds.Remove(angle.Key);
}
}
}
Thanks,
Johnny,
Hello Johnny,
Thanks for your reply. We’re still in the proof of concept phase and haven’t done any coding yet. But it’s good to know there’s a way to add turn restrictions. We’ll probably send some more posts pretty soon.
Thanks for your complete answer.
Have a good day,
Rodrigo Ludwig
Rodrigo,
You are so welcome, please feel free to ask any question.
Thanks,
Johnny,