sizelatlng.h 3.65 KB
Newer Older
lm's avatar
lm committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
/**
******************************************************************************
*
* @file       sizelatlng.h
* @author     The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief      
* @see        The GNU Public License (GPL) Version 3
* @defgroup   OPMapWidget
* @{
* 
*****************************************************************************/
/* 
* This program is free software; you can redistribute it and/or modify 
* it under the terms of the GNU General Public License as published by 
* the Free Software Foundation; either version 3 of the License, or 
* (at your option) any later version.
* 
* This program is distributed in the hope that it will be useful, but 
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
* for more details.
* 
* You should have received a copy of the GNU General Public License along 
* with this program; if not, write to the Free Software Foundation, Inc., 
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef SIZELATLNG_H
#define SIZELATLNG_H


#include <QString>

 
namespace internals {
struct PointLatLng;
struct SizeLatLng
{
public:
    SizeLatLng();
    static  SizeLatLng Empty;

    SizeLatLng(SizeLatLng const&  size)
    {
       this->widthLng = size.widthLng;
       this->heightLat = size.heightLat;
    }

     SizeLatLng(PointLatLng const&  pt);


     SizeLatLng(double const& heightLat, double const&  widthLng)
    {
       this->heightLat = heightLat;
       this->widthLng = widthLng;
    }

     friend SizeLatLng operator+(SizeLatLng const&  sz1, SizeLatLng const&  sz2);
     friend SizeLatLng operator-(SizeLatLng const&  sz1, SizeLatLng const&  sz2);
     friend bool operator==(SizeLatLng const&  sz1, SizeLatLng const&  sz2);
     friend bool operator!=(SizeLatLng const&  sz1, SizeLatLng const&  sz2);


//     static explicit operator PointLatLng(SizeLatLng size)
//    {
//       return new PointLatLng(size.HeightLat(), size.WidthLng());
//    }


     bool IsEmpty()const
     {
         return ((this->widthLng == 0) && (this->heightLat == 0));
     }

     double WidthLng()const
     {
         return this->widthLng;
     }
     void SetWidthLng(double const& value)
     {
         this->widthLng = value;
     }


     double HeightLat()const
     {
         return this->heightLat;
     }
     void SetHeightLat(double const& value)
     {
         this->heightLat = value;
     }

     static SizeLatLng Add(SizeLatLng const& sz1, SizeLatLng const& sz2)
    {
       return SizeLatLng(sz1.HeightLat() + sz2.HeightLat(), sz1.WidthLng() + sz2.WidthLng());
    }

     static SizeLatLng Subtract(SizeLatLng const& sz1, SizeLatLng const& sz2)
    {
       return SizeLatLng(sz1.HeightLat() - sz2.HeightLat(), sz1.WidthLng() - sz2.WidthLng());
    }

//     override bool Equals(object obj)
//    {
//       if(!(obj is SizeLatLng))
//       {
//          return false;
//       }
//       SizeLatLng ef = (SizeLatLng) obj;
//       return (((ef.WidthLng == this->WidthLng) && (ef.HeightLat == this->HeightLat)) && ef.GetType().Equals(base.GetType()));
//    }

//     override int GetHashCode()
//    {
//       return base.GetHashCode();
//    }

//     PointLatLng ToPointLatLng()
//    {
//       return (PointLatLng) this;
//    }

     QString ToString()
    {
         return ("{WidthLng=" + QString::number(this->widthLng) + ", HeightLng=" + QString::number(this->heightLat) + "}");
    }


private:
    double heightLat;
    double widthLng;
};

}
#endif // SIZELATLNG_H