Exemple #1
0
 public static PuntoF operator -(PuntoF a)
 {
     PuntoF p = new PuntoF();
     p.x = - a.x;
     p.y = - a.y;
     return p;
 }
Exemple #2
0
        /*
        public static bool operator ==(PuntoF a, PuntoF b)
        {
            if ((a.x == b.x) && (a.y == b.y))
                return true;
            else
                return false;
        }

        public static bool operator !=(PuntoF a, PuntoF b)
        {
            if ((a.x != b.x) || (a.y != b.y))
                return true;
            else
                return false;
        }
        */
        public static PuntoF operator+(PuntoF a, PuntoF b)
        {
            PuntoF p = new PuntoF();
            p.x = b.x + a.x;
            p.y = b.y + a.y;
            return p;
        }
        public double getdY(WayPoint wpt)
        {
            PuntoF p = mapa.InterpolaLonLat((float)wpt.Longitude, (float)wpt.Latitude) -
                       mapa.InterpolaLonLat((float)center.Longitude, (float)center.Latitude);

            return(p.y);
        }
Exemple #4
0
 public static PuntoF operator -(PuntoF a, PuntoF b)
 {
     PuntoF p = new PuntoF();
     p.x = a.x - b.x;
     p.y = a.y - b.y;
     return p;
 }
        public double GetLatitude(double dy)
        {
            _dy = (float)dy + _height / 2;
            PuntoF wpt = mapa.InterpolaXY(_dx - homeXY.x, _dy - homeXY.y);

            return(wpt.y);
        }
        public double GetLongitude(double dx)
        {
            _dx = (float)dx + _width / 2;
            PuntoF wpt = mapa.InterpolaXY(_dx - homeXY.x, _dy - homeXY.y);

            return(wpt.x);
        }
Exemple #7
0
 public static PuntoF operator *(PuntoF a, float f)
 {
     PuntoF p = new PuntoF();
     p.x = f * a.x;
     p.y = f * a.y;
     return p;
 }
Exemple #8
0
        void UpdateHomeXY()
        {
            if (mapa == null)
            {
                mapa = lista.GetBest(new PuntoF((float)center.Longitude, (float)center.Latitude));
            }
            if (center != null && mapa != null)
            {
                PuntoF centroControl = new PuntoF(this.Width, this.Height) / 2;
                PuntoF centroGPS     = mapa.InterpolaLonLat((float)center.Longitude, (float)center.Latitude);
                PuntoF resta         = centroControl - centroGPS;
                if (resta.x > 0)
                {
                    resta.x = 0;
                }
                if (resta.y > 0)
                {
                    resta.y = 0;
                }
                if (resta.x < this.Width - mapa.img.Width)
                {
                    resta.x = this.Width - mapa.img.Width;
                }
                if (resta.y < this.Height - mapa.img.Height)
                {
                    resta.y = this.Height - mapa.img.Height;
                }

                homeXY = resta;
            }
            else
            {
                homeXY = new PuntoF(0, 0);
            }
        }
        void UpdateHomeXY()
        {
            if (mapa == null)
            {
                mapa = lista.GetBest(new PuntoF((float)center.Longitude, (float)center.Latitude));
            }
            if (center != null && mapa != null)
            {
                PuntoF centroControl = new PuntoF(this.Width, this.Height) / 2;
                PuntoF centroGPS = mapa.InterpolaLonLat((float)center.Longitude, (float)center.Latitude);
                PuntoF resta = centroControl - centroGPS;
                if (resta.x > 0)
                    resta.x = 0;
                if (resta.y > 0)
                    resta.y = 0;
                if (resta.x < this.Width - mapa.img.Width)
                    resta.x = this.Width - mapa.img.Width;
                if (resta.y < this.Height - mapa.img.Height)
                    resta.y = this.Height - mapa.img.Height;

                homeXY = resta;
            }
            else
            {
                homeXY = new PuntoF(0, 0);
            }
        }
Exemple #10
0
        public static PuntoF operator -(PuntoF a, PuntoF b)
        {
            PuntoF p = new PuntoF();

            p.x = a.x - b.x;
            p.y = a.y - b.y;
            return(p);
        }
Exemple #11
0
        public static PuntoF operator -(PuntoF a)
        {
            PuntoF p = new PuntoF();

            p.x = -a.x;
            p.y = -a.y;
            return(p);
        }
Exemple #12
0
        /*
         * public static bool operator ==(PuntoF a, PuntoF b)
         * {
         *  if ((a.x == b.x) && (a.y == b.y))
         *      return true;
         *  else
         *      return false;
         * }
         *
         * public static bool operator !=(PuntoF a, PuntoF b)
         * {
         *  if ((a.x != b.x) || (a.y != b.y))
         *      return true;
         *  else
         *      return false;
         * }
         */
        public static PuntoF operator+(PuntoF a, PuntoF b)
        {
            PuntoF p = new PuntoF();

            p.x = b.x + a.x;
            p.y = b.y + a.y;
            return(p);
        }
Exemple #13
0
        public static PuntoF operator /(PuntoF a, float f)
        {
            PuntoF p = new PuntoF();

            p.x = a.x / f;
            p.y = a.y / f;
            return(p);
        }
