Ejemplo n.º 1
0
        private void MGRS_Validating(object sender, CancelEventArgs e)
        {
            string mgrs;

            if (!string.IsNullOrEmpty(MGRS.Text) && !GPSTrack.IsValidMGRS(MGRS.Text, out mgrs))
            {
                e.Cancel = true;
            }
        }
Ejemplo n.º 2
0
        private void UpdateTeamStatus(TrackingData Data)
        {
            TeamData     td;
            ListViewItem lvi = new ListViewItem();

            try
            {
                int _prev_speed     = 0;
                int _prev_direction = 0;

                if (m_Teams.ContainsKey(Data.CID))
                {
                    td = m_Teams[Data.CID];
                    // The GPS update came - change the status from Delayed to Tracking
                    if (td.Status == TrackStatus.DELAYED)
                    {
                        td.Status = TrackStatus.TRACKING;
                    }
                    _prev_speed     = td.Coordinates.Speed;
                    _prev_direction = td.Coordinates.Direction;
                    if (_prev_direction > 180)
                    {
                        _prev_direction -= 180;
                    }
                }
                else
                {
                    td        = new TeamData();
                    td.CID    = Data.CID;
                    td.Status = TrackStatus.TRACKING;
                    td.Name   = Data.CID;
                }
                td.Coordinates       = Data.Coordinates;
                td.Coordinates.MGRS  = GPSTrack.FormatMGRS(td.Coordinates.MGRS);
                td.Coordinates       = GPSTrack.MGRS_To_LatLon(td.Coordinates);
                td.Coordinates.Time  = DateTime.Now;
                td.Coordinates.Speed = (td.Coordinates.Speed + _prev_speed) / 2;
                if (td.Coordinates.Direction > 180)
                {
                    td.Coordinates.Direction -= 180;
                }
                td.Coordinates.Direction = (td.Coordinates.Direction + _prev_direction) / 2;
                if (td.Coordinates.Direction < 0)
                {
                    td.Coordinates.Direction += 180;
                }

                m_Teams[td.CID] = td;
                UpdateTrackingHistory(td);
                UpdateTeamDisplay(td);
                m_statusStrip.Items[0].Text = String.Format("{0} is receiving SA updates", m_SerialCommPort.PortName);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.InnerException + ex.ToString());
            }
        }
Ejemplo n.º 3
0
        private void MGRS_TextChanged(object sender, EventArgs e)
        {
            string mgrs;

            if (GPSTrack.IsValidMGRS(MGRS.Text, out mgrs))
            {
                MGRS.Text = mgrs;
                UpdateLatLon();
            }
        }
Ejemplo n.º 4
0
 private void UpdateMGRS()
 {
     if (!string.IsNullOrEmpty(LatLon.Text))
     {
         Coords cc = new Coords();
         cc.Latitude  = Latitude;
         cc.Longitude = Longitude;
         cc           = GPSTrack.LatLon_To_MGRS(cc);
         MGRS.Text    = cc.MGRS;
     }
 }
Ejemplo n.º 5
0
 private void UpdateLatLon()
 {
     if (!string.IsNullOrEmpty(MGRS.Text))
     {
         Coords cc = new Coords();
         cc.MGRS     = MGRS.Text;
         cc          = GPSTrack.MGRS_To_LatLon(cc);
         Latitude    = cc.Latitude;
         Longitude   = cc.Longitude;
         LatLon.Text = GPSTrack.FormatLatLon(Latitude, Longitude);
     }
 }
Ejemplo n.º 6
0
        private void LatLon_Validating(object sender, CancelEventArgs e)
        {
            double Lat, Lon;
            string latlon;

            if (string.IsNullOrEmpty(LatLon.Text))
            {
                return;
            }
            if (GPSTrack.IsValidLatLon(LatLon.Text, out Lat, out Lon, out latlon))
            {
                Latitude    = Lat;
                Longitude   = Lon;
                LatLon.Text = latlon;
            }
            else
            {
                e.Cancel = true;
            }
        }
