예제 #1
0
        private void cbxAddStop_CheckedChanged(object sender, EventArgs e)
        {
            RoutingLayer routingLayer = (RoutingLayer)((LayerOverlay)winformsMap1.Overlays["RoutingOverlay"]).Layers["RoutingLayer"];

            Route();
            winformsMap1.Refresh(winformsMap1.Overlays["RoutingOverlay"]);
        }
예제 #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            mapView = new MapView(View.Frame);
            View.Add(mapView);
            ComposeTableControl();

            mapView.MapUnit       = GeographyUnit.Meter;
            mapView.ZoomLevelSet  = ThinkGeoCloudMapsOverlay.GetZoomLevelSet();
            mapView.MapSingleTap += MapViewMapSingleTap;

            ThinkGeoCloudMapsOverlay thinkGeoCloudMapsOverlay = new ThinkGeoCloudMapsOverlay();

            mapView.Overlays.Add(thinkGeoCloudMapsOverlay);

            layerOverlay = new LayerOverlay();
            routingLayer = new RoutingLayer();
            layerOverlay.Layers.Add(routingLayer);
            mapView.Overlays.Add(layerOverlay);

            string shapeFilePath = Path.Combine("AppData", "DallasCounty-3857.shp");
            string rtgPath       = Path.Combine("AppData", "DallasCounty-3857.rtg");
            var    routingSource = new RtgRoutingSource(rtgPath);
            var    featureSource = new ShapeFileFeatureSource(shapeFilePath);

            routingEngine = new RoutingEngine(routingSource, featureSource);
            routingEngine.GeographyUnit        = GeographyUnit.Meter;
            routingEngine.SearchRadiusInMeters = 200;

            mapView.CurrentExtent = new RectangleShape(-10781100.2970769, 3875007.18710502, -10767407.8727504, 3854947.78546675);
            mapView.Refresh();
        }
예제 #3
0
        private void Route()
        {
            FeatureSource featureSource = new ShapeFileFeatureSource(Path.Combine(rootPath, "DallasCounty-4326.shp"));
            RoutingSource routingSource = new RtgRoutingSource(Path.Combine(rootPath, "DallasCounty-4326.shortest.rtg"));
            RoutingEngine routingEngine = new RoutingEngine(routingSource, featureSource);

            RoutingLayer           routingLayer = (RoutingLayer)((LayerOverlay)winformsMap1.Overlays["RoutingOverlay"]).Layers["RoutingLayer"];
            Collection <LineShape> paths        = new Collection <LineShape>();

            if (cbxAddStop.Checked)
            {
                paths.Add(routingEngine.GetRoute(routingLayer.StartPoint, routingLayer.StopPoints[0]).Route);
                paths.Add(routingEngine.GetRoute(routingLayer.StopPoints[0], routingLayer.EndPoint).Route);
            }
            else
            {
                paths.Add(routingEngine.GetRoute(routingLayer.StartPoint, routingLayer.EndPoint).Route);
            }

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

            inmemoryLayer.Routes.Clear();
            foreach (LineShape item in paths)
            {
                inmemoryLayer.Routes.Add(item);
            }
        }
예제 #4
0
        private void RenderMap()
        {
            winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#e6e5d1"));
            winformsMap1.CurrentExtent = new RectangleShape(-96.905564, 32.926216, -96.651506, 32.744942);

            WorldStreetsAndImageryOverlay worldStreetsAndImageryOverlay = new WorldStreetsAndImageryOverlay();

            winformsMap1.Overlays.Add(worldStreetsAndImageryOverlay);

            ShapeFileFeatureLayer streetsLayer = new ShapeFileFeatureLayer(Path.Combine(rootPath, "DallasCounty-4326.shp"));

            streetsLayer.Open();

            RoutingLayer routingLayer = new RoutingLayer();

            streetsLayer.Open();
            routingLayer.StartPoint = streetsLayer.FeatureSource.GetFeatureById(txtStartId.Text, ReturningColumnsType.NoColumns).GetShape().GetCenterPoint();
            routingLayer.EndPoint   = streetsLayer.FeatureSource.GetFeatureById(txtEndId.Text, ReturningColumnsType.NoColumns).GetShape().GetCenterPoint();
            streetsLayer.Close();
            LayerOverlay routingOverlay = new LayerOverlay();

            routingOverlay.Layers.Add("RoutingLayer", routingLayer);
            winformsMap1.Overlays.Add("RoutingOverlay", routingOverlay);

            InMemoryFeatureLayer routingExtentLayer = new InMemoryFeatureLayer();

            routingExtentLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = new AreaStyle(new GeoPen(GeoColor.SimpleColors.Green));
            routingExtentLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            routingExtentLayer.InternalFeatures.Add(new Feature(new RectangleShape(-97.080185, 33.013491, -96.465213, 32.490127)));
            routingOverlay.Layers.Add("RoutingExtentLayer", routingExtentLayer);

            winformsMap1.Refresh();
        }
