private void UpdateArguments(InteractionArguments interactionArguments)
        {
            if (TrackMode != TrackMode.None)
            {
                PointShape point = new PointShape(interactionArguments.WorldX, interactionArguments.WorldY);

                if (searchingVertices.Count < 1)
                {
                    return;
                }

                try
                {
                    Vertex vertex = GetClosestVertex(searchingVertices, point);

                    interactionArguments.WorldX = vertex.X;
                    interactionArguments.WorldY = vertex.Y;

                    ScreenPointF screen = ExtentHelper.ToScreenCoordinate(interactionArguments.CurrentExtent, new PointShape(vertex), interactionArguments.MapWidth, interactionArguments.MapHeight);
                    interactionArguments.ScreenX = screen.X;
                    interactionArguments.ScreenY = screen.Y;
                }
                catch
                { }
            }
        }
Exemplo n.º 2
0
        private void winformsMap1_MouseDown(object sender, MouseEventArgs e)
        {
            InMemoryFeatureLayer mouseMoveLayer = (InMemoryFeatureLayer)((LayerOverlay)winformsMap1.Overlays["MouseMoveOverlay"]).Layers["MouseMoveLayer"];

            if (mouseMoveLayer.InternalFeatures.Count > 0 && string.IsNullOrEmpty(currentStopId))
            {
                isPointSelected = true;
                InMemoryFeatureLayer stopLayer    = (InMemoryFeatureLayer)((LayerOverlay)winformsMap1.Overlays["StopOverlay"]).Layers["StopLayer"];
                PointShape           currentShape = ExtentHelper.ToWorldCoordinate(winformsMap1.CurrentExtent, ((MouseEventArgs)e).X, ((MouseEventArgs)e).Y, winformsMap1.Width, winformsMap1.Height);

                FeatureLayer austinstreetsLayer = winformsMap1.FindFeatureLayer("AustinstreetsLayer");
                austinstreetsLayer.Open();
                Collection <Feature> tempFeatures = austinstreetsLayer.QueryTools.GetFeaturesNearestTo(currentShape, GeographyUnit.DecimalDegree, 1, new string[] { });
                Feature stopRoad = tempFeatures[0];
                austinstreetsLayer.Close();
                currentStopId = stopRoad.Id;
                Feature stopPoint   = new Feature(stopRoad.GetShape().GetCenterPoint().GetWellKnownBinary(), stopRoad.Id);
                Feature lastFeature = stopLayer.InternalFeatures[stopLayer.InternalFeatures.Count - 1];
                //winformsMap1.Overlays["StopOverlay"].Lock.EnterWriteLock();
                //try
                //{
                stopLayer.InternalFeatures.RemoveAt(stopLayer.InternalFeatures.Count - 1);
                stopLayer.InternalFeatures.Add(currentStopId, stopPoint);
                stopLayer.InternalFeatures.Add(lastFeature.Id, lastFeature);
                //}
                //finally
                //{
                //    winformsMap1.Overlays["StopOverlay"].Lock.ExitWriteLock();
                //}
                winformsMap1.Overlays["StopOverlay"].Lock.IsDirty = true;
            }
        }
        protected override void DrawCore(GeoCanvas canvas, Collection <SimpleCandidate> labelsInAllLayers)
        {
            // Draw shape like area and point
            base.DrawCore(canvas, labelsInAllLayers);

            // Draw annotation label
            if (!ZoomLevelSet.CustomZoomLevels.Any(z => z.CustomStyles.OfType <CompositeStyle>().SelectMany(c => c.Styles).Any(s => s is TextStyle)))
            {
                Collection <Feature> annotationFeatures = ((TobinBasFeatureSource)FeatureSource).AnnotationFeatures;
                foreach (var item in annotationFeatures)
                {
                    float textSize = float.Parse(item.ColumnValues["TextSize"].ToString());

                    double     latDiff    = DecimalDegreesHelper.GetLatitudeDifferenceFromDistance(textSize, DistanceUnit.Feet);
                    PointShape startPoint = (PointShape)item.GetShape();
                    PointShape endPoint   = new PointShape(startPoint.X, startPoint.Y + latDiff);
                    float      fontSize   = ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, startPoint, canvas.Width, canvas.Height).Y -
                                            ExtentHelper.ToScreenCoordinate(canvas.CurrentWorldExtent, endPoint, canvas.Width, canvas.Height).Y;

                    if (fontSize > minAnnotationFontSize)
                    {
                        TextStyle textStyle = new TextStyle("TextString", new GeoFont(), new GeoSolidBrush(GeoColor.SimpleColors.Black));
                        textStyle.DuplicateRule   = LabelDuplicateRule.UnlimitedDuplicateLabels;
                        textStyle.OverlappingRule = LabelOverlappingRule.AllowOverlapping;
                        textStyle.YOffsetInPixel  = 1 * fontSize;
                        textStyle.RotationAngle   = double.Parse(item.ColumnValues["TextAngle"]);
                        textStyle.Font            = new GeoFont("Arial", fontSize);
                        textStyle.Draw(new Collection <Feature> {
                            item
                        }, canvas, new Collection <SimpleCandidate>(), labelsInAllLayers);
                    }
                }
            }
        }
        private void AndroidMap_MapSingleTap(object sender, MotionEvent e)
        {
            LayerOverlay         worldOverlay     = (LayerOverlay)androidMap.Overlays["WorldOverlay"];
            FeatureLayer         worldLayer       = (FeatureLayer)worldOverlay.Layers["WorldLayer"];
            LayerOverlay         highlightOverlay = (LayerOverlay)androidMap.Overlays["HighlightOverlay"];
            InMemoryFeatureLayer highlightLayer   = (InMemoryFeatureLayer)highlightOverlay.Layers["HighlightLayer"];

            PointF location = new PointF(e.GetX(), e.GetY());

            var worldLocation = ExtentHelper.ToWorldCoordinate(androidMap.CurrentExtent, location.X,
                                                               location.Y, androidMap.Width, androidMap.Height);

            worldLayer.Open();
            Collection <Feature> selectedFeatures = worldLayer.QueryTools.GetFeaturesContaining(worldLocation, ReturningColumnsType.NoColumns);

            worldLayer.Close();

            highlightLayer.Open();
            highlightLayer.InternalFeatures.Clear();
            if (selectedFeatures.Count > 0)
            {
                androidMap.ZoomTo(selectedFeatures[0].GetBoundingBox());
                highlightLayer.InternalFeatures.Add(selectedFeatures[0]);
            }
            highlightLayer.Close();
            highlightOverlay.Refresh();
        }
Exemplo n.º 5
0
        private void AndroidMapMapSingleTap(object sender, Android.Views.MotionEvent e)
        {
            PointF     location = new PointF(e.GetX(), e.GetY());
            PointShape position = ExtentHelper.ToWorldCoordinate(androidMap.CurrentExtent, location.X,
                                                                 location.Y, androidMap.Width, androidMap.Height);

            LayerOverlay overlay   = androidMap.Overlays["RoadOverlay"] as LayerOverlay;
            FeatureLayer roadLayer = overlay.Layers["TXlkaA40"] as FeatureLayer;

            LayerOverlay         highlightOverlay = androidMap.Overlays["HighlightOverlay"] as LayerOverlay;
            InMemoryFeatureLayer highlightLayer   = (InMemoryFeatureLayer)highlightOverlay.Layers["HighlightLayer"];

            roadLayer.Open();
            Collection <Feature> selectedFeatures = roadLayer.QueryTools.GetFeaturesNearestTo(position, GeographyUnit.DecimalDegree, 1, new string[1] {
                "fename"
            });

            roadLayer.Close();

            if (selectedFeatures.Count > 0)
            {
                LineBaseShape lineShape = (LineBaseShape)selectedFeatures[0].GetShape();
                highlightLayer.Open();
                highlightLayer.InternalFeatures.Clear();
                highlightLayer.InternalFeatures.Add(new Feature(lineShape));
                highlightLayer.Close();

                double length        = lineShape.GetLength(GeographyUnit.DecimalDegree, DistanceUnit.Meter);
                string lengthMessage = string.Format(CultureInfo.InvariantCulture, "{0} has a length of {1:F2} meters.", selectedFeatures[0].ColumnValues["fename"].Trim(), length);

                messageLabel.Text = lengthMessage;
                highlightOverlay.Refresh();
            }
        }
