Exemplo n.º 1
0
        public void WriteGpxRoute(GpxRoute route)
        {
            if (route != null)
            {
                WriteStartElement("rte");

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

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

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

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

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

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

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

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

                WriteStartElement("rtept");

                foreach (GpxPoint point in route.Points)
                {
                    WriteGpxPoint(point, PointType.RoutePoint);
                }

                //end of points
                WriteEndElement();
                //end of route
                WriteEndElement();
            }
        }
Exemplo n.º 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;
        }
Exemplo n.º 3
0
 public void AddRoute(GpxRoute route)
 {
     if (route != null)
         _Routes.Add(route);
 }