/*-------------------------------------------------------------------------- /* /* Command name: sdtsarc /* Version: 1.0 /* Language: AML /* Arc Version and Platform: 7.0.2 UNIX /* Subsystem: Arc /* /*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /* /* Purpose: To perform an Arc SDTSIMPORT command on a compressed (gzip) tar /* file created by the ARCSDTS command. The resultant coverage is /* restored to it's original form before the ARCSDTS command was /* issued on it. /* /*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /* /* Arguments: /* Variable name, Type, Definition /* ------------------------------------------------------------- /* infile input/char Name of tar file (uncompressed or compressed) /* containing SDTSEXPORT files to be converted /* into a coverage. /* outcov input/char Name of coverage to be created, optional, /* default is compressed tar prefix. /* /*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /* /* Programs or menus called: None /* /* Programs or menus called by: None /* /*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /* /* History: /* Author/Site, Date, Version Event /* ------------------------------------------------------------------------- /* mnegri 1/17/95 1.0 Original coding /* /*-------------------------------------------------------------------------- /* /* Disclaimer: /* Although this program has been used by the U.S. Geological Survey, no /* warranty, expressed or implied, is made by the USGS as to the accuracy /* and functioning of the program and related program material nor shall the /* fact of distribution constitute any such warranty, and no responsibility /* is assumed by the USGS in connection herewith. /* /*-------------------------------------------------------------------------- &args infile outcov /* Error trapping &if [null %infile%] &then &return Usage: SDTSARC {out_cover} &sv infile [locase %infile%] &if ^ [exists %infile% -file] &then &return %infile% does not exist. /* Check to see if infile is uncompressed or compressed tar file. &if [substr %infile% [calc [length %infile%] - 3] 4] ne .tar &then &do &if [length %infile%] < 8 &then &do &type %infile% is not a compressed (w/ .tar.gz suffix) &return or uncompressed tar file. &end &if [substr %infile% [calc [length %infile%] - 6] 7] ne .tar.gz &then &do &type %infile% is not a compressed (w/ .tar.gz suffix) &return or uncompressed tar file. &end &end &sv home [pathname [dir *]] &if [null %outcov%] &then &do &sv outcov [before [entryname %infile%] .tar] &sv outdir %home% &if [exists %outcov% -cover] &then &return Coverage %outcov% already exists. &end &else &do &if [exists %outcov% -cover] &then &return Coverage %outcov% already exists. &sv outdir [pathname [dir %outcov%]] &if ^ [exists %outdir% -directory] &then ~ &return Directory %outdir% does not exist. &sv outcov [entryname %outcov%] &sv useoutcov &end &if ^ [access %outdir% -write] &then ~ &return You do not have write access to %outdir% &mess &off &all &sv origecho [show &echo] &type Creating temporary directory to store SDTSEXPORT files... /* Create non-existent directory to "un-tar" ARCSDTS file, perform SDTSIMPORT, /* then project cover to original projection and switch DOC files if necessary. &sv done = .FALSE. &do count = 1 &repeat %count% + 1 &until %done% &if ^ [exists %outdir%/xxtempdir%count% -directory] &then &sv done = .TRUE. &end &sv tempdir %outdir%/xxtempdir%count% createworkspace %tempdir% &sv fullfile [pathname %infile%] &sv infile [entryname %infile%] &wo %tempdir% /* Uncompress tar file, "tar xvof" check adf files for original coverage info. &sv cpy [copy %fullfile% %infile% -file] &if %infile% cn '.gz' &then &sys gunzip %infile% &type Retrieving tar file in temporary directory... &type &sys tar xvof [before %infile% .gz] > /dev/null /* Run SDTSIMPORT, convert coverage back to original state if created with /* ARCSDTS. &if [exists arcsdts.adf -file] &then &do /* File created w/ ARCSDTS &type %fullfile% created with ARCSDTS command. &sv fileunit [open arcsdts.adf ostat -r] /* Determine cover type and name for SDTSIMPORT option needed. &sv covtype [read %fileunit% rstat] &sv covname [read %fileunit% rstat] &sv sdtspref [read %fileunit% rstat] &sv cerr [close %fileunit%] &if ^ [null %covname%] and ^ [variable useoutcov] &then &sv outcov %covname% &if [null %sdtspref%] &then &do &sys ls -1 > check.fil &sv fileunit [open check.fil ostat -r] &sv sdtspref [substr [read %fileunit% rstat] 1 4] &sv cerr [close %fileunit%] &end &select %covtype% &when point sdtsimport %sdtspref% box_cov %outcov% &when link sdtsimport %sdtspref% %outcov% xxtemp_p &otherwise sdtsimport %sdtspref% %outcov% &end &type Restoring coverage to original state, please wait... &if %covtype% eq line &then &do /* Remove polygon topology. &sv derr [delete %outcov%.PAT -info] tables sel %outcov%.AAT calc FNODE# = 0 calc TNODE# = 0 calc LPOLY# = 0 calc RPOLY# = 0 quit &if [exists %outcov%/pal.adf -file] &then ~ &sv derr [delete %outcov%/pal.adf -file] &if [exists %outcov%/pax.adf -file] &then ~ &sv derr [delete %outcov%/pax.adf -file] &if [exists %outcov%/pal -file] &then &sv derr [delete %outcov%/pal -file] &if [exists %outcov%/pax -file] &then &sv derr [delete %outcov%/pax -file] build %outcov% line &end &if %covtype% eq link &then &do /* Remove polygon topology, insert points back &if [extract 1 [show display]] ne 0 &then &do &sv origdisp [show display] display 0 1 0 &end arcedit create tempcov %outcov% &sv cpy [copy %outcov%.AAT tempcov.AAT -info] ef lines get %outcov% &sv cpy [copy xxtemp_p.PAT tempcov.PAT -info] ef points get xxtemp_p save quit additem TEMPCOV.AAT TEMPCOV.AAT TEMPCOV# 4 5 B # [translate %outcov%]# additem TEMPCOV.AAT TEMPCOV.AAT TEMPCOV-ID 4 5 B # [translate %outcov%]-ID tables sel TEMPCOV.AAT calc TEMPCOV# = [translate %outcov%]# calc TEMPCOV-ID = [translate %outcov%]-ID calc FNODE# = 0 calc TNODE# = 0 calc LPOLY# = 0 calc RPOLY# = 0 quit &if [exists %outcov%/pal.adf -file] &then ~ &sv derr [delete %outcov%/pal.adf -file] &if [exists %outcov%/pax.adf -file] &then ~ &sv derr [delete %outcov%/pax.adf -file] &if [exists %outcov%/pal -file] &then &sv derr [delete %outcov%/pal -file] &if [exists %outcov%/pax -file] &then &sv derr [delete %outcov%/pax -file] dropitem TEMPCOV.AAT TEMPCOV.AAT [translate %outcov%]# dropitem TEMPCOV.AAT TEMPCOV.AAT [translate %outcov%]-ID build tempcov line build tempcov point kill %outcov% all kill xxtemp_p all rename tempcov %outcov% &end &if [exists prj.adf -file] &then &do project cover %outcov% tempcov prj.adf &select %covtype% &when point build tempcov point &when link &do build tempcov point build tempcov line &end &when line build tempcov line &when net &do build tempcov line build tempcov poly &end &when poly build tempcov poly &end &type Copying documentation to projected coverage... &type &type If AML Error occurs the ARCSDTS DOCUMENT Rev. differs from &type your system's. Use DOCUMENT w/ UPDATE to modify where necessary. &severity &error &ignore &mess &on &if %covtype% eq point &then &do document tempcov copy box_cov &mess &off &all &echo &off &end &else document tempcov copy %outcov% &mess &off &all &type &echo &off &severity &error &fail &if [exists box_cov -cover] &then kill box_cov all kill %outcov% all rename tempcov %outcov% &end /* &if [exists prj.adf -file] &if %covtype% eq point and ^ [exists prj.adf -file] &then &do &type Copying documentation to projected coverage... &type &type If AML Error occurs the ARCSDTS DOCUMENT Rev. differs from &type your system's. Use DOCUMENT w/ UPDATE to modify where necessary. &severity &error &ignore &mess &on document %outcov% copy box_cov &mess &off &all &type &echo &off &severity &error &fail kill box_cov all &end &end &else &do /* File not created w/ ARCSDTS &type %fullfile% not created with ARCSDTS command... &sv nonarcsdts &sys ls -1 > check.fil &sv fileunit [open check.fil ostat -r] &sv i = 1 &do &until %rstat% = 102 &sv checkfil [read %fileunit% rstat] &if [substr %checkfil% 5 4] eq APNE &then &sv out_pnt &if %i% = 1 &then &sv sdtspref [substr %checkfil% 1 4] &sv i = %i% + 1 &end &sv cerr [close %fileunit%] &severity &error &ignore &if [variable out_pnt] &then &do &sv done = .FALSE. &do count = 1 &repeat %count% + 1 &until %done% &if ^ [exists %outdir%/pointcov%count% -cover] &then &sv done = .TRUE. &end &sv out_pnt pointcov%count% &type Trying to create %outcov% and %out_pnt% coverages with SDTSIMPORT... sdtsimport %sdtspref% %outcov% %out_pnt% &end &else &do &type Trying to create %outcov% coverages with SDTSIMPORT... sdtsimport %sdtspref% %outcov% &end &severity &error &fail &end &if [variable nonarcsdts] &then &do &if [exists %outcov% -cover] &then &do log %outcov% add SDTSARC %infile% %outcov% copy %outcov% %outdir%/%outcov% &type %outdir%/%outcov% successfully created. &end &else &do &sv unsuc &type Could not create %outcov%... &end &if [variable out_pnt] &then &do &if [exists %out_pnt% -cover] &then &do log %out_pnt% add SDTSARC %infile% %outcov% copy %out_pnt% %outdir%/%out_pnt% &type %outdir%/%out_pnt% successfully created. &end &else &type Could not create %out_pnt%... &end &end &else &do log %outcov% add SDTSARC %infile% %outcov% copy %outcov% %outdir%/%outcov% &type %outdir%/%outcov% successfully created. &end &wo %home% &if [exists %tempdir% -dir] &then &sv derr [delete %tempdir% -dir] &if ^ [variable unsuc] &then &do log * add SDTSARC %infile% %outcov% &end &if [variable origdisp] &then display %origdisp% &if [variable origecho] &then &echo %origecho% &type SDTSARC finished. &mess &on &return