예제 #1
0
        private void _RebuildDataMap()
        {
            _Map.Points.Clear();
            _Map.Lines.Clear();
            foreach (var Track in _Tracks)
            {
                Records.Record LastTrackPoint = null;

                foreach (var TrackPoint in Track)
                {
                    var Point = new System.Windows.Forms.DataMap.Point();

                    Point.Object      = TrackPoint;
                    Point.Color       = TrackPoint.Get <System.Drawing.Color>("color");
                    Point.Size        = TrackPoint.Get <System.Single>("size");
                    Point.GeoLocation = new System.Point(TrackPoint.Get <System.Double>("longitude"), TrackPoint.Get <System.Double>("latitude"));
                    _Map.Points.Add(Point);
                    if ((Track.DrawLines == true) && (LastTrackPoint != null))
                    {
                        var Line = new System.Windows.Forms.DataMap.Line();

                        Line.Object           = new System.Pair <Records.Record, Records.Record>(LastTrackPoint, TrackPoint);
                        Line.Color            = System.Drawing.Color.Black;
                        Line.Width            = 2.0f;
                        Line.BeginGeoLocation = new System.Point(LastTrackPoint.Get <System.Double>("longitude"), LastTrackPoint.Get <System.Double>("latitude"));
                        Line.EndGeoLocation   = new System.Point(TrackPoint.Get <System.Double>("longitude"), TrackPoint.Get <System.Double>("latitude"));
                        _Map.Lines.Add(Line);
                    }
                    LastTrackPoint = TrackPoint;
                }
            }
            _Map.Refresh();
        }
예제 #2
0
        private void _OnOpenButtonClicked(System.Object Sender, System.EventArgs EventArguments)
        {
            var OpenFileDialog = new System.Windows.Forms.OpenFileDialog();

            if (OpenFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                using (var Stream = new System.IO.FileStream(OpenFileDialog.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read))
                {
                    if (OpenFileDialog.FileName.EndsWith(".gpx") == true)
                    {
                        var GPX   = GPS.GPX.DOM10.GPX.ReadFromStream(Stream);
                        var Track = new Mapper.Track();

                        Track.DrawLines = false;
                        foreach (var GPXTrack in GPX.Tracks)
                        {
                            foreach (var GPXTrackSegment in GPXTrack.TrackSegments)
                            {
                                foreach (var GPXTrackPoint in GPXTrackSegment.TrackPoints)
                                {
                                    var TrackPoint = new Records.Record();

                                    TrackPoint.Add("latitude", System.Windows.Forms.Map.GetLatitudeLocationFromLatitudeCoordinates(GPXTrackPoint.Latitude));
                                    TrackPoint.Add("longitude", System.Windows.Forms.Map.GetLongitudeLocationFromLongitudeCoordinates(GPXTrackPoint.Longitude));
                                    TrackPoint.Add("altitude", GPXTrackPoint.Elevation);
                                    TrackPoint.Add("speed", GPXTrackPoint.Speed);
                                    TrackPoint.Add("size", 5.0f);
                                    TrackPoint.Add("color", System.Drawing.Color.Black);
                                    Track.Append(TrackPoint);
                                }
                            }
                        }
                        _Tracks.Add(Track);
                        Track.AddField("altitude-difference-before", 0.0);
                        Track.AddField("altitude-difference-after", 0.0);
                        Track.UpdateFieldOfSecondOfPair <System.Double, System.Double>("altitude-difference-before", "altitude", (One, Two) => Two - One);
                        Track.UpdateFieldOfFirstOfPair <System.Double, System.Double>("altitude-difference-after", "altitude", (One, Two) => Two - One);
                        Track.AddField("altitude-difference", "altitude-difference-before", "altitude-difference-after", (System.Double Before, System.Double After) => (Before + After) / 2.0);
                    }
                    else if (OpenFileDialog.FileName.EndsWith(".kml") == true)
                    {
                        var KML = GPS.KML.Version_2_2.KML.ReadFromStream(Stream);

                        foreach (var Placemark in KML.Placemarks)
                        {
                            var Track = new Mapper.Track();

                            Track.DrawLines = true;
                            if (Placemark.Name != null)
                            {
                                Track.Name = Placemark.Name;
                            }
                            if (Placemark.LineString != null)
                            {
                                foreach (var Coordinates in Placemark.LineString.Coordinates)
                                {
                                    var TrackPoint = new Records.Record();

                                    TrackPoint.Add("latitude", System.Windows.Forms.Map.GetLatitudeLocationFromLatitudeCoordinates(Coordinates.Latitude));
                                    TrackPoint.Add("longitude", System.Windows.Forms.Map.GetLongitudeLocationFromLongitudeCoordinates(Coordinates.Longitude));
                                    if (Coordinates.Altitude != null)
                                    {
                                        TrackPoint.Add("altitude", Coordinates.Altitude);
                                    }
                                    TrackPoint.Add("size", 5.0f);
                                    TrackPoint.Add("color", System.Drawing.Color.Black);
                                    Track.Append(TrackPoint);
                                }
                            }
                            _Tracks.Add(Track);
                        }
                    }
                }
                _RebuildDataMap();
            }
        }