예제 #5
0
        private void btnFindBestRoute_Click(object sender, EventArgs e)
        {
            LayerOverlay overlay      = (LayerOverlay)winformsMap1.Overlays["RoutingOverlay"];
            RoutingLayer routingLayer = (RoutingLayer)overlay.Layers["RoutingLayer"];

            Stopwatch watch = new Stopwatch();

            watch.Start();
            RoutingResult routingResult = routingEngine.GetRoute(routingLayer.StartPoint, routingLayer.StopPoints, int.Parse(txtIterations.Text));

            watch.Stop();
            // Render the route
            routingLayer.Routes.Clear();
            routingLayer.Routes.Add(routingResult.Route);
            winformsMap1.Refresh(winformsMap1.Overlays["RoutingOverlay"]);

            routingLayer.StopPoints.Clear();
            foreach (PointShape stop in routingResult.OrderedStops)
            {
                routingLayer.StopPoints.Add(stop);
            }
            routingLayer.ShowStopOrder = true;
            txtTimeUsed.Text           = watch.ElapsedMilliseconds.ToString(CultureInfo.InvariantCulture) + " ms";
            txtDistance.Text           = routingResult.Distance.ToString(CultureInfo.InvariantCulture);
            winformsMap1.Refresh(overlay);
        }
예제 #6
0
        private void RenderMap()
        {
            winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#e6e5d1"));
            winformsMap1.CurrentExtent = new RectangleShape(-97.763384, 30.299707, -97.712382, 30.259309);

            OleDbLineFeatureLayer austinstreetsLayer = new OleDbLineFeatureLayer(featureSource);

            austinstreetsLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle    = LineStyles.LocalRoad3;
            austinstreetsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            LayerOverlay austinstreetsOverlay = new LayerOverlay();

            austinstreetsOverlay.Layers.Add("AustinstreetsLayer", austinstreetsLayer);
            winformsMap1.Overlays.Add("AustinstreetsOverlay", austinstreetsOverlay);

            RoutingLayer routingLayer = new RoutingLayer();

            austinstreetsLayer.Open();
            routingLayer.StartPoint = austinstreetsLayer.FeatureSource.GetFeatureById(txtStartId.Text, ReturningColumnsType.NoColumns).GetShape().GetCenterPoint();
            routingLayer.EndPoint   = austinstreetsLayer.FeatureSource.GetFeatureById(txtEndId.Text, ReturningColumnsType.NoColumns).GetShape().GetCenterPoint();
            austinstreetsLayer.Close();
            LayerOverlay routingOverlay = new LayerOverlay();

            routingOverlay.Layers.Add("RoutingLayer", routingLayer);
            winformsMap1.Overlays.Add("RoutingOverlay", routingOverlay);

            winformsMap1.Refresh();
        }