Exemplo n.º 6
0
        private void AndroidMap_MapSingleTap(object sender, Android.Views.MotionEvent e)
        {
            PointF     location = new PointF(e.GetX(), e.GetY());
            PointShape position = ExtentHelper.ToWorldCoordinate(androidMap.CurrentExtent, location.X,
                                                                 location.Y, androidMap.Width, androidMap.Height);

            LayerOverlay         worldOverlay     = (LayerOverlay)androidMap.Overlays["WorldOverlay"];
            LayerOverlay         highlightOverlay = (LayerOverlay)androidMap.Overlays["HighlightOverlay"];
            FeatureLayer         worldLayer       = (FeatureLayer)worldOverlay.Layers["WorldLayer"];
            InMemoryFeatureLayer highlightLayer   = (InMemoryFeatureLayer)highlightOverlay.Layers["HighlightLayer"];

            worldLayer.Open();
            Collection <Feature> selectedFeatures = worldLayer.QueryTools.GetFeaturesContaining(position, new string[1] {
                "CNTRY_NAME"
            });

            worldLayer.Close();

            highlightLayer.Open();
            highlightLayer.InternalFeatures.Clear();
            if (selectedFeatures.Count > 0)
            {
                highlightLayer.InternalFeatures.Add(selectedFeatures[0]);
            }
            highlightLayer.Close();

            highlightOverlay.Refresh();
        }
        private void MapControl_MouseMove(object sender, MouseEventArgs e)
        {
            PointShape mouseLocation = ExtentHelper.ToWorldCoordinate(map.CurrentExtent, new ScreenPointF(e.X, e.Y), map.Width, map.Height);

            lblFooterLocationX.Text = string.Format(CultureInfo.InvariantCulture, "X:{0:N2}", mouseLocation.X);
            lblFooterLocationY.Text = string.Format(CultureInfo.InvariantCulture, "Y:{0:N2}", mouseLocation.Y);
        }
Exemplo n.º 8
0
        private void winformsMap1_MapClick(object sender, MapClickWinformsMapEventArgs e)
        {
            //Here we use a buffer of 15 in screen coordinate. This means that regardless of the zoom level, we will always find the nearest feature
            //within 15 pixels to where we clicked.
            int screenBuffer = 15;

            //Logic for converting screen coordinate values to world coordinate for the spatial query. Notice that the distance buffer for the spatial query
            //will change according to the zoom level while it remains the same for the screen buffer distance.
            ScreenPointF clickedPointF = new ScreenPointF(e.ScreenX, e.ScreenY);
            ScreenPointF bufferPointF  = new ScreenPointF(clickedPointF.X + screenBuffer, clickedPointF.Y);

            double distanceBuffer = ExtentHelper.GetWorldDistanceBetweenTwoScreenPoints(winformsMap1.CurrentExtent, clickedPointF, bufferPointF,
                                                                                        winformsMap1.Width, winformsMap1.Height, winformsMap1.MapUnit, DistanceUnit.Meter);

            ShapeFileFeatureLayer streetLayer = (ShapeFileFeatureLayer)winformsMap1.FindFeatureLayer("StreetLayer");
            Collection <string>   columnNames = new Collection <string>();

            columnNames.Add("FENAME");

            Collection <Feature> features = streetLayer.FeatureSource.GetFeaturesNearestTo(new PointShape(e.WorldX, e.WorldY), winformsMap1.MapUnit, 1, columnNames, distanceBuffer, DistanceUnit.Meter);


            //Adds the feature clicked on to the selected layer to be displayed as highlighed and with the name labeled.
            InMemoryFeatureLayer selectLayer = (InMemoryFeatureLayer)winformsMap1.FindFeatureLayer("SelectLayer");

            selectLayer.InternalFeatures.Clear();

            if (features.Count > 0)
            {
                selectLayer.InternalFeatures.Add(features[0]);
            }

            //Refreshes only the select layer.
            winformsMap1.Refresh(winformsMap1.Overlays["SelectOverlay"]);
        }
