# ties all these subroutines together.
sub PrintForm {
&setVariables;
$pagetitle = "Station Comparison Page";
&printHtmlHeader; # printhtml.pl
&printJavaScript; # printhtml.pl
&printImageMap; # printhtml.pl
&printLeftColumn; # printhtml.pl
&printLeftColumnLinks; # printhtml.pl
&PrintTopGraph;
&PrintBottomGraph;
&printHtmlFooter; # printhtml.pl
}
sub PrintTopGraph {
print "Station $station: $stationname
";
print "";
print "$stationtitle
";
&PrintTopScatterplotLink;
&PrintTopNotepadLink;
print "\n";
$locale = "top";
# DecideAsssignmentHeader Prints the display text that says what is
# affected or if $changed how it was affected
DecideAsssignmentHeader("top"); # generalinfo.pl
if (($station != '7') && ($station != '0')){
# DecideImproveOrRetract evaluates $changed and prints
# either the improve or retract link.
DecideImproveOrRetract("top"); # printdisplay.pl
}
# PrintGraphLocation sets values for the fortran program
# it builds $orderforplot and calls GenerateGraph, (in callprogs.pl)
# prints the graphic HTML tag and then the links to the data files
PrintGraphLocation("top"); # printdisplay.pl
# CanImprovementsBeMade evaluates whether or not station 7 is still
# able to be improved. It then prints a little message on 7 that
# improvements can still be made
CanImprovementsBeMade("top"); # printdisplay.pl
$locale = 0;
}
sub PrintBottomGraph {
$changed = 0;
# HasImprovementBeenMade sets $changed to 1 if changed
HasImprovementBeenMade($bottomstation);
$locale = "bottom";
PrintGraphLocation("bottom");
DecideAsssignmentHeader("bottom"); # generalinfo.pl
if (($bottomstation != '7') && ($bottomstation != '0')){
DecideImproveOrRetract("bottom");
}
CanImprovementsBeMade("bottom");
$locale = 0;
}
# we are done printing to the screen
sub DecideImproveOrRetract {
if ($changed == 0){
# we need to print implement best management link
print "Implement Improvement: ";
if ("@_" eq "top"){
print "$topimprov";
}
elsif ("@_" eq "bottom"){
print "$bottomimprov";
}
}
elsif ($changed == 1){
# we need to print retract best management link
print "Retract Improvement: ";
if ("@_" eq "top"){
print "$topimprov
";
}
elsif ("@_" eq "bottom"){
print "$bottomimprov
";
}
}
}
sub PrintGraphLocation {
if ("@_" eq "top"){
# analyzes $topgraph and sets a numeric value to $parameter
&SetTopParameter;
# initalize variables for GenerateGraph
$orderforplot = '';
$aa = 0;
$skip = 0;
# Assemble string to go on line 4 of the file that the
# fortran program reads. Honk if you like "the grassy knoll".
while ($aa < 6){
if ("$order[$aa]"){
$orderforplot = ("$orderforplot" . "$order[$aa]");
$skip++;
}
else {
$orderforplot = ("$orderforplot" . "0");
}
$aa++;
}
$start = $topfrom;
$end = $topto;
$range = $topyrange;
$rangeto = $topyrangeto;
if ($skip == 6){$changed = 1;}
$region = $station;
$pid = $$;
# $topgraphic is the name of the outputted gif
$topgraphic = GenerateGraph(); # callprogs.pl
print "
\n";
print "
\n";
print "\n";
print "\n";
&PrintTopGifTag;
print " | | \n";
print "";
print " User \n";
print "$user \n";
if ($values1[1]){
print " \n";
print "Minimum Value \n";
print "$values1[1] \n";
print "Maximum Value \n";
print "$values1[2] \n";
print "Average Value \n";
print "$values1[3] \n";
print "Total Load \n";
print "$values1[4] \n";
print " \n";
if (($changed == 1) && ($values1[1])){
if ($improved_7 eq "print_one_line"){;}
else{
print "Minimum Value \n";
print "$values2[1] \n";
print "Maximum Value \n";
print "$values2[2] \n";
print "Average Value \n";
print "$values2[3] \n";
print "Total Load \n";
print "$values2[4] \n";
}
}
print "\n";
}
print " \n";
print " |
\n";
print "
\n
\n";
&PrintTopLinkToDatafiles;
print "\n";
}
elsif ("@_" eq "bottom"){
# define variables for GenerateGraph
# $changed, @_,
#$orderforplot = ;
if ($bottomgraph eq "nitrogen"){ $parameter = '1';}
elsif ($bottomgraph eq "phosphorus"){ $parameter = '2';}
elsif ($bottomgraph eq "sediments"){ $parameter = '3';}
elsif ($bottomgraph eq "heavymetal"){ $parameter = '4';}
elsif ($bottomgraph eq "toxins"){ $parameter = '5';}
elsif ($bottomgraph eq "watertemp"){ $parameter = '6';}
elsif ($bottomgraph eq "precip"){ $parameter = '12';}
elsif ($bottomgraph eq "temperature"){ $parameter = '11';}
elsif ($bottomgraph eq "ph"){ $parameter = '7';}
elsif ($bottomgraph eq "do"){ $parameter = '8';}
elsif ($bottomgraph eq "bod"){ $parameter = '9';}
elsif ($bottomgraph eq "saturateddo"){ $parameter = '10';}
elsif ($bottomgraph eq "runoff"){ $parameter = '13';}
elsif ($bottomgraph eq "totalflow"){ $parameter = '14';}
elsif ($bottomgraph eq "groundwater"){ $parameter = '15';}
$region = $bottomstation;
$skip =0;
$orderforplot = '';
$aa = 0;
while ($aa < 6){
if ("$order[$aa]"){
$orderforplot = ("$orderforplot" . "$order[$aa]");
$skip++;
}
else {
$orderforplot = ("$orderforplot" . "0");
}
$aa++;
}
$start = $botfrom;
$end = $botto;
$range = $botyrange;
$rangeto = $botyrangeto;
if ($skip == 6){$changed = 1;}
$pid = ($$ + 1);
$bottomgraphic = GenerateGraph();
if ($bottomgraphic){
# print "
\n";
print "
\n";
print "Station $bottomstation: $bottomstationname
";
print "";
print "$bottomstationtitle
";
print "
\n";
print "\n";
print "\n";
print "![](\"$justthedomain/$tmpgif/$bottomgraphic\")
\n";
print " | | \n";
print "";
print " User \n";
print "$user \n";
if ($values1[1]){
print " \n";
print "Minimum Value \n";
print "$values1[1] \n";
print "Maximum Value \n";
print "$values1[2] \n";
print "Average Value \n";
print "$values1[3] \n";
print "Total Load \n";
print "$values1[4] \n";
print " \n";
if (($changed == 1) && ($values2[1])){
if ($improved_7 eq "print_one_line"){;}
else{
print "Minimum Value \n";
print "$values2[1] \n";
print "Maximum Value \n";
print "$values2[2] \n";
print "Average Value \n";
print "$values2[3] \n";
print "Total Load \n";
print "$values2[4] \n";
}
}
print "\n";
}
print " \n";
print " |
\n";
print "
\n
\n";
if ($changed == 0){
print "View pre-implementation Data
\n";
}
elsif ($changed == 1){
print "View pre-implementation Data\n";
if ($improved_7 eq "print_one_line"){;}
else{
print " | View post-implementation Data
\n";
}
}
#print " Notepad
";
print "\n";
}
else {
print "
\n";
print "\n";
print "Unable to create Graphic for Parameter: $error\n";
}
}
}
sub CanImprovementsBeMade {
if ("@_" eq "top"){
$noprinttwice = "no";
if (($station eq '7') && ($done eq "no")){
print <<"HTML";
Improvements can still be made to the watershed.
To display changed water conditions for Station 7,
Improve all of the stations.
HTML
$noprinttwice = "yes";
}
}
elsif ("@_" eq "bottom"){
if (($bottomstation eq '7') && ($done eq "no") && ($noprinttwice eq "no")){
print <<"HTML";
Improvements can still be made to the watershed.
To display changed water conditions for Station 7,
Improve all of the stations.
HTML
}
}
}
sub setVariables{
# calling from improve
if ($method eq "query"){
$topyrange = $query{'topyrange'};
$topyrangeto = $query{'topyrangeto'};
$botyrange = $query{'botyrange'};
$botyrangeto = $query{'botyrangeto'};
$user = $query{'user'};
$station = $query{'topstation'};
$topgraph = $query{'topgraph'};
$bottomstation = $query{'bottomstation'};
$bottomgraph = $query{'bottomoption'};
$topfrom = $query{'topfrom'};
$topto = $query{'topto'};
$botfrom = $query{'botfrom'};
$botto = $query{'botto'};
$date = `date`; chomp ($date);
print LOGFILE "\n\n\n$user viewed graph page from bmp at $date";
}
# calling from map link
if ($method eq "map"){
$topyrange = $query{'topyrange'};
$topyrangeto = $query{'topyrangeto'};
$botyrange = $query{'botyrange'};
$botyrangeto = $query{'botyrangeto'};
$user = $query{'user'};
$station = $query{'map'};
$topgraph = "nitrogen";
$bottomstation = $query{'map'};
$bottomgraph = "precip";
$topfrom = $query{'topfrom'};
$topto = $query{'topto'};
$botfrom = $query{'botfrom'};
$botto = $query{'botto'};
$date = `date`; chomp ($date);
print LOGFILE "\n\n\n$user viewed graph page from map at $date";
}
# calling from submit on form
elsif ($method eq "form"){
$topyrange = $form{'topyrange'};
$topyrangeto = $form{'topyrangeto'};
$botyrange = $form{'botyrange'};
$botyrangeto = $form{'botyrangeto'};
$user = $form{'user'};
$station = $form{'topstation'};
$topgraph = $form{'topgraph'};
$bottomstation = $form{'bottomstation'};
$bottomgraph = $form{'bottomoption'};
$topfrom = $form{'topfrom'};
$topto = $form{'topto'};
$botfrom = $form{'botfrom'};
$botto = $form{'botto'};
$date = `date`; chomp ($date);
print LOGFILE "\n\n\n$user viewed graph page from form at $date";
}
if ($topgraph eq 'nitrogen'){
$stationtitle = "Nitrogen Concentration (Mg/L)";
}
elsif ($topgraph eq 'phosphorus'){
$stationtitle = "Phosphorus (Mg/L)";
}
elsif ($topgraph eq 'sediments'){
$stationtitle = "Sediments (Mg/L)";
}
elsif ($topgraph eq 'heavymetal'){
$stationtitle = "Heavy Metal (Mg/L)";
}
elsif ($topgraph eq 'toxins'){
$stationtitle = "Toxins (Mg/L)";
}
elsif ($topgraph eq 'watertemp'){
$stationtitle = "Water Temperature (Degrees Celsius)";
}
elsif ($topgraph eq 'temperature'){
$stationtitle = "Air Temperature (Degrees Celsius)";
}
elsif ($topgraph eq 'precip'){
$stationtitle = "Precipitation (Inches)";
}
elsif ($topgraph eq 'ph'){
$stationtitle = "pH";
}
elsif ($topgraph eq 'do'){
$stationtitle = "Dissolved Oxygen (Mg/L)";
}
elsif ($topgraph eq 'bod'){
$stationtitle = "BOD (Mg/L)";
}
elsif ($topgraph eq 'saturateddo'){
$stationtitle = "Saturated DO (Mg/L)";
}
elsif ($topgraph eq 'runoff'){
$stationtitle = "Runoff (Meters Cubed)";
}
elsif ($topgraph eq 'totalflow'){
$stationtitle = "Total Flow (Meters Cubed)";
}
elsif ($topgraph eq 'groundwater'){
$stationtitle = "Groundwater (Meters Cubed)";
}
if ($bottomgraph eq 'nitrogen'){
$bottomstationtitle = "Nitrogen Concentration (mg/L)";
}
elsif ($bottomgraph eq 'phosphorus'){
$bottomstationtitle = "Phosphorus (Mg/L)";
}
elsif ($bottomgraph eq 'sediments'){
$bottomstationtitle = "Sediments (Mg/L)";
}
elsif ($bottomgraph eq 'heavymetal'){
$bottomstationtitle = "Heavy Metal (Mg/L)";
}
elsif ($bottomgraph eq 'toxins'){
$bottomstationtitle = "Toxins (Mg/L)";
}
elsif ($bottomgraph eq 'watertemp'){
$bottomstationtitle = "Water Temperature (Degrees Celsius)";
}
elsif ($bottomgraph eq 'temperature'){
$bottomstationtitle = "Air Temperature (Degrees Celsius)";
}
elsif ($bottomgraph eq 'precip'){
$bottomstationtitle = "Precipitation (Inches)";
}
elsif ($bottomgraph eq 'ph'){
$bottomstationtitle = "pH";
}
elsif ($bottomgraph eq 'do'){
$bottomstationtitle = "Dissolved Oxygen (Mg/L)";
}
elsif ($bottomgraph eq 'bod'){
$bottomstationtitle = "BOD (Mg/L)";
}
elsif ($bottomgraph eq 'saturateddo'){
$bottomstationtitle = "Saturated DO (Mg/L)";
}
elsif ($bottomgraph eq 'runoff'){
$bottomstationtitle = "Runoff (Meters Cubed)";
}
elsif ($bottomgraph eq 'totalflow'){
$bottomstationtitle = "Total Flow (Meters Cubed)";
}
elsif ($bottomgraph eq 'groundwater'){
$bottomstationtitle = "Groundwater (Meters Cubed)";
}
if ($station eq "0"){
$stationname = "Pristine Forest";
$topaltname = "Pristine_Forest";
$topimprov = "None";
}
elsif ($station eq "1"){
$stationname = "Logging Forest";
$topaltname = "Logging_Forest";
$topimprov = "Forbid Clear Cutting";
}
elsif ($station eq "2"){
$stationname = "Agricultural Area";
$topaltname = "Agricultural_Area";
$topimprov = "Strip Cropping";
}
elsif ($station eq "3"){
$stationname = "Residential Area";
$topaltname = "Residental_Area";
$topimprov = "Require a Stream Buffer";
}
elsif ($station eq "4"){
$stationname = "Commercial/Industrial Area";
$topaltname = "Commercial_Industrial_Area";
$topimprov = "Require a Runoff Pond / Cache Basin";
}
elsif ($station eq "5"){
$stationname = "Wetlands Area";
$topaltname = "Wetlands_Area";
$topimprov = "Protect Wetlands";
}
elsif ($station eq "6"){
$stationname = "Urban Area";
$topaltname = "Urban_Area";
$topimprov = "Separate Storm and Sanitary Sewers";
}
elsif ($station eq "7"){
$stationname = "River Mouth";
$topaltname = "River_Mouth";
$topimprov = "Make Changes Upstream";
}
print LOGFILE "\nTop Station: $station $stationname $topgraph x from $topfrom to $topto";
if($topyrange eq "" && $topyrangeto eq "") {
print LOGFILE " y default";
}
else {
print LOGFILE " y from $topyrange to $topyrangeto";
}
$changed = 0;
HasImprovementBeenMade($station);
$topbmp = $changed;
$finished = $done;
if ($topbmp eq 1){
print LOGFILE " w/bmp";
}
elsif ($topbmp eq 0){
print LOGFILE " w/o bmp";
}
if ($bottomstation eq "0"){
$bottomstationname = "Pristine Forest";
$botaltname = "Pristine_Forest";
$bottomimprov = "None";
}
elsif ($bottomstation eq "1"){
$bottomstationname = "Logging Forest";
$botaltname = "Logging_Forest";
$bottomimprov = "Forbid Clear Cutting";
}
elsif ($bottomstation eq "2"){
$bottomstationname = "Agricultural Area";
$botaltname = "Agricultural_Area";
$bottomimprov = "Strip Cropping";
}
elsif ($bottomstation eq "3"){
$bottomstationname = "Residential Area";
$botaltname = "Residential_Area";
$bottomimprov = "Require a Stream Buffer";
}
elsif ($bottomstation eq "4"){
$bottomstationname = "Commercial/Industrial Area";
$botaltname = "Commercial_Industrial_Area";
$bottomimprov = "Require a Runoff Pond / Cache Basin";
}
elsif ($bottomstation eq "5"){
$bottomstationname = "Wetlands Area";
$botaltname = "Wetlands_Area";
$bottomimprov = "Protect Wetlands";
}
elsif ($bottomstation eq "6"){
$bottomstationname = "Urban Area";
$botaltname = "Urban_Area";
$bottomimprov = "Separate Storm and Sanitary Sewers";
}
elsif ($bottomstation eq "7"){
$bottomstationname = "River Mouth";
$botaltname = "River_Mouth";
$bottomimprov = "Make Changes Upstream";
}
print LOGFILE "\nBottom Station: $bottomstation $bottomstationname $bottomgraph x from $botfrom to $botto";
if($botyrange eq "" && $botyrangeto eq ""){
print LOGFILE " y default";
}
else {
print LOGFILE " y from $botyrange to $botyrangeto";
}
$changed = 0;
HasImprovementBeenMade($bottomstation);
$botbmp = $changed;
$finished = $done;
if ($botbmp eq 1) {
print LOGFILE " w/bmp";
}
elsif ($botbmp eq 0) {
print LOGFILE " w/o bmp";
}
}
sub PrintTopScatterplotLink{
# HasImprovementBeenMade sets $changed to 1 if changed
# Also sets $done to yes or no, meaning whether or not all
# the stations have been improved.
# we are evaluating the bottom graph now in order to decide if
# we need to print the scatterplot link.
# initalize $changed
$changed = 0;
HasImprovementBeenMade($bottomstation); # ordercontrol.pl
# store bottom changed in another variable, reset $changed
$bottomch = $changed;
if($bottomstation==7 && $improved_7 eq "print_two_lines") {
$bottomch = 1;
}
$changed = 0;
# we are evaluating the top graph now $station is kind of like
# saying topstation vs bottomstation, only not saying top.
HasImprovementBeenMade($station);
if($station==7 && $improved_7 eq "print_two_lines") {
$changed=1;
}
# now see if the durations of top and bottom graphs are the same
$alen = ($topto - $topfrom);
$blen = ($botto - $botfrom);
# print "ALEN: $alen. BLEN: $blen";
# decide and print scatterplot link
if (($alen == $blen) && ($changed == $bottomch)){
print "Draw Scatter Plot";
print " ";
print " Help";
}
else {
print "Draw Scatter Plot";
print " ";
print "Help";
}
}
sub PrintTopNotepadLink{
print " ";
print " Open Notepad
";
# print " Open Notepad
";
}
sub SetTopParameter{
if ($topgraph eq "nitrogen"){ $parameter = '1';}
elsif ($topgraph eq "phosphorus"){ $parameter = '2';}
elsif ($topgraph eq "sediments"){ $parameter = '3';}
elsif ($topgraph eq "heavymetal"){ $parameter = '4';}
elsif ($topgraph eq "toxins"){ $parameter = '5';}
elsif ($topgraph eq "watertemp"){ $parameter = '6';}
elsif ($topgraph eq "temperature"){ $parameter = '11';}
elsif ($topgraph eq "ph"){ $parameter = '7';}
elsif ($topgraph eq "do"){ $parameter = '8';}
elsif ($topgraph eq "bod"){ $parameter = '9';}
elsif ($topgraph eq "saturateddo"){ $parameter = '10';}
elsif ($topgraph eq "precip"){ $parameter = '12';}
elsif ($topgraph eq "runoff"){ $parameter = '13';}
elsif ($topgraph eq "totalflow"){ $parameter = '14';}
elsif ($topgraph eq "groundwater"){ $parameter = '15';}
}
sub PrintTopLinkToDatafiles{
# print the link to the datafiles
if ($changed == 0){
print "View pre-implementation Data
\n";
}
elsif ($changed == 1){
print "View pre-implementation Data\n";
if ($improved_7 eq "print_one_line"){;}
else{
print " | View post-implementation Data
\n";
}
}
}
sub PrintTopGifTag{
$pathtogif = "/var/www/html/tmpgif/$topgraphic";
# see if file exists and print tag
if (!(-e $pathtogif)){
print "
\n";
print "\n";
print "Unable to create Graphic for Parameter: $error\n\n";
}
else {
print "![](\"$justthedomain/$tmpgif/$topgraphic\")
\n";
}
}
1;