I have a street shapefile of my city. I viewed it in ArcView and everything looks fine about it. I used Map Suite Routing Explorer to build the rtg and rtx files. Then, with the code below I want to get the route between two points on it and as you can see, I have a strange route. I wonder what the problem is. Is it the data? Why isn't it working with my data?
// Set the Map Unit and current extent
winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.StandardColors.LightGoldenrodYellow);
// Define a new layer to render the Medellin streets
ShapeFileFeatureLayer StreetLayer = new ShapeFileFeatureLayer(@"..\..\Data\Routing\Medellin.shp");
StreetLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.LocalRoad3;
StreetLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("Name", "Arial", 10, DrawingFontStyles.Regular, GeoColor.StandardColors.Black);
StreetLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
LayerOverlay StreetOverlay = new LayerOverlay();
StreetOverlay.Layers.Add("MedellinStreetsLayer", StreetLayer);
winformsMap1.Overlays.Add("MedellinStreetOverlay", StreetOverlay);
//StreetLayer.Open();
winformsMap1.CurrentExtent = new RectangleShape(-75.6033, 6.2488, -75.5872, 6.2386);
//StreetLayer.Close();
// Define a Routing layer to render the route and stops
RoutingLayer routingLayer = new RoutingLayer();
StreetLayer.Open();
Collection<Feature> features1 = StreetLayer.FeatureSource.GetFeaturesByColumnValue("OSM_ID", "33179250");
Collection<Feature> features2 = StreetLayer.FeatureSource.GetFeaturesByColumnValue("OSM_ID", "31540427");
routingLayer.StartPoint = features1[0].GetShape().GetCenterPoint();
routingLayer.EndPoint = features2[0].GetShape().GetCenterPoint();
StreetLayer.Close();
LayerOverlay routingOverlay = new LayerOverlay();
routingOverlay.Layers.Add("RoutingLayer", routingLayer);
winformsMap1.Overlays.Add("RoutingOverlay", routingOverlay);
RtgRoutingSource rtgRoutingSource = new RtgRoutingSource(@"..\..\Data\Routing\Medellin.rtg");
RoutingEngine routingEngine = new RoutingEngine(rtgRoutingSource, StreetLayer.FeatureSource);
winformsMap1.Overlays["RoutingOverlay"].Lock.EnterWriteLock();
try
{
routingLayer.Routes.Clear();
routingLayer.Routes.Add(routingEngine.GetRoute(routingLayer.StartPoint, routingLayer.EndPoint).Route);
}
finally
{
winformsMap1.Overlays["RoutingOverlay"].Lock.ExitWriteLock();
}
winformsMap1.Refresh();