Ejemplo n.º 1
0
        private static string GetName(MotionPathData motionPathData)
        {
            long l = motionPathData.startTime;

            l *= 10000;  // Ticks
            l += offset; // 1970
            DateTime t  = new DateTime(l);
            var      tz = int.Parse(motionPathData.timeZone);

            tz /= 100;
            t   = t.AddHours(tz);

            return(t.ToString("yyyy-MM-ddTHH_mm_ssZ") + " - " + ConvertCategory(motionPathData.sportType));
        }
Ejemplo n.º 2
0
        private static GpxTrack GetGpxTrack(MotionPathData motionPathData)
        {
            var attributes = motionPathData.attribute.Split(";");
            int i          = 0;

            Point p = null;
            List <GpxWaypoint> waypoints = new List <GpxWaypoint> ();

            while (i < attributes.Length)
            {
                i++;
                var a    = attributes[i];
                var pair = a.Split("=");
                if (pair.Length != 2)
                {
                    break;
                }
                switch (pair[0])
                {
                case "k":
                {
                    AddWaypoint(p, waypoints);
                    p = new Point();

                    break;
                }

                case "lat":
                {
                    if (p != null)
                    {
                        double d = double.Parse(pair[1]);
                        p.Lat = d;
                    }

                    break;
                }

                case "lon":
                {
                    if (p != null)
                    {
                        double d = double.Parse(pair[1]);
                        p.Long = d;
                    }
                    break;
                }

                case "alt":
                {
                    if (p != null)
                    {
                        double d = double.Parse(pair[1]);
                        p.Elev = d;
                    }
                    break;
                }

                case "t":
                {
                    if (p != null)
                    {
                        var d = double.Parse(pair[1]);
                        var l = Convert.ToInt64(d);
                        if (l > 10000000000)
                        {
                            l *= 10000;         // convert to ticks
                        }
                        else
                        {
                            l *= 10000000;
                        }

                        l += offset;         // 1970-01-01
                        DateTime t = new DateTime(l);
                        p.T = t;
                    }
                    break;
                }
                }
                AddWaypoint(p, waypoints);
            }
            System.Collections.Immutable.ImmutableArray <GpxTrackSegment> segments = System.Collections.Immutable.ImmutableArray <GpxTrackSegment> .Empty;
            segments = segments.Add(new GpxTrackSegment(new ImmutableGpxWaypointTable(waypoints), null));

            var gpxTrack = new GpxTrack(GetName(motionPathData),
                                        "Steps: " + motionPathData.totalSteps,
                                        "Cals: " + motionPathData.totalCalories,
                                        "",
                                        System.Collections.Immutable.ImmutableArray <GpxWebLink> .Empty,
                                        null,
                                        null,
                                        motionPathData.sportType,
                                        segments
                                        );

            return(gpxTrack);
        }