Exemplo n.º 9
0
        public string ToPdf(Map map, GeoCollection <object> args)
        {
            PdfDocument document         = new PdfDocument();
            PdfPage     page             = document.AddPage();
            string      selectedItemText = args[0].ToString();

            if (selectedItemText == "Landscape")
            {
                page.Orientation = PageOrientation.Landscape;
            }
            PdfGeoCanvas pdfGeoCanvas = new PdfGeoCanvas();

            // This allows you to control the area in which you want the
            // map to draw in.  Leaving this commented out uses the whole page
            //pdfGeoCanvas.DrawingArea = new Rectangle(200, 50, 400, 400);
            Collection <SimpleCandidate> labelsInLayers = new Collection <SimpleCandidate>();

            foreach (Layer layer in map.StaticOverlay.Layers)
            {
                RectangleShape printExtent = ExtentHelper.GetDrawingExtent(map.CurrentExtent, (float)map.WidthInPixels, (float)map.HeightInPixels);
                pdfGeoCanvas.BeginDrawing(page, printExtent, GeographyUnit.DecimalDegree);
                layer.Open();
                layer.Draw(pdfGeoCanvas, labelsInLayers);
                layer.Close();
                pdfGeoCanvas.EndDrawing();
            }

            string relativePath = string.Format("~/Controllers/{0}/{1}", ControllerContext.RouteData.Values["Controller"], "MapSuite PDF Map.pdf");
            string filename     = Server.MapPath(relativePath);

            document.Save(filename);

            return(VirtualPathUtility.ToAbsolute(relativePath));
        }
        private void WpfMap_MouseMove(object sender, MouseEventArgs e)
        {
            toolTip.IsOpen = false;
            mapModel.HighlightOverlay.HighlightFeature = null;
            if (!mapModel.HighlightOverlay.IsPanningMap)
            {
                Point      screenLocation = e.GetPosition(mapModel.MapControl);
                PointShape worldLoction   = ExtentHelper.ToWorldCoordinate(mapModel.MapControl.CurrentExtent, new ScreenPointF((float)screenLocation.X, (float)screenLocation.Y), (float)mapModel.MapControl.ActualWidth, (float)mapModel.MapControl.ActualHeight);

                // Here we get tootip for the highlighted feature.
                if (worldLoction.X > -180 && worldLoction.X < 180 && worldLoction.Y > -90 && worldLoction.Y < 90)
                {
                    mapModel.DefaultFeatureLayer.Open();
                    List <string>        columnNames     = mapModel.DefaultFeatureLayer.FeatureSource.GetColumns().Select(x => x.ColumnName).ToList();
                    Collection <Feature> nearestFeatures = mapModel.DefaultFeatureLayer.QueryTools.GetFeaturesNearestTo(worldLoction, mapModel.MapControl.MapUnit, 1, columnNames, 1, DistanceUnit.Meter);
                    if (nearestFeatures.Count > 0)
                    {
                        var highlightedFeature = nearestFeatures[0];
                        mapModel.HighlightOverlay.HighlightFeature = highlightedFeature;
                        mapModel.HighlightOverlay.Refresh();
                        var content = GetToolTip(highlightedFeature);
                        toolTip.Content = content;
                        toolTip.IsOpen  = true;
                    }
                }
            }
            mapModel.HighlightOverlay.Refresh();
        }
Exemplo n.º 11
0
        private void ZoomToFilterMenuItem_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            MenuItem      menuItem      = (MenuItem)sender;
            LayerListItem layerListItem = (LayerListItem)menuItem.Tag;
            LayerListItem tempItem      = layerListItem;

            while (!(tempItem.ConcreteObject is FeatureLayer))
            {
                tempItem = tempItem.Parent;
            }
            FeatureLayer selectedLayer = tempItem.ConcreteObject as FeatureLayer;

            if (selectedLayer != null)
            {
                Collection <Feature> resultFeatures = new Collection <Feature>();
                selectedLayer.SafeProcess(() =>
                {
                    resultFeatures = selectedLayer.QueryTools.GetAllFeatures(ReturningColumnsType.AllColumns);
                });

                FilterStyle filterStyle = (FilterStyle)layerListItem.ConcreteObject;
                foreach (var condition in filterStyle.Conditions)
                {
                    resultFeatures = condition.GetMatchingFeatures(resultFeatures);
                }
                if (resultFeatures.Count > 0)
                {
                    RectangleShape boundingBox = ExtentHelper.GetBoundingBoxOfItems(resultFeatures);
                    GisEditor.ActiveMap.CurrentExtent = boundingBox;
                    GisEditor.ActiveMap.Refresh();
                }
            }
        }
        private void wpfMap1_MouseMove(object sender, MouseEventArgs e)
        {
            //Gets the PointShape in world coordinates from screen coordinates.
            Point point = e.MouseDevice.GetPosition(null);

            ScreenPointF screenPointF = new ScreenPointF((float)point.X, (float)point.Y);
            PointShape   pointShape   = ExtentHelper.ToWorldCoordinate(wpfMap1.CurrentExtent, screenPointF, (float)wpfMap1.ActualWidth, (float)wpfMap1.ActualHeight);

            //Uses the WrapDatelineProjection to get the proper decimal degree value on the virtual maps to the right and left of the central map.
            WrapDatelineProjection wrapDatelineProjection = new WrapDatelineProjection();

            //Sets the HalfExtentWidth of the wrapdateline overlay we want to apply the projection on.
            //Here it is 180 because, the full extent width is 360.
            wrapDatelineProjection.HalfExtentWidth = wpfMap1.Overlays["WMK"].GetBoundingBox().Width / 2;//180;

            wrapDatelineProjection.Open();
            Vertex projVertex = wrapDatelineProjection.ConvertToExternalProjection(pointShape.X, pointShape.Y);

            wrapDatelineProjection.Close();

            try
            {
                //Shows the real coordinates.
                textBox1.Text = "real X: " + string.Format("{0}", System.Math.Round(pointShape.X)) +
                                "  real Y: " + string.Format("{0}", System.Math.Round(pointShape.Y));
                //Shows the Long Lat after the WrapDatelineProjection
                textBox3.Text = "Long.: " + System.Math.Round(projVertex.X) +
                                "  Lat.: " + System.Math.Round(projVertex.Y);
            }
            catch { }
        }
