/* ------------------------------------------------------------------------- /* GIS Laboratory /* Division of Geological and Planetary Sciences /* Caltech /* ------------------------------------------------------------------------- /* Program : GMT_TO_ARC.AML /* Purpose : Read a GMT file containing X/Y line coordinates and produce a /* line coverage with the GMT attribute. /* ------------------------------------------------------------------------- /* Calls : init - file definition and initialization /* Called by: ARC prompt /* ------------------------------------------------------------------------- /* Arguments: in_file - path to file containing input data /* Globals : none /* ------------------------------------------------------------------------- /* Notes : The program runs from the ARC prompt and does the following: /* 1) reads a file containing X/Y coordinates and associated /* GMT attributes from an ascii file /* 2) constructs a line file and an attribute file /* 3) generates a line coverage from the line file /* 4) runs the BUILD function on the line file /* 5) creates an INFO file and adds the attribute data from /* the attribute file /* 6) joins the data to the .AAT file /* /* A sample of the datafile is as such: /* /* 9108645 7.0 34.5956 OCT 16 1999 -118.9 32.775 -114.4 35.8 /* > 10 contour /* -116.775 35.3775 10 /* -116.768 35.375 10 /* -116.75 35.3684 10 /* -116.725 35.3511 10 /* -116.724 35.35 10 /* > 20 contour /* : /* : /* : /* /* ------------------------------------------------------------------------- /* History : 10/18/99 - Tony Soeller; program created /* ========================================================================= &args in_file &severity &error &routine bailout &severity &warning &ignore &call init /* Bypass first (header) record &s dummy = [unquote [read %fileunit1% eof]] /* Loop through each line in the input data file extracting the longitude and /* latitude values and the desired attributes. Store the longitude and /* latitude values in one file and the line attribute in a second file. &s rec_no = 1 &do &while %eof% ne 102 &s vals = [unquote [read %fileunit1% eof]] &if %eof% eq 102 &then &goto the_end &s long = [extract 1 %vals%] &s lat = [extract 2 %vals%] &if [quote %long%] cn '>' &then &do &if %rec_no% ne 1 &then &s write_stat = [write %fileunit2% end] &s coord_record = %rec_no% &s write_stat = [write %fileunit2% %coord_record%] &s att_record = %rec_no%,%lat% &s write_stat = [write %fileunit3% %att_record%] &s rec_no = %rec_no% + 1 &end &else &do &s coord_record = %long%,%lat% &s write_stat = [write %fileunit2% %coord_record%] &end &end &label the_end /* Complete the line file &s write_stat = [write %fileunit2% end] &s write_stat = [write %fileunit2% end] /* Close the files &s closestat = [close -all] /* Define the path of the look-up table for INFO &s path = [path %att_file%] /* Generate, build, and add item to the line cover generate %cov_name% input %coor_file% line quit /* exit from GENERATE build %cov_name% line /* Create INFO table that will store the attribute data &data arc info arc define LINE.CODE [translate %cov_name%]-ID,4,5,B VALUE,16,16,N,7 add from %path% q stop &end /* Join the data from the "attribute table" to the .AAT joinitem %cov_name%.aat line.code %cov_name%.aat %cov_name%-id # linear /* Delete the LINE.CODE file &s delete_stat = [delete line.code -info] &s delete_stat = [delete %coor_file% -file] &s delete_stat = [delete %att_file% -file] &return gmt_to_arc.aml completed successfully. /**************************************************************************** &routine init /* Open the input data file &s fileunit1 = [open %in_file% open_status -r] &if %open_status% ne 0 &then &return Could not open file %in_file%. /* Check for existence of line coverage &s file_index = [index %in_file% .] &if %file_index% gt 0 &then &do &s file_index = %file_index% - 1 &s file_prefix = [substr %in_file% 1 %file_index%] &end &else &s file_prefix = %in_file% &if [exists %file_prefix% -cover] &then &return Program stopped: line coverage %file_prefix% already exists &s cov_name = %file_prefix% /* Assemble the current date as a string &s today = [translate [date -usa] _ /] /* Define the names of the coordinate and attribute files; delete if existant &s coor_file = coor.%today% &if [exists %coor_file% -file] &then &s delete_status [delete %coor_file% -file] &s att_file = att.%today% &if [exists %att_file% -file] &then &s delete_status [delete %att_file% -file] /* Open the INFO file where attributes will be stored &if [exists line.code -info] &then &s delete_stat = [delete line.code -info] /* Open the line file where coordinates will be stored &s fileunit2 = [open %coor_file% open_status -w] &if %open_status% ne 0 &then &return Could not open file %coor_file%. /* Open the attribute file where attributes will be stored &s fileunit3 = [open %att_file% open_status -w] &if %open_status% ne 0 &then &return Could not open file %att_file%. &return &routine BAILOUT &s ok [close -all] &return &inform Error condition in gmt_to_arc.aml