Exemple #14
0
        public static PuntoF operator *(float f, PuntoF a)
        {
            PuntoF p = new PuntoF();

            p.x = f * a.x;
            p.y = f * a.y;
            return(p);
        }
Exemple #15
0
        public PuntoF InterpolaXY(float x, float y)
        {
            PuntoF punto1 = TopLeft * (1.0f - x / img_with) + TopRight * (x / img_with);
            PuntoF punto2 = BottonLeft * (1.0f - x / img_with) + BottonRight * (x / img_with);
            PuntoF punto  = punto1 * (1.0f - y / img_heigh) + punto2 * (y / img_heigh);

            return(punto);
        }
Exemple #16
0
        public bool LoadOziexplorer(string Filename)
        {
            string       str;
            StreamReader sr = new StreamReader(Filename);

            str = sr.ReadLine();
            if (str.Contains("OziExplorer"))
            {
                str = sr.ReadLine();
                this.img_filename  = Filename.Substring(0, Filename.LastIndexOf('\\') + 1);
                this.img_filename += str;
                this.img_heigh     = 0;
                this.img_with      = 0;

                while (!sr.EndOfStream)
                {
                    str = sr.ReadLine();
                    string[] var = str.Split(',');
                    if (var[0] == "MMPNUM")
                    {
                        int i = int.Parse(var[1]);
                        puntos = new Calibracion[4];
                    }
                    else if (var[0] == "MMPXY")
                    {
                        int i    = int.Parse(var[1]) - 1;
                        int mi_x = int.Parse(var[2]);
                        int mi_y = int.Parse(var[3]);
                        puntos[i].x = mi_x;
                        puntos[i].y = mi_y;
                        if (puntos[i].x > img_with)
                        {
                            img_with = mi_x;
                        }
                        if (puntos[i].y > img_heigh)
                        {
                            img_heigh = mi_y;
                        }
                    }
                    else if (var[0] == "MMPLL")
                    {
                        int i = int.Parse(var[1]) - 1;
                        puntos[i].lon = float.Parse(var[2], System.Globalization.CultureInfo.InvariantCulture);
                        puntos[i].lat = float.Parse(var[3], System.Globalization.CultureInfo.InvariantCulture);
                    }
                }

                TopLeft     = Buscar(false, false);
                TopRight    = Buscar(true, false);
                BottonLeft  = Buscar(false, true);
                BottonRight = Buscar(true, true);
                return(true);
            }
            return(false);
        }
        public void setY(double y)
        {
            _y = (float)y - homeXY.y;

            PuntoF p = mapa.InterpolaLonLat((float)center.Longitude, (float)center.Latitude);

            p.x += _x;
            p.y += _y;
            PuntoF tmp = mapa.InterpolaXY(p.x, p.y);

            tmpCenter = new WayPoint("", tmp.x, tmp.y);
        }
Exemple #18
0
 protected override void OnMouseMove(MouseEventArgs e)
 {
     base.OnMouseMove(e);
     if (mapa != null)
     {
         PuntoF pos = new PuntoF(e.X, e.Y);
         pos = pos - homeXY;
         PuntoF p = mapa.InterpolaXY(pos.x, pos.y);
         lon = p.x;
         lat = p.y;
         this.Invalidate();
     }
 }
Exemple #19
0
 public MapaCalibrado GetBest(PuntoF pos)
 {
     MapaCalibrado best = lista[0];
     float dist = (best.CentroLonLat() - pos).mod();
     foreach (MapaCalibrado mapa in lista)
     {
         float f = (mapa.CentroLonLat() - pos).mod();
         if (f < dist)
         {
             dist = f;
             best = mapa;
         }
     }
     return best;
 }
Exemple #20
0
        public MapaCalibrado GetBest(PuntoF pos)
        {
            MapaCalibrado best = lista[0];
            float         dist = (best.CentroLonLat() - pos).mod();

            foreach (MapaCalibrado mapa in lista)
            {
                float f = (mapa.CentroLonLat() - pos).mod();
                if (f < dist)
                {
                    dist = f;
                    best = mapa;
                }
            }
            return(best);
        }
        void UpdateHomeXY(int Width, int Height)
        {
            mapa = lista.GetBest(new PuntoF((float)tmpCenter.Longitude, (float)tmpCenter.Latitude));

            if (tmpCenter != null && mapa != null)
            {
                PuntoF centroControl = new PuntoF(Width, Height) / 2;
                PuntoF centroGPS     = mapa.InterpolaLonLat((float)tmpCenter.Longitude, (float)tmpCenter.Latitude);
                PuntoF resta         = centroControl - centroGPS;
                /* */
                if (resta.x > 0)
                {
                    resta.x = 0;
                }
                if (resta.y > 0)
                {
                    resta.y = 0;
                }
                if (resta.x < Width - mapa.img.Width)
                {
                    resta.x = Width - mapa.img.Width;
                }
                if (resta.y < Height - mapa.img.Height)
                {
                    resta.y = Height - mapa.img.Height;
                }
                /* */
                centroGPS = centroControl - resta;
                PuntoF tmp = mapa.InterpolaXY(centroGPS.x, centroGPS.y);
                center = new WayPoint("", tmp.x, tmp.y);

                homeXY = resta;
            }
            else
            {
                homeXY = new PuntoF(0, 0);
            }
        }
