Пример #1
0
        public void WriteGpxFile(GpxDocument doc)
        {
            if (doc != null)
            {
                string file = String.Format("{0}\\{1}.gpx", SelectedPath, Values.Settings.ProjectOptions.ProjectName);
                if (File.Exists(file))
                    File.Delete(file);

                using (GpxWriter gw = new GpxWriter(file, doc))
                {
                    gw.WriteStartDocument();
                    gw.WriteStartGpx();
                    gw.WriteGpxDocument();
                    gw.WriteEndGpx();
                    gw.WriteEndDocument();
                }
            }
        }
Пример #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 WriteGpxDocument(GpxDocument doc)
        {
            if (_open && doc != null)
            {
                if(doc.MetaData != null)
                    WriteGpxMetadata(doc.MetaData);

                if (doc.Waypoints != null && doc.Waypoints.Count > 0)
                {
                    foreach (GpxPoint point in doc.Waypoints)
                    {
                        WriteGpxPoint(point, PointType.WayPoint);
                    }
                }

                if (doc.Routes != null && doc.Routes.Count > 0)
                {
                    foreach (GpxRoute route in doc.Routes)
                    {
                        WriteGpxRoute(route);
                    }
                }

                if (doc.Tracks != null && doc.Tracks.Count > 0)
                {
                    foreach (GpxTrack track in doc.Tracks)
                    {
                        WriteGpxTrack(track);
                    }
                }

                if (doc.Extensions != null)
                    WriteGpxExtensions(doc.Extensions);
            }
        }
Пример #4
0
 private void init(string filename, GpxDocument doc)
 {
     Document = doc;
     _FileName = filename;
     Formatting = Formatting.Indented;
     Indentation = 4;
 }
Пример #5
0
 public GpxWriter(string filename, GpxDocument doc)
     : base(filename, null)
 {
     init(filename, doc);
 }