Beispiel #1
0
            public void Laden(object o, EventArgs ea)
            {
                running = true;
                dir2    = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;
                string filenaam = System.IO.Path.Combine(dir2, "route1.txt");

                string tekst = File.ReadAllText(filenaam);

                string[] regels = tekst.Split('\n');

                foreach (string zin in regels)
                {
                    string[] acht = zin.Split(' ');
                    if (acht.Length == 8)
                    {
                        int   y  = int.Parse(acht[0]);
                        int   M  = int.Parse(acht[1]);
                        int   d  = int.Parse(acht[2]);
                        int   h  = int.Parse(acht[3]);
                        int   m  = int.Parse(acht[4]);
                        int   s  = int.Parse(acht[5]);
                        float px = float.Parse(acht[6]);
                        float py = float.Parse(acht[7]);

                        Meting meting = new Meting(new DateTime(y, M, d, h, m, s), new PointF(px, py));
                        Console.WriteLine(meting.ToString());
                        route.Add(meting);
                        this.Invalidate();
                    }
                }

                Status.Text = "De opgeslagen route is geladen."; //hier nog de naam van het document of de datum oid toevoegen als we nog listview doen
            }
Beispiel #2
0
        public static float Afstand(Meting pt, Meting vorige)
        {
            float dx      = pt.punt.X - vorige.punt.X;
            float dy      = pt.punt.Y - vorige.punt.Y;
            float afstand = (float)Math.Sqrt(dx * dx + dy * dy) / 1000;

            return(afstand);
        }
Beispiel #3
0
            public void OnLocationChanged(Location loc)
            {
                huidig = Kaart.Projectie.Geo2RD(loc);
                t      = DateTime.Now;
                Meting pt = new Meting(t, huidig);


                //Elk huidige punt wordt opgeslagen in de lijst 'route' waardoor de afgelegde route getekend wordt
                if (gestart == true)
                {
                    route.Add(pt);
                }

                this.Invalidate();
            }
Beispiel #4
0
        public static float TotaleAfstand(List <Meting> route)
        {
            float res = 0;

            Meting vorige = null;

            foreach (Meting pt in route)
            {
                if (vorige != null)
                {
                    res += Meting.Afstand(pt, vorige);
                }
                vorige = pt;
            }

            return(res);
        }
Beispiel #5
0
        /*public string GetShareText()
         * {
         *  string res;
         *
         *  res = $"🏃 {huidigTijd.ToString("H:mm:ss")}-{huidigTextX} ; {huidigTextY}\n";
         *
         *  return res;
         * }*/

        public static float Snelheid(Meting pt, Meting vorige)
        {
            //float snelheid = 0;
            //Afstand berekenen in km
            float dx      = pt.punt.X - vorige.punt.X;
            float dy      = pt.punt.Y - vorige.punt.Y;
            float afstand = (float)Math.Sqrt(dx * dx + dy * dy) / 1000;

            //Tijd in uren
            //verschil = new TimeSpan();
            TimeSpan verschil = pt.dt - vorige.dt;
            //Console.WriteLine(verschil);
            //float.Parse(verschil);

            //Snelheid in km/uur
            float snelheid = afstand / (float)verschil.TotalHours;

            //Console.WriteLine(snelheid);
            //Console.WriteLine((float)verschil.TotalHours);


            return(snelheid);
        }