예제 #7
0
        private void RenderMap()
        {
            winformsMap1.MapUnit       = GeographyUnit.DecimalDegree;
            winformsMap1.CurrentExtent = new RectangleShape(-96.905564, 32.926216, -96.651506, 32.744942);

            //WorldMapKitWmsDesktopOverlay worldMapKitsOverlay = new WorldMapKitWmsDesktopOverlay();
            //winformsMap1.Overlays.Add(worldMapKitsOverlay);

            ShapeFileFeatureLayer featureLayer = new ShapeFileFeatureLayer(Path.Combine(rootPath, "DallasCounty-4326.shp"));

            featureLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle    = new LineStyle(new GeoPen(GeoColors.LightGray, 1));
            featureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            ShapeFileFeatureSource featureSource = new ShapeFileFeatureSource(Path.Combine(rootPath, "DallasCounty-4326.shp"));

            featureSource.Open();
            RoutingLayer routingLayer = new RoutingLayer();

            routingLayer.StartPoint = featureSource.GetFeatureById(txtStartId.Text, ReturningColumnsType.NoColumns).GetShape().GetCenterPoint();
            routingLayer.EndPoint   = featureSource.GetFeatureById(txtEndId.Text, ReturningColumnsType.NoColumns).GetShape().GetCenterPoint();
            LayerOverlay routingOverlay = new LayerOverlay();

            routingOverlay.Layers.Add("afda", featureLayer);
            routingOverlay.Layers.Add("RoutingLayer", routingLayer);
            winformsMap1.Overlays.Add("RoutingOverlay", routingOverlay);

            InMemoryFeatureLayer routingExtentLayer = new InMemoryFeatureLayer();

            routingExtentLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = new AreaStyle(new GeoPen(GeoColor.SimpleColors.Green));
            routingExtentLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            routingExtentLayer.InternalFeatures.Add(new Feature(new RectangleShape(-97.080185, 33.013491, -96.465213, 32.490127)));
            routingOverlay.Layers.Add("RoutingExtentLayer", routingExtentLayer);

            winformsMap1.Refresh();
        }
예제 #8
0
        private void RenderMap()
        {
            winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#e6e5d1"));
            winformsMap1.CurrentExtent = new RectangleShape(-97.7649196668701, 30.3019741827087, -97.749040989502, 30.2906445318298);

            WorldStreetsAndImageryOverlay worldStreetsAndImageryOverlay = new WorldStreetsAndImageryOverlay();

            winformsMap1.Overlays.Add(worldStreetsAndImageryOverlay);

            ShapeFileFeatureLayer dallasStreetsLayer = new ShapeFileFeatureLayer(Path.Combine(rootPath, "DallasWithOneWayRoad.shp"));

            dallasStreetsLayer.Open();

            RoutingLayer routingLayer = new RoutingLayer();

            dallasStreetsLayer.Open();
            routingLayer.StartPoint = dallasStreetsLayer.FeatureSource.GetFeatureById(txtStartId.Text, ReturningColumnsType.NoColumns).GetShape().GetCenterPoint();
            routingLayer.EndPoint   = dallasStreetsLayer.FeatureSource.GetFeatureById(txtEndId.Text, ReturningColumnsType.NoColumns).GetShape().GetCenterPoint();
            dallasStreetsLayer.Close();
            LayerOverlay routingOverlay = new LayerOverlay();

            routingOverlay.Layers.Add("RoutingLayer", routingLayer);
            winformsMap1.Overlays.Add("RoutingOverlay", routingOverlay);
            ShowTheShortestPath(routingLayer);

            InMemoryFeatureLayer routingExtentLayer = new InMemoryFeatureLayer();

            routingExtentLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = new AreaStyle(new GeoPen(GeoColor.SimpleColors.Green));
            routingExtentLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            routingExtentLayer.InternalFeatures.Add(new Feature(new RectangleShape(-97.815409, 30.369949, -97.657999, 30.217922)));
            routingOverlay.Layers.Add("RoutingExtentLayer", routingExtentLayer);

            winformsMap1.Refresh();
        }
