Ejemplo n.º 1
0
        public static ESRI.ArcGIS.Client.Geometry.Polyline LoadTrack( trksegTypeCollection trksegs )
        {
            trksegs.RequireArgument<trksegTypeCollection>( "trksegs" ).NotNull<trksegTypeCollection>();

            ESRI.ArcGIS.Client.Geometry.Polyline line = new ESRI.ArcGIS.Client.Geometry.Polyline();
            line.Paths = new ObservableCollection<ESRI.ArcGIS.Client.Geometry.PointCollection>();
            foreach( var trkseg in trksegs )
            {
                line.Paths.Add( LoadTrackSegment( trkseg.trkpt ) );
            }

            return line;
        }
Ejemplo n.º 2
0
        private void gpx_save_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.Filter = "GPX file|*.gpx";
            saveFileDialog1.Title  = "Save To GPX File";
            saveFileDialog1.ShowDialog();

            // If the file name is not an empty string open it for saving.
            if (saveFileDialog1.FileName != "")
            {
                GpxClass track = new GpxClass();

                wptTypeCollection trkpt = new wptTypeCollection();
                foreach (Location lc in gpx_locations)
                {
                    wptType wpt = new wptType();
                    wpt.lat          = (decimal)lc.Latitude;
                    wpt.lon          = (decimal)lc.Longitude;
                    wpt.ele          = (decimal)lc.Altitude;
                    wpt.eleSpecified = true;
                    trkpt.Add(wpt);
                }

                trksegType trk_seg = new trksegType();
                trk_seg.trkpt = trkpt;

                trksegTypeCollection trk_seg_cl = new trksegTypeCollection();
                trk_seg_cl.Addtrkseg(trk_seg);

                trkType trk = new trkType();
                trk.name   = DateTime.Now.ToString("MM/dd/yyyy h:mm tt");
                trk.trkseg = trk_seg_cl;

                track.trk = new trkTypeCollection();
                track.trk.Add(trk);
                track.ToFile(saveFileDialog1.FileName);

                System.Windows.Forms.MessageBox.Show("GPX file is saved!");

                // back to the teleport mode.
                cur_click_mode            = e_click_mode.teleport;
                gpx_create_button.Content = "Create GPX";
                way_points.Text           = "";
                gpx_locations.Clear();
                myMap.Children.Clear();
                gpx_save_button.IsEnabled = false;
            }
        }
Ejemplo n.º 3
0
        private static trksegTypeCollection ReadTrackSegments( IEnumerable<XElement> elements )
        {
            elements.RequireArgument<IEnumerable<XElement>>( "elements" ).NotNull<IEnumerable<XElement>>();

            trksegTypeCollection trksegs = new trksegTypeCollection();

            foreach( XElement element in elements )
            {
                trksegs.Add(ReadTrackSegment(element));
            }

            return trksegs;
        }