Exemplo n.º 13
0
        private void AndroidMap_MapSingleTap(object sender, Android.Views.MotionEvent e)
        {
            PointF     location = new PointF(e.GetX(), e.GetY());
            PointShape position = ExtentHelper.ToWorldCoordinate(androidMap.CurrentExtent, location.X,
                                                                 location.Y, androidMap.Width, androidMap.Height);

            LayerOverlay worldOverlay = (LayerOverlay)androidMap.Overlays["WorldOverlay"];
            FeatureLayer worldLayer   = (FeatureLayer)worldOverlay.Layers["WorldLayer"];

            LayerOverlay         highlightOverlay = (LayerOverlay)androidMap.Overlays["HighlightOverlay"];
            InMemoryFeatureLayer highlightLayer   = (InMemoryFeatureLayer)highlightOverlay.Layers["HighlightLayer"];

            worldLayer.Open();
            Collection <Feature> selectedFeatures = worldLayer.QueryTools.GetFeaturesContaining(position, new string[1] {
                "CNTRY_NAME"
            });

            worldLayer.Close();

            highlightLayer.Open();
            highlightLayer.InternalFeatures.Clear();
            if (selectedFeatures.Count > 0)
            {
                AreaBaseShape areaShape = (AreaBaseShape)selectedFeatures[0].GetShape();
                double        area      = areaShape.GetArea(GeographyUnit.DecimalDegree, AreaUnit.SquareKilometers);
                messageTextView.Text = string.Format(CultureInfo.InvariantCulture, "{0} has an area of {1:N0} square kilometers.", selectedFeatures[0].ColumnValues["CNTRY_NAME"].Trim(), area);

                highlightLayer.InternalFeatures.Add(selectedFeatures[0]);
            }
            highlightLayer.Close();
            highlightOverlay.Refresh();
        }
Exemplo n.º 14
0
        private void MapViewMapSingleTap(object sender, UIGestureRecognizer e)
        {
            CGPoint    location = e.LocationInView(View);
            PointShape position = ExtentHelper.ToWorldCoordinate(mapView.CurrentExtent, (float)location.X, (float)location.Y, (float)View.Frame.Width, (float)View.Frame.Height);

            routingLayer.Routes.Clear();
            if (firstClick)
            {
                routingLayer.StartPoint = position;
                firstClick = false;
            }
            else
            {
                routingLayer.EndPoint = position;
                firstClick            = true;
            }

            routingLayer.Routes.Clear();
            if (routingLayer.StartPoint != null && routingLayer.EndPoint != null)
            {
                RoutingResult routingResult = routingEngine.GetRoute(routingLayer.StartPoint, routingLayer.EndPoint);
                routingLayer.Routes.Add(routingResult.Route);
                ShowTurnByTurnDirections(routingResult.RouteSegments, routingResult.Features);
            }

            layerOverlay.Refresh();
        }
Exemplo n.º 15
0
        private static void ZoomToExtent()
        {
            RectangleShape resultExtent = null;

            if (GisEditor.LayerListManager.SelectedLayerListItem == null)
            {
                return;
            }
            if (GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject is Overlay && GisEditor.LayerListManager.SelectedLayerListItems.Count > 0)
            {
                Collection <RectangleShape> extents = new Collection <RectangleShape>();
                foreach (var item in GisEditor.LayerListManager.SelectedLayerListItems)
                {
                    var tmpOverlay = item.ConcreteObject as Overlay;
                    if (tmpOverlay != null)
                    {
                        extents.Add(tmpOverlay.GetBoundingBox());
                    }
                }
                resultExtent = ExtentHelper.GetBoundingBoxOfItems(extents);
            }
            else if (GisEditor.LayerListManager.SelectedLayerListItems.Count > 0)
            {
                Collection <RectangleShape> extents = new Collection <RectangleShape>();
                foreach (var item in GisEditor.LayerListManager.SelectedLayerListItems)
                {
                    Layer tmpLayer = item.ConcreteObject as Layer;
                    if (tmpLayer != null && tmpLayer.HasBoundingBox)
                    {
                        tmpLayer.SafeProcess(() =>
                        {
                            extents.Add(tmpLayer.GetBoundingBox());
                        });
                    }
                }
                resultExtent = ExtentHelper.GetBoundingBoxOfItems(extents);
            }
            else if (GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject is Overlay)
            {
                resultExtent = (GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as Overlay).GetBoundingBox();
            }
            else if (GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject is Layer)
            {
                Layer layer = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as Layer;
                if (layer.HasBoundingBox)
                {
                    layer.SafeProcess(() =>
                    {
                        resultExtent = layer.GetBoundingBox();
                    });
                }
            }

            if (resultExtent != null)
            {
                GisEditor.ActiveMap.CurrentExtent = resultExtent;
                GisEditor.ActiveMap.Refresh();
            }
        }
        private void WpfMap_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Point      currentPoint = e.GetPosition(WpfMap);
            PointShape worldPoint   = ExtentHelper.ToWorldCoordinate(WpfMap.CurrentExtent, new ScreenPointF((float)currentPoint.X, (float)currentPoint.Y), (float)WpfMap.ActualWidth, (float)WpfMap.ActualHeight);

            CurrentX.Text = worldPoint.X.ToString("f6", CultureInfo.InvariantCulture);
            CurrentY.Text = worldPoint.Y.ToString("f6", CultureInfo.InvariantCulture);
        }