예제 #9
0
        private void RenderMap()
        {
            winformsMap1.MapUnit = GeographyUnit.Meter;
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#e6e5d1"));
            winformsMap1.CurrentExtent = new RectangleShape(-10787478.039515, 3885514.4616168, -10759196.432323, 3861498.009642);

            GoogleMapsOverlay googleMapsOverlay = new GoogleMapsOverlay();

            googleMapsOverlay.TileCache = new FileBitmapTileCache("C:\\ImageCache");
            winformsMap1.Overlays.Add(googleMapsOverlay);

            ShapeFileFeatureSource featureSource = new ShapeFileFeatureSource(Path.Combine(rootPath, "DallasCounty-3857.shp"));

            featureSource.Open();
            RoutingLayer routingLayer = new RoutingLayer();

            routingLayer.StartPoint = featureSource.GetFeatureById(txtStartId.Text, ReturningColumnsType.NoColumns).GetShape().GetCenterPoint();
            routingLayer.EndPoint   = featureSource.GetFeatureById(txtEndId.Text, ReturningColumnsType.NoColumns).GetShape().GetCenterPoint();
            LayerOverlay routingOverlay = new LayerOverlay();

            routingOverlay.Layers.Add("RoutingLayer", routingLayer);
            winformsMap1.Overlays.Add("RoutingOverlay", routingOverlay);

            InMemoryFeatureLayer routingExtentLayer = new InMemoryFeatureLayer();

            routingExtentLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = new AreaStyle(new GeoPen(GeoColor.SimpleColors.Green));
            routingExtentLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            routingExtentLayer.InternalFeatures.Add(new Feature(new RectangleShape(-10806916.7603168, 3897094.80494128, -10738458.3904247, 3827820.76830281)));
            routingOverlay.Layers.Add("RoutingExtentLayer", routingExtentLayer);

            winformsMap1.Refresh();
        }
예제 #10
0
        private void RenderMap()
        {
            winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#e6e5d1"));
            winformsMap1.CurrentExtent = new RectangleShape(-96.905564, 32.926216, -96.651506, 32.744942);

            WorldStreetsAndImageryOverlay worldStreetsAndImageryOverlay = new WorldStreetsAndImageryOverlay();

            winformsMap1.Overlays.Add(worldStreetsAndImageryOverlay);

            RoutingLayer routingLayer   = new RoutingLayer();
            LayerOverlay routingOverlay = new LayerOverlay();

            winformsMap1.Overlays.Add("RoutingOverlay", routingOverlay);
            routingOverlay.Layers.Add("RoutingLayer", routingLayer);

            string[] startCoordinates = txtStartCoordinate.Text.Split(',');
            routingLayer.StartPoint = new PointShape(double.Parse(startCoordinates[0], CultureInfo.InvariantCulture), double.Parse(startCoordinates[1], CultureInfo.InvariantCulture));
            foreach (object item in lsbPoints.Items)
            {
                string[]   coordinate     = item.ToString().Split(',');
                PointShape pointNeedVisit = new PointShape(double.Parse(coordinate[0], CultureInfo.InvariantCulture), double.Parse(coordinate[1], CultureInfo.InvariantCulture));
                routingLayer.StopPoints.Add(pointNeedVisit);
            }
            routingLayer.ShowStopOrder = false;

            InMemoryFeatureLayer routingExtentLayer = new InMemoryFeatureLayer();

            routingExtentLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = new AreaStyle(new GeoPen(GeoColor.SimpleColors.Green));
            routingExtentLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            routingExtentLayer.InternalFeatures.Add(new Feature(new RectangleShape(-97.080185, 33.013491, -96.465213, 32.490127)));
            routingOverlay.Layers.Add("RoutingExtentLayer", routingExtentLayer);

            winformsMap1.Refresh();
        }
예제 #11
0
        private void InitalizeMap()
        {
            mapView.MapUnit      = GeographyUnit.Meter;
            mapView.ZoomLevelSet = new ThinkGeoCloudMapsZoomLevelSet();
            mapView.SingleTap   += MapView_SingleTap;

            // Please input your ThinkGeo Cloud Client ID / Client Secret to enable the background map.
            ThinkGeoCloudRasterMapsOverlay baseOverlay = new ThinkGeoCloudRasterMapsOverlay("ThinkGeo Cloud Client ID", "ThinkGeo Cloud Client Secret");

            mapView.Overlays.Add(baseOverlay);

            layerOverlay = new LayerOverlay();
            routingLayer = new RoutingLayer();
            layerOverlay.Layers.Add(routingLayer);
            mapView.Overlays.Add(layerOverlay);

            var routingSource = new RtgRoutingSource(DataManager.GetDataPath("DallasCounty-3857.rtg"));
            var featureSource = new ShapeFileFeatureSource(DataManager.GetDataPath("DallasCounty-3857.shp"));

            routingEngine = new RoutingEngine(routingSource, featureSource);
            routingEngine.GeographyUnit        = GeographyUnit.Meter;
            routingEngine.SearchRadiusInMeters = 100;

            mapView.CurrentExtent = new RectangleShape(-10781100.2970769, 3875007.18710502, -10767407.8727504, 3854947.78546675);
        }
