89 lines
2.7 KiB
PHP
89 lines
2.7 KiB
PHP
<?php
|
|
// Connecting, selecting database
|
|
|
|
$dbconn = pg_connect("host=localhost dbname=nws user=nws password=nws")
|
|
or die('Could not connect: ' . pg_last_error());
|
|
|
|
|
|
//select camid,url,description from cams where cwa = 'RLX' and method = 'rtsp' and active = true AND (EXTRACT(EPOCH FROM (current_timestamp - lastsuccess ))/60) < (interval + 20) and lat > %s and lat < %s and lon > %s and lon < %s order by lastsuccess desc limit 25
|
|
|
|
|
|
//no gets, curent point outage info
|
|
|
|
//error_reporting(-1); // reports all errors
|
|
//ini_set("display_errors", "1"); // shows all errors
|
|
//ini_set("log_errors", 1);
|
|
//ini_set("error_log", "php-error.log");
|
|
|
|
|
|
|
|
|
|
|
|
if($_GET['camstatic']) {
|
|
if ($_GET['camstatic'] == 'radius') {
|
|
|
|
|
|
if($_GET['lat1']) {
|
|
$lat1 = pg_escape_string($_GET['lat1']);
|
|
if($_GET['lon1']) {
|
|
$lon1 = pg_escape_string($_GET['lon1']);
|
|
if($_GET['radius']) {
|
|
$radius = pg_escape_string($_GET['radius']);
|
|
$rad = $radius / 70;
|
|
|
|
$lat1 = floatval($lat1);
|
|
$lon1 = floatval($lon1);
|
|
$radius = floatval($rad);
|
|
$query = "select * from cams where active = true and cwa = 'RLX' and (EXTRACT(EPOCH FROM (current_timestamp - lastsuccess ))/60) < (interval + 20) and st_dwithin(geom, ST_SetSRID(ST_Point(" . strval($lon1) . ", " . strval($lat1) . "), 4326)," . strval($radius) . ") order by elevation desc";
|
|
$result = pg_query($dbconn,$query) or die('Query failed: ' . pg_last_error());
|
|
|
|
while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
|
|
$array[] = $line;
|
|
}
|
|
echo json_encode($array);
|
|
pg_free_result($result);
|
|
pg_close($dbconn);
|
|
}}}}}
|
|
|
|
if($_GET['camstatic']) {
|
|
if ($_GET['camstatic'] == 'bbox') {
|
|
if($_GET['lat1']) {
|
|
$lat1 = pg_escape_string($_GET['lat1']);
|
|
if($_GET['lon1']) {
|
|
$lon1 = pg_escape_string($_GET['lon1']);
|
|
if($_GET['lat2']) {
|
|
$lat2 = pg_escape_string($_GET['lat2']);
|
|
if($_GET['lon2']) {
|
|
$lon2 = pg_escape_string($_GET['lon2']);
|
|
if($_GET['elevbottom']) {
|
|
$elevbottom = pg_escape_string($_GET['elevbottom']);
|
|
if($_GET['elevtop']) {
|
|
$elevtop = pg_escape_string($_GET['elevtop']);
|
|
|
|
//$lat1 = floatval($lat1);
|
|
//$lon1 = floatval($lon1);
|
|
//$lat2 = floatval($lat2);
|
|
//$lon2 = floatval($lon2);
|
|
//$elevbottom = floatval($elevbottom);
|
|
//$elevtop = floatval($elevtop);
|
|
//echo($lat1,$lat2,$lon1,$lon2,$elevbottom,$elevtop);
|
|
$result = pg_query_params($dbconn,
|
|
"select * from cams where active = true and cwa = 'RLX' and elevation > $5 and elevation < $6 and (EXTRACT(EPOCH FROM (current_timestamp - lastsuccess ))/60) < (interval + 20) and lat < $1 and lat > $2 and lon < $3 and lon > $4 order by elevation desc",
|
|
array($lat1,$lat2,$lon1,$lon2,$elevbottom,$elevtop)) or die('Query failed: ' . pg_last_error());
|
|
while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
|
|
$array[] = $line;
|
|
}
|
|
echo json_encode($array);
|
|
pg_free_result($result);
|
|
pg_close($dbconn);
|
|
}}}}}}}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|