Пример #1
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;
        }
Пример #2
0
 public void WriteGpxPoint(GpxPoint point)
 {
     WriteGpxPoint(point, PointType.WayPoint);
 }
Пример #3
0
        public void WriteGpxPoint(GpxPoint point, PointType type)
        {
            if (point != null)
            {
                switch (type)
                {
                    case PointType.RoutePoint:
                        WriteStartElement("rtept");
                        break;
                    case PointType.TrackPoint:
                        WriteStartElement("trkpt");
                        break;
                    case PointType.WayPoint:
                    default:
                        WriteStartElement("wpt");
                        break;
                }

                WriteAttributeString("lat", point.Latitude.ToString());
                WriteAttributeString("lon", point.Longitude.ToString());

                if (point.Altitude != null)
                    WriteElementString("ele", point.Altitude.ToString());
                if (point.Time != null)
                    WriteElementString("time", point.Time.ToString());
                if (point.MagVar != null)
                    WriteElementString("magvar", point.MagVar.ToString());
                if (point.GeoidHeight != null)
                    WriteElementString("geoidheight", point.GeoidHeight.ToString());
                if (point.Name != null && point.Name != "")
                    WriteElementString("name", point.Name);
                if (point.Comment != null && point.Comment != "")
                    WriteElementString("cmt", point.Comment);
                if (point.Description != null && point.Description != "")
                    WriteElementString("desc", point.Description);
                if (point.Source != null && point.Source != "")
                    WriteElementString("src", point.Source);
                if (point.Link != null && point.Link != "")
                    WriteElementString("link", point.Link);
                if (point.Symmetry != null && point.Symmetry != "")
                    WriteElementString("sym", point.Symmetry);
                if (point.Fix != null)
                    WriteElementString("fix", point.Fix.ToString());
                if (point.SatteliteNum != null)
                    WriteElementString("sat", point.SatteliteNum.ToString());
                if (point.HDOP != null)
                    WriteElementString("hdop", point.HDOP.ToString());
                if (point.VDOP != null)
                    WriteElementString("vdop", point.VDOP.ToString());
                if (point.PDOP != null)
                    WriteElementString("pdop", point.PDOP.ToString());
                if (point.AgeOfData != null)
                    WriteElementString("ageofdata", point.AgeOfData.ToString());
                if (point.DGpsId != null && point.DGpsId != "")
                    WriteElementString("dgpsid", point.DGpsId);

                WriteGpxExtensions(point.Extensions);

                WriteEndElement();
            }
        }
Пример #4
0
 public void AddPoint(GpxPoint point)
 {
     if(point != null)
         _Waypoints.Add(point);
 }