예제 #12
0
        private void FindPath()
        {
            RoutingLayer routingLayer = (RoutingLayer)((LayerOverlay)winformsMap1.Overlays["RoutingOverlay"]).Layers["RoutingLayer"];

            routingLayer.Routes.Clear();
            routingLayer.Routes.Add(routingEngine.GetRoute(txtStartId.Text, txtEndId.Text).Route);

            winformsMap1.Refresh(winformsMap1.Overlays["RoutingOverlay"]);
        }
예제 #13
0
        private void ShowTheShortestPath(RoutingLayer routingLayer)
        {
            RoutingSource routingSource = new RtgRoutingSource(Path.Combine(rootPath, "DallasWithOneWayRoad.rtg"));
            RoutingEngine routingEngine = new RoutingEngine(routingSource, featureSource);
            RoutingResult routingResult = routingEngine.GetRoute(txtStartId.Text, txtEndId.Text);

            routingLayer.Routes.Clear();
            routingLayer.Routes.Add(routingResult.Route);
        }
예제 #14
0
        void cbmPrioritiy_SelectedIndexChanged(object sender, EventArgs e)
        {
            RoutingResult routingResult = routingEngine.GetRoute(txtStartId.Text, txtEndId.Text);

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

            routingLayer.Routes.Clear();
            routingLayer.Routes.Add(routingResult.Route);

            winformsMap1.CurrentExtent = new RectangleShape(-96.905564, 32.926216, -96.651506, 32.744942);
            winformsMap1.Refresh(winformsMap1.Overlays["RoutingOverlay"]);
        }
예제 #15
0
        private void btnRoute_Click(object sender, EventArgs e)
        {
            RoutingSource          routingSource = new RtgRoutingSource(Path.Combine(rootPath, "DallasCounty-4326.shortest.rtg"));
            ShapeFileFeatureSource featureSource = new ShapeFileFeatureSource(Path.Combine(rootPath, "DallasCounty-4326.shp"));

            RoutingEngine routingEngine = new RoutingEngine(routingSource, featureSource);
            RoutingLayer  routingLayer  = (RoutingLayer)((LayerOverlay)winformsMap1.Overlays["RoutingOverlay"]).Layers["RoutingLayer"];
            RoutingResult routingResult = routingEngine.GetRoute(routingLayer.StartPoint, routingLayer.EndPoint);

            routingLayer.Routes.Clear();
            routingLayer.Routes.Add(routingResult.Route);

            winformsMap1.Refresh(winformsMap1.Overlays["RoutingOverlay"]);
        }
예제 #16
0
        void cbmAlgorithm_SelectedIndexChanged(object sender, EventArgs e)
        {
            FeatureSource featureSource = new ShapeFileFeatureSource(Path.Combine(rootPath, "DallasCounty-4326.shp"));
            RoutingSource routingSource = new RtgRoutingSource(Path.Combine(rootPath, "DallasCounty-4326.shortest.rtg"));
            RoutingEngine routingEngine = new RoutingEngine(routingSource, GetAlgorithm(), featureSource);
            RoutingResult routingResult = routingEngine.GetRoute(txtStartId.Text, txtEndId.Text);

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

            routingLayer.Routes.Clear();
            routingLayer.Routes.Add(routingResult.Route);

            winformsMap1.Refresh(winformsMap1.Overlays["RoutingOverlay"]);
        }
