BlackKite, Vehicle Tracking System User Manual
Rev. 1.4.0
Zilogic Systems
Page 46
(byte) 0x00,
(byte) 0x99,
(byte) 0xC8,
(byte) 0x04 };
double latitude = getLatitude(bk_coord);
assert latitude == 12.983199;
double longitude = getLongitude(bk_coord);
assert longitude == 80.255232;
}
}
Speed and Direction
• Tag Type: 0x33
• Length: 4 bytes
• Format
– Bytes 0:1 - Speed in km/hr, multiplied by 10, as unsigned integer
– Bytes 2:3 - Direction in degrees, multiplied by 10, as unsigned integer
• Example: For the following values, the speed and direction field is represented as
5C 00
48 08
Sub-field
Value
Representation
Speed
9.2 km/hr
5C 00
Direction
212 degrees
48 08
Java Code to Compute Speed and Direction.
public class BlackKite {
/*
* Convert bytes to int, discarding sign extension.
*/
private static int b2i(byte val) {
return ((int) val) & 0xFF;
}
/*
* Returns speed in km per hour, from tag value corresponding to
* tag type 0x33.
*/
public static double getSpeed(byte[] bytes) {
int speed = (b2i(bytes[1]) << 8) + b2i(bytes[0]);
return speed / 10.0;
}
/*
* Returs heading direction in degrees, from tag value
* corresponding to tag type 0x33.
*/
public static double getDirection(byte[] bytes) {