Ejemplo n.º 7
0
        private void CreateTrackingDocument(StringBuilder htmlOutput)
        {
            lock (_curr_data)
            {
                foreach (TeamData td in _curr_data)
                {
                    htmlOutput.Append("<Placemark>");
                    htmlOutput.Append("<name>" + td.Name + "</name>");
                    switch (td.Status)
                    {
                    case TrackStatus.PLACES:
                        htmlOutput.Append("<styleUrl>#place-status-template</styleUrl>");
                        break;

                    case TrackStatus.DELAYED:
                        htmlOutput.Append("<styleUrl>#team-delayed-template</styleUrl>");
                        break;

                    default:
                        htmlOutput.Append("<styleUrl>#team-tracking-template</styleUrl>");
                        break;
                    }
                    htmlOutput.Append("<ExtendedData>  <SchemaData schemaUrl=\"#TeamStatusId\">");
                    htmlOutput.Append("<SimpleData name=\"TeamName\">" + td.Name + "</SimpleData>");
                    htmlOutput.Append("<SimpleData name=\"Description\">" + td.Description + "</SimpleData>");
                    htmlOutput.Append("<SimpleData name=\"Members\">");
                    foreach (string memb in td.TeamMembers)
                    {
                        htmlOutput.Append(memb + "&lt;br/&gt;");
                    }
                    htmlOutput.Append("</SimpleData>");
                    htmlOutput.Append("<SimpleData name=\"MGRS\">" + td.Coordinates.MGRS + "</SimpleData>");
                    htmlOutput.Append("<SimpleData name=\"LatLon\">" + GPSTrack.FormatLatLon(td.Coordinates.Latitude, td.Coordinates.Longitude) + "</SimpleData>");
                    htmlOutput.Append("<SimpleData name=\"Speed\">" + td.Coordinates.Speed + "</SimpleData>");
                    htmlOutput.Append("<SimpleData name=\"Dir\">" + td.Coordinates.Direction + "</SimpleData>");
                    htmlOutput.Append("<SimpleData name=\"Time\">" + td.Coordinates.Time.ToShortTimeString() +
                                      td.Coordinates.Time.ToUniversalTime().ToString(" (HH:mm:ssZ)") + "</SimpleData>");
                    htmlOutput.Append("</SchemaData> </ExtendedData> ");
                    htmlOutput.Append("<Point>  <coordinates> ");
                    htmlOutput.Append(td.Coordinates.Longitude.ToString("N10") + "," + td.Coordinates.Latitude.ToString("N10"));
                    htmlOutput.Append("," + td.Coordinates.Altitude.ToString());
                    htmlOutput.Append("</coordinates>    </Point> ");
                    htmlOutput.Append("</Placemark>");

                    // Add projected team path
                    if (td.Coordinates.Speed > 2)
                    {
                        htmlOutput.Append("<Placemark>");
                        htmlOutput.Append("<name>" + td.Name + "</name>");
                        htmlOutput.Append("<styleUrl>#projected-line</styleUrl>");
                        htmlOutput.Append("<LineString> ");
                        htmlOutput.Append("<extrude>1</extrude> <tessellate>1</tessellate> <altitudeMode>relativeToGround </altitudeMode> ");
                        htmlOutput.Append("<coordinates> ");
                        htmlOutput.Append(td.Coordinates.Longitude.ToString("N10") + "," + td.Coordinates.Latitude.ToString("N10") + ",2 ");
                        Coords projected = GPSTrack.NewPosition(td.Coordinates);
                        htmlOutput.Append(projected.Longitude.ToString("N10") + "," + projected.Latitude.ToString("N10") + ",2");
                        htmlOutput.Append("</coordinates>    </LineString> ");
                        htmlOutput.Append("</Placemark>");
                    }
                }
            }
        }