RXtoRINEX  V2.1
RXtoRINEX provides tools to collect data from GPS / GNSS receivers in mobile devices, convert them to RINEX or RTK formats, and process RINEX files.
Functions
Utilities.h File Reference
#include <string>
#include <vector>

Go to the source code of this file.

Functions

vector< string > getTokens (string source, char separator)
 
bool isBlank (char *buffer, int n)
 
void formatGPStime (char *buffer, int bufferSize, char *fmtYtoM, char *fmtSec, int week, double tow)
 
void formatLocalTime (char *buffer, int bufferSize, char *fmt)
 
int getGPSweek (int year, int month, int day, int hour, int min, float sec)
 
int getGPSweek (double secs)
 
double getGPStow (int year, int month, int day, int hour, int min, float sec)
 
double getGPStow (double secs)
 
void setWeekTow (int year, int month, int day, int hour, int min, double sec, int &week, double &tow)
 
double getSecsGPSEphe (int year, int month, int day, int hour, int min, float sec)
 
double getSecsGPSEphe (int week, double tow)
 
string strToUpper (string strToConvert)
 
int getTwosComplement (unsigned int number, unsigned int nbits)
 
int getSigned (unsigned int number, int nbits)
 
unsigned int reverseWord (unsigned int wordToReverse, int nBits=32)
 
unsigned int getBits (unsigned int *stream, int bitpos, int len)
 

Detailed Description

Contains definition of routines used in several places.

Copyright 2015 Francisco Cancillo

This file is part of the RXtoRINEX tool.

RXtoRINEX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. RXtoRINEX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

A copy of the GNU General Public License can be found at http://www.gnu.org/licenses/.

Ver. |Date |Reason for change

------------------------------—

V1.0 |2/2015 |First release

V2.0 |2/2016 |Added functions

Function Documentation

void formatGPStime ( char *  buffer,
int  bufferSize,
char *  fmtYtoM,
char *  fmtSec,
int  week,
double  tow 
)

formatGPStime format a GPS time point giving text GPS calendar data using time formats provided.

Parameters
bufferthe text buffer where calendar data are placed
bufferSizeof the text buffer in bytes
fmtYtoMthe format to be used for year, month, day, hour and minute (all int), as per strftime
fmtSecthe format to be used for seconds (a double), as per sprintf
weekthe GPS week from 6/1/1980
towthe GPS time of week, or seconds from the beginning of the week
void formatLocalTime ( char *  buffer,
int  bufferSize,
char *  fmt 
)

formatLocalTime gives text calendar data of local time using the format provided (as per strftime).

Parameters
bufferthe text buffer where calendar data are placed
bufferSizeof the text buffer in bytes
fmtthe format to be used for conversion, as per strftime
double getGPStow ( int  year,
int  month,
int  day,
int  hour,
int  min,
float  sec 
)

getGPStow compute the Time Of Week (seconds from the begeing of week at Sunday 00:00h ) for a given GPS date and time

Parameters
yearof the date
monthof the date
dayof the date
hourof the date
minof the date
secsecond of the date
Returns
the TOW for the given date
double getGPStow ( double  secs)

getGPStow compute the Time Of Week (seconds from the begeing of week at Sunday 00:00h ) for a given instant

Parameters
secsseconds from of the GPS ephemeris (6/1/1980 00:00:0.0)
Returns
the TOW for the given instant
int getGPSweek ( int  year,
int  month,
int  day,
int  hour,
int  min,
float  sec 
)

getGPSweek compute number of weeks from the GPS ephemeris (6/1/1980) to a given GPS date and time

Parameters
yearof the date
monthof the date
dayof the date
hourof the date
minof the date
secsecond of the date
Returns
the weeks from 6/1/1980 to the given date
int getGPSweek ( double  secs)

getGPSweek compute number of weeks from the GPS ephemeris (6/1/1980) to a given instant in seconds

Parameters
secsseconds from of the GPS ephemeris (6/1/1980 00:00:0.0)
Returns
the weeks from 6/1/1980 to the given instant
double getSecsGPSEphe ( int  year,
int  month,
int  day,
int  hour,
int  min,
float  sec 
)

getSecsGPSEphe computes time instant in seconds from the GPS ephemeris (6/1/1980) to a given date and time

Parameters
yearof the date
monthof the date
dayof the date
hourof the date
minof the date
secsecond of the date
Returns
the seconds from 0h of 6/1/1980 to the given date
double getSecsGPSEphe ( int  week,
double  tow 
)

getSecsGPSEphe compute instant in seconds from the GPS ephemeris (6/1/1980) to a given date stated in GPS week and tow

Parameters
weekthe GPS week number (continuous, without roll over)
towthe time of week
Returns
the seconds from 0h of 6/1/1980 to the given date stated in GPS week and tow
int getSigned ( unsigned int  number,
int  nbits 
)

getSigned converts a signed representation from a given number of bits to standard 32 bits signed representation (two's complement). Number is an integer containing a bit stream of nbits length which represents a nbits signed integer, that is:

  • if the most significant bit is 0, the number is positive. Its value in a 32 bits representation is the same.
  • if the most significant bit is 1, the number is negative and must be converted to standard negative number of 32 bits
Parameters
numberthe 32 bits pattern with the number to be interpreted
nbitsthe number of significative bits in the pattern
Returns
the value of the number (its 32 bits representation)
vector<string> getTokens ( string  source,
char  separator 
)

getTokens gets tokens from a string separated by the given separator

Parameters
sourcea string to be split into tokens
separatorthe character used to separate tokens
Returns
a vector of strings containing the extracted tokens
int getTwosComplement ( unsigned int  number,
unsigned int  nbits 
)

getTwosComplement converts a two's complement representation from a given number of bits to 32 bits. Number is an integer containing a bit stream of nbits length which represents a nbits integer in two's complement, that is:

  • if number is in the range 0 to 2^(nbits-1) is positive. Its value in a 32 bits representation is the same.
  • if number is in the range 2^(nbits-1) to 2^(nbits)-1, is negative and must be converted subtracting 2^(nbits)
Parameters
numberthe 32 bits pattern with the number to be interpreted
nbitsthe number of significative bits in the pattern
Returns
the value of the number (its 32 bits representation)
bool isBlank ( char *  buffer,
int  n 
)

isBlank checks if in the given char buffer all chars are blanks

Parameters
bufferthe array of chars to check
nthe length to check
Returns
true if all n chars are blanks, false otherwise
void setWeekTow ( int  year,
int  month,
int  day,
int  hour,
int  min,
double  sec,
int &  week,
double &  tow 
)

setWeekTow compute GPS week and tow for a given GPS date and time

Parameters
yearof the date
monthof the date
dayof the date
hourof the date
minof the date
secsecond of the date
weekGPS week to be computed
towGPS tow to be computed
string strToUpper ( string  strToConvert)

strToUpper converts the characters in the given string to upper case

Parameters
strToConvertthe string to convert to upper case
Returns
the converted string