public static string GetCoordinatesFromListOfOffsetIds(string inPath)
        {
            StringBuilder s = new StringBuilder("");

            if (File.Exists(inPath))
            {
                LONGPOSITION lp         = new LONGPOSITION();
                string       tmp        = "";
                string[]     parameters = new string[2];

                StreamReader sr = new StreamReader(inPath);
                while (!sr.EndOfStream)
                {
                    tmp        = sr.ReadLine();
                    parameters = tmp.Split(';');
                    CApplicationAPI.GetCoordinatesFromOffset(
                        out _mySError,
                        parameters[0],
                        int.Parse(parameters[1]),
                        out lp,
                        0);
                    s.AppendLine(lp.lX.ToString() + ";" + lp.lY.ToString());
                }
                sr.Close();
            }
            return(s.ToString());
        }
        public static void HighlightPoi(string inPoiCategory, string inPoiName, string inSound, int inX, int inY, int inMaxTime)
        {
            LONGPOSITION lp  = new LONGPOSITION(inX, inY);
            int          ret = CApplicationAPI.HighlightPoi(out _mySError, inPoiCategory, inPoiName, inSound, lp, inMaxTime);

            O("HighlightPoi returns: " + ret.ToString());
        }
        public static void DirectGeocoding(int inX, int inY, int inMaxTime)
        {
            LONGPOSITION lp         = new LONGPOSITION(inX, inY);
            string       strAddress = "";
            SRoadInfo    sri        = new SRoadInfo();
            int          ret        = CApplicationAPI.GetLocationInfo(out _mySError, lp, out strAddress, out sri, inMaxTime);

            O("GetLocationInfo returns: " + ret + ", errorcode: " + MySError.nCode.ToString());
            if (ret == 1)
            {
                O("lRoadOffset: " + sri.lRoadOffset.ToString());
                O("OnroadPosition: X:" + sri.OnroadPosition.lX.ToString() + " Y: " + sri.OnroadPosition.lY.ToString());
                O("OffroadDistance:" + sri.dwOffroadDistance);
                O("IsCongestionCharge: " + sri.IsCongestionCharge.ToString());
                O("IsFerry: " + sri.IsFerry.ToString());
                O("IsoCode: " + sri.IsoCode.ToString());
                O("IsPaved: " + sri.IsPaved.ToString());
                O("IsProhibited: " + sri.IsProhibited.ToString());
                O("IsTollRoad: " + sri.IsTollRoad.ToString());
                O("IsTunnel: " + sri.IsTunnel.ToString());
                O("IsUrban: " + sri.IsUrban.ToString());
                O("RoadClass: " + sri.RoadClass.ToString());
                O("SpeedCategory: " + sri.SpeedCategory.ToString());
                O("SpeedRestriction: " + sri.SpeedRestriction.ToString());
                O("strAddress: " + strAddress);
            }

            int ret2 = CApplicationAPI.ShowCoordinatesOnMap(out _mySError, lp, 2, true, 0);

            O("ShowCoordinatesOnMap returns: " + ret2.ToString());
        }
        public static void GetCoordinatesFromOffset(string inIsoCode, int inRoadOffset, int inMaxTime)
        {
            LONGPOSITION lp  = new LONGPOSITION();
            int          ret = CApplicationAPI.GetCoordinatesFromOffset(out _mySError, inIsoCode, inRoadOffset, out lp, inMaxTime);

            O("GetCoordinatesFromOffset returns: " + ret.ToString());
            O("x=" + lp.lX.ToString() + ", y=" + lp.lY.ToString());
        }
        public static void StartNavigation(int inlX, int inlY, int inFlags, bool inbShowApplication, bool inbSearchAddress, int inMaxTime)
        {
            LONGPOSITION lp = new LONGPOSITION(inlX, inlY);
            SWayPoint    wp = new SWayPoint();

            wp.Location = lp;
            int ret = CApplicationAPI.StartNavigation(out _mySError, ref wp, inFlags, inbShowApplication, inbSearchAddress, inMaxTime);

            O("StartNavigation returns: " + ret.ToString() + ", errorcode: " + _mySError.nCode.ToString());
        }
Exemplo n.º 6
0
        //CANDIDO
        //public BatteryLevel batteryId = Microsoft.WindowsMobile.Status.SystemState.PowerBatteryStrength;
        public void anadePoi(string nombre, string tipo,int CoorX, int CoorY, int time)
        {
            //IMAGEN EN SYGIC
            SError err;
            try
            {
                int res = CApplicationAPI.DeletePoiCategory(out err, nombre, "ESP", 1000);//(Borramos Para las pruebas)
                string dirImagen = @nombre + ".bmp";
                res = CApplicationAPI.AddPoiCategory(out err, nombre, dirImagen, "ESP", 1000);
                LONGPOSITION position = new LONGPOSITION(CoorX, CoorY);//X, Y);
                SPoi poi = new SPoi(position,nombre, tipo, 0);
                res = CApplicationAPI.AddPoi(out err, ref poi, time);
            }
            catch { }
               //SONIDO

            //Sound sound = new Sound(Assembly.GetExecutingAssembly().GetManifestResourceStream("SoundSample."+tipo+".wav"));
            //sound.Play();
            //OpenFileDialog dialog1 = new OpenFileDialog();
               //dialog1.ShowDialog()
               // Properties.Resources.

               string _appFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
               string dirSonido = _appFolder + @"\Sounds\" + tipo + ".wav";
               dirSonido =  "\\Tarjeta de almacenamiento\\FLEET_MOBILE_14d\\MisSonidos\\" + tipo + ".wav";//parking.wav";
            try
            {
                //PlaySound((LPCWSTR)dirSonido, 0, SND_LOOP | SND_ASYNC | SND_FILENAME);
                WSounds ws = new WSounds();

                ws.Play(dirSonido, ws.SND_FILENAME | ws.SND_ASYNC);

               /* DriveHandler.SendDriveToForeground(1);
                System.Threading.Thread.Sleep(5000);
                DriveHandler.SendDriveToBackground(1);*/
            }
            catch //()Exception ex)
            {
                //Invoke(myDelegate, new Object[] { "Error: " + ex.Message });
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Converts an adress to a nearby GPS location represented in LONGPOSITION
 /// </summary>
 /// <param name="longPosition_out">the result of conversion</param>
 /// <param name="strAddress_in">the address that user wants to convert</param>
 /// <param name="isPostal_in">if true, city's name is required in postal code (e.g. not it's name. This works only in few countries)
 /// <param name="valueMatch_in">if true, fuzzy search is on</param>
 /// <returns>1 if successful, other value otherwise</returns>
 public static int LocationFromAddress(out LONGPOSITION longPosition_out, string strAddress_in, bool isPostal_in, bool valueMatch_in)
 {
     int aResult;
     //creating location from address represented in string
     //mySerror - error
     //position
     //location in string
     //postal == false, we got city's name in string not it's postal code
     //valueMatch == true, fuzzy searching is on
     //timeout set to infinity - search can take long time
     aResult = CApplicationAPI.LocationFromAddress(out mySerror, out longPosition_out, strAddress_in, isPostal_in, valueMatch_in, myTimeout);
     CheckSerror();
     return aResult;
 }
        //Función que cada cierto tiempo va
        private void vigila()
        {
            //  int velocidad, X, Y;
            //bool atasco;
            SError err;
            SGpsPosition gps;
            // SRoadInfo road;
            int speedLimit = 0, atascado = 0;
            string direccionTJam;
            // LONGPOSITION posTJam;

            string text = "";// "Current position:\r\n\t";
            string text2 = "";// "Current speed:\r\n\t";//VELOCIDAD ACTUAL
            string text3 = "GPS Time:\r\n\t";//HORA GPS
            string text4 = "Condition:\r\n\t";//ATASCO
               // string text5;
               // string text6, a = ".";

            if (DriveHandler.StartDrive("\\Tarjeta de almacenamiento\\FLEET_MOBILE_14d\\Drive\\WindowsMobile\\Drive.exe", new int[] { 0, 0, 0, 0 }) == 1)//20, 60, 320, 240 }) == 1)
            {
                Formulario.Invoke(Formulario.myDelegate, new Object[] { "Entro en Detecta incidente" });
                DriveHandler.SendDriveToBackground(10);
                //Hilo que está todo el tiempo detectando posibles atascos.*/
                while (!Formulario.cerrar)
                {
                    //Se obtiene información de posición gps y velocidad de circulación
                    if (CApplicationAPI.GetActualGpsPosition(out err, out gps, false, 1000) == 1)
                    {
                        LONGPOSITION position = new LONGPOSITION(gps.Longitude, gps.Latitude);
                        CApplicationAPI.MetersToWorldDegree(ref position);
                        double longitude = position.lX;// / 100000.0;
                        double latitude = position.lY;// / 100000.0;
                        double altitud = gps.Altitude;
                        string sentido = "";
                        text = longitude + "°," + latitude + "°";

                        // Formulario.Invoke(Formulario.myDelegate3, new Object[] { text });
                        text2 = gps.Speed + "km/h"; //VELOCIDAD ACTUAL
                        try
                        {
                        Formulario.Invoke(Formulario.myDelegate2, new Object[] { text2 });
                        // text3 = gps.Time + "hora" + gps.Date + "fecha";//HORA Y FECHA
                        if (CApplicationAPI.GetLocationInfo(out err, position, out direccionTJam, 0) == 1)
                        {
                          //  Formulario.Invoke(Formulario.myDelegate3, new Object[] { direccionTJam });
                        }

                            //Se obtiene la velocidad límite de la vía
                            if (CApplicationAPI.GetCurrentSpeedLimit(out err, out speedLimit, 1000) == 1)
                            {
                                //Si estamos cin una vía y la velocidad de circulación es considereblemente inferior
                                //a la velocidad normal de la via marcamos un posible atasco

                                //Mostramos la velocidad límite de la vía
                                string velocidadlimite2 = "Velocidad limite" + speedLimit.ToString();
                                //Formulario.Invoke(Formulario.myDelegate, new Object[] { velocidadlimite2 });
                                /* a += ".";
                                 Formulario.Invoke(Formulario.myDelegate, new Object[] { a });*/
                                string velocidad = "Velocidad circulacion" + gps.Speed;
                                //Formulario.Invoke(Formulario.myDelegate, new Object[] { velocidad });

                                if ((gps.Speed >= 0) && (gps.Speed <= (speedLimit / 4))) // gps.Speed < 4))//
                                // if (speedLimit <= 0)//jeza-->quitarlinea
                                {
                                    //Mostramos la velocidad límite de la vía

                                    //string velocidadlimite = speedLimit.ToString();
                                    //Formulario.Invoke(Formulario.myDelegate3, new Object[] { velocidadlimite });

                                    if (atascado == 0)
                                    {
                                        text4 = "Possible Traffic Jam";
                                        //Formulario.Invoke(Formulario.myDelegate, new Object[] { text4 });
                                    }
                                    atascado++;
                                    if (atascado == 10)
                                    {//En caso de detectar atasco, coger información de la vía, añadirlo en el gps, enviar para que firmen

                                        //Se muestra en el Mapa que hay un posible atasco
                                        // if (CApplicationAPI.FlashMessage(out err, "Possible Traffic Jam", true, 1000) == 1)
                                        //      Formulario.Invoke(Formulario.myDelegate, new Object[] { "Add event: Traffic Jam" });

                                        //Formulario.Invoke(Formulario.myDelegate, new Object[] { "ATASCO!!" });

                                        //Se recoge el nombre de la vía donde hay atasco y el sentido de la marcha
                                        if (CApplicationAPI.GetLocationInfo(out err, position, out direccionTJam, 0) == 1)
                                        {
                                            //Se obtiene el sentido de la marcha
                                            sentido = ObtenerSentidoMarcha(gps.Course);
                                            Formulario.Invoke(Formulario.myDelegate, new Object[] { "Traffic Jam in: " + direccionTJam });
                                            Formulario.Invoke(Formulario.myDelegate, new Object[] { "Sense: " + sentido });
                                        }
                                        //Se llama a la función encargada de manejar los incidentes y el hilo actual sigue vigilando.
                                        ManejaIncidente(direccionTJam, sentido, longitude, latitude, altitud);

                                        // Thread HiloManejaIncidente = new Thread(new ThreadStart(hiloParam.ManejaIncidente));
                                        //HiloManejaIncidente.Start();
                                        //Thread.Sleep(300 * 1000);
                                        atascado = 0;
                                    }
                                }
                                else
                                {
                                    atascado = 0;
                                }
                            }
                        }
                        catch //(Exception p)
                        {
                           // Formulario.Invoke(Formulario.myDelegate, new Object[] { "Error: " + p.Message });
                        }

                    }
                    else
                    {
                        text += err.GetDescription();
                        text2 += err.GetDescription(); //VELOCIDAD ACTUAL
                        text3 += err.GetDescription(); //GPS FECHA
                        text4 += err.GetDescription();
                    }
                    //dormimos el hilo un segundo
                    Thread.Sleep(1000);
                }
            }
        }
        private void añadePoi(int X, int Y)
        {
            string dirimconges = "\\Tarjeta de almacenamiento\\FLEET_MOBILE_14d\\Res\\icons\\poi\\1_favo_3.bmp";
            SError err;

            SPoi poi;

            LONGPOSITION position = new LONGPOSITION(X, Y);

            int res = CApplicationAPI.AddPoiCategory(out err, "Restaurante", dirimconges, "ESP", 0);
            Formulario.Invoke(Formulario.myDelegate, new Object[] { "El resultado de añadir una categoría es: " + err.GetDescription() });

            //res = CApplicationAPI.LocationFromAddress(out err, out position, "SVK,Bratislava,Zochova,1", false, false, 0);

            poi = new SPoi(position, "Restaurante", "New POI", 0);

            res = CApplicationAPI.AddPoi(out err, ref poi, 0);
            Formulario.Invoke(Formulario.myDelegate, new Object[] { "El resultado de añadir el POI es: " + err.GetDescription() });

            int b = res;

            // CApplicationAPI.AddPoiCategory(out error, strCategory, strBitmapPath, strISOCode, nMaxTime);
            //int a= CApplicationAPI.AddPoi(out Error, ref Poi ,MaxTime);
            //Formulario.Invoke(Formulario.myDelegate, new Object[] {"El resultado de añadePOI es "+a+ " "+Error.nCode});
        }
Exemplo n.º 10
0
        /*
         * Función que devuelve la vía por la que circulamos y el sentido en el que circulamos
         * return via|sentido
         */
        public string ViaSentidoMarcha()
        {
            SError err;
            SGpsPosition gps;
            string sentido, direccionTJam, result = "";

            //Se obtiene la posición gps
            try
            {
                if (CApplicationAPI.GetActualGpsPosition(out err, out gps, false, 1000) == 1)
                {
                    LONGPOSITION position = new LONGPOSITION(gps.Longitude, gps.Latitude);

                    //Se obtiene el nombre de la vía
                    if (CApplicationAPI.GetLocationInfo(out err, position, out direccionTJam, 0) == 1)
                    {
                        //Se obtiene el sentido de la marcha
                        sentido = ObtenerSentidoMarcha(gps.Course);
                        result = direccionTJam + "|" + sentido;
                    }
                }
            }
            catch { }
            return result;
        }
Exemplo n.º 11
0
        public void posibleparking()
        {
            SError err;
            SGpsPosition gps;
            string hostName = Dns.GetHostName();
            IPHostEntry thisHost = Dns.GetHostEntry(hostName);
            string thisIpAddr = thisHost.AddressList[0].ToString();
            Cliente mycliente = new Cliente(Formulario, "9050");
            DateTime inicio = DateTime.Now.AddSeconds(10.00);//si en menos de X segundos detecta la señal gps avisa de posible aparcamiento
            string auxiliar, via, sentido;
            Cripto criputiles = new Cripto(Formulario);
            BD DButiles = new BD(Formulario);

            while (DateTime.Compare(DateTime.Now, inicio) < 0)
            {
                try
                {
                    if (CApplicationAPI.GetActualGpsPosition(out err, out gps, false, 1000) == 1)
                    {
                        LONGPOSITION position = new LONGPOSITION(gps.Longitude, gps.Latitude);
                        sentido = ObtenerSentidoMarcha(gps.Course);
                        CApplicationAPI.GetLocationInfo(out err, position, out via, 0);

                        int CoorX = gps.Longitude;
                        int CoorY = gps.Latitude;
                        int CoorZ = gps.Altitude;
                        //string viaOnombre = "calle";
                        //string sentido = "sentido";
                        DateTime fechaDato = DateTime.Now;
                        string datoAparcamiento = via + ";" + sentido + ";" + CoorX + ";" + CoorY + ";" + CoorZ + ";" + fechaDato;//Estos datos los coge de un fichero
                        string firma = criputiles.RSAfirma(datoAparcamiento);

                        Formulario.Invoke(Formulario.myDelegate, new Object[] { "Possible parking in: " + CoorX + "," + CoorY });
                        auxiliar = criputiles.Encrypt(datoAparcamiento+";"+firma, DButiles.recuperamySK());
                        mycliente.respuesta("P2", Server.myPseudonimo,auxiliar , thisIpAddr);
                        DButiles.insertarEvento("P2", via, sentido, CoorX, CoorY, CoorZ, fechaDato, firma);

                        break;
                    }
                }
                catch { }
                Thread.Sleep(1000);
            }
        }