Exemplo n.º 17
0
        private void btnHigh_Click(object sender, EventArgs e)
        {
            ZoomLevelSet zoomLevelSet = new ZoomLevelSet();

            winformsMap1.CurrentExtent = ExtentHelper.ZoomToScale(zoomLevelSet.ZoomLevel03.Scale, winformsMap1.CurrentExtent, GeographyUnit.DecimalDegree, winformsMap1.Width, winformsMap1.Height);

            winformsMap1.Refresh();
        }
Exemplo n.º 18
0
        private void AndroidMap_CurrentExtentChanged(object sender, CurrentExtentChangedMapViewEventArgs e)
        {
            PointShape upperLeftPoint  = e.NewExtent.UpperLeftPoint;
            PointShape lowerRightPoint = e.NewExtent.LowerRightPoint;

            labelExtent.Text = string.Format("Map cureent extent: {0}, {1}, {2}, {3}", upperLeftPoint.X.ToString("n2"), upperLeftPoint.Y.ToString("n2"), lowerRightPoint.X.ToString("n2"), lowerRightPoint.Y.ToString("n2"));
            labelScale.Text  = string.Format("Map cureent scale: {0}", ExtentHelper.GetScale(e.NewExtent, (float)androidMap.Width, androidMap.MapUnit).ToString("n4"));
        }
        private void operationImage_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Point  mousePoint                = e.GetPosition(operationImage);
            double panPanelRadius            = panIconSize * .5;
            double globeRadius               = globeIconSize * .5;
            Point  center                    = new Point(panPanelRadius, panPanelRadius);
            double distanceFromMouseToCenter = Math.Sqrt(Math.Pow(mousePoint.X - center.X, 2) + Math.Pow(mousePoint.Y - center.Y, 2));

            if (distanceFromMouseToCenter <= globeRadius)
            {
                // zoom to whole world.
                if (CurrentMap != null && isGlobeButtonEnabled)
                {
                    Collection <BaseShape> rectangles = new Collection <BaseShape>();
                    foreach (Overlay overlay in CurrentMap.Overlays)
                    {
                        RectangleShape rect = overlay.GetBoundingBox();
                        if (rect != null)
                        {
                            rectangles.Add(rect);
                        }
                    }

                    if (rectangles.Count != 0)
                    {
                        RectangleShape targetExtent = OnGlobeButtonClick(ExtentHelper.GetBoundingBoxOfItems(rectangles));
                        if (targetExtent != null)
                        {
                            CurrentMap.CurrentExtent = targetExtent;
                            CurrentMap.Refresh();
                        }
                    }
                }
                e.Handled = true;
            }
            else if (distanceFromMouseToCenter <= panPanelRadius)
            {
                // change switcher mode.
                double degree = GetDegree(mousePoint.X - center.X, center.Y - mousePoint.Y);
                if ((degree >= 0 && degree < 90) || (degree <= 0 && degree >= -30))
                {
                    isSwitchedByMouse = true;
                    SwitcherMode      = SwitcherMode.TrackZoom;
                }
                else if ((degree >= 90 && degree <= 180) || (degree < -150 && degree >= -180))
                {
                    isSwitchedByMouse = true;
                    SwitcherMode      = SwitcherMode.Pan;
                }
                else
                {
                    isSwitchedByMouse = true;
                    SwitcherMode      = SwitcherMode.Identify;
                }

                e.Handled = true;
            }
        }
