Exemple #1
0
        public void Run()
        {
            mRunning = true;
            int[] next = null;
            while ((next = mDistEvaluator.NextIJ()) != null)
            {
                int i = next[0];
                int j = next[1];
                mRoute.Clear();
                mRoute.Waypoints.Add(mMap.GetLocation(mDistEvaluator.GetLat(i), mDistEvaluator.GetLon(i)), "" + i);
                mRoute.Waypoints.Add(mMap.GetLocation(mDistEvaluator.GetLat(j), mDistEvaluator.GetLon(j)), "" + j);
                mRoute.Calculate();

                mDistEvaluator.SaveDistTime(i, j, mRoute.Distance, mRoute.TripTime / MapPoint.GeoTimeConstants.geoOneMinute);

                mDistEvaluator.PrintProgress();
            }

            mRoute.Clear();
            mMap.Saved = true;
            mMapPoint.Quit();
            mRunning = false;
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            MapPoint.Map map = mainFrm.frmMapPoint.Map.ActiveMap;

            map.ActiveRoute.Clear();

            frmDriver frm = new frmDriver();

            frm.loadProfileAutomatic(mainFrm.CURRENT_DRIVER_PROFILE, map.ActiveRoute.DriverProfile);

            MapPoint.Location start = null;


            if (mainFrm.listBox1.SelectedIndex > -1)
            {
                smartrack p = mainFrm.sm_array[mainFrm.listBox1.SelectedIndex];
                start = map.GetLocation(p.Lat, p.Lon, map.Altitude);
            }

            map.ActiveRoute.Waypoints.Add(start, "Partenza");
            map.ActiveRoute.Waypoints.Add(currentLocation, "Arrivo");

            map.ActiveRoute.DriverProfile.IncludeRestStops = true;
            try
            {
                map.ActiveRoute.Calculate();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            if (map.ActiveRoute.IsCalculated)
            {
                addNewPOI(txtDestination.Text);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (olnyAdd == false)
            {
                //***************** associo l'obiettivo al mezzo ******************
                if (mainFrm.listBox1.SelectedIndex == -1)
                {
                    MessageBox.Show("Per associare un bersaglio è necessario selezionare prima il mezzo.");
                    return;
                }
                smartrack sm = mainFrm.searchDevicebyDescription(mainFrm.listBox1.SelectedItem.ToString());
                //sm.Bersaglio = currentLocation;

                string bersaglio = currentLocation.Name + "|" + currentLocation.Latitude + "|" + currentLocation.Longitude;

                sm.SetBersaglio(bersaglio);
                mainFrm.deviceCtrl1.refreshStatus();

                if (MessageBox.Show(this, "Bersaglio associato. Visualizzo anche l'itinerario?", "Info", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    MapPoint.Map map = mainFrm.frmMapPoint.Map.ActiveMap;
                    map.ActiveRoute.Clear();

                    frmDriver frm = new frmDriver();
                    frm.loadProfileAutomatic(mainFrm.CURRENT_DRIVER_PROFILE, map.ActiveRoute.DriverProfile);

                    MapPoint.Location start = null;

                    mainFrm.frmMapPoint.Map.Units = MapPoint.GeoUnits.geoKm;
                    if (mainFrm.listBox1.SelectedIndex > -1)
                    {
                        smartrack p = mainFrm.sm_array[mainFrm.listBox1.SelectedIndex];
                        start = map.GetLocation(p.Lat, p.Lon, map.Altitude);
                    }

                    map.ActiveRoute.Waypoints.Add(start, "Partenza");
                    map.ActiveRoute.Waypoints.Add(currentLocation, "Arrivo");
                    try
                    {
                        map.ActiveRoute.Calculate();
                        map.ActiveRoute.Application.ItineraryVisible = false;

                        string Reso = "Viaggio da: " + start.Name + " a " + currentLocation.Name + "\r\n";

                        Reso += "Totale Km: " + map.ActiveRoute.Distance + ". Durata prevista tragitto: " + Math.Ceiling((map.ActiveRoute.DrivingTime * 24 * 60)) + " minuti.\r\n";
                        Reso += @"Costo totale (stimato in base al profilo di guida): " + Math.Round(map.ActiveRoute.Cost, 2) + "€";
                        if (!String.IsNullOrEmpty(mainFrm.CURRENT_DRIVER_PROFILE))
                        {
                            Reso += "\r\nProfilo di guida selezionato: " + System.IO.Path.GetFileName(mainFrm.CURRENT_DRIVER_PROFILE);
                        }
                        else
                        {
                            Reso += "\r\nProfilo di guida selezionato: nessuno";
                        }

                        if (MessageBox.Show(this, Reso + "\nAssocio l'obiettivo e salvo l'informazione?", "Info", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                            {
                                using (StreamWriter wr = new StreamWriter(saveFileDialog1.FileName, true))
                                {
                                    wr.WriteLine("**************************************");
                                    wr.WriteLine(Reso);
                                    wr.WriteLine("**************************************");
                                }
                            }

                            /* //***************** associo l'obiettivo al mezzo ******************
                             * smartrack sm = mainFrm.searchDevicebyDescription(mainFrm.listBox1.SelectedItem.ToString());
                             * sm.Bersaglio = currentLocation;
                             * mainFrm.deviceCtrl1.refreshStatus();*/
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Impossibile associare il bersaglio. Possibile causa:" + ex.Message);
                    }
                }
                this.Close();
            }
            else
            {
                this.Close();
            }
        }