#!/usr/bin/perl # use File::Temp qw/tempfile/; { do "acqPATHs.pl"; $str = $ENV{"QUERY_STRING"}; ($dir, $fnm, $ax1, $ay1, $ax2, $ay2) = split(/\+/, $str); if ($dir ne "") { $dir .= "/"; } $path = "$DATAPATH/$dir$fnm"; # $err = 0; if (-f $path) { if (open(IN, "< $path")) { $_ = ; while (/^#/) { $_ = ; } $area = substr($_,0,8); $nc1 = substr($_,8,4); $nc2 = substr($_,12,4); if ($nc2 eq " ") { $ncc = $nc1-0; if (($ncc<0) || ($ncc>=400)) { $ncc = -1; } elsif ($ncc<200) { $ncc += 800; } else { $ncc -= 200; } } else { $ncc = $nc2-0; } $_ = ; ($ixs, $iys, $mszx, $mszy, $mx, $my, $dmy) = split; $xsz = ($mx-1) * $mszx; $ysz = ($my-1) * $mszy; $sz = ($xsz > $ysz) ? $xsz/360: $ysz/360; $fs = 1; while ($sz > 50) { $fs *= 10; $sz /= 10; } if ($sz <= 10) { $sd = $fs*10; } elsif ($sz <= 20) { $sd = $fs*20; } elsif ($sz <= 25) { $sd = $fs*25; } else { $sd = $fs*50; } $xm = $ixs + $xsz/2; $xm = int($xm/$sd) * $sd; $xl = $xm - $sd*200; $ym = $iys + $ysz/2; $ym = int($ym/$sd) * $sd; $yl = $ym - $sd*200; close(IN); #----------------------------------------------------------------------------- # Remove temporary file "$HTMLPATH/fout/AMXS.*.png" older than 1H. @files = glob("$HTMLPATH/fout/AMXS.*.png"); $now = time(); foreach $f(@files) { if (($now-(stat($f))[9]) > 3600) { unlink $f; } } #----------------------------------------------------------------------------- # Generate a temporary file "$HTMLPATH/fout/AMXS.XXXXXX.png". #----------------------------------------------------------------------------- ($fh, $file) = tempfile("AMXS.XXXXXX", SUFFIX=>'.png', DIR=>"$HTMLPATH/fout"); binmode($fh); $name = substr($file,length("$HTMLPATH/fout/")); #----------------------------------------------------------------------------- # ######################################################## # # Generate PNG image (stdout) from Grid-data ($path) # # # ( mkmpng2 llx:lly:msz infile [outfile] ) # # ######################################################## if (open(IN, "bin/mkmpng2 $xl:$yl:$sd $path |")) { binmode(IN); $len = sysread(IN,$buf,80); if (substr($buf,1,3) ne "PNG") { $err = 1; $msg = "***** $buf"; } else { while ($len) { $lout = syswrite($fh,$buf,$len); if (defined($lout)) { $len = sysread(IN,$buf,1024); unless (defined($len)) { $len = 0; $err = 1; $msg = "Unexpected SYSREAD error"; } } else { $len = 0; $err = 1; $msg = "Unexpected SYSWRITE error"; } } } close(IN); } else { $err = 1; $msg = "setgp.cgi: mkmpng start fail."; } close($fh); # } else { $err = 1; $msg = "setgp.cgi: $path open fail."; } } else { $err = 1; $msg = "setgp.cgi: $path not found."; } if ($err == 1) { print "Content-type: text/html; charset=iso-8859-1\n\n"; #### $htmlbody =< AMXS setgp
ERROR:        
__MESG__
EOM #### $htmlbody =~ s/__MESG__/$msg/; print $htmlbody; } else { print "Content-type: text/html; charset=iso-8859-1\n\n"; #### $htmlbody =< AMXS setsp
(Using Canvas API) Drag mouse along the desired section, then the parameters are set automatically.   If acceptable, click "OK" button.
The parameters can be adjusted by arrow or by dragging either end of the section.


EOM #### $htmlbody =~ s/__TFN__/$name/g; $htmlbody =~ s/__NCC__/$ncc/eg; $htmlbody =~ s/__LLX__/$xl/; $htmlbody =~ s/__LLY__/$yl/; $htmlbody =~ s/__MSZ__/$sd/; print $htmlbody; } }