예제 #17
0
        private void btnRoute_Click(object sender, EventArgs e)
        {
            ShapeFileFeatureSource featureSource = new ShapeFileFeatureSource(Path.Combine(rootPath, "DallasCounty-4326.shp"));
            RoutingSource          routingSource = new CustomRoutingSource(featureSource);
            RoutingEngine          routingEngine = new RoutingEngine(routingSource, featureSource);
            RoutingResult          routingResult = routingEngine.GetRoute(txtStartId.Text, txtEndId.Text);

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

            routingLayer.Routes.Clear();
            routingLayer.Routes.Add(routingResult.Route);

            winformsMap1.Refresh(winformsMap1.Overlays["RoutingOverlay"]);
        }
예제 #18
0
        private void btnRoute_Click(object sender, EventArgs e)
        {
            // Switch the start and end points
            string temp = txtStartId.Text;

            txtStartId.Text = txtEndId.Text;
            txtEndId.Text   = temp;

            RoutingLayer routingLayer = (RoutingLayer)((LayerOverlay)winformsMap1.Overlays["RoutingOverlay"]).Layers["RoutingLayer"];
            PointShape   tempPoint    = routingLayer.StartPoint;

            routingLayer.StartPoint = routingLayer.EndPoint;
            routingLayer.EndPoint   = tempPoint;

            ShowTheShortestPath(routingLayer);

            winformsMap1.Refresh(winformsMap1.Overlays["RoutingOverlay"]);
        }
예제 #19
0
        private void RenderMap()
        {
            winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#e6e5d1"));
            winformsMap1.CurrentExtent = new RectangleShape(-96.905564, 32.926216, -96.651506, 32.744942);

            WorldStreetsAndImageryOverlay worldStreetsAndImageryOverlay = new WorldStreetsAndImageryOverlay();

            winformsMap1.Overlays.Add(worldStreetsAndImageryOverlay);

            routingLayer = new RoutingLayer();
            string[] startCoordinates = txtStartPoint.Text.Split(',');
            routingLayer.StartPoint = new PointShape(double.Parse(startCoordinates[0], CultureInfo.InvariantCulture), double.Parse(startCoordinates[1], CultureInfo.InvariantCulture));
            string[] endCoordinates = txtEndPoint.Text.Split(',');
            routingLayer.EndPoint = new PointShape(double.Parse(endCoordinates[0], CultureInfo.InvariantCulture), double.Parse(endCoordinates[1], CultureInfo.InvariantCulture));
            LayerOverlay routingOverlay = new LayerOverlay();

            routingOverlay.Layers.Add("RoutingLayer", routingLayer);
            winformsMap1.Overlays.Add("RoutingOverlay", routingOverlay);

            InMemoryFeatureLayer adjacentRoadsLayer = new InMemoryFeatureLayer();

            adjacentRoadsLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle    = new LineStyle(new GeoPen(GeoColor.FromArgb(160, GeoColor.SimpleColors.Yellow), 6));
            adjacentRoadsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            LayerOverlay roadsOverlay = new LayerOverlay();

            winformsMap1.Overlays.Add("RoadsOverlay", roadsOverlay);
            roadsOverlay.Layers.Add("adjacentRoadsLayer", adjacentRoadsLayer);

            InMemoryFeatureLayer currentRoadLayer = new InMemoryFeatureLayer();

            currentRoadLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle    = new LineStyle(new GeoPen(GeoColor.FromArgb(160, GeoColor.SimpleColors.Red), 6));
            currentRoadLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            roadsOverlay.Layers.Add("currentRoadLayer", currentRoadLayer);

            InMemoryFeatureLayer currentEditLayer = new InMemoryFeatureLayer();

            currentEditLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle    = new LineStyle(new GeoPen(GeoColor.SimpleColors.Blue, 6));
            currentEditLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            roadsOverlay.Layers.Add("currentEditLayer", currentEditLayer);

            winformsMap1.Refresh();
        }
