大众点评网坐标转换

function decode($poi) {
 $settings = array(
 'digi'=> 16,
 'add'=> 10,
 'plus'=> 7,
 'cha'=> 36,
 'center'=> array(
 'lat'=> 34.957995,
 'lng'=> 107.050781,
 'isDef'=> true
 )
 );
 $i = -1;
 $h = 0;
 $b = "";
 $j = strlen($poi);
 $g = ord($poi{$j-1});
 $c = substr($poi, 0, $j-1);
 $j--;
 
 for($e=0; $e<$j; $e++) {
 $d = base_convert($c{$e}, $settings['cha'], 10)-$settings['add'];
 if ($d>=$settings['add']) 
 {
 $d = $d- $settings['plus'];
 }
 $b .= base_convert($d, 10, $settings['cha']);
 if ($d>$h) {
 $i = $e;
 $h = $d;
 }
 }
 $a = intval(substr($b, 0, $i), $settings['digi']);
 $f = intval(substr($b, $i+1), $settings['digi']);
 $l = ($a+$f-intval($g))/2;
 $k = ($f-$l)/100000;
 $l /= 100000;
 $lat = $k;
 $lng = $l;
 return array($lng, $lat);
}

你可能感兴趣的:(大众点评网坐标转换)