⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 long.cpp

📁 This is a GPS communication source code to interrupt the NMEA code though serial port. Very good
💻 CPP
字号:
#include "nmea0183.h"
#pragma hdrstop

/*
** Author: Samuel R. Blackburn
** Internet: sam_blackburn@pobox.com
**
** You can use it any way you like as long as you don't try to sell it.
**
** Copyright, 1997, Samuel R. Blackburn
**
** $Workfile: long.cpp $
** $Revision: 6 $
** $Modtime: 10/12/98 6:50a $
*/

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#define new DEBUG_NEW
#endif

LONGITUDE::LONGITUDE()
{
   Empty();
}

LONGITUDE::~LONGITUDE()
{
   Empty();
}

void LONGITUDE::Empty( void )
{
   Longitude = 0.0;
   Easting   = EW_Unknown;
}

BOOL LONGITUDE::IsDataValid( void )
{
   if ( Easting != East && Easting != West )
   {
      return( FALSE );
   }

   return( TRUE );
}

void LONGITUDE::Parse( int position_field_number, int east_or_west_field_number, const SENTENCE& sentence )
{
   // Thanks go to Eric Parsonage (ericpa@mpx.com.au) for finding a nasty
   // little bug that used to live here.

   double position = 0.0;

   position = sentence.Double( position_field_number );

   CString east_or_west;

   east_or_west = sentence.Field( east_or_west_field_number );

   Set( position, east_or_west );
}

void LONGITUDE::Set( double position, const char *east_or_west )
{
   ASSERT( east_or_west != NULL );

   Longitude  = position;
   Coordinate = position;

   if ( east_or_west[ 0 ] == 'E' )
   {
      Easting = East;
   }
   else if ( east_or_west[ 0 ] == 'W' )
   {
      Easting = West;
   }
   else
   {
      Easting = EW_Unknown;
   }
}

void LONGITUDE::Write( SENTENCE& sentence )
{
   char temp_string[ 80 ];

   ::sprintf( temp_string, "%08.2f", Longitude );
   sentence += temp_string;
   
   if ( Easting == East )
   {
      sentence += "E";
   }
   else if ( Easting == West )
   {
      sentence += "W";
   }
   else
   {
      /*
      ** Thanks to Jan-Erik Eriksson (Jan-Erik.Eriksson@st.se) for
      ** finding and fixing a bug here
      */

      sentence += "";
   }
}

const LONGITUDE& LONGITUDE::operator = ( const LONGITUDE& source )
{
   Longitude = source.Longitude;
   Easting   = source.Easting;

   return( *this );
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -