getMessage(), "\n";
}
}
try {
// $block_count=$argc-1;
// $bns = array(1122);
//$block_count=1;
$bns = explode("_",$_GET["the_block"]);
$block_count=count($bns);
// for ($ind = 0;$ind<$block_count;$ind++)$bns[$ind] = $argv[$ind+1];
for ($ib = 0; $ib < $block_count; $ib++) {
$height_currentdate = get_the_heightanddate($bns[$ib]);
$height[$ib] = $height_currentdate[0];
$current_date[$ib] = $height_currentdate[1];
}
$con = pg_connect("host=$host dbname=$db port=5432 user=$user password=$pass");
if (!$con) {
echo "Could not connect to server\n";
}
$the_clause = 'b.block_number=' . "'" . $bns[0] . "' ";
for ($ib = 1; $ib < $block_count; $ib++) {
$the_clause = $the_clause . 'or b.block_number=' . "'" . $bns[$ib] . "' ";
}
$the_clause = ' (' . $the_clause . ') ';
$query1 = 'SELECT b.block_number, a.building_id, c.value, c.is_valid, d.value, d.is_valid, a.points,e.ge_latitude,e.ge_longitude FROM saintlouisdev.geo_footprints a, saintlouisdev.temporal_objects b, saintlouisdev.vc_dates c, saintlouisdev.vc_dates d,CesiumLatLong e WHERE ' . $the_clause;
$query2 = ' AND a.temporalobject_ptr_id=b.id AND b.start_date_id=c.id AND b.end_date_id=d.id AND e.building_id=a.building_id;';
$query = $query1 . $query2;
$rs = pg_query($con, $query) or die("Cannot execute query: $query\n");
pg_close($con);
$i = 0;
while ($row = pg_fetch_row($rs)) {
// $justpoints=substr($row[6],9);
$tok1 = strtok(substr($row[6], 9), " ");
$tok2 = strtok(" ");
for ($j = 0; $j < 5; $j++) {
$mydata[$i][$j] = $row[$j + 1];
}
$mydata[$i][5] = $tok1;
$mydata[$i][6] = $tok2;
$mydata[$i][7] = $row[7];
$mydata[$i][8] = $row[8];;
$i++;
}
$count = $i;
$con = pg_connect("host=$host dbname=$db port=5432 user=$user password=$pass")
or die("Could not connect to server\n");
$query1 = 'select a.points from geo_blocks a ,temporal_objects b WHERE ';
$query2 = ' and a.temporalobject_ptr_id=b.id';
$query = $query1 . $the_clause . $query2;
//echo $query.'
';
$rs = pg_query($con, $query) or die("Cannot execute query: $query\n");
pg_close($con);
for ($ib = 0; $ib < $block_count; $ib++) {
$row = pg_fetch_row($rs);
$tok1 = strtok(substr($row[0], 9), " ");
$tok2 = strtok(" ");
$output = shell_exec('java toLatLon ' . $tok1 . ' ' . $tok2);
$ind = strrpos($output, ' ');
$lat = substr($output, 0, $ind);
$lon = substr($output, ($ind + 1), -1);
$thecorners[$ib] = $lon . ',' . $lat;
$firstcorner = $thecorners[$ib];
for ($i = 0; $i < 3; $i++) {
$tok1 = strtok(",");
$tok1 = strtok(" ");
$tok2 = strtok(" ");
$output = shell_exec('java toLatLon ' . $tok1 . ' ' . $tok2);
$ind = strrpos($output, ' ');
$lat = substr($output, 0, $ind);
$lon = substr($output, ($ind + 1), -1);
$thecorners[$ib] = $thecorners[$ib] . ',' . $lon . ',' . $lat;
}
$thecorners[$ib] = $thecorners[$ib] . ',' . $firstcorner;
// echo $thecorners[$ib]."\n";
}
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
?>