// GeoCoord.cpp: implementation of the GeoCoord class. // //*****************************************************************************| // Vitaly Eremenko // created: 22.07.2001 // updated: 22.07.2001 //*****************************************************************************| ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "GeoCoord.h" #include "ConvGeoCoord.h" #include "GuiMathUtils.h" double GeoCoord::s_rAngleErr = 0.0001; // geo-grad. double GeoCoord::s_rDistErr = 0.1; // meter ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// GeoCoord::GeoCoord() //------------------ { m_rAltitude = 0.; m_rLatitude = 0.; m_rLongitude = 0.; } //=============================================================================| GeoCoord::~GeoCoord() //------------------- { } //=============================================================================| GeoCoord& GeoCoord::operator = (const GeoCoord &i_Geo) //---------------------------------------------------- { if (this == &i_Geo) return *this; m_rAltitude = i_Geo.m_rAltitude; m_rLatitude = i_Geo.m_rLatitude; m_rLongitude = i_Geo.m_rLongitude; return *this; } //=============================================================================| bool GeoCoord::operator == (const GeoCoord &i_Geo) const //---------------------------------------------------- { if (this == &i_Geo) return true; // the same object if (fabs(m_rAltitude - i_Geo.m_rAltitude) > s_rDistErr) return false; if (fabs(m_rLatitude - i_Geo.m_rLatitude) > s_rAngleErr) return false; if (fabs(m_rLongitude - i_Geo.m_rLongitude) > s_rAngleErr) return false; return true; // the same point in max.error radius } //=============================================================================| CString GeoCoord::LatitudeToStr() //------------------------------- { return ConvGeoCoord::S_AngleDegToString(m_rLatitude); } //=============================================================================| CString GeoCoord::LongitudeToStr() //-------------------------------- { return ConvGeoCoord::S_AngleDegToString(m_rLongitude); } //=============================================================================| // inp: i_sDegMinSec - string angle format must be "ddd:mm:ss.ms", // where: // ddd - degree value -360...360; // mm - angle minutes 0...59 // ss.ms - angle seconds with milliseconds (0 ... 59.999999...) void GeoCoord::SetLatitudeFromStr(CString i_sDegMinSec) //----------------------------------------------------- { int nErr = 0; double rLat = ConvGeoCoord::S_StringToAngleDeg(i_sDegMinSec, &nErr); if (nErr >= 0) m_rLatitude = rLat; } //=============================================================================| // inp: i_sDegMinSec - string angle format must be "ddd:mm:ss.ms", // where: // ddd - degree value -360...360; // mm - angle minutes 0...59 // ss.ms - angle seconds with milliseconds (0 ... 59.999999...) void GeoCoord::SetLongitudeFromStr(CString i_sDegMinSec) //----------------------------------------------------- { int nErr = 0; double rLong = ConvGeoCoord::S_StringToAngleDeg(i_sDegMinSec, &nErr); if (nErr >= 0) m_rLongitude = rLong; } //=============================================================================| double GeoCoord::LatitudeToRadian() //--------------------------------- { double rRad = GuiMathUtils::S_DegreeToRadian(m_rLatitude); double rLatRad = GuiMathUtils::S_RadianToAzimuth(rRad); return rLatRad; } //=============================================================================| double GeoCoord::LongitudeToRadian() //---------------------------------- { double rRad = GuiMathUtils::S_DegreeToRadian(m_rLongitude); double rLonRad = GuiMathUtils::S_RadianToAzimuth(rRad); return rLonRad; } //=============================================================================|