title: Decoding 4 byte latitude/4 byet longitude of Concox TR06 GPS tracker
body: <p>We have a Concox TG06 GPS tracker. I am receiving data from it via TCP, but I am struggling to decode the latitude and longitude coordinates (in C#). According to the protocol manual, the message from the tracker (terminal) to the server looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/pIdwJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pIdwJ.png" alt="Concox TR06 position protocol"></a></p>
  
  <p>As you can see, the latitude and longitude coordinates are 4 bytes each. Further down, the manual explains how these coordinates are formatted:</p>
  
  <p><strong><em>5.2.1.6 Latitude</strong>
  Four bytes are consumes, defining the latitude value of location data. The range of the value is 0 - 162000000, indicating a range of 0°-90°. The conversion method thereof is as follow:
  Converting the value of latitude and longitude output by GPS module into a decimal based on minute; multiplying the converted decimal by 30000; and converting the multiplied result into hexadecimal. Example: 22º32.7658’=(22X60+32.7658)X30000=40582974, then converted into a hexadecimal number 40582974(Decimal)= 26B3F3E(Hexadecimal) at last the value is 0x02 0x6B 0x3F 0x3E</em></p>
  
  <p>I am REALLY struggling to work this out backwards - i.e. getting from the four bytes (0x02 0x6B 0x3F 0x3E) to the latitude coordinate (not necessarily in degrees and minutes, as I use decimal degrees in my code). Basically I am trying to create a function whose shell looks like this:</p>
  
  <pre><code>private double DecodeLat(byte[] latBytes)
  {
      double latitude;
      // implementation
      return latitude;
  {
  </code></pre>
  
  <p>(And obviously same for longitude). I would greatly appreciate any help at all!</p>
  
  <p>Thank you</p>