Alejandro Acuña
2024-11-19 72a8eee716de93344f977ab79be7d3bfeb341462
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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);
        }
 
    }
    
}