|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcourselog.gpsutils.Converters
public class Converters
Utility routines to convert values, either from NMEA, either from numeric to strings. Try to reduce memory allocation as much as possible. Try to be fast.
Field Summary | |
---|---|
static int |
classCurrentFormat
Flag indicating the format for converting speeds and distances. |
static int |
DDMMSS_LAT
Convert angle to a latitude string (N/S). |
static int |
DDMMSS_LON
Convert angle to a longitude string (E/W). |
static int |
FORMAT_KM_M
Option specifying units in (km/h, m). |
static int |
FORMAT_KT_NM
Option specifying units in (Kt, Nm). |
static double |
KILOMETERSPERNAUTICMILES
Number of kilometers per nautic miles |
Constructor Summary | |
---|---|
Converters()
|
Method Summary | |
---|---|
static java.lang.String |
ddmmss(double ang,
int flgLatLon)
Convert an angle into a new String. |
static java.lang.String |
formatAltitude(double alt)
Convert an altitude in meters into a new String. |
static java.lang.String |
formatDistance(double len)
Format a distance value in meters into a string. |
static java.lang.String |
formatDuration(double dur)
Provides a new String indicating a duration in seconds. |
static java.lang.String |
formatHeading(double hdg)
Formats a heading into a new String. |
static java.lang.String |
formatSpeed(double spd)
Format a speed in km/h. |
static java.lang.String |
formatUTC(double utc)
Generate a new String from a double values expressed with hhmmss.ssss value into a string HH:MM:SS |
static void |
intToHexBytes(int val,
byte[] charChk,
int idxChk,
int len)
Convert an int into an hexadecimal serie of char into a buffer. |
static double |
nMEA2Deg(double nMEAVal)
Change a double value of latitude or longitude parsed from NMEA sentence into a decimal degree value. |
static void |
parseCSVSentence(java.lang.String code,
byte[] b,
int idxS,
int iEnd,
double[] tVal,
int[] tInt,
char[] tChar)
General parser of a CSV sentence. |
static int |
readIntFromBuffer(byte[] b,
int start,
int stop)
Reads an int value from buffer b. |
static int |
valByteHex(byte[] charChk,
int idxChk,
int len)
Convert hexadecimal value of length len, starting at idxChk in buffer charChk. |
static int |
writeDblInBuffer(byte[] b,
int start,
int len,
int dec,
double val)
Write a double value val into buffer b. |
static int |
writeIntInBuffer(byte[] b,
int start,
int len,
int val)
Write an int value val into buffer b. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final double KILOMETERSPERNAUTICMILES
public static final int DDMMSS_LAT
ddmmss(double,int)
,
Constant Field Valuespublic static final int DDMMSS_LON
ddmmss(double,int)
,
Constant Field Valuespublic static final int FORMAT_KM_M
public static final int FORMAT_KT_NM
public static int classCurrentFormat
Constructor Detail |
---|
public Converters()
Method Detail |
---|
public static int valByteHex(byte[] charChk, int idxChk, int len)
charChk
- Buffer containing the hexadecimal value.idxChk
- Index of first character in the buffer.len
- Length of the value to convert.
public static void intToHexBytes(int val, byte[] charChk, int idxChk, int len)
val
- Value to convert.charChk
- Buffer to put the hex characters in.idxChk
- Starting index where to put the Hex characters.len
- Length of the hex string to produce.public static double nMEA2Deg(double nMEAVal)
nMEAVal
- Degrees value from NMEA format.
public static java.lang.String ddmmss(double ang, int flgLatLon)
DD°MM'SS"X
where X depends
on the value of flag flgLatLon (latitude, longitude).
ang
- Angle values in decimal degrees.flgLatLon
- Flag indicating wether its a latitude or a longitude.
DDMMSS_LAT
public static java.lang.String formatUTC(double utc)
hhmmss.ssss
value into a string HH:MM:SS
utc
- Time value obtained from NMEA.
public static java.lang.String formatDuration(double dur)
dur
- Duration value in seconds.
public static java.lang.String formatAltitude(double alt)
alt
- Altitude value in degrees.
public static java.lang.String formatHeading(double hdg)
hdg
- Heading value in degrees.
public static java.lang.String formatDistance(double len)
len
- Distance to format in meters.
public static java.lang.String formatSpeed(double spd)
spd
- Speed value in km/h.
public static int writeIntInBuffer(byte[] b, int start, int len, int val)
b
- Buffer to put value in.start
- Start index in buffer (sign or blank).len
- Length (number of digits excluding sign).val
- Value to put in the buffer.
public static int readIntFromBuffer(byte[] b, int start, int stop)
b
- Buffer to put value in.start
- Start index in buffer (sign or blank).stop
- Index of the position where conversion stops.
public static int writeDblInBuffer(byte[] b, int start, int len, int dec, double val)
b
- Buffer to put value in.start
- Start index in buffer (sign or blank).len
- Total length excluding the leading sign or blank.dec
- Number of decimals.val
- Double value to format.
public static void parseCSVSentence(java.lang.String code, byte[] b, int idxS, int iEnd, double[] tVal, int[] tInt, char[] tChar)
'V' means a double. 'C' means a single char. 'I' means an integer.
Example : code of NMEA GGA sentence is "VVCVCIIVVCVCVI". 2 first values are double (UTC and lat), then comes 'N' or 'S' indicator, then longitude with 'W' or 'E' then status as int, then number of satellites. tVal[0]=UTC, tVal[1]=Lat, tVal[2]=lon, ... tInt[0]=status, tInt[1]=nb sats, tChar[0]='N' or 'S', tChar[1]='W' or 'E', ...
code
- Sequence if identifier to decode the sentenceb
- Buffer containing dataidxS
- Start of relevant data.iEnd
- End of relevant data.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |