/* Program: GIRASARC2.AML /* Usage: GIRASARC2 {ALBERS | UTM} {central_meridian} /* /* Purpose: /* Extends the giras-to-arc compatibility by bringing in the GIRAS data set /* into an Arc coverage with a projection file present, already in "real" /* coordinates. In this example, it shall be brought into the correct /* original coordinate system, if UTM meters, with zone determined from one /* of the registration tics. /* /*------------------------------------------------------------------------ /* Platform: DG Aviion (Unix workstation) /* System Dependencies: /* System dependent settings are stored in variables near the beginning /* of the code. By modifying those settings, this program may be ported /* to other systems or platforms. /* /* The system dependent settings involve the following: /* 1. redirection of output from an Info session; /* 2. system commands to concatenate and copy system files; /* 3. system path name delimiter character. /* 4. path name to workspace where Info templates for files used by /* Document.aml are stored /* /*------------------------------------------------------------------------ /* Arguments: /* name of input file, which must be in USGS GIRAS /* format. /* /* name of cover to be created. /* /* {ALBERS | UTM} projection system to be used for . /* /* ALBERS standard USGS WRD projection for maps of the U.S. /* projection parameters used are: /* projection albers /* units meters /* parameters /* 29 30 00 /* 45 30 00 /* {central_meridian} argument /* 23 00 00 /* 0.0 /* 0.0 /* /* UTM standard UTM projection, units meters. /* /* {central_meridian} When ALBERS is the selected projection, the central /* meridian may be specified as: -ddd mm ss. /* If not specified, the default is -96 00 00. /* /*------------------------------------------------------------------------ /* Output: /* Cover containing spatial data theme from GIRAS file. /* The INFO files associated with the cover include four /* documentation files used by Document.aml: /* .DOC, .ATT, .NAR, and .REF /* /* NL Cover containing quadrangle neatline. Should be /* used as a snapcover to adjust the arcs along the /* outer boundary of the quadrangle. /* /*------------------------------------------------------------------------ /* History: /* Rev.0.1 DDNEBERT USGS-WRD, 11/15/91, Original coding /* Rev 0.2 DDNEBERT USGS-WRD, 11/19/91, Added standard Albers projection /* Rev.0.3 RBZELT USGS-WRD, 12/11/91, Deleted double precision; /* modified check of central_meridian; /* modified so UTM is not assumed to /* be the GIRAS projection system; /* added save of header info in info /* file .HDR; /* modified deletion of global var's; /* added generation of neatline cover. /* Rev.0.4 RBZELT USGS-WRD, 01/16/92, modified system dependencies from /* hard to soft coding; /* added save of tranform report in /* info file .HDR; /* added insert of log from tmpcov in /* log of . /* Rev.0.4.1 RBZELT USGS-WRD, 01/22/92, corrected &mess setting during the /* transform command; modified to check /* for existence of LL. /* Rev.0.5 RBZELT USGS-WRD, 03/03/92, added Girasdocument subroutine, /* which is documented separately. /* Rev 0.5.1 DDNEBERT USGS-WRD 03/09/92 Added a new PAT item called LUCODE to /* store the Anderson classification value /* Rev 0.5.2 RBZELT USGS-WRD, 04/06/92 Added trap for crash during Girasarc /* /* Rev 0.5.3 DDNEBERT USGS-WRD 03/10/93 Conversion for Arc 6 pathnames /* and expanded documentation (ATT and NAR) /* /* EPARTING EPA-GIS 04/21/93 Substituted TABLES for INFO /*======================================================================== &args infile outcov prjopt cm1 cm2 cm3 &if [null %outcov%] &then &do &ty Usage: GIRASARC2 {ALBERS | UTM | NONEAT} {central_meridian} &ty Example: GIRASARC2 willow.giras willow ALBERS -105 30 00 &return &end &s outcov [translate %outcov%] &s noneat = 0 &if not [exists %infile% -file] &then &return %infile% not found. &if [exists %outcov% -cov] &then &return %outcov% already exists. &if [exists %outcov%LL -cov] &then &return %outcov%LL already exists. &if [exists tmpcov -cov] &then kill tmpcov all &if [translate %prjopt%] = NONEAT &then &do &s prjopt = ALBERS &s noneat = 1 &end &if [null %prjopt%] &then &s prjopt = ALBERS &s prjopt = [translate %prjopt%] &if %prjopt% = ALBERS and [null %cm1%] ~ &then &s cm = '-96 00 00' &else &s cm = [quote %cm1% %cm2% %cm3%] &if not [null %cm1%] and [null %cm3%] &then ~ &return {central_meridian} requires degrees minutes seconds, e.g. -120 30 00 /* Basic housekeeping &s home [show workspace] &s outcov = [translate %outcov%] /* turns to upper case &s full_cov = [pathname %outcov%] /* full cover with pathname &s work = [dir %full_cov%] /* directory of cov to be doc'ed &s entry_cov = [entryname %full_cov%] &s info_cov = %work%:%entry_cov% &s infosub = %work%/info /* name of INFO subdir for silent INFO &s mess_off = [unquote '&off &all'] /* toggle messages for debugging /*&s mess_off = [unquote '&on'] /* ******* system-dependent settings follow ****************** &s srce $ARCHOME/atool/support/arcsupport/doc/info /* Directory that holds templates &s scrnoff [unquote '> /dev/null'] /* appended to &data to hide terminal output /*&s scrnoff [unquote ' '] &s d / /* pathname delimiter /* store system commands to insert log from tmpcov into log of : &s com1 [unquote [locase [quote cat %outcov%%d%log >> %home%%d%tmpcov%d%log]]] &s comr [unquote [locase [quote rm %outcov%%d%log]]] &s com2 [unquote [locase [quote cp %home%%d%tmpcov%d%log %outcov%%d%log]]] /* ************************************************************ /* Version number &type \'[GIRASARC2 3/10/93 Ver. 0.5.3 for Arc 6.1.1]' \ /* test for projection type... &select %prjopt% &when UTM &do &type Will transform to local UTM meters... &s cm = ' ' &end &when ALBERS &do &type Will first transform to UTM meters then to Albers projection &type with [unquote %cm%] Central Meridian... &end &otherwise &do &type Projection type %prjopt% not supported. &return Exiting GIRASARC2... &end &end &type Converting GIRAS data... &mess %mess_off% &severity &error &ignore girasarc %infile% tmpcov &if not [exists tmpcov -cov] &then &do &ty Unable to successfully complete conversion of GIRAS file. Bailing out... &mess &on &severity &error &fail &return &end build tmpcov poly &severity &error &fail &mess &on &if not [exists tmpcov -poly] &then &do &type Unable to build coverage, running CLEAN instead... tolerance tmpcov fuzzy 1 clean tmpcov &end &mess &on &type Reading header information for transformation... &s girunit [open %infile% ostat -r] /* read record 1 &s buff [read %girunit% rstat] &if %rstat% ne 0 &then &return Bad read of %infile%... &s nsc [substr %buff% 41 5] &s mtp [substr %buff% 46 5] &s mpj [substr %buff% 56 5] &s msc [substr %buff% 61 10] &s mda [substr %buff% 71 10] /* read records 2 and 3 &do i = 1 &to 2 &s buff [read %girunit% rstat] &if %rstat% ne 0 &then &return Bad read of %infile%... &end /* extract 4 pairs of control point lat/longs &do i = 1 &to 8 &s .j = %i% &call setdd &s elem%.j% = %.dd% &end /* read record 4 &s buff [read %girunit% rstat] &if %rstat% ne 0 &then &return Bad read of %infile%... &s jda [substr %buff% 61 10] /* extract 2 pairs of control point lat/longs &do i = 1 &to 4 &s .j = %i% &call setdd &s .j = 8 + %i% &s elem%.j% = %.dd% &end /* read record 5 &s buff [read %girunit% rstat] &if %rstat% ne 0 &then &return Bad read of %infile%... &s title [substr %buff% 1 64] &s cerr [close -all] /* Create an appropriate item in PAT &select [unquote %mtp%] &when 1 &do &s aitem LUCODE &s awid 2 &end &when 2 &do &s aitem COUNTYFIPS &s awid 5 &end &when 4 &do &s aitem CENSUS &s awid 10 &end &when 10 &do &s aitem HUC &s awid 8 &end &when 20 &do &s aitem FEDLAND &s awid 2 &end &when 40 &do &s aitem STATELAND &s awid 10 &end &otherwise &do &s aitem GIRAS &s awid 10 &end &end /* add landuse code item to PAT... additem tmpcov.pat tmpcov.pat %aitem% %awid% %awid% I &mess %mess_off% tables SEL TMPCOV.PAT CALC %aitem% = TMPCOV-ID /* CALC TMPCOV-ID = TMPCOV# - 1 Q STOP /* idedit tmpcov poly /* load the projection stuff into an empty cover. &mess %mess_off% create %entry_cov%ll tables sel %entry_cov%ll.tic add 1,-%elem2%,%elem1% 2,-%elem4%,%elem3% 3,-%elem6%,%elem5% 4,-%elem8%,%elem7% 5,-%elem10%,%elem9% 6,-%elem12%,%elem11% [unquote ' '] q stop &if %noneat% = 1 &then &goto skip1 /* generate neatline cover &ty Generating quadrangle neatline ... generate %entry_cov%nl_ll lines 1 -%elem2%,%elem1% -%elem4%,%elem3% -%elem6%,%elem5% -%elem8%,%elem7% -%elem10%,%elem9% -%elem12%,%elem11% -%elem2%,%elem1% -%elem2%,%elem1% end end q densifyarc %entry_cov%nl_ll # .0002 vertex &label skip1 &mess &on /* check if GIRAS data is in UTM projection &if [unquote %mpj%] ne 1 &then &return ~ GIRAS data not in expected UTM projection. Cannot perform coord transform. /* project tics to UTM &mess %mess_off% project cover %entry_cov%ll %work%%d%%entry_cov% input projection geographic units dd parameters output projection utm units meters parameters -%.deg% %.min% %.sec% 45 00 00 end /* transform GIRAS data to UTM, saving RMSE info in watch file &if [exists %outcov%.wat] &then &s ok [delete %outcov%.wat] &if [exists %outcov%.tmp] &then &s ok [delete %outcov%.tmp] &mess &on &watch %work%%d%%entry_cov%.tmp transform tmpcov %work%%d%%entry_cov% &watch &off /* Put quotes around the watch file so tables can ADD FROM properly &s f5 = [open %work%%d%%entry_cov%.tmp openstatus -read] &s f6 = [open %work%%d%%entry_cov%.wat openstatus -write] &do &until %readstatus% > 0 &s rec = [read %f5% readstatus] &s qrec = [quote %rec%] &s wrec = [write %f6% %qrec%] &end &if [close %f5%] > 0 &then &type %work%%d%%entry_cov%.tmp did close properly &if [close %f6%] > 0 &then &type %work%%d%%entry_cov%.wat did close properly /* If ALBERS selected, then do the following projections &if %prjopt% = ALBERS &then &do &worksp %work% rename %entry_cov% %entry_cov%U &type Projecting %outcov% into ALBERS projection... &mess %mess_off% project cover %entry_cov%U %entry_cov% output projection albers units meters parameters 29 30 00 45 30 00 [unquote %cm%] 23 00 00 0.0 0.0 end build %entry_cov% poly &if %noneat% = 1 &then &goto skip2 /* project neatline to ALBERS &ty Projecting neatline into ALBERS projection ... project cover %home%%d%%entry_cov%nl_ll %entry_cov%nl input projection geographic units dd parameters output projection albers units meters parameters 29 30 00 45 30 00 [unquote %cm%] 23 00 00 0.0 0.0 end &end /* to close ALBERS do loop /* If UTM selected, then project neatline to UTM &if %prjopt% = UTM &then &do &worksp %work% &ty Projecting neatline into UTM projection ... &mess %mess_off% project cover %home%%d%%entry_cov%nl_ll %entry_cov%nl input projection geographic units dd parameters output projection utm units meters parameters -%.deg% %.min% %.sec% 45 00 00 end &end /* to close UTM do loop &label skip2 &call girasdocument /* insert log file from tmpcov into log file of output &sys %com1% &sys %comr% &sys %com2% &type Cleaning up... &mess %mess_off% &worksp %home% kill tmpcov kill %entry_cov%ll all &if [exists %entry_cov%nl_ll -cov] &then kill %entry_cov%nl_ll &if [exists %entry_cov%U -cover] &then kill %entry_cov%U all &s ok [delete %work%%d%%entry_cov%.wat] &s ok [delete %work%%d%%entry_cov%.tmp] &delvar .dd &delvar .deg &delvar .j &delvar .min &delvar .sec &mess &on log %work%%d%%entry_cov% add GIRASARC2 %infile% %entry_cov% %prjopt% [unquote %cm%] [username] &return /***************************************************************** &routine setdd &s xtic = [extract %.j% [unquote %buff%]] &if [length %xtic%] = 6 &then &do &s .deg = [substr %xtic% 1 2] &s .min = [substr %xtic% 3 2] &s .sec = [substr %xtic% 5 2] &s .dd = %.deg% + ( %.min% / 60 ) + ( %.sec% / 3600 ) &end &if [length %xtic%] = 7 &then &do &s .deg = [substr %xtic% 1 3] &s .min = [substr %xtic% 4 2] &s .sec = [substr %xtic% 6 2] &s .dd = %.deg% + ( %.min% / 60 ) + ( %.sec% / 3600 ) &end &return /*-------------------------------------------------------------------------- /* /* routine name: GIRASDOCUMENT /* Language: AML /* Revision: 0.1 /* Version: Arc 6.1 UNIX /* /*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /* /* Purpose: /* /* To create coverage documentation, consistent with the standard Document.aml /* for use in the USGS Water Resources Division, for a coverage created using /* GIRASARC2.AML. The documentation is created as a combination of INFO and /* free-format text files that are managed as INFO files to ensure Export/ /* Import translation. /* /*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /* /* Arguments: /* Variable name, Type, Definition /* ------------------------------------------------------------ /* character Name of coverage to be documented. /* /*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /* /* History: /* Author/Site, Date, Event /* ------------------------------------------------------------ /* RBZELT, Lawrence, KS 2/27/92 0.1 Original coding which includes modified /* versions of the get_templates and input_doc /* subroutines from Document.aml version 0.9.4 /* (1/10/92 by DDNEBERT) /* ddnebert 3/31/93 0.2 Modified to point to new template location /* but still for DOCUMENT version 0.9.9 /* Added better NAR template and DOC entries /* eparting-EPA 4/21/93 Use TABLES rather than INFO /*-------------------------------------------------------------------------- &routine girasdocument &if not [exists %info_cov%.DOC -info] &then &call get_templates &call input_doc /* enter basic documentation information &mess %mess_off% log %work%%d%%entry_cov% add girasdocument %entry_cov% [username] &workspace %home% &mess &on &return /************************************************************************* /* routine copies DOC REF NAT and ATT templates from source directory &routine get_templates &mess %mess_off% &ty Copying documentation templates ... &do nam &list DOC REF ATT &if [exists %srce%!ARC!DOC.%nam% -info] &then ~ copyinfo %srce%!ARC!DOC.%nam% %info_cov%.%nam% &else &do &mess &on &type Document error. Info template file %nam% not found. &end /* if not exists do end &end /* do list end &if [exists %srce%!ARC!DOC.GIR -info] &then ~ copyinfo %srce%!ARC!DOC.GIR %info_cov%.NAR &else copyinfo %srce%!ARC!DOC.NAR %info_cov%.NAR &mess &on &return /****************************************************************************** /* routine puts data into the documentation files &routine input_doc &workspace %work% &describe %entry_cov% &mess %mess_off% &s pre = [quote %dsc$precision%] &s fda = [quote [unquote %dsc$fuzzy%] [unquote %dsc$dangle%]] &s acs = [quote %dsc$arcs%] &s sgm = [quote %dsc$segments%] &s pol = [quote %dsc$polygons%] &s pts = [quote %dsc$points%] &s tcs = [quote %dsc$tics%] &s ann = [quote %dsc$annos%] &s .doc$resolution '127 meters' &select [unquote %mtp%] &when 1 &do &s .doc$theme 'Land Use and Land Cover' &s .doc$resolution '127 meters, 4-16 ha min polys' &end &when 2 &s .doc$theme 'Political Units' &when 4 &s .doc$theme 'Census County Subdivisions' &when 10 &s .doc$theme 'Hydrologic Units' &when 20 &do &s .doc$resolution '127 meters, 16 ha min polys' &s .doc$theme 'Federal Land Ownership' &end &when 40 &s .doc$theme 'State Land Ownership' &otherwise &s .doc$theme [quote GIRAS Map Type [unquote %mtp%]] &end &s .doc$description %title% &s .doc$contact 'Ed Partington at EPA' &s .doc$contactinstr 'Phone (703) 235-5595' &s .doc$organization 'EPA/OIRM/PSD/IIMB/GIS' &s .doc$coverrev 1.0 &s .doc$location %title% &select [unquote %msc%] &when 393699,393700,393701 &s .doc$scale '250000' &otherwise &s .doc$scale [quote [unquote %msc%] (coord.unit=.001 in.)] &end &s .doc$archive 'on-line ARC/INFO' &s .doc$pubstatus 'Published.' &s .doc$citation1 [quote U.S. Geological Survey, 1990, Land Use and Land Cover Digital] &s .doc$citation2 [quote Data from 1:250,000- and 1:100,000-Scale Maps -- Data Users Guide 4] &s .doc$citation3 [quote [unquote %title%], [unquote %mda%]:] &s .doc$citation4 [quote [unquote %.doc$scale%].] &s .doc$citation5 ' ' &mess &on &s ext = [quote %dsc$xmin% %dsc$ymin% %dsc$xmax% %dsc$ymax%] &if [length %ext%] gt 78 &then &s ext = 'NULL extent -- coverage has no features' /* &messages %mess_off% &ty Adding brief documentation ... &mess &off &workspace %work% &if [exists %info_cov%.doc -info] &then &do tables SEL [translate %entry_cov%].DOC ADD girasarc [date -ftag] [username] [date -ftag] %entry_cov% %work% %ext% %pre% %fda% %acs% %sgm% %pol% %pts% %tcs% %ann% %.doc$theme% %.doc$description% %.doc$contact% %.doc$contactinstr% %.doc$organization% %.doc$coverrev% %.doc$location% %.doc$resolution% %.doc$scale% %.doc$archive% %.doc$pubstatus% %.doc$citation1% %.doc$citation2% %.doc$citation3% %.doc$citation4% %.doc$citation5% [unquote ' '] /* /* End of entry to DOC file /* SEL [translate %entry_cov%].ATT ADD %work% ITEM [translate %entry_cov%].PAT AREA 4 5 B 0 [USERNAME] 'Area of polygon in square coverage units' 'Positive real numbers' 'Computed by software' 'Valid for equal-area projection' %work% ITEM [translate %entry_cov%].PAT PERIMETER 4 12 F 3 [USERNAME] 'Perimeter of polygon in coverage units' 'Positive real numbers' 'Computed by software' 'Valid for projection and fuzzy tolerance' %work% ITEM [translate %entry_cov%].PAT [translate %entry_cov%]# 4 5 B 0 [USERNAME] 'Internal feature number' 'Sequential unique positive integer' 'Computed by software' 'No qualifications' %work% ITEM [translate %entry_cov%].PAT [translate %entry_cov%]-ID 4 10 B 0 [USERNAME] 'User-assigned feature number' 'Integer' 'Same as LUCODE initially' 'Not applicable' %work% ITEM [translate %entry_cov%].PAT LUCODE 2 2 I 0 [USERNAME] 'Anderson level II land use classification' 'See narrative file' 'U.S. Geological Survey NMD' 'Unverified in conversion process' [unquote ' '] /* /* End of ATT definition /* SEL [translate %entry_cov%].NAR ADD 'Map Header Information from GIRAS file' ---------------------------------------------------------- [quote title: [unquote %title%]] [quote file creation date: [unquote %jda%]] [quote map type: [unquote %mtp%]] [quote projection: [unquote %mpj%]] [quote scale: 1:[unquote %msc%]] [quote source materials date: [unquote %mda%]] [quote number of map sections: [unquote %nsc%]] ---------------------------------------------------------- 'Report of error in coordinate transformation:' ------------------------------------------------------------------------ [unquote ' '] ADD FROM %work%%d%%entry_cov%.WAT Q STOP &end /* do when DOC exists end &else &do /* when DOC file doesn't exist tables DEF [translate %entry_cov%].DOC2 DOC_ITEM_VALU,80,C [unquote ' '] ADD none [date -ftag] [username] [date -ftag] %entry_cov% %work% %ext% %pre% %fda% %acs% %sgm% %pol% %pts% %tcs% %ann% %.doc$theme% %.doc$description% %.doc$contact% %.doc$contactinstr% %.doc$organization% %.doc$coverrev% %.doc$location% %.doc$resolution% %.doc$scale% %.doc$archive% %.doc$pubstatus% %.doc$citation1% %.doc$citation2% %.doc$citation3% %.doc$citation4% %.doc$citation5% [unquote ' '] /* /* End of entry to DOC file /* SEL %entry_cov%.NAR ADD 'Map Header Information from GIRAS file' ---------------------------------------------------------- [quote title: [unquote %title%]] [quote file creation date: [unquote %jda%]] [quote map type: [unquote %mtp%]] [quote projection: [unquote %mpj%]] [quote scale: 1:[unquote %msc%]] [quote source materials date: [unquote %mda%]] [quote number of map sections: [unquote %nsc%]] ---------------------------------------------------------- - 'Report of error in coordinate transformation:' ------------------------------------------------------------------------ [unquote ' '] ADD FROM %work%%d%%entry_cov%.WAT Q STOP &end /* do when not exists .DOC end &workspace %home% &messages &on &return /*****************************************************************************