Пример #1
0
        public void WriteGpxTrack(GpxTrack track)
        {
            if (track != null)
            {
                WriteStartElement("trk");

                if (track.Name != null && track.Name != "")
                    WriteElementString("name", track.Name);

                if (track.Comment != null && track.Comment != "")
                    WriteElementString("cmt", track.Comment);

                if (track.Description != null && track.Description != "")
                    WriteElementString("desc", track.Description);

                if (track.Source != null && track.Source != "")
                    WriteElementString("src", track.Source);

                if (track.Link != null && track.Link != "")
                    WriteElementString("link", track.Link);

                if (track.Number != null)
                    WriteElementString("number", track.Number.ToString());

                if (track.Type != null && track.Type != "")
                    WriteElementString("type", track.Type);

                if (track.Extensions != null)
                    WriteGpxExtensions(track.Extensions);

                if (track.Segments != null)
                {
                    foreach (GpxTrackSeg seg in track.Segments)
                    {
                        WriteGpxTrackSegment(seg);
                    }
                }

                //end of route
                WriteEndElement();
            }
        }
Пример #2
0
        public GpxDocument CreateGpxDoc(DataAccessLayer DAL)
        {
            GpxDocument doc = new GpxDocument("USFS TwoTrails - http://www.fs.fed.us/fmsc/measure/geospatial/twotrails/");

            doc.MetaData = new GpxMetadata();
            doc.MetaData.Time = DateTime.Now;
            doc.MetaData.Name = Values.Settings.ProjectOptions.ProjectName;
            doc.MetaData.Link = "http://www.fs.fed.us/fmsc/measure/geospatial/twotrails/";

            #region Create Polygons

            List<TtPolygon> polys = DAL.GetPolygons();

            foreach (TtPolygon poly in polys)
            {
                GpxRoute AdjRoute = new GpxRoute(poly.Name + " - Adj Boundary", poly.Description);
                GpxTrack AdjTrack = new GpxTrack(poly.Name + " - Adj Navigation", poly.Description);

                GpxRoute UnAdjRoute = new GpxRoute(poly.Name + " - UnAdj Boundary", poly.Description);
                GpxTrack UnAdjTrack = new GpxTrack(poly.Name + " - UnAdj Navigation", poly.Description);

                AdjTrack.Segments.Add(new GpxTrackSeg());
                UnAdjTrack.Segments.Add(new GpxTrackSeg());

                List<TtPoint> points = DAL.GetPointsInPolygon(poly.CN);
                TtMetaData md = null;

                if (points.Count > 0)
                {
                    md = DAL.GetMetaDataByCN(points[0].MetaDefCN);

                    if (md == null)
                        throw new Exception("Meta Data is null.  Cant obtain UTM Zone");
                }

                if (points != null && points.Count > 0)
                {
                    foreach (TtPoint point in points)
                    {
                        double lat, lon;
                        TtUtils.UTMtoLatLon(point.AdjX, point.AdjY, md.Zone, out lat, out lon);
                        GpxPoint adjpoint = new GpxPoint(lat, lon, point.AdjZ);

                        TtUtils.UTMtoLatLon(point.UnAdjX, point.UnAdjY, md.Zone, out lat, out lon);
                        GpxPoint unAdjpoint = new GpxPoint(lat, lon, point.UnAdjZ);

                        adjpoint.Name = point.PID.ToString();
                        adjpoint.Time = point.Time;
                        adjpoint.Comment = point.Comment;
                        adjpoint.Description = "Point Operation: " + point.op.ToString() + "<br>UtmX:" + point.AdjX +
                            "<br>UtmY: " + point.AdjY;

                        unAdjpoint.Name = point.PID.ToString();
                        unAdjpoint.Time = point.Time;
                        unAdjpoint.Comment = point.Comment;
                        unAdjpoint.Description = "Point Operation: " + point.op.ToString() + "<br>UtmX:" + point.UnAdjX +
                            "<br>UtmY: " + point.UnAdjY;

                        #region Add points to lists
                        if (point.IsBndPoint())
                        {
                            AdjRoute.Points.Add(adjpoint);
                            UnAdjRoute.Points.Add(unAdjpoint);
                        }

                        if (point.IsNavPoint())
                        {
                            AdjTrack.Segments[0].Points.Add(adjpoint);
                            UnAdjTrack.Segments[0].Points.Add(unAdjpoint);
                        }
                        else if (point.op == OpType.Quondam)
                        {
                            QuondamPoint p = (QuondamPoint)point;

                            if (p.IsNavPoint())
                            {
                                AdjTrack.Segments[0].Points.Add(adjpoint);
                                UnAdjTrack.Segments[0].Points.Add(unAdjpoint);
                            }
                        }

                        if (point.op == OpType.WayPoint)
                        {
                            doc.AddPoint(unAdjpoint);
                        }
                        #endregion
                    }
                }

                doc.AddRoute(AdjRoute);
                doc.AddRoute(UnAdjRoute);
                doc.AddTrack(AdjTrack);
                doc.AddTrack(UnAdjTrack);
            }

            #endregion

            return doc;
        }
Пример #3
0
 public void AddTrack(GpxTrack Track)
 {
     if (Track != null)
         _Tracks.Add(Track);
 }