Exemplo n.º 20
0
        private void WpfMap_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Point point = e.MouseDevice.GetPosition(null);

            ScreenPointF screenPointF = new ScreenPointF((float)point.X, (float)point.Y);
            PointShape   pointShape   = ExtentHelper.ToWorldCoordinate(WpfMap.CurrentExtent, screenPointF, (float)WpfMap.ActualWidth, (float)WpfMap.ActualHeight);

            textBox1.Text = $"X: {pointShape.X}  Y: {pointShape.Y}";
        }
Exemplo n.º 21
0
        private RectangleShape ToWorldCoordinate(GeoCanvas canvas, DrawingRectangleF drawingRectangle)
        {
            PointShape upperLeftPoint  = ExtentHelper.ToWorldCoordinate(canvas.CurrentWorldExtent, drawingRectangle.CenterX - drawingRectangle.Width / 2, drawingRectangle.CenterY - drawingRectangle.Height / 2, canvas.Width, canvas.Height);
            PointShape lowerRightPoint = ExtentHelper.ToWorldCoordinate(canvas.CurrentWorldExtent, drawingRectangle.CenterX + drawingRectangle.Width / 2, drawingRectangle.CenterY + drawingRectangle.Height / 2, canvas.Width, canvas.Height);

            RectangleShape worldRectangle = new RectangleShape(upperLeftPoint, lowerRightPoint);

            return(worldRectangle);
        }
Exemplo n.º 22
0
        private void AndroidMap_MapSingleTap(object sender, MotionEvent e)
        {
            PointF     location      = new PointF(e.GetX(), e.GetY());
            PointShape worldPosition = ExtentHelper.ToWorldCoordinate(androidMap.CurrentExtent, location.X,
                                                                      location.Y, androidMap.Width, androidMap.Height);

            screenPositionLable.Text = string.Format("Screen Position:({0:N4},{1:N4})", location.X, location.Y);
            worldPositionLable.Text  = string.Format("World Position: ({0:N4},{1:N4})", worldPosition.X, worldPosition.Y);
        }
        private static void ShowOptionsIfNoSelectedFeatureInCurrentExtent(Collection <Feature> features)
        {
            MessageBoxResult result = MessageBox.Show(string.Format(GisEditor.LanguageManager.GetStringResource("GoogleEarthAnyFeaturesSelected")), GisEditor.LanguageManager.GetStringResource("GeneralMessageBoxInfoCaption"), MessageBoxButton.YesNo);

            if (result == MessageBoxResult.Yes)
            {
                GisEditor.ActiveMap.CurrentExtent = ExtentHelper.GetBoundingBoxOfItems(features);
                GisEditor.ActiveMap.Refresh();
            }
        }
Exemplo n.º 24
0
        private void ZoomToFeatures(IEnumerable <Feature> features, FeatureLayer featureLayer)
        {
            RectangleShape extent        = features.Count() == 1 ? GetBoundingBox(features.FirstOrDefault()) : ExtentHelper.GetBoundingBoxOfItems(features);
            RectangleShape drawingExtent = ExtentHelper.GetDrawingExtent(extent, (float)GisEditor.ActiveMap.ActualWidth, (float)GisEditor.ActiveMap.ActualHeight);
            var            scale         = ExtentHelper.GetScale(drawingExtent, (float)map.ActualWidth, map.MapUnit);

            map.ZoomTo(extent.GetCenterPoint(), scale);
            //GisEditor.UIManager.RefreshPlugins(new RefreshArgs(extent.GetCenterPoint(), "Identify"));
            GisEditor.UIManager.RefreshPlugins(new RefreshArgs(new Tuple <IEnumerable <Feature>, FeatureLayer>(features, featureLayer), "Identify"));
        }
Exemplo n.º 25
0
        private void TrackToExtent(Layer layer)
        {
            layer.Open();
            RectangleShape extent = layer.GetBoundingBox();

            layer.Close();

            winformsMap1.CurrentExtent = ExtentHelper.GetDrawingExtent(extent, winformsMap1.Width, winformsMap1.Height);

            winformsMap1.Refresh();
        }
Exemplo n.º 26
0
        private void AndroidMap_MapSingleTap(object sender, MotionEvent e)
        {
            Marker marker   = new Marker(this);
            PointF location = new PointF(e.GetX(), e.GetY());

            marker.Position = ExtentHelper.ToWorldCoordinate(androidMap.CurrentExtent, location.X, location.Y, (float)androidMap.Width, (float)androidMap.Height);
            marker.SetImageBitmap(BitmapFactory.DecodeResource(Resources, Resource.Drawable.Pin));
            marker.YOffset = -(int)(22 * Resources.DisplayMetrics.Density);
            markerOverlay.Markers.Add(marker);
            markerOverlay.Refresh();
        }
