/*        private void AddMarker_Click(object sender, RoutedEventArgs e)
 *      {
 *          //setUserPlaneCoord(36.4, 51.2, 30.0);
 *          centerAtPoint(10.0, 10.0);
 *      }
 */
        private void drawUserPlaneWaypoint()
        {
            var userPlaneWPLayer = MyMap.Layers["UserPlaneWaypoints"] as Esri.ArcGISRuntime.Layers.GraphicsLayer;

            if (userPlaneWPLayer == null)
            {
                userPlaneWPLayer               = new Esri.ArcGISRuntime.Layers.GraphicsLayer();
                userPlaneWPLayer.ID            = "UserPlaneWaypoints";
                userPlaneWPLayer.RenderingMode = Esri.ArcGISRuntime.Layers.GraphicsRenderingMode.Static;
                MyMap.Layers.Add(userPlaneWPLayer);
            }

            var lineSym = new Esri.ArcGISRuntime.Symbology.SimpleLineSymbol();

            lineSym.Color = Colors.Purple;
            lineSym.Width = 3;
            lineSym.Style = Esri.ArcGISRuntime.Symbology.SimpleLineStyle.Solid;

            Esri.ArcGISRuntime.Geometry.Polyline line = new Esri.ArcGISRuntime.Geometry.Polyline(wPoints);
            var lineGraphic = new Esri.ArcGISRuntime.Layers.Graphic();

            lineGraphic.Geometry = line;
            lineGraphic.Symbol   = lineSym;
            userPlaneWPLayer.Graphics.Add(lineGraphic);

            flightPlanInitialized = true;
        }
        private void initPlanePathLayer(double coordx, double coordy)
        {
            if (!showPlanePath)
            {
                return;
            }

            //var planePathLayer = MyMap.Layers["UserPlaneRealPath"] as Esri.ArcGISRuntime.Layers.GraphicsLayer;
            var planePathLayer = new Esri.ArcGISRuntime.Layers.GraphicsLayer();

            planePathLayer.ID            = "UserPlaneRealPath";
            planePathLayer.RenderingMode = Esri.ArcGISRuntime.Layers.GraphicsRenderingMode.Dynamic;
            MyMap.Layers.Add(planePathLayer);

            var lineSym = new Esri.ArcGISRuntime.Symbology.SimpleLineSymbol();

            lineSym.Color = Colors.Red;
            lineSym.Width = 2;
            lineSym.Style = Esri.ArcGISRuntime.Symbology.SimpleLineStyle.Solid;

            List <Esri.ArcGISRuntime.Geometry.MapPoint> userPlanePositionsList = new List <Esri.ArcGISRuntime.Geometry.MapPoint>();

            userPlanePositionsList.Add(new Esri.ArcGISRuntime.Geometry.MapPoint(coordx, coordy, Esri.ArcGISRuntime.Geometry.SpatialReferences.Wgs84));
            userPlanePositionsList.Add(new Esri.ArcGISRuntime.Geometry.MapPoint(coordx, coordy, Esri.ArcGISRuntime.Geometry.SpatialReferences.Wgs84));


            Esri.ArcGISRuntime.Geometry.Polyline line = new Esri.ArcGISRuntime.Geometry.Polyline(userPlanePositionsList);
            var lineGraphic = new Esri.ArcGISRuntime.Layers.Graphic();

            lineGraphic.Geometry = line;
            lineGraphic.Symbol   = lineSym;
            planePathLayer.Graphics.Add(lineGraphic);

            planePathInitialized = true;
        }
        private void setUserPlaneCoord(double coordx, double coordy, double rotation)
        {
            // --------------------------- User Plane live coordiantes and heading ---------------------
            var userPlaneGraphicsLayer = MyMap.Layers["UserAirplaneCoord"] as Esri.ArcGISRuntime.Layers.GraphicsLayer;

            if (userPlaneGraphicsLayer == null)
            {
                userPlaneGraphicsLayer               = new Esri.ArcGISRuntime.Layers.GraphicsLayer();
                userPlaneGraphicsLayer.ID            = "UserAirplaneCoord";
                userPlaneGraphicsLayer.RenderingMode = Esri.ArcGISRuntime.Layers.GraphicsRenderingMode.Dynamic;
                MyMap.Layers.Add(userPlaneGraphicsLayer);
            }

            var pictureSym = new Esri.ArcGISRuntime.Symbology.PictureMarkerSymbol();

            var path = System.IO.Path.Combine(Environment.CurrentDirectory, planeIcoUri);
            var uri  = new Uri(path);

            pictureSym.SetSourceAsync(uri);
            pictureSym.Angle  = rotation;
            pictureSym.Height = 50;
            pictureSym.Width  = 50;


            var pointGraphic = new Esri.ArcGISRuntime.Layers.Graphic();
            var mapPoint     = new Esri.ArcGISRuntime.Geometry.MapPoint(coordx, coordy, Esri.ArcGISRuntime.Geometry.SpatialReferences.Wgs84);

            pointGraphic.Geometry = mapPoint;
            pointGraphic.Symbol   = pictureSym;
            userPlaneGraphicsLayer.Graphics.Add(pointGraphic);
        }
