Rami,
Generally there are two columns, one indicates whether the road is one-way, another is for the direction. Could you post them?
It seems that there are two reasons:
- There is no one-way information in the .rtg file you gave. Building one-way routing index is a little different from normal data. You can refer to the attachment about how to build one-way index file and rebuild .rtg file.
- Currently, there isn’t a build-in function to deal with routing on a single “one-way” road. If the input start and end feature id are the same, we need some custom code like below:
PointShape startPoint;
PointShape endPoint;
string startFeatureId = featureSource.GetFeaturesNearestTo(startPoint, GeographyUnit.DecimalDegree, 1, ReturningColumnsType.NoColumns)[0].Id;
string endFeatureId = featureSource.GetFeaturesNearestTo(endPoint, GeographyUnit.DecimalDegree, 1, ReturningColumnsType.NoColumns)[0].Id;
string startSegmentId = routingSource.GetRouteSegmentByFeatureId(startFeatureId).FeatureId;
string endSegmentId = routingSource.GetRouteSegmentByFeatureId(endFeatureId).FeatureId;
RoutingResult result = new RoutingResult();
if (startSegmentId == endSegmentId)
{
Feature feature = featureSource.GetFeatureById(startFeatureId, new string[] { "ONE_WAY", "INDICATOR" });
LineShape line = ((MultilineShape)feature.GetShape()).Lines[0];
double startDistance = startPoint.GetDistanceTo(new PointShape(line.Vertices[0].X, line.Vertices[0].Y), GeographyUnit.DecimalDegree, DistanceUnit.Meter);
double endDistance = endPoint.GetDistanceTo(new PointShape(line.Vertices[0].X, line.Vertices[0].Y), GeographyUnit.DecimalDegree, DistanceUnit.Meter);
// if the one-way direction is from start to end
if (feature.ColumnValues["ONE_WAY"] == "Y" && feature.ColumnValues["INDICATOR"] == "0")
{
if (startDistance < endDistance)
{
result.Features.Add(new Feature(line));
}
else
{
result = routingEngine.GetRoute(startFeatureId, endFeatureId);
}
}
else if (feature.ColumnValues["ONE_WAY"] == "Y" && feature.ColumnValues["INDICATOR"] == "0")
{
if (startDistance > endDistance)
{
result.Features.Add(new Feature(line));
}
else
{
result = routingEngine.GetRoute(startFeatureId, endFeatureId);
}
}
}
Thanks,
Johnny
1910-BuildOneWayData-Step2.zip (3.91 KB)