source: pacpussensors/trunk/NMEA0183/src/LONG.cpp@ 80

Last change on this file since 80 was 59, checked in by DHERBOMEZ Gérald, 10 years ago

Integration of new modules:

  • GPS NMEA0183 decoder
  • Span CPT Decoder

Update of:

File size: 2.1 KB
RevLine 
[59]1#include "nmea0183.h"
2#pragma hdrstop
3
4/*
5** Author: Samuel R. Blackburn
6** Internet: sam_blackburn@pobox.com
7**
8** You can use it any way you like as long as you don't try to sell it.
9**
10** Copyright, 1997, Samuel R. Blackburn
11**
12** $Workfile: long.cpp $
13** $Revision: 6 $
14** $Modtime: 10/12/98 6:50a $
15*/
16
17#ifdef _MSC_VER
18# pragma warning(disable:4996)
19#endif // _MSC_VER
20
21LONGITUDE::LONGITUDE()
22{
23 Empty();
24}
25
26LONGITUDE::~LONGITUDE()
27{
28 Empty();
29}
30
31void LONGITUDE::Empty( void )
32{
33 Longitude = 0.0;
34 Easting = EW_Unknown;
35}
36
37BOOL LONGITUDE::IsDataValid( void )
38{
39 if ( Easting != East && Easting != West )
40 {
41 return( FALSE );
42 }
43
44 return( TRUE );
45}
46
47void LONGITUDE::Parse( int position_field_number, int east_or_west_field_number, const SENTENCE& sentence )
48{
49 // Thanks go to Eric Parsonage (ericpa@mpx.com.au) for finding a nasty
50 // little bug that used to live here.
51
52 double position = 0.0;
53
54 position = sentence.Double( position_field_number );
55
56 QString east_or_west;
57
58 east_or_west = sentence.Field( east_or_west_field_number );
59
60 Set( position, east_or_west.toLatin1() );
61}
62
63void LONGITUDE::Set( double position, const char *east_or_west )
64{
65 Longitude = position;
66 Coordinate = position;
67
68 if ( east_or_west[ 0 ] == 'E' )
69 {
70 Easting = East;
71 }
72 else if ( east_or_west[ 0 ] == 'W' )
73 {
74 Easting = West;
75 }
76 else
77 {
78 Easting = EW_Unknown;
79 }
80}
81
82void LONGITUDE::Write( SENTENCE& sentence )
83{
84 char temp_string[ 80 ];
85
86 ::sprintf( temp_string, "%08.2f", Longitude );
87 sentence += temp_string;
88
89 if ( Easting == East )
90 {
91 sentence += "E";
92 }
93 else if ( Easting == West )
94 {
95 sentence += "W";
96 }
97 else
98 {
99 /*
100 ** Thanks to Jan-Erik Eriksson (Jan-Erik.Eriksson@st.se) for
101 ** finding and fixing a bug here
102 */
103
104 sentence += "";
105 }
106}
107
108const LONGITUDE& LONGITUDE::operator = ( const LONGITUDE& source )
109{
110 Longitude = source.Longitude;
111 Easting = source.Easting;
112
113 return( *this );
114}
Note: See TracBrowser for help on using the repository browser.