Exemple #22
0
        protected override void OnPaint(PaintEventArgs e)
        {
            //base.OnPaint(e);
            UpdateHomeXY();

            if (mapa != null)
            {
                Graphics g    = e.Graphics;
                Font     f    = new Font(FontFamily.GenericSansSerif, 12.0f);
                string   str  = "Lon " + lon + " Lat " + lat;
                SizeF    size = g.MeasureString(str, f);
                g.DrawImage(mapa.img, homeXY.x, homeXY.y);

                g.FillRectangle(Brushes.White, 0, 0, size.Width, size.Height);
                g.DrawString(str, f, Brushes.Black, new PointF(0, 0));

                PuntoF p = mapa.InterpolaLonLat(lon, lat) + homeXY;
                e.Graphics.FillRectangle(Brushes.Red, p.x - 5, p.y - 5, 10, 10);

                PuntoF q = mapa.InterpolaLonLat((float)center.Longitude, (float)center.Latitude) + homeXY;
                e.Graphics.FillRectangle(Brushes.Yellow, q.x - 5, q.y - 5, 10, 10);
            }
        }
Exemple #23
0
 protected override void OnMouseMove(MouseEventArgs e)
 {
     base.OnMouseMove(e);
     if (mapa != null)
     {
         PuntoF pos = new PuntoF(e.X, e.Y);
         pos = pos - homeXY;
         PuntoF p = mapa.InterpolaXY(pos.x, pos.y);
         lon = p.x;
         lat = p.y;
         this.Invalidate();
     }
 }
 void UpdateHomeXY(int Width, int Height)
 {
     mapa = lista.GetBest(new PuntoF((float)tmpCenter.Longitude, (float)tmpCenter.Latitude));
 
     if (tmpCenter != null && mapa != null)
     {
         PuntoF centroControl = new PuntoF(Width, Height) / 2;
         PuntoF centroGPS = mapa.InterpolaLonLat((float)tmpCenter.Longitude, (float)tmpCenter.Latitude);
         PuntoF resta = centroControl - centroGPS;
         /* */
         if (resta.x > 0)
             resta.x = 0;
         if (resta.y > 0)
             resta.y = 0;
         if (resta.x < Width - mapa.img.Width)
             resta.x = Width - mapa.img.Width;
         if (resta.y < Height - mapa.img.Height)
             resta.y = Height - mapa.img.Height;
         /* */
         centroGPS = centroControl - resta;
         PuntoF tmp= mapa.InterpolaXY(centroGPS.x, centroGPS.y);
         center = new WayPoint("", tmp.x, tmp.y);
         
         homeXY = resta;
     }
     else
     {
         homeXY = new PuntoF(0, 0);
     }
 }
Exemple #25
0
        public bool LoadOziexplorer(string Filename)
        {
            string str;
            StreamReader sr = new StreamReader(Filename);
            str = sr.ReadLine();
            if (str.Contains("OziExplorer"))
            {
                str = sr.ReadLine();
                this.img_filename = Filename.Substring(0, Filename.LastIndexOf('\\') + 1);
                this.img_filename += str;
                this.img_heigh = 0;
                this.img_with = 0;
             
                while (!sr.EndOfStream)
                {
                    str = sr.ReadLine();
                    string[] var = str.Split(',');
                    if (var[0] == "MMPNUM")
                    {
                        int i = int.Parse(var[1]);
                        puntos = new Calibracion[4];
                    }
                    else if (var[0] == "MMPXY")
                    {
                        int i = int.Parse(var[1]) - 1;
                        int mi_x = int.Parse(var[2]);
                        int mi_y = int.Parse(var[3]);
                        puntos[i].x = mi_x;
                        puntos[i].y = mi_y;
                        if (puntos[i].x > img_with)
                            img_with = mi_x;
                        if (puntos[i].y > img_heigh)
                            img_heigh = mi_y;
                    }
                    else if (var[0] == "MMPLL")
                    {
                        int i = int.Parse(var[1]) - 1;
                        puntos[i].lon = float.Parse(var[2], System.Globalization.CultureInfo.InvariantCulture);
                        puntos[i].lat = float.Parse(var[3], System.Globalization.CultureInfo.InvariantCulture);
                    }

                }

                TopLeft = Buscar(false, false);
                TopRight = Buscar(true, false);
                BottonLeft = Buscar(false, true);
                BottonRight = Buscar(true, true);
                return true;
            }
            return false;
        }
Exemple #26
0
        public float mod()
        {
            PuntoF a = this;

            return((float)Math.Sqrt(a.x * a.x + a.y * a.y));
        }
Exemple #27
0
 public static PuntoF operator /(PuntoF a, float f)
 {
     PuntoF p = new PuntoF();
     p.x = a.x/f;
     p.y = a.y/f;
     return p;
 }