/* project_headers.aml /* written as 1.0 9:30 AM 3 September 1998 DEC &s tool := project_headers /* create listing of all *.HDR files in the current directory &if [exists header.lis -file] &then &s dok [delete header.lis -file] &s lok [filelist *.hdr header.lis -file] &if %lok% < -1 &then &return &warning %tool%: error: too many HDR files &if %lok% < 0 &then &return &warning %tool%: error: could not create HDR filelist &if %lok% < 1 &then &return &warning %tool%: error: no HDR files found &type %tool%: %lok% header files found ... &s cnt %lok% /* be sure all the new *.HDR files will be saved somewhere else &s pwd [show &workspace] &if ^ [exists nad27 -dir] &then createworkspace nad27 /* loop through all *.HDR files in the current directory &if [exists coordin.dat -file] &then &s dok [delete coordin.dat -file] &s unit1 [open header.lis ook -r] &if %ook% ^= 0 &then &return &warning %tool%: could not open HDR filelist &s unit2 [open coordin.dat ook -w] &if %ook% ^= 0 &then &return &warning %tool%: could not open coordinate list &do n := 1 &to %cnt% &by 1 &s infile [read %unit1% rok] &if %rok% ^= 0 &then &type %tool%: error: can not read HDR filelist &s unit3 [open %infile% ook -r] &if %ook% ^= 0 &then &do &type %tool%: error: could not open file %infile% &s ulxmap -99999 &s ulymap -99999 &end &else &do &s done .false. &do &until %done% &s string [locase [read %unit3% rok]] &if %rok% ^= 0 &then &s done .true. &else &do &if [index %string% ulymap] ^= 0 &then &s ulymap [trim [after %string% ulymap]] &if [index %string% ulxmap] ^= 0 &then &s ulxmap [trim [after %string% ulxmap]] &end &end &end &s cok [close %unit3%] &if ^ [variable ulymap] &then &s ulymap -99999 &if ^ [variable ulxmap] &then &s ulxmap -99999 &if %ulymap% = -99999 | %ulxmap% = -99999 &then &s file%n% .false. &else &s file%n% .true. &if [value file%n%] &then &s wok [write %unit2% %ulxmap%' '%ulymap%] &if %wok% ^= 0 &then &type %tool%: error: can not write to coordinate list &dv ulxmap &dv ulymap &end &s cok [close %unit2%] &s cok [close %unit1%] /* project the coordinate file (contains X,Y for all *.HDR files) /****** if your headers are moving from one coordinate system and datum ****** /****** to another, here is the place where you define ALL projection ****** /****** parameters for both the INPUT and OUTPUT coordinates ****** &if [exists coordout.dat -file] &then &s dok [delete coordout.dat -file] project file coordin.dat coordout.dat INPUT PROJECTION UTM ZONE 10 UNITS METERS DATUM NAD83 SPHEROID GRS80 PARAMETERS OUTPUT PROJECTION UTM ZONE 10 UNITS METERS DATUM NAD27 SPHEROID CLARKE1866 PARAMETERS END &if [exists coordout.prj -file] &then &s dok [delete coordout.prj -file] /* recreate new headers by looping through all *.HDR files &s unit4 [open header.lis ook -r] &if %ook% ^= 0 &then &return &warning %tool%: error: could not open HDR filelist &s unit5 [open coordout.dat ook -r] &if %ook% ^= 0 &then &return &warning %tool%: error: could not open reprojected coordinate list &s good := 0 &do n := 1 &to %cnt% &by 1 &s infile [read %unit4% rok] &if %rok% ^= 0 &then &type %tool%: error: could not read HDR filelist &if [value file%n%] = .false. &then &type %tool%: error: could not reproject %infile% &else &do &s good [calc %good% + 1] &s unit6 [open %infile% ook -r] &if %ook% ^= 0 &then &return &warning %tool%: error: could not open old HDR file &s unit7 [open %pwd%/nad27/%infile% ook -w] &if %ook% ^= 0 &then &return &warning %tool%: error: could not open new HDR file &s newcoords [trim [read %unit5% rok]] &if %rok% ^= 0 &then &type %tool%: error: could not read reprojected coordinates &s ulymap [trim [after %newcoords% ' ']] &s ulxmap [trim [before %newcoords% ' ']] &s done .false. &do &until %done% &s string [quote [locase [read %unit6% rok]]] &if %rok% ^= 0 &then &s done .true. &else &do &if [index %string% ulymap] ^= 0 &then &s string [quote 'ulymap '%ulymap%] &if [index %string% ulxmap] ^= 0 &then &s string [quote 'ulxmap '%ulxmap%] &s wok [write %unit7% [unquote %string%]] &if %wok% ^= 0 &then &type %tool%: error: could not write new HDR file record &end &end &s cok [close %unit7%] &s cok [close %unit6%] &end &end &s cok [close %unit5%] &s cok [close %unit4%] &if [exists coordin.dat -file] &then &s dok [delete coordin.dat -file] &if [exists coordout.dat -file] &then &s dok [delete coordout.dat -file] &if [exists header.lis -file] &then &s dok [delete header.lis -file] &return &inform \%tool%: %good% header file reprojected