zoukankan      html  css  js  c++  java
  • 解密经纬度数据(火星坐标)

    //解密后的经纬度数据(火星坐标)

    public function decode_poi($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;
    $lon = $l;

    return array($lon, $lat);
    }





  • 相关阅读:
    函数进阶-生成器
    函数进阶-列表生成式
    闭包
    命名空间
    内置方法
    函数
    squid清除缓存
    subprocess实现管道
    Python统计脚本行数(fileinput)
    fabric note
  • 原文地址:https://www.cnblogs.com/huqiang/p/6825584.html
Copyright © 2011-2022 走看看