예제 #20
0
        private void RenderMap()
        {
            winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#e6e5d1"));
            winformsMap1.CurrentExtent = new RectangleShape(-96.905564, 32.926216, -96.651506, 32.744942);

            WorldStreetsAndImageryOverlay worldStreetsAndImageryOverlay = new WorldStreetsAndImageryOverlay();

            winformsMap1.Overlays.Add(worldStreetsAndImageryOverlay);

            RoutingLayer routingLayer = new RoutingLayer();

            string[] startCoordinates = txtStartCoordinate.Text.Split(',');
            routingLayer.StartPoint = new PointShape(double.Parse(startCoordinates[0], CultureInfo.InvariantCulture), double.Parse(startCoordinates[1], CultureInfo.InvariantCulture));
            string[] endCoordinates = txtEndCoordinate.Text.Split(',');
            routingLayer.EndPoint = new PointShape(double.Parse(endCoordinates[0], CultureInfo.InvariantCulture), double.Parse(endCoordinates[1], CultureInfo.InvariantCulture));
            LayerOverlay routingOverlay = new LayerOverlay();

            routingOverlay.Layers.Add("RoutingLayer", routingLayer);
            winformsMap1.Overlays.Add("RoutingOverlay", routingOverlay);

            featureSource.Open();
            startFeature = featureSource.GetFeaturesNearestTo(routingLayer.StartPoint, winformsMap1.MapUnit, 1, ReturningColumnsType.NoColumns)[0];
            endFeature   = featureSource.GetFeaturesNearestTo(routingLayer.EndPoint, winformsMap1.MapUnit, 1, ReturningColumnsType.NoColumns)[0];

            roadblocksLayer = new InMemoryFeatureLayer();
            MemoryStream stream = new MemoryStream();

            Properties.Resources.roadblock.Save(stream, ImageFormat.Png);
            roadblocksLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(new GeoImage(stream));
            //stream.Close();
            roadblocksLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            routingOverlay.Layers.Add("roadblocksLayer", roadblocksLayer);

            InMemoryFeatureLayer routingExtentLayer = new InMemoryFeatureLayer();

            routingExtentLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = new AreaStyle(new GeoPen(GeoColor.SimpleColors.Green));
            routingExtentLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            routingExtentLayer.InternalFeatures.Add(new Feature(new RectangleShape(-97.080185, 33.013491, -96.465213, 32.490127)));
            routingOverlay.Layers.Add("RoutingExtentLayer", routingExtentLayer);

            winformsMap1.Refresh();
        }
예제 #21
0
        private void btnRoute_Click(object sender, EventArgs e)
        {
            RoutingSource routingSource = new RtgRoutingSource(@"..\..\SampleData\AustinStreetFromOleDb.rtg");
            RoutingEngine routingEngine = new RoutingEngine(routingSource, new DijkstraRoutingAlgorithm(), featureSource);
            RoutingResult routingResult = routingEngine.GetRoute(txtStartId.Text, txtEndId.Text);

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

            winformsMap1.Overlays["RoutingOverlay"].Lock.EnterWriteLock();
            try
            {
                routingLayer.Routes.Clear();
                routingLayer.Routes.Add(routingResult.Route);
            }
            finally
            {
                winformsMap1.Overlays["RoutingOverlay"].Lock.ExitWriteLock();
            }

            winformsMap1.Refresh();
        }
