How to convert my binary (hex) data to latitude and longitude?

前端 未结 3 799
伪装坚强ぢ
伪装坚强ぢ 2021-01-06 01:41

I have some binary data stream which passes geo location coordinates - latitude and longitude. I need to find the method they are encoded.

4adac812 = 74°26.2         


        
相关标签:
3条回答
  • 2021-01-06 02:34

    Brainstorming here.

    If we look at the lower 6 bits of the second byte (data[1]&0x3f) we get the "minutes" value for most of the examples.

    0xda & 0x3f = 0x1a = 26; // ok
    0x60 & 0x3f = 0; // ok
    0xe8 & 0x3f = 0x28 = 40; // ok
    0x3c & 0x3f = 0x3c = 60; // should be 56
    0xfd & 0x3f = 0x3d = 61; // should be 59
    

    Perhaps this is the right direction?

    0 讨论(0)
  • 2021-01-06 02:44

    I have reordered your data so that we first have 3 longitures and then 3 latitudes:

    74.438085, 74.438338, 74.669105, 43.004605, 42.938628, 42.993772

    This is the best fit of the hexadecimals i can come up with is:

    74.437368, 74.439881, 74.668392, 42.993224, 42.961388, 42.982391

    The differences are: -0.000717, 0.001543, -0.000713, -0.011381, 0.022760, -0.011381

    The program that generates these values from the complete Hex'es (4 not 3 bytes) is:

    int main(int argc, char** argv) {
        int a[] = { 0x4adac812, 0x4adaee12, 0x4ae86d11, 0x2b6059f9, 0x2a3c8df9, 0x2afd0efb };
        int i = 0;
        while(i<3) {
            double b = (double)a[i] / (2<<(3*8)) * 8.668993 -250.0197;
            printf("%f\n",b);
            i++;
        }
        while(i<6) {
            double b = (double)a[i] / (2<<(3*8)) *  0.05586007 +41.78172;
            printf("%f\n",b);
        i++;
        }
        printf("press key");
        getch();
    }
    
    0 讨论(0)
  • 2021-01-06 02:48

    I have tried your new data packets:

    74+40.1463/60 74+26.3003/60 74+26.2851/60 42+56.3177/60 43+0.2763/60 42+59.6263/60

    74.66910, 74.43834, 74.43809, 42.93863, 43.00460, 42.99377
    

    My program gives:

    74.668392, 74.439881, 74.437368, 42.961388, 42.993224, 39.407346
    

    The differences are:

    -0.000708,  0.001541,  -0.000722,  0.022758, -0.011376, -3.586424
    

    I re-used the 4 constants i derived from your first packet as those are probably stored in your client somewhere. The slight differences might be the result of some randomization the client does to prevent you from getting the exact value or reverse-engineering their protocol.

    0 讨论(0)
提交回复
热议问题