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 |
|
---|
21 | LONGITUDE::LONGITUDE()
|
---|
22 | {
|
---|
23 | Empty();
|
---|
24 | }
|
---|
25 |
|
---|
26 | LONGITUDE::~LONGITUDE()
|
---|
27 | {
|
---|
28 | Empty();
|
---|
29 | }
|
---|
30 |
|
---|
31 | void LONGITUDE::Empty( void )
|
---|
32 | {
|
---|
33 | Longitude = 0.0;
|
---|
34 | Easting = EW_Unknown;
|
---|
35 | }
|
---|
36 |
|
---|
37 | BOOL LONGITUDE::IsDataValid( void )
|
---|
38 | {
|
---|
39 | if ( Easting != East && Easting != West )
|
---|
40 | {
|
---|
41 | return( FALSE );
|
---|
42 | }
|
---|
43 |
|
---|
44 | return( TRUE );
|
---|
45 | }
|
---|
46 |
|
---|
47 | void 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 |
|
---|
63 | void 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 |
|
---|
82 | void 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 |
|
---|
108 | const LONGITUDE& LONGITUDE::operator = ( const LONGITUDE& source )
|
---|
109 | {
|
---|
110 | Longitude = source.Longitude;
|
---|
111 | Easting = source.Easting;
|
---|
112 |
|
---|
113 | return( *this );
|
---|
114 | }
|
---|