Beispiel #6
0
            protected override void OnDraw(Canvas canvas)
            {
                base.OnDraw(canvas);
                Paint verf = new Paint();

                if (running == true)
                {
                    verf.Color = Color.DarkRed;

                    //Midx en midy staan voor het midden van de kaart
                    midx = (centrum.X - 136000) * 0.4f;
                    midy = -(centrum.Y - 458000) * 0.4f;

                    //De kaart (geo) wordt getekend met behulp van de matrix
                    Matrix mat = new Matrix();
                    mat.PostTranslate(-midx, -midy);
                    mat.PostScale(Schaal, Schaal);
                    mat.PostTranslate(canvas.Width / 2, canvas.Height / 2);

                    canvas.DrawBitmap(geo, mat, verf);

                    //Teken de afgelegde route
                    foreach (Meting pt in route)
                    {
                        float bx = pt.punt.X - centrum.X;
                        float qx = bx * 0.4f;
                        float tx = qx * Schaal;
                        float a  = this.Width / 2 + tx;

                        float by = pt.punt.Y - centrum.Y;
                        float qy = by * 0.4f;
                        float ty = qy * Schaal;
                        float b  = this.Height / 2 + -ty;

                        canvas.DrawCircle(a, b, 10, verf);
                    }

                    //Centrum is het midden van de kaart en huidig is het huidige punt van de GPS
                    if (huidig != null)
                    {
                        float ax = huidig.X - centrum.X;
                        float px = ax * 0.4f;
                        float sx = px * Schaal;
                        float x  = this.Width / 2 + sx;

                        float ay = huidig.Y - centrum.Y;
                        float py = ay * 0.4f;
                        float sy = py * Schaal;
                        float y  = this.Height / 2 + -sy;

                        //Het pijltje dat aangeeft waar de user zich bevindt wordt getekend met behulp van de matrix
                        Matrix pmat = new Matrix();
                        pmat.PostTranslate(-arrow.Width / 2, -arrow.Height / 2);
                        pmat.PostRotate(this.Hoek);
                        pmat.PostTranslate(x, y);

                        canvas.DrawBitmap(arrow, pmat, null);
                    }
                }
                else
                {
                    Meting vorige = null;
                    max = 0;
                    min = 1000;
                    float snelheidafgelegd;
                    tijdsverschil = 0;
                    // float x = 50;

                    //vaste, constante delen van de grafiek
                    verf.Color    = Color.Black;
                    verf.TextSize = 30;
                    canvas.DrawRect(40, 0, 50, this.Height - 200, verf);
                    canvas.DrawRect(40, this.Height - 200, this.Width, this.Height - 190, verf);
                    canvas.DrawText("15", 5, 30, verf);
                    canvas.DrawText("0", 15, this.Height - 210, verf);


                    if (route != null && route.Count != 0)
                    {
                        //Startpunt en starttijd berekenen
                        Meting   startpunt = route[0];
                        DateTime starttijd = startpunt.dt;

                        //Eindpunt en eindtijd berekenen
                        Meting   eindpunt = route[route.Count - 1];
                        DateTime eindtijd = eindpunt.dt;

                        canvas.DrawText($"{starttijd}", 40, this.Height - 165, verf);
                        canvas.DrawText($"{eindtijd}", this.Width - 270, this.Height - 165, verf);


                        //Console.WriteLine(eindtijd);
                        //Console.WriteLine(starttijd);

                        //Het totale tijdsverschil
                        tijdsverschil = (float)(eindtijd - starttijd).TotalHours;
                        //Console.WriteLine(tijdsverschil.TotalSeconds);
                    }

                    //Teken de grafiek
                    float afgelegdeafstand = 0;
                    totaleafstand = Meting.TotaleAfstand(route);
                    float vorigex = 0;
                    float vorigey = 0;
                    float x       = 0;
                    float y       = 0;
                    //Gemiddelde snelheid berekenen en tekenen
                    verf.Color         = Color.Gray;
                    gemiddeldesnelheid = totaleafstand / tijdsverschil;
                    float yGS = (this.Height) - (gemiddeldesnelheid / 15 * (this.Height - 200) + 200);
                    canvas.DrawLine(40, yGS, this.Width, yGS, verf);
                    canvas.DrawText("Gem. snelheid", this.Width - 300, yGS + 35, verf);

                    foreach (Meting pt in route)
                    {
                        verf.Color = Color.DarkRed;


                        if (vorige != null)// er is een vorig punt
                        {
                            //snelheidafgelegd = 15;
                            snelheidafgelegd = Meting.Snelheid(pt, vorige);
                            //Console.WriteLine(snelheidafgelegd);

                            //snelheidafgelegd = 0;
                            afgelegdeafstand += Meting.Afstand(pt, vorige);

                            x = (afgelegdeafstand / totaleafstand) * (this.Width - 40) + 40; //totale afstand
                            y = (this.Height) - (snelheidafgelegd / 15 * (this.Height - 200) + 200);
                            float r = 10;

                            canvas.DrawCircle(x, y, r, verf);
                            if (vorigex != 0 && vorigey != 0)
                            {
                                canvas.DrawLine(vorigex, vorigey, x, y, verf);
                            }

                            //a += 30;

                            //Berekenen maximale snelheid
                            if (snelheidafgelegd > max)
                            {
                                max = snelheidafgelegd;
                            }

                            //Berekenen minimale snelheid
                            if (snelheidafgelegd < min)
                            {
                                min = snelheidafgelegd;
                            }

                            // canvas.DrawLine((((this.Width - x) / (float)tijdsduur.TotalSeconds) * (float)tijdpuntOud.TotalSeconds) + x, y - (y / 15) * snelheidOud, y - (y / 15) * snelheid, roze);
                            // canvas.DrawLine();
                        }
                        //Console.WriteLine(min);
                        vorige  = pt;
                        vorigex = x;
                        vorigey = y;
                        //Console.WriteLine(max);
                    }



                    //Informatie op het scherm zetten

                    //Laagste snelheid
                    canvas.DrawText($"De laagste snelheid was: {(int)min} km/u.", 30, this.Height - 80, verf);

                    //Hoogste snelheid
                    canvas.DrawText($"De hoogste snelheid was: {(int)max} km/u.", 30, this.Height - 10, verf);

                    //Gemiddelde snelheid
                    canvas.DrawText($"De gemiddelde snelheid was: {(int)gemiddeldesnelheid} km/u.", this.Width / 2, this.Height - 80, verf);

                    //Aantal calorieën verbrand
                    float kcal1 = 13 * 70; //Standaard aantal kcal en een gemiddeld gewicht genomen.
                    kcal2 = kcal1 * tijdsverschil;
                    canvas.DrawText($"Je hebt ongeveer {(int)kcal2} kcal verbrand.", this.Width / 2, this.Height - 10, verf);
                }
            }