Exemple #4
0
        private void btnLoad_Click(object sender, RoutedEventArgs e)
        {
            SQLCode sql = new SQLCode();

            //{1/1/0001 12:00:00 AM
            if (startDateTime == Convert.ToDateTime("1/1/0001") || endDateTime == Convert.ToDateTime("1/1/0001"))
            {
                MessageBox.Show("Missing Date/Time information, preload data first");
                return;
            }

            if (string.IsNullOrEmpty(cboTrucks.Text))
            {
                MessageBox.Show("Please select a truck first");
                return;
            }

            sql.loadPlaybackData(cboTrucks.Text, startDateTime, endDateTime);
            if (globalData.playbackData.Count > 0)
            {
                foreach (List <playBackRow> list in globalData.playbackData)
                {
                    //draw data on the map
                    var graphicsLayer = new Esri.ArcGISRuntime.Layers.GraphicsLayer();
                    graphicsLayer.ID = "PointPlots";
                    Esri.ArcGISRuntime.Geometry.SpatialReference aSpacRef = new Esri.ArcGISRuntime.Geometry.SpatialReference(4326);
                    MyMap.Layers.Add(graphicsLayer);

                    LineSeries2D series = new LineSeries2D();
                    //series.ArgumentScaleType = ScaleType.DateTime;

                    int iCount = 0;
                    foreach (playBackRow row in list)
                    {
                        //Add Data to the chart
                        string st     = string.Empty;
                        string hour   = row.timeStamp.Hour.ToString();
                        string minute = row.timeStamp.Minute.ToString();
                        string second = row.timeStamp.Second.ToString();
                        while (hour.Length < 2)
                        {
                            hour = "0" + hour;
                        }
                        while (minute.Length < 2)
                        {
                            minute = "0" + minute;
                        }
                        while (second.Length < 2)
                        {
                            second = "0" + second;
                        }
                        st = hour + "." + minute + "." + second;
                        series.Points.Add(new SeriesPoint(st, row.Speed));


                        //Add Data to the map
                        var markerSym = new Esri.ArcGISRuntime.Symbology.SimpleMarkerSymbol();
                        switch (row.Status.ToUpper())
                        {
                        case "ONPATROL":
                            markerSym.Color = ConvertStringToColor("#219846");
                            break;

                        case "ONBREAK":
                            markerSym.Color = ConvertStringToColor("#5ef2fb");
                            break;

                        case "ONLUNCH":
                            markerSym.Color = ConvertStringToColor("#5ef2fb");
                            break;

                        case "FORCEDBREAK":
                            markerSym.Color = ConvertStringToColor("#5ef2fb");
                            break;

                        case "ROLLOUT":
                            markerSym.Color = ConvertStringToColor("#5ef2fb");
                            break;

                        case "ONINCIDENT":
                            markerSym.Color = ConvertStringToColor("#265cff");
                            break;

                        case "ONTOW":
                            markerSym.Color = ConvertStringToColor("#dee742");
                            break;

                        case "ROLLIN":
                            markerSym.Color = ConvertStringToColor("#5ef2fb");
                            break;

                        case "ENROUTE":
                            markerSym.Color = ConvertStringToColor("#f37330");
                            break;

                        default:
                            markerSym.Color = Colors.Red;
                            break;
                        }
                        //markerSym.Color = Colors.Red;
                        markerSym.Style = Esri.ArcGISRuntime.Symbology.SimpleMarkerStyle.Circle;
                        markerSym.Size  = 5;

                        Esri.ArcGISRuntime.Geometry.MapPoint aPoint = new Esri.ArcGISRuntime.Geometry.MapPoint();
                        aPoint.SpatialReference = aSpacRef;
                        aPoint.X = row.Lon;
                        aPoint.Y = row.Lat;

                        var pointGraphic = new Esri.ArcGISRuntime.Layers.Graphic();
                        pointGraphic.Geometry = aPoint;
                        pointGraphic.Symbol   = markerSym;

                        graphicsLayer.Graphics.Add(pointGraphic);
                        iCount += 1;
                    }
                    //series.ArgumentScaleType = ScaleType.DateTime;

                    chart.Series.Add(series);
                }

                myGrid.ItemsSource = globalData.playbackData[0];

                List <statusData> status = sql.getStatusData(cboTrucks.Text, startDateTime, endDateTime);
                spStatus.Children.Clear();
                foreach (statusData sd in status)
                {
                    Label l = new Label();
                    l.Content = sd.statusName + " " + sd.statusMins.ToString();
                    spStatus.Children.Add(l);
                }
            }
        }