54 const long GPSZcount::ZCOUNT_MINUTE = 40;
55 const long GPSZcount::ZCOUNT_HOUR = 2400;
56 const long GPSZcount::ZCOUNT_DAY = 57600;
57 const long GPSZcount::ZCOUNT_WEEK = 403200;
59 GPSZcount::GPSZcount(
short inWeek,
67 catch(gnsstk::InvalidParameter& ip)
73 GPSZcount::GPSZcount(
long inFullZcount)
77 setFullZcount(inFullZcount);
79 catch(gnsstk::InvalidParameter& ip)
94 gnsstk::InvalidParameter ip(
"GPS Week invalid: " +
95 asString<short>(inWeek)) ;
104 if(validZcount(inZcount) != 0)
106 gnsstk::InvalidParameter ip(
"GPS Z-count invalid: " +
107 asString<long>(inZcount));
118 setZcount(inZcount & 0x7FFFFL);
122 setWeek((inZcount >> 19) & 0x3FFL);
125 catch(gnsstk::InvalidParameter& ip)
127 ip.addText(
"GPS Full Z-count invalid: " + asString<long>(inZcount)) ;
142 return setWeek(week + inWeeks);
144 catch(gnsstk::InvalidParameter& ip)
146 gnsstk::InvalidRequest ir(ip) ;
147 ir.addText(
"Addition of " +
asString(inWeeks) +
148 " weeks renders this object invalid.");
160 short originalWeek(week);
161 long originalZcount(zcount);
166 addWeeks(inZcounts / ZCOUNT_WEEK);
169 long tmp = zcount + (inZcounts % ZCOUNT_WEEK);
176 else if (tmp >= ZCOUNT_WEEK)
186 catch(gnsstk::InvalidRequest& ir)
188 setWeek(originalWeek);
189 setZcount(originalZcount);
190 ir.addText(
"Did not add " +
asString(inZcounts) +
" Z-counts.") ;
194 catch(gnsstk::InvalidParameter& ip)
196 setWeek(originalWeek);
197 setZcount(originalZcount);
198 gnsstk::InvalidRequest ir(ip);
199 ir.addText(
"Did not add " +
asString(inZcounts) +
" Z-counts.") ;
213 return addZcounts(1);
225 return addZcounts(-1);
240 return (
double(week) - right.
week) * ZCOUNT_WEEK
241 + (zcount - right.
zcount) ;
244 long GPSZcount::operator%(
const long right)
const
246 return zcount % right;
251 return addZcounts(inZcounts);
256 return addZcounts(-inZcounts);
268 if (week < right.
week)
272 if (week == right.
week &&
282 if (week > right.
week)
286 if (week == right.
week &&
296 if (week == right.
week &&
306 return (!
operator==(right));
309 bool GPSZcount::operator<=(
const GPSZcount& right)
const
311 return (!
operator>(right));
314 bool GPSZcount::operator>=(
const GPSZcount& right)
const
316 return (!
operator<(right));
319 GPSZcount::operator std::string()
const
321 return asString<short>(week) +
"w" + asString<long>(zcount) +
"z";
325 unsigned long inZcountBlock,
326 unsigned long inZcountOffset)
328 if ((
long)inZcountBlock < ZCOUNT_WEEK)
332 if ( (getWeek() == other.
getWeek()) &&
333 (((getZcount() - inZcountOffset) / inZcountBlock) ==
334 ((other.
getZcount() - inZcountOffset) / inZcountBlock)) )
342 if (
long((getTotalZcounts() - inZcountOffset) / inZcountBlock) ==
358 out << week <<
"w" << zcount <<
"z" << flush;
362 out <<
"GPS Full Week: " << setw(6) << week << endl
363 <<
"GPS Z-count: " << setw(6) << zcount << endl;
368 long GPSZcount::validZcount(
long z)
374 if (z >= GPSZcount::ZCOUNT_WEEK)
376 return (z - (GPSZcount::ZCOUNT_WEEK - 1));