/* Program: img_plot_orig.aml /* /* Purpose: Creates a plotfile in the specified output format from the /* input image(s) or grids. /* /* Usage: &r img_plot_orig {output_plotfile_format} /* /* If no output format given, defaults to Arc 1040 metafile (.gra) /* Ex: &r %prog% denver.bil ---> creates denver.gra 1040 file /* &r %prog% * ---> creates 1040 file for each image /* &r %prog% * gra ---> " " " " " " /* &r %prog% *.img eps ---> creates an EPS file for each *.img /* &r %prog% * cgm ---> creates a CGM file for each image /* &r %prog% mor_doq* cgm ---> creates a CGM file from the grid /* /* Supported input formats: TIFF, BIL, BIP, BSQ, RLC, Arc GRID, /* SUNRASTER, ERDAS, IMAGINE, GRASS /* Supported output formats: Arc 1040 (GRA), EPS, CGM /* If running Arc 7.1 or higher, also supports JPEG, BMP input images /* /* Notes: Edit the default pagesize variables below to produce the /* appropriate plot size. Based on the dimensions of each input /* image, the pagesize will be set to landscape (X > Y), /* portrait (Y > X), or square (X = Y). /* /* History: JKosovich 09/10/97 Original coding /* JKosovich 03/27/98 Renamed from img_plot.aml to img_plot_orig /* (new img_plot program is menu-driven). This /* program retains ability to use wildcard "*". /* JKosovich 04/09/98 Fixed SEARCH usage /* /*------------------------------------------------------------------------------ /* &args input outformat &severity &error &routine bailout &s prog = [ENTRYNAME %aml$file% -NOEXT -FILE] /* current AML being run /******************** SET DEFAULT PAGESIZES HERE (X Y) ************************ &s landscape = 24 18 &s portrait = 18 24 &s square = 20 20 /******************************************************************************* /* /***** Determine ARC/INFO version for supported image formats ***** /* &s arcver = [EXTRACT 1 [SHOW VERSION]] /* eg. 7.0.4, 7.1, 7.1.1 &s arcver1 = [BEFORE %arcver% .] /* eg. 7 &if %arcver1% < 7 &then &return &warning \*** NOTE: Must use Arc version 7.0 or newer (%arcver%)\\ &s arcver2 = [SUBSTR [AFTER %arcver% .] 1 1] /* digit after the 7, eg. 0, 1 &if %arcver2% = 0 & %arcver1% = 7 &then /* if 7.0.3, 7.0.4, etc. &do &s inlist1 = TIFF, BIL, BIP, BSQ, RLC, Arc GRID, &s inlist2 = SUNRASTER, ERDAS, IMAGINE, GRASS &s outlist1 = GRA, EPS, CGM &s ex = bil &end &else &if %arcver2% > 0 | %arcver1% > 7 &then /* if 7.1, 7.1.1, 8.0, etc. &do &s inlist1 = TIFF, JPEG, BIL, BIP, BMP, BSQ, RLC, &s inlist2 = SUNRASTER, ERDAS, IMAGINE, GRASS, Arc GRID &s outlist1 = GRA, EPS, CGM &s ex = jpeg &end &s outlist = %outlist1% /* /***** Check for proper number of args. If no output, default to .gra ***** /* &if [NULL %outformat%] &then &do &if [NULL %input%] &then &call usage &else &s outformat = GRA &end /* /***** Check for supported output image formats, set DISPLAY option # ***** /* &if [KEYWORD %outformat% %outlist%] <= 0 &then /* if not found or ambiguous &call usage &select [UPCASE %outformat%] &when GRA &s disopt = ' ' &when EPS &s disopt = 2 &when CGM &s disopt = 6 &otherwise &s disopt = ' ' /* just in case &end /* select /* /***** If input is a single file ***** /* &if [SEARCH %input% *] = 0 &then /* if no *, then treat as single file &do &if ^ [EXISTS %input% -FILE] & ^ [EXISTS %input% -GRID] &then &return &warning \*** ERROR: File/Grid %input% not found in directory!\\ &if ^ [EXISTS %input% -IMAGE] &then &return &warning \*** ERROR: File %input%: Unrecognized image format!\\ &else &do &s image = %input% &s outfilename = [LOCASE [ENTRYNAME %image% -NOEXT -FILE].%outformat%] &call plot &end &end /* /***** If input is a wildcard string ***** /* &else &do &s tmpfile = xximgplot &if [EXISTS %tmpfile% -FILE] &then &s dok = [DELETE %tmpfile%] &s numimg = [FILELIST %input% %tmpfile% -FULL -IMAGE] &if %numimg% = 0 &then &do &s dok = [DELETE %tmpfile%] &return &warning \*** NOTE: No "%input%" files found in directory.\\ &end &s file = [OPEN %tmpfile% ook -READ] &s eof = .FALSE. &s image = [UNQUOTE [READ %file% rok]] /* /***** Image plotting loop ***** /* &do &until %eof% /* Or: until %rok% = 102 &s outfilename = [LOCASE [ENTRYNAME %image% -NOEXT -FILE].%outformat%] &call plot &s image = [UNQUOTE [READ %file% rok]] &if %rok% = 102 &then &s eof = .TRUE. /*Or: &s eof = [NULL %image%] &end /* End do until /* /***** Close and delete file ***** /* &s cok = [CLOSE %file%] &s dok = [DELETE %tmpfile%] &end /* End wildcard loop /* /***** All done, exit successfully ***** /* &type \******************************************************** &type AML Program completed successfully. &type Thanks for using %prog%.aml, [UPCASE [USERNAME]]! &type ********************************************************\\ &return /* /* /*----------------------------- ROUTINE USAGE -------------------------------- /* &routine usage /* &type &type ************************************************************************** &type *** USAGE: &r %prog% {output_plotfile_format} &type *** &type *** If no output format given, defaults to Arc 1040 metafile (.gra) &type *** Ex: &r %prog% denver.%ex% --> creates denver.gra 1040 file &type *** &r %prog% * --> creates 1040 file for each image &type *** &r %prog% * gra --> " " " " " " &type *** &r %prog% *.%ex% cgm --> creates CGM file for each *.%ex% &type *** &r %prog% * eps --> creates EPS file for each image &type *** &r %prog% mor_doq cgm --> creates a CGM file from the grid &type *** Supported input formats: %inlist1% &type *** %inlist2% &type *** Supported output formats: %outlist1% &type *** &type *** Current pagesize settings, inches X Y (edit AML to modify these): &type *** Landscape = %landscape%, Portrait = %portrait%, Square = %square% &type *** The appropriate page shape is automatically determined from the &type *** dimensions of each input image (ie. if image is longer in X than Y, &type *** plot will have landscape orientation of %landscape%, etc.). &type ************************************************************************** &type &type &return; &return &error /* /* /*----------------------------- ROUTINE PLOT --------------------------------- /* &routine plot /* &type \*** Creating output plotfile %outfilename%. Please wait... DISPLAY 0 &if [SHOW PROGRAM] ^= ARCPLOT &then ARCPLOT DISPLAY 1040 %disopt% %outfilename% &type \*** Plotting image...\ MAPEXTENT IMAGE %image% &s xmax = [EXTRACT 3 [SHOW MAPEXTENT PAGE]] &s ymax = [EXTRACT 4 [SHOW MAPEXTENT PAGE]] /* /***** If longer in x than y, landscape, etc. ***** /* &if %xmax% > %ymax% &then PAGESIZE %landscape% &else &if %xmax% < %ymax% &then PAGESIZE %portrait% &else PAGESIZE %square% IMAGE %image% QUIT &type *** Output plotfile %outfilename% created. &return /* /* /*----------------------------- ROUTINE BAILOUT ------------------------------ /* &routine bailout /* &severity &error &ignore &if [SHOW PROGRAM] = ARCPLOT &then QUIT /* /***** Close files (no problem if not open) ***** /* &s cok = [CLOSE -ALL] &if [VARIABLE tmpfile] &then &if [EXISTS %tmpfile% -FILE] &then &s dok = [DELETE %tmpfile%] /* &type \***** Error occurred at line %aml$errorline% in %aml$errorfile% *****\ /* &return; &return &error