google maps - PHP different result when converting CID to LAT -


i have scripts converting cid lat , lac long. in localhost in production server (using same script) give me different result.

result in localhost: cid = 55073 => lat = -6.254678 (true result)

result in production server cid = 55073 => lat = 4288.712618 (incorrect result)

here's script

if(isset($lac) && isset ($cid))      {          $data = "\x00\x0e" .         "\x00\x00\x00\x00\x00\x00\x00\x00" .         "\x00\x00" .         "\x00\x00" .         "\x00\x00" .         "\x1b" .         "\x00\x00\x00\x00" .         "\x00\x00\x00\x00" .         "\x00\x00\x00\x00" .         "\x00\x00" .         "\x00\x00\x00\x00" .         "\x00\x00\x00\x00" .         "\x00\x00\x00\x00" .         "\x00\x00\x00\x00" .         "\xff\xff\xff\xff" .         "\x00\x00\x00\x00";          $is_umts_cell = ($cid > 65535);         if ($is_umts_cell) // gsm: 4 hex digits, utms: 6 hex digits             $data[0x1c] = 5;         else             $data[0x1c] = 3;          $hexlac = substr("00000000" . dechex($lac), -8);         $hexcid = substr("00000000" . dechex($cid), -8);          $data[0x1f] = pack("h*", substr($hexcid, 0, 2));         $data[0x20] = pack("h*", substr($hexcid, 2, 2));         $data[0x21] = pack("h*", substr($hexcid, 4, 2));         $data[0x22] = pack("h*", substr($hexcid, 6, 2));          $data[0x23] = pack("h*", substr($hexlac, 0, 2));         $data[0x24] = pack("h*", substr($hexlac, 2, 2));         $data[0x25] = pack("h*", substr($hexlac, 4, 2));         $data[0x26] = pack("h*", substr($hexlac, 6, 2));          /* used file_get_contents() @ laptop webserver, seems php version          * @ hosting company old , not supporting that.          * hosting company, here we're using curl.          */         $use_curl = true;         if ($use_curl) {             $ch = curl_init();             curl_setopt($ch, curlopt_url, "http://www.google.com/glm/mmap");             curl_setopt($ch, curlopt_header, true);             curl_setopt($ch, curlopt_returntransfer, true);             curl_setopt($ch, curlopt_binarytransfer, 1);             curl_setopt($ch, curlopt_httpheader, array (                 "content-type: application/binary"             ));             curl_setopt($ch, curlopt_postfields, $data);             curl_setopt($ch, curlopt_post, 1);             $response = curl_exec($ch);             if (curl_errno($ch))                 return -1;              $header_size = curl_getinfo($ch, curlinfo_header_size);             $str = substr($response, $header_size);              curl_close($ch);         } else {             $context = array (                 'http' => array (                     'method' => 'post',                     'header' => "content-type: application/binary\r\n" . "content-length: " . strlen($data                 ) . "\r\n",                 'content' => $data             ));             $xcontext = stream_context_create($context);             $str = file_get_contents("http://www.google.com/glm/mmap", false, $xcontext);             echo 'use post'; exit;         }          $opcode1 = ((ord($str[0]) << 8)) | ord($str[1]);         $opcode2 = ord($str[2]);          if (($opcode1 != 0x0e) || ($opcode2 != 0x1b))             return -2;          $retcode = ((ord($str[3]) << 24) | (ord($str[4]) << 16) | (ord($str[5]) << 8) | (ord($str[6])));         if ($retcode != 0)             return -2;          $lat = ((ord($str[7]) << 24) | (ord($str[8]) << 16) | (ord($str[9]) << 8) | (ord($str[10]))) / 1000000;         $lon = ((ord($str[11]) << 24) | (ord($str[12]) << 16) | (ord($str[13]) << 8) | (ord($str[14]))) / 1000000;          // exit script if cannot geocode cell e.g. not on google's database         if ($lat == 0 , $lon == 0)             return -3;          $data = array(            'cellid' => $cid,            'lac' => $lac,            'lat' => $lat,            'lon' => $lon,         );          if($retr)         {             return array (                 "lat" => $lat,                 "lng" => $lon             );         }else{             header('cache-control: no-cache, must-revalidate');             header('content-type: application/json');             echo json_encode(array(                                 'lat' => $lat,                                 'lng' => $lon                             ));         }     }    


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -