toSixFigureString(); $gs = strtolower(substr($str,0,2)); $file = "/var/www/downloads/lfp/$gs/$gs".$str[2].$str[5]. (($n%10000==5000) ? "n":"s") . (($e%10000==5000) ? "e":"w") . ".hgtl"; if(!file_exists($file)) { header("HTTP/1.1 404 Not Found"); echo "Cannot find matching height file ($file)"; } else { header("Content-type: application/json"); $fp=fopen($file,"r"); $json["heights"]=array(); for($h=0; $h<10201; $h++) { $ha=fread($fp,2); $json["heights"][]=ord($ha[0]) + ord($ha[1])*256; } fclose($fp); $json["res"] = 50; // metres $json["box"] = array((int)$e,(int)$n,$e+5000,$n+5000); echo json_encode($json); } ?>