示例#1
0
文件: api.php 项目: hozmaster/odopoi
    if (is_numeric($tllon) && -180.0 <= $tllon && $tllon < 180.0 && is_numeric($tllat) && -90.0 <= $tllat && $tllat <= 90.0 && is_numeric($brlon) && -180.0 <= $brlon && $brlon < 180.0 && is_numeric($brlat) && -90.0 <= $brlat && $brlat <= 90.0 && is_numeric($zoom) && $zoom >= 0 && $zoom < 20) {
        $min_lat = $tllat < $brlat ? $tllat : $brlat;
        $max_lat = $tllat > $brlat ? $tllat : $brlat;
        $min_lon = $tllon < $brlon ? $tllon : $brlon;
        $max_lon = $tllon > $brlon ? $tllon : $brlon;
        $key = "poi_" . $min_lat . "_" . $max_lat . "_" . $min_lon . "_" . $max_lon . "_" . $zoom;
        if (strcmp($cache_type, "FileCache") == 0) {
            $cache = new FileCache();
        } else {
            $cache = new NoCache();
        }
        $xml = $cache->get($key);
        if ($xml == FALSE) {
            $db = new MySQLDatabase($hostname, $database, $username, $password);
            $db->connect();
            $poi = new POIManager($db);
            $gpx = $poi->getWpts($min_lat, $max_lat, $min_lon, $max_lon, $zoom);
            $xml = $gpx->toXml();
            $db->disconnect();
            $cache->put($key, $xml);
        }
        header("Content-type: text/xml; charset=utf-8");
        print $xml;
    } else {
        header("Content-type: text/plain; charset=utf-8");
        print "Invalid Input";
    }
} else {
    header("Content-type: text/plain; charset=utf-8");
    print "Unsupported Action";
}