Exemplo n.º 27
0
        private void winformsMap1_MouseMove(object sender, MouseEventArgs e)
        {
            //Displays the X and Y in screen coordinates.
            statusStrip1.Items["toolStripStatusLabelScreen"].Text = "X:" + e.X + " Y:" + e.Y;

            //Gets the PointShape in world coordinates from screen coordinates.
            PointShape pointShape = ExtentHelper.ToWorldCoordinate(winformsMap1.CurrentExtent, new ScreenPointF(e.X, e.Y), winformsMap1.Width, winformsMap1.Height);

            //Displays world coordinates.
            statusStrip1.Items["toolStripStatusLabelWorld"].Text = "(world) X:" + Math.Round(pointShape.X, 4) + " Y:" + Math.Round(pointShape.Y, 4);
        }
Exemplo n.º 28
0
        protected override void DrawCore(IEnumerable <Feature> features, GeoCanvas canvas, Collection <SimpleCandidate> labelsInThisLayer, Collection <SimpleCandidate> labelsInAllLayers)
        {
            PointStyle pointStyle = new PointStyle(geoImage);

            foreach (Feature feature in features)
            {
                MultilineShape lineShape = (MultilineShape)feature.GetShape();
                lineStyle.Draw(new BaseShape[] { lineShape }, canvas, labelsInThisLayer, labelsInAllLayers);

                List <Vertex> allVertices = lineShape.Lines.SelectMany(l => l.Vertices).ToList();

                double totalDistance = 0;
                for (int i = 0; i < allVertices.Count - 1; i++)
                {
                    PointShape pointShape1 = new PointShape(allVertices[i]);
                    PointShape pointShape2 = new PointShape(allVertices[i + 1]);

                    LineShape tempLineShape = new LineShape();
                    tempLineShape.Vertices.Add(allVertices[i]);
                    tempLineShape.Vertices.Add(allVertices[i + 1]);

                    double angle = GetAngleFromTwoVertices(allVertices[i], allVertices[i + 1]);
                    // Left side
                    if (imageDirection == ImageDirection.Left)
                    {
                        if (angle >= 270)
                        {
                            angle -= 180;
                        }
                    }
                    // Right side
                    else
                    {
                        if (angle <= 90)
                        {
                            angle += 180;
                        }
                    }
                    pointStyle.RotationAngle = (float)angle;

                    float  screenDistance  = ExtentHelper.GetScreenDistanceBetweenTwoWorldPoints(canvas.CurrentWorldExtent, pointShape1, pointShape2, canvas.Width, canvas.Height);
                    double currentDistance = Math.Round(pointShape1.GetDistanceTo(pointShape2, canvas.MapUnit, DistanceUnit.Meter), 2);
                    double worldInterval   = (currentDistance * imageSpacing) / screenDistance;
                    while (totalDistance <= currentDistance)
                    {
                        PointShape tempPointShape = tempLineShape.GetPointOnALine(StartingPoint.FirstPoint, totalDistance, canvas.MapUnit, DistanceUnit.Meter);
                        pointStyle.Draw(new BaseShape[] { tempPointShape }, canvas, labelsInThisLayer, labelsInAllLayers);
                        totalDistance = totalDistance + worldInterval;
                    }

                    totalDistance = totalDistance - currentDistance;
                }
            }
        }
Exemplo n.º 29
0
        private void AppendCoordinates(IEnumerable <ScreenPointF> screenPoints, float xOffset, float yOffset, StringBuilder contentStringBuilder)
        {
            contentStringBuilder.AppendLine(@"<coordinates>");

            foreach (ScreenPointF screenPoint in screenPoints)
            {
                PointShape pointShape = ExtentHelper.ToWorldCoordinate(virtualWorldExtent, screenPoint.X + xOffset, screenPoint.Y + yOffset, virtualMapWidth, virtualMapHeight);
                contentStringBuilder.AppendFormat(" {0},{1} ", pointShape.X, pointShape.Y);
            }
            contentStringBuilder.AppendLine(@"</coordinates>");
        }
Exemplo n.º 30
0
        private void wpfMap1_MouseMove(object sender, MouseEventArgs e)
        {
            //Gets the PointShape in world coordinates from screen coordinates.
            Point point = e.MouseDevice.GetPosition(null);

            ScreenPointF screenPointF = new ScreenPointF((float)point.X, (float)point.Y);
            PointShape   pointShape   = ExtentHelper.ToWorldCoordinate(wpfMap1.CurrentExtent, screenPointF, (float)wpfMap1.Width, (float)wpfMap1.Height);

            textBox1.Text = "X: " + Math.Round(pointShape.X) +
                            "  Y: " + Math.Round(pointShape.Y);
        }