예제 #22
0
        private void RenderMap()
        {
            winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#e6e5d1"));
            winformsMap1.CurrentExtent = new RectangleShape(-96.9055649057617, 32.9262169589844, -96.6515060678711, 32.7449425449219);

            //WorldStreetsAndImageryOverlay worldStreetsAndImageryOverlay = new WorldStreetsAndImageryOverlay();
            //winformsMap1.Overlays.Add(worldStreetsAndImageryOverlay);

            ShapeFileFeatureLayer featureLayer = new ShapeFileFeatureLayer(Path.Combine(rootPath, "DallasCounty-4326.shp"));

            featureLayer.Open();
            featureLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle    = new LineStyle(new GeoPen(GeoColors.LightGray, 1));
            featureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            string[]   startCoordinates = txtStartCoordinate.Text.Split(',');
            PointShape startPoint       = new PointShape(double.Parse(startCoordinates[0], CultureInfo.InvariantCulture), double.Parse(startCoordinates[1], CultureInfo.InvariantCulture));

            string[]   endCoordinates = txtEndCoordinate.Text.Split(',');
            PointShape endPoint       = new PointShape(double.Parse(endCoordinates[0], CultureInfo.InvariantCulture), double.Parse(endCoordinates[1], CultureInfo.InvariantCulture));

            RoutingLayer routingLayer = new RoutingLayer();

            routingLayer.StartPoint = startPoint;
            routingLayer.EndPoint   = endPoint;
            LayerOverlay routingOverlay = new LayerOverlay();

            routingOverlay.Layers.Add("afda", featureLayer);
            routingOverlay.Layers.Add("RoutingLayer", routingLayer);
            winformsMap1.Overlays.Add("RoutingOverlay", routingOverlay);

            InMemoryFeatureLayer routingExtentLayer = new InMemoryFeatureLayer();

            routingExtentLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = new AreaStyle(new GeoPen(GeoColor.SimpleColors.Green));
            routingExtentLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            routingExtentLayer.InternalFeatures.Add(new Feature(new RectangleShape(-97.080185, 33.013491, -96.465213, 32.490127)));
            routingOverlay.Layers.Add("RoutingExtentLayer", routingExtentLayer);

            winformsMap1.Refresh();
        }
예제 #23
0
        private void btnRoute_Click(object sender, EventArgs e)
        {
            RoutingLayer routingLayer = (RoutingLayer)((LayerOverlay)winformsMap1.Overlays["RoutingOverlay"]).Layers["RoutingLayer"];

            routingLayer.Routes.Clear();
            routingLayer.Routes.Add(routingEngine.GetRoute(txtStartId.Text, txtEndId.Text).Route);

            InMemoryFeatureLayer POIsOnRouteLayer = new InMemoryFeatureLayer();
            MemoryStream         stream           = new MemoryStream();

            Properties.Resources.Gas_Station.Save(stream, ImageFormat.Png);
            POIsOnRouteLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle   = new PointStyle(new GeoImage(stream));
            POIsOnRouteLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            LayerOverlay POIsOnRouteOverlay = new LayerOverlay();

            POIsOnRouteOverlay.Layers.Add(POIsOnRouteLayer);
            winformsMap1.Overlays.Add(POIsOnRouteOverlay);

            ShapeFileFeatureLayer poiLayer = (ShapeFileFeatureLayer)((LayerOverlay)winformsMap1.Overlays["POIoverlay"]).Layers["POIlayer"];

            poiLayer.Open();
            Collection <Feature> features = poiLayer.QueryTools.GetFeaturesWithinDistanceOf(routingLayer.Routes[0], GeographyUnit.DecimalDegree, DistanceUnit.Meter,
                                                                                            100, ReturningColumnsType.NoColumns);

            poiLayer.Close();
            POIsOnRouteLayer.Open();
            POIsOnRouteLayer.EditTools.BeginTransaction();
            foreach (Feature feature in features)
            {
                POIsOnRouteLayer.EditTools.Add(feature);
            }
            POIsOnRouteLayer.EditTools.CommitTransaction();
            POIsOnRouteLayer.Close();

            winformsMap1.Refresh(winformsMap1.Overlays["RoutingOverlay"]);
        }
예제 #24
0
        private void Route()
        {
            RoutingLayer routingLayer = (RoutingLayer)((LayerOverlay)winformsMap1.Overlays["RoutingOverlay"]).Layers["RoutingLayer"];

            avoidableFeatureIds.Clear();
            foreach (Feature feature in roadblocksLayer.InternalFeatures)
            {
                avoidableFeatureIds.Add(feature.Id);
            }

            routingLayer.Routes.Clear();
            RoutingResult routingResult = routingEngine.GetRoute(routingLayer.StartPoint, routingLayer.EndPoint);

            if (routingResult.Features.Count == 0)
            {
                MessageBox.Show("No route exists!");
            }
            else
            {
                routingLayer.Routes.Add(routingResult.Route);
            }

            winformsMap1.Refresh(winformsMap1.Overlays["RoutingOverlay"]);
        }