&type pr -f -w80 */source* | lp -dhp4si
&type ----------------------------------------------------------------------------
/* Housekeeping: identify user, set file names
&sv User [translate [substr [username] 1 1]][substr [username] 2 [calc [length [username]] - 1]]
&type Closing all open files:
&sv close = [close -all]
&sv html_dir = /hri/db/cover/catalog
&sv tempcatfile = %html_dir%/catlis.htm
&sv prov = /hri/db/cover/s-africa/spr_500
/* date in ISO format
&sv ISOdate = [date -year]-[substr[date -usa] 1 2]-[substr[date -vmsdate] 1 2] - [before[date -vmstime] .]
/* Create the main HTML index file:
&sv TxtF = [open %tempcatfile% OpenStatus -write]
&sv wtf [write %TxtF% [quote ]]
&sv wtf [write %TxtF% [quote ]]
&sv wtf [write %TxtF% [quote IWQS GIS coverage catalogue]]
&sv wtf [write %TxtF% [quote Geographic Information Systems Coverages at the Institute for Water Quality Studies
]]
&sv wtf [write %TxtF% [quote Created by user %User% with catalog.aml on %ISOdate%
]]
&sv wtf [write %TxtF% [quote
]]
&sv wtf [write %TxtF% [quote
Some form of copyright exists for most of these coverages, and we only intend them for use within the Department of Water and Sanitation.]]
&sv wtf [write %TxtF% [quote
]]
&sv wtf [write %TxtF% [quote
Please click on an underlined file name to list its metadata.]]
&if [null %dir%] | [quote %dir%] = # | [quote %dir%] = . &then
&sv dir = [show workspace]
&if [null %Graphics%] &then
&sv Graphics = C
&else
&do
&if [locase [substr [quote %Graphics%] 1 1]] = 'g' &then &sv Graphics = G
&if [locase [substr [quote %Graphics%] 1 1]] = 'c' &then &sv Graphics = C
&if %Graphics% <> G and %Graphics% <> C &then &sv Graphics N
&end
/* Find out whether this is a single coverage, or a directory.
/* If a directory, how many coverages exist in the directory?
&if [exists %dir% -cover] &then
&do
&type Processing the single coverage %dir%:
&sv Single = .true.
&sv nCovers = 1
&sv LastCov = 1
&end
&else
&do
&type Now making catalogue of data in %dir%
&sv Single = .false.
&if [exists tempcatlist -file] &then &sys \rm tempcatlist
&sv nCovers = [filelist %dir% tempcatlist -FULL -cover -all]
&sv CovF = [open tempcatlist OpenStatus -read]
/* Generate HTML table of coverage names with two coverage names per line:
&sv wtf [write %TxtF% [quote ]]
&sv StartLine = .true.
&do nCov = 1 &to %nCovers%
&sv cover = [read %CovF% ReadStatus]
&if %StartLine% &then &sv wtf [write %TxtF% [quote ]]
&sv wtf ~
[write %TxtF% ~
[quote %nCov% | %dir%/[entryname %cover%] | ]]
&if %StartLine% &then &sv StartLine = .false.
&else
&do
&sv wtf [write %TxtF% [quote
]]
&sv StartLine = .true.
&end
&end
&if ^ %StartLine% &then
&do
&sv wtf [write %TxtF% [quote ]]
&sv StartLine = .true.
&end
&sv wtf [write %TxtF% [quote
]]
&sv CloseCovF = [close %CovF%]
&sv CovF = [open tempcatlist OpenStatus -read]
&type %nCovers% coverages found in %dir%
&if [null %LastCov%] &then &sv LastCov = %nCovers%
&else
&if %LastCov% > %nCovers% &then &sv LastCov = %nCovers%
&sv nCovSel = ( %LastCov% )
&if %nCovers% < 1 &then &stop No coverages found in %dir%.
&end
/* Type confirmation details:
&type Date: %ISOdate%
&type AML: %AML$FULLFILE%
&type Username [username]
&type Directory: %dir%
&type nCovSel: %nCovSel%
&type LastCov: %LastCov%
&type tempcatfile: %tempcatfile%
&type Graphics: %Graphics%
&if [exists /prjws8/users/michael/script/whatami -file] &then
&sys /prjws8/users/michael/script/whatami
&do nCov = 1 &to %LastCov%
&if %Single% &then
&sv cover = %dir%
&else
&sv cover = [read %CovF% ReadStatus]
&sv covernd = [calc [length %cover%] - 1]
&sv coverfile = %cover%
/* Store standard Arc/Info data about the coverage in a file for later use:
&if [exists describe.tmp -file] &then &sv deldesc [delete describe.tmp -file]
listoutput describe.tmp
describe %cover%
listoutput screen
&sv source_html %html_dir%/[entryname %cover%].htm
&sv SorF [open %source_html% OpenStatus -write]
&type HTML file = %source_html% with open status %OpenStatus%
&if [exists tempdesc.tmp -file] &then &sv ddes [delete tempdesc.tmp -file]
&sv wtf [write %SorF% [quote ]]
&sv wtf [write %SorF% [quote ]]
&sv wtf [write %SorF% [quote IWQS GIS coverage [entryname %cover%]]]
&sv wtf [write %SorF% [quote ]]
&sv wtf [write %SorF% [quote ]]
&sv wtf [write %SorF% [quote
]]
&if [exists %cover%/source -file] &then
&do
&sv Close_SorF [close %SorF%]
&sys echo '' >> %source_html%
&sys nawk -f /prjws8/users/michael/data/sour2desc.awk %cover%/source >> %source_html%
&sys echo '
' >> %source_html%
&sv SorF [open %source_html% OpenStatus -append]
&end
&sv wtf [write %SorF% [quote
]]
&call DateStampDir
&sv cov [substr [entryname %cover%] 1 3]
&sv er [substr [entryname %cover%] 4 [calc [length [entryname %cover%]] - 3]]
&sv wtf [write %SorF% [quote (%nCov%) %dir%/%cov%%er%
]]
&type %dir%
&sv wtf [write %SorF% [quote Institute for Water Quality Studies metadata.
] ]
&sv ISOdate = [date -year]-[substr[date -usa] 1 2]-[substr[date -vmsdate] 1 2] - [before[date -vmstime] .]
&sv wtf [write %SorF% [quote Summary created by user %User% with catalog.aml on %ISOdate%]]
&type File owner: %owner%, datestamp: %date%
&sv wtf [write %SorF% [quote
File owner: %owner%, last modified: %date%]]
ArcPlot
display 1040
tempcatalog
&type -tempcatalog
mapextent %cover%
shadeset color
pageunits cm
textset font
textsymbol 1
&call MapFrame
&if ^ [exists %cover%/source] and ^ [exists %cover%/source.adf] &then
&do
&type No source file for %cover%
&sv wtf [write %SorF% 'No metadata file (source) available.']
&if [exists sources/[entryname %cover%] -file] &then
&do
&type Retrieving sources/[entryname %cover%] into %cover%/source:
&sys cp sources/[entryname %cover%] %cover%/source
&end
&end
&sv ctf [close %SorF%]
&sys echo 'Projection information (see end of this page for details)
' >> %source_html%
&sys grep -i projection describe.tmp >> %source_html%
&sys echo '
' >> %source_html%
&sys grep -i spheroid describe.tmp >> %source_html%
&sys echo '
' >> %source_html%
&if [exists %cover%/source] &then
&sys nawk -f /prjws8/users/michael/data/sour2htm.awk %cover%/source >> %source_html%
&if [exists %cover%/source.adf] &then
&sys nawk -f /prjws8/users/michael/data/sour2htm.awk %cover%/source.adf >> %source_html%
&sv SorF = [open %source_html% OpenStatus -append]
&sv wtf [write %SorF% [quote ]]
&sv wtf [write %SorF% [quote
]]
&echo &on /*Debug Bailing out of ARCPLOT
&call FeatureTypeTable
quit
&echo &off /*Debug Bailing out of ARCPLOT
&call ThumbNailMap
&sv ctf [close %SorF%]
&sys echo '
' >> %source_html%
&sys echo '
Map specifications:' >> %source_html%
&sys echo '' >> %source_html%
&sys cat describe.tmp >> %source_html%
&sys echo '
' >> %source_html%
&sys echo ' ' >> %source_html%
&end
&sv wtf [write %TxtF% [quote ]]
&sv cTxtF [close %TxtF%]
&sv ISOdate = [date -year]-[substr[date -usa] 1 2]-[substr[date -vmsdate] 1 2] - [before[date -vmstime] .]
&type Completed %AML$FULLFILE% at %ISOdate%
&if [exists tempcatlist -file] &then &sys \rm tempcatlist
&if [exists tempcatalog.gra -file] &then &sys \rm tempcatalog.gra
&return
/*------------------------------------------------------------------------------
&routine SizePage
&sv page_x = [calc [extract 3 [show mapextent]] - [extract 1 [show mapextent]] ]
&sv page_y = [calc [extract 4 [show mapextent]] - [extract 2 [show mapextent]] ]
&sv page_max = [max %page_x% %page_y%]
&sv xp = [calc 100 * ( %page_x% / %page_max% ) ]
&sv yp = [calc 100 * ( %page_y% / %page_max% ) ]
&sv xm = 0.1
&sv ym = 0.1
&return
/*------------------------------------------------------------------------------
&routine DateStampFile
&if [exists tempdirlist -file] &then &sys \rm tempdirlist
&if [exists %coverfile% -file] &then
&do
&sys \ls -l %coverfile% > tempdirlist
&sys \cat tempdirlist
&sv CovI = [open tempdirlist OpenStatus -read]
&sv di = [unquote [read %CovI% ReadStatus]]
&sv close = [close %CovI%]
&type %di%
&sv owner = [extract 3 %di%]
/*&sv size = [calc [extract 4 %di%] / 1024]
&sv size = [calc [extract 5 %di%] / 1024]
&if %size% < 1 &then &sv filsiz = 1k
&else &sv filsiz = [round %size%]k
/*&sv td = [extract 7 %di%]
&sv td = [extract 8 %di%]
&if [quote [substr %td% 3 1]] = ':' &then
/*&sv date = [extract 6 %di%] [extract 5 %di%] (less than 1yr ago)
&sv date = [extract 7 %di%] [extract 6 %di%] (less than 1yr ago)
&else
/*&sv date = [extract 6 %di%] [extract 5 %di%] [extract 7 %di%]
&sv date = [extract 7 %di%] [extract 6 %di%] [extract 8 %di%]
&end
&else
&do
&sv date = ?
&sv owner = ?
&sv filsiz = ?
&sv close = [close %CovI%]
&end
&return
/*------------------------------------------------------------------------------
&routine DateStampDir
&if [exists tempdirlist -file] &then &sys \rm tempdirlist
&sys ls -ld %coverfile% > tempdirlist
&sys cat tempdirlist
&sv CovI = [open tempdirlist OpenStatus -read]
&if %OpenStatus% = 0 &then
&do
&sv di = [unquote [read %CovI% ReadStatus]]
&sv close = [close %CovI%]
&type %di%
&sv owner = [extract 3 %di%]
/*&sv td = [extract 7 %di%]
&sv td = [extract 8 %di%]
&if [quote [substr %td% 3 1]] = ':' &then
/*&sv date = [extract 6 %di%] [extract 5 %di%] (less than 1yr ago)
&sv date = [extract 7 %di%] [extract 6 %di%] (less than 1yr ago)
&else
/*&sv date = [extract 6 %di%] [extract 5 %di%] [extract 7 %di%]
&sv date = [extract 7 %di%] [extract 6 %di%] [extract 8 %di%]
&end
&else
&do
&sv date = ?
&sv owner = ?
&type File error %OpenStatus% on tempdirlist: date = %date%
&sv close = [close %CovI%]
&end
&return
/*------------------------------------------------------------------------------
&routine FeatureTypeTable
/* Tabulate the feature types:
&do type &list Annotation Arc Point Polygon
&if [exists %cover% -%type%] &then
&do
&if %type% = Annotation &then &sv fil = txt
&if %type% = Arc &then &sv fil = aat
&if %type% = Point &then &sv fil = pat
&if %type% = Polygon &then &sv fil = pat
&sv coverfile = %cover%/%fil%
&call DateStampFile
&if %type% = Annotation &then
&do
&sv wtf [write %SorF% [quote
%type% items, %filsiz%byte:]]
&sv wtf [write %SorF% [quote
%date%, %owner%:]]
&end
&else
&do
&sv wtf [write %SorF% [quote
%type% items, %filsiz%byte:]]
&sv wtf [write %SorF% [quote
%date%, %owner%:]]
&sv items [listitem %cover% -%type% -all -all tempitem.lis]
&sys cat tempitem.lis
&if %items% > 1 &then &type checking %items% INFO items
&sv wtf [write %SorF% [quote
%items% data fields]]
&sv InfF = [open tempitem.lis OpenStatus -read]
&sv wtf [write %SorF% [quote ]]
&sv wtf [write %SorF% [quote ITEM | EXAMPLES | WIDTH | TYPE | REDEFINED? | INDEXED? |
]]
&if %items% > 0 &then
&do ItIn = 1 &to %items%
&sv itemName = [read %InfF% ReadStatus]
&sv itemDefn = [iteminfo %cover% -%type% %itemName% -definition]
&if [iteminfo %cover% -%type% %itemName% -redefined] &then &sv itemRedf = (ReDefined)
&else &sv itemRedf = [unquote '']
&if [iteminfo %cover% -%type% %itemName% -indexed] &then &sv itemIndx = (Indexed)
&else &sv itemIndx = [unquote '']
&sv fieldwidth = [extract 1 %itemDefn%]
&sv fieldtype = [extract 3 %itemDefn%]
&if %fieldtype% = B &then &sv fieldtype = binary
&if %fieldtype% = C &then &sv fieldtype = character
&if %fieldtype% = F &then &sv fieldtype = floatpnt
&if %fieldtype% = I &then &sv fieldtype = integer
&if %fieldtype% = N &then &sv fieldtype = numeric
&sv fielddecs = [extract 4 %itemDefn%]
&if %fieldtype% = character &then
&do
&sv eg = [unquote '-']
clearselect %cover% %type%
reselect %cover% %type% %itemName% ne ''
&sv nSelItm = [extract 1 [show select %cover% %type%]]
&if %nSelItm% > 0 &then
&do
&sv eg = [quote [show select %cover% %type% 1 item %itemName%]]
&sv eg = [quote [subst %eg% '[' '(' ]]
&sv eg = [subst %eg% ']' ')' ]
&sv eg = [unquote %eg% ]
&end
&sv wtf [write %SorF% [quote %itemName% | %eg% | %fieldwidth% | %fieldtype% | %itemRedf% | %itemIndx% |
]]
&end
&else
&do
&sv eg = 0
clearselect %cover% %type%
reselect %cover% %type% %itemName% > 0
&sv nSelItm = [extract 1 [show select %cover% %type%]]
&if %nSelItm% > 0 &then
&do
&sv eg = [quote [show select %cover% %type% 1 item %itemName%]]
&sv eg = [quote [subst %eg% '[' '(' ]]
&sv eg = [subst %eg% ']' ')' ]
&sv eg = [unquote %eg% ]
&end
&sv wtf [write %SorF% [quote %itemName% | %eg% | %fieldwidth%.%fielddecs% | %fieldtype% | %itemRedf% | %itemIndx% |
]]
&end
&end
&sv closeinf = [close %InfF%]
&sv wtf [write %SorF% [quote
]]
&sv wtf [write %SorF% [quote
]]
&end
&end
&end
&return
/*------------------------------------------------------------------------------
&routine ThumbNailMap
&sv cov_jpg = %html_dir%/[entryname %cover%].jpg
&sv cov_jgw = %html_dir%/[entryname %cover%].jgw
&if %Graphics% = G and [exists %cov_jpg% -file] &then &sv djpg [delete %cov_jpg% -file]
&if %Graphics% = N or ( %Graphics% = C and [exists %cov_jpg% -file] ) &then
&type Not creating graphic
&else
&do
ArcPlot
display 1040
tempcatalog
&type -tempcatalog
mapextent %cover%
shadeset color
textset font
textsymbol 1
markerset mineral
mapposition cen cen
mapextent %cover%
clipmapextent off
&sv page_x = [calc [extract 3 [show mapextent]] - [extract 1 [show mapextent]] ]
&sv page_y = [calc [extract 4 [show mapextent]] - [extract 2 [show mapextent]] ]
&sv page_max = [max %page_x% %page_y%]
&sv xp = [calc 10 * ( %page_x% / %page_max% ) ]
&sv yp = [calc 10 * ( %page_y% / %page_max% ) ]
&sv disp_max = [max %xp% %yp%]
&sv disp_scale = [calc 256 / %disp_max%]
&sv disp_x = [round [calc %disp_scale% * %xp%] ]
&sv disp_y = [round [calc %disp_scale% * %yp%] ]
display 9999 size %disp_x% %disp_y%
pagesize %xp% %yp%
mapposition cen cen
mapextent %cover%
clipmapextent off
&type maplimits 0 0 %xp% %yp%
maplimits 0 0 %xp% %yp%
shadesymbol 14
shadecolor gray90
shadeput 14
linesymbol 1
box [show maplimits]
/*patch [show maplimits]
&if [exists %cover%/prj] or [exists %cover%/prj.adf] &then
&do
mapprojection AUTO %cover%
clearselect %prov% poly
reselect %prov% poly name = 'SEA'
polygonshade %prov% 5
&end
clearselect
&severity &error &ignore
&if [exists %cover% -arc] or [exists %cover% -polygon] or ~
[exists %cover%/arc -file] or [exists %cover%/arc.adf -file] ~
&then
arcs %cover%
&else
pointmarkers %cover% 323
&severity &error &fail
&if [exists tempras -file] &then &sv dt [delete tempras -file]
&if [exists temprasw -file] &then &sv dt [delete temprasw -file]
screensave tempras
quit
&type Converting graphics file %nCov% into JPG...
&if [exists %cov_jpg% -file] &then &sv deljpg [delete %cov_jpg% -file]
&if [exists %cov_jgw% -file] &then &sv deljgw [delete %cov_jgw% -file]
convertimage tempras %cov_jpg% jfif
&end
&return
/*------------------------------------------------------------------------------
&routine JPGpage
arcplot
&sv disp_max = [max %xp% %yp%]
&sv disp_scale = [calc 256 / %disp_max%]
&sv disp_x = [round [calc %disp_scale% * %xp%] ]
&sv disp_y = [round [calc %disp_scale% * %yp%] ]
display 9999 size %disp_x% %disp_y%
pageunits cm
pagesize %xp% %yp%
plot tempcatalog box 0 0 %xp% %yp%
quit
&return
/*------------------------------------------------------------------------------
&routine MapFrame
/* Set up a neat frame for the thumbnail map:
mapextent %cover%
&sv xm1 = [extract 1 [show mapextent] ,]
&sv ym1 = [extract 2 [show mapextent] ,]
&sv xm2 = [extract 3 [show mapextent] ,]
&sv ym2 = [extract 4 [show mapextent] ,]
/* Round off coordinates to nearest metre, or nearest 1/1000 of a degree:
&if [abs %xm1%] < 999 &then
&sv xm1 [calc [round [calc 1000 * %xm1%]] / 1000]
&else
&sv xm1 [round %xm1% ]
&if [abs %ym1%] < 999 &then
&sv ym1 [calc [round [calc 1000 * %ym1%]] / 1000]
&else
&sv ym1 [round %ym1% ]
&if [abs %xm2%] < 999 &then
&sv xm2 [calc [round [calc 1000 * %xm2%]] / 1000]
&else
&sv xm2 [round %xm2% ]
&if [abs %ym2%] < 999 &then
&sv ym2 [calc [round [calc 1000 * %ym2%]] / 1000]
&else
&sv ym2 [round %ym2% ]
&sv %xm1% = [unquote '']
&sv %xm2% = [unquote '']
&sv %ym1% = [unquote '']
&sv %ym2% = [unquote '']
&if %xm1% < 0 &then &sv xm1s W
&if %xm1% > 0 &then &sv xm1s E
&if %xm2% < 0 &then &sv xm2s W
&if %xm2% > 0 &then &sv xm2s E
&if %ym1% < 0 &then &sv ym1s S
&if %ym1% > 0 &then &sv ym1s N
&if %ym2% < 0 &then &sv ym2s S
&if %ym2% > 0 &then &sv ym2s N
clipmapextent off
&type (%nCov%) %cover% map extents:
&type %ym2%
&type '|'
&type '|'
&type '|'
&type %ym1%
&type . %xm1% ------- %xm2%
&sv wtf [write %SorF% [quote
Map extent:]]
&sv wtf [write %SorF% [quote ]]
&sv wtf [write %SorF% [quote | %xm1%%xm1s% | . | %xm2%%xm2s% |
]]
&sv wtf [write %SorF% [quote %ym2%%ym2s% | - |  | - | %ym2%%ym2s% |
]]
&sv wtf [write %SorF% [quote %ym1%%ym1s% | . | . | . | %ym1%%ym1s% |
]]
&sv wtf [write %SorF% [quote | %xm1%%xm1s% | . | %xm2%%xm2s% |
]]
&sv wtf [write %SorF% [quote
]]
&sv ctf [close %SorF%]
&return