package art.servers.fleetserver.radio.sepura;
|
|
import art.library.model.devices.vehicle.VehiclePosition;
|
import art.servers.fleetserver.Shared;
|
|
|
public class MOD_10_1147
|
{
|
|
|
/**
|
* MOD-10-1147. 7.4.1 Proprietary Format Minimal Compact Full Location Report
|
* Provides time within the current hour, position, and position uncertainty.
|
*/
|
|
|
public static VehiclePosition proprietaryFormatMinimalCompactFullLocationReport(String data) throws Exception
|
{
|
try
|
{
|
BinaryStreamASCII stream = new BinaryStreamASCII(data);
|
|
int protocoloIdentifier = (int)stream.readLong(8);
|
int gpsCodingScheme = (int)stream.readLong(8);
|
|
if ((protocoloIdentifier == 0x03) && (gpsCodingScheme == 0x80))
|
{
|
int gpsTimeWithinHour = (int)stream.readLong(12);
|
long latitude = stream.readLong(24);
|
long longitude = stream.readLong(24);
|
int locationUncertanly = (int)stream.readLong(4);
|
int additionLocationInformation = (int)stream.readLong(1);
|
|
VehiclePosition position = new VehiclePosition();
|
position.timestamp = System.currentTimeMillis();
|
position.latitude = ((double)latitude * 180.0) / Math.pow(2.0,24.0);
|
position.longitude = ((double)longitude * 360.0) / Math.pow(2.0,24.0);
|
|
switch (locationUncertanly)
|
{
|
case 0: position.accuracy = 1; break;
|
case 1: position.accuracy = 2; break;
|
case 2: position.accuracy = 4; break;
|
case 3: position.accuracy = 10; break;
|
case 4: position.accuracy = 22; break;
|
case 5: position.accuracy = 50; break;
|
case 6: position.accuracy = 103; break;
|
case 7: position.accuracy = 224; break;
|
case 8: position.accuracy = 484; break;
|
case 9: position.accuracy = 1049; break;
|
case 10: position.accuracy = 2272; break;
|
case 11: position.accuracy = 4921; break;
|
case 12: position.accuracy = 10658; break;
|
case 13: position.accuracy = 23085; break;
|
case 14: position.accuracy = 50000; break;
|
case 15: position.accuracy = 0; break;
|
default : position.accuracy = 0; break;
|
}
|
|
return position;
|
}
|
|
throw new Exception(Shared.configuration.getMessage("Analysing error"));
|
|
}
|
catch (Exception e)
|
{
|
String message = Shared.configuration.getMessage("Proprietary format minimal compact full location report");
|
message = message + ", " + e.getMessage();
|
throw new Exception(message);
|
}
|
|
}
|
|
}
|