Example #1
0
    ajaxerr("insufficent parameters");
}
$da = json_decode($data, true);
$mem = new Memcached();
$mem->addServer('localhost', 11211);
$key = md5($data['address']);
switch ($op) {
    case 'get':
        // 查詢結果, 如果沒有設定 memcache, 當作加入 cache 的依據
        list($result, $msg) = geocoder($op, $da);
        if ($result == 0) {
            $mem->set($key, $data['address'], 3600);
            ajaxerr($msg);
        } else {
            ajaxok($msg);
        }
        break;
    case 'set':
        if ($mem->get($key) == $data['address']) {
            list($result, $msg) = geocoder($op, $da);
            if ($result > 0) {
                $mem->delete($key);
                ajaxok($msg);
            } else {
                ajaxerr($msg);
            }
        } else {
            ajaxerr("you can't update cache");
        }
        break;
}
    "version": "3",
    "flag": "0",
    "count": "7",
    "gpx": "1",
    "keepon_id": "270"
*/
$mids = array();
$ret = array("add" => array(), "del" => array(), "all" => array(), "count" => array("add" => 0, "del" => 0));
foreach ($data as $map) {
    if ($map['hide'] == 1) {
        continue;
    }
    if (!in_array($map['mid'], $keys)) {
        $content = sprintf("<a href='%s%s/show.php?mid=%s&info=%s&version=%d' target=_twmap>%s<img src='img/map.gif' title='地圖產生器' border=0/></a>", $site_url, $site_html_root, $map['mid'], urlencode(sprintf("%dx%s-%dx%d", $map['locX'], $map['locY'], $map['shiftX'], $map['shiftY'])), $map['version'], $map['title']);
        if ($map['keepon_id']) {
            $content .= sprintf("<a href='http://www.keepon.com.tw/DocumentHandler.ashx?id=%s' target='_keepon'>%s</a>", $map['keepon_id'], "連結登山補給站");
        }
        $ret['add'][$map['mid']] = array('url' => sprintf('%s%s/api/getkml.php?mid=%d', $site_url, $site_html_root, $map['mid']), 'desc' => $content);
    }
    $ret['all'][] = $map['mid'];
    $mids[] = $map['mid'];
}
foreach ($keys as $key) {
    if (!in_array($key, $mids)) {
        $ret['del'][$key] = 1;
    }
}
$ret['count']['add'] = count($ret['add']);
$ret['count']['del'] = count($ret['del']);
ajaxok($ret);
Example #3
0
<?php

require_once "../config.inc.php";
$twDEM_path = "../db/DEM/twdtm_asterV2_30m.tif";
$loc = $_REQUEST['loc'];
if (empty($loc)) {
    ajaxerr("insufficent parameters");
}
list($lat, $lon) = explode(",", $_REQUEST['loc']);
$ele = get_elev($twDEM_path, $lat, $lon, 1);
$data['elevation'] = $ele;
ajaxok($data);
Example #4
0
if ($r == 0) {
    ajaxerr("empty");
}
$data = get_waypoint($x, $y, $r, $detail);
$trk_data = get_track($x, $y, $r, $detail);
// 整理一下 data
if ($data === false || count($data) == 0 && count($trk_data) == 0) {
    header('Access-Control-Allow-Origin: *');
    ajaxerr("empty result");
}
if (empty($detail) || $detail == 0) {
    // 傳回高度
    $twDEM_path = "../db/DEM/twdtm_asterV2_30m.tif";
    $ele = get_elev($twDEM_path, $y, $x, 1);
    header('Access-Control-Allow-Origin: *');
    ajaxok(array("wpt" => $data, "trk" => $trk_data, "ele" => $ele));
} else {
    // web page
    echo "<html>";
    echo "<head><title>TWMAP waypoint detail</title><meta charset=\"UTF-8\">";
    echo "<script src='https://code.jquery.com/jquery-2.1.4.min.js'></script>";
    echo "<style>\n\t<script src='https://code.jquery.com/jquery-2.1.4.min.js'></script>\n\t/* Document level adjustments */\nhtml {\n  font-size: 17px;\n}\n@media (max-width: 900px) {\n  html,table { font-size: 15px; }\n}\n@media (max-width: 400px) {\n  html,table { font-size: 13px; }\n}\n\ntable, td, th {\n    border: 1px solid green;\n}\n\nth {\n    background-color: green;\n    color: white;\n}\n\n</style></head>";
    echo "<body><div id='wpt_info' align=center>";
    echo "<hr>以下 GPS 航跡皆為山友無私貢獻分享,請大家上山前做好準備,快樂出門,平安回家!";
    echo "<br>距座標點" . $_REQUEST['r'] . "M 的範圍的航點資訊";
    echo "<table>";
    echo "<tr><th width=30%>名稱<th>高度(M)<th>顯示<th>下載<th>地圖";
    $ans = array();
    foreach ($data as $row) {
        if (isset($ans[$row['name']][$row['ele']]) && $ans[$row['name']][$row['ele']][0] == $row['title']) {
            $row['dup'] = 1;