예제 #1
0
        private void btnRoute_Click(object sender, EventArgs e)
        {
            ShapeFileFeatureSource featureSource = new ShapeFileFeatureSource(@"..\..\SampleData\Austinstreets.shp");
            RoutingSource          routingSource = new RtgRoutingSource(@"..\..\SampleData\routeDataForFastest.rtg");
            RoutingEngine          routingEngine = new RoutingEngine(routingSource, featureSource);
            RoutingResult          routingResult = routingEngine.GetShortestPath(txtStartId.Text, txtEndId.Text);

            InMemoryFeatureLayer routingLayer = (InMemoryFeatureLayer)((LayerOverlay)winformsMap1.Overlays["RoutingOverlay"]).Layers["RoutingLayer"];

            winformsMap1.Overlays["RoutingOverlay"].Lock.EnterWriteLock();
            try
            {
                routingLayer.InternalFeatures.Clear();
                foreach (Feature feature in routingResult.Features)
                {
                    routingLayer.InternalFeatures.Add(feature);
                }
            }
            finally
            {
                winformsMap1.Overlays["RoutingOverlay"].Lock.ExitWriteLock();
            }

            winformsMap1.Refresh();
        }