/* ------------------------------------------------------------------------- /* GIS Laboratory /* Geological and Planetary Sciences Division /* Caltech /* ------------------------------------------------------------------------- /* Program : LINE_ON_LINE.AML /* Purpose : Construct a point coverage wherein the points are at the /* intersections of arcs from two input line coverages. Move /* values from a specific attribute in the target line coverage /* to the new point coverage. /* ------------------------------------------------------------------------- /* Calls : init /* Called by: none /* ------------------------------------------------------------------------- /* Arguments: target_cov - line coverage that contains the attribute that /* is to be extracted /* inter_cov - line coverage that will be used to intersect the /* target coverage to yield intersecting points /* out_cov - point coverage that is to be generated /* target_item - item in the target cover whose values are to be /* extracted and added to the new point coverage /* Globals : none /* ------------------------------------------------------------------------- /* Notes : 1) use APPEND (notest) to append the two input coverages /* 2) open a temporary watch file /* 3) use INTERSECTARCERR to produce a report of the coordinates /* of the intersections of the two lines /* 4) extract the coordinates from the watch file and construct /* a generate file /* 5) use GENERATE to produce a point coverage of the /* intersections /* 6) add the target item to the point coverage /* 7) in Arcplot, step through all the points in the generated /* point coverage and select the arc from the associated /* target coverage; move the target item from the line cover /* to the point cover /* 8) remove temporary files /* ------------------------------------------------------------------------- /* History : 04/06/98 - Tony Soeller; program created /* ========================================================================= &args target_cov inter_cov out_cov target_item /*. &severity &error &routine run_away /* Check for valid coverages &call init /* Append the two input line coverages append %temp_cov% notest %target_cov% %inter_cov% end /* Open a watch file and produce a report of intersections &watch %temp_cov%.wat intersecterr %temp_cov% &watch &off /* Open the watch file and generate file &s fileunit1 = [open %temp_cov%.wat status -r] &if %status% ne 0 &then &return Error: not able to open intersection file %temp_cov%.wat &s fileunit2 = [open %temp_cov%.gen status -w] &if %status% ne 0 &then &return Error: not able to open generate file %temp_cov%.gen /* Extract the coordinates from the watch file; write to the gen file &s id = 100 &s string = [read %fileunit1% read_stat] &do &while %read_stat% ne 102 &if %string% cn '----------' &then &do &while %read_stat% ne 102 &s string = [read %fileunit1% read_stat] &s x_val = [extract 5 [unquote %string%]] &s y_val = [extract 6 [unquote %string%]] &if [type %x_val%] > -1 &then &s read_stat = 102 &else &do &s id = %id% + 1 &s rec = [quote %id%, %x_val%, %y_val%] &s write_stat = [write %fileunit2% %rec%] &end &end &else &s string = [read %fileunit1% read_stat] &end &s write_stat = [write %fileunit2% [quote end]] &s close_stat = [close -all] /* Generate the point coverage generate %out_cov% input %temp_cov%.gen points quit /* Get the characteristics of the target attribute and /* build and attribute the point coverage &s vals [iteminfo %target_cov% -line %target_item% -definition] &s size = [extract 1 %vals%] &s chars = [extract 2 %vals%] &s a_type = [extract 3 %vals%] &s decimals = [extract 4 %vals%] build %out_cov% point additem %out_cov%.pat %out_cov%.pat %target_item% %size% %chars% ~ %a_type% %decimals% /* Pay a visit to arcplot ap mape %out_cov% /* Step through each point in the /* point coverage and find its associated arc &describe %out_cov% &do i = 1 &to %dsc$points% clearsel resel %out_cov% point %out_cov%# = %i% resel %target_cov% line overlap %out_cov% point 0.2 passthru &if %a_type% eq C &then &do &s val = [show select %target_cov% line 1 item %target_item%] moveitem %out_cov% point [quote %val%] to %target_item% &end &else calc %out_cov% point %target_item% = ~ [show select %target_cov% line 1 item %target_item%] &end quit /* Delete the temporary coverages and files kill %temp_cov% all &s del_stat = [delete %temp_cov%.wat] &s del_stat = [delete %temp_cov%.gen] /* Re-open the resident watch file (if one existed) &if %watch_sw% &then &watch %watch_file% &append &return /**************************************************************************** /* Subroutine INIT /**************************************************************************** /* /* Check for proper input and existence of input coverages, lines, and item /* &routine init &if [show program] ne ARC &then &return Program stopped: line_on_line.aml must be run from the Arc: prompt &if [null %target_item%] &then &return Usage: &r line_in_line &if ^ [exists %target_cov% -cover] &then &return Program stopped: coverage [quote %target_cov%] does not exist &if ^ [exists %inter_cov% -cover] &then &return Program stopped: coverage [quote %inter_cov%] does not exist &if [exists %out_cov% -cover] &then &return Program stopped: coverage [quote %out_cov%] already exists &if [exists %out_cov% -file] &then &return Program stopped: [quote %out_cov%] is currently the name of a file &s temp_cov = xx_%out_cov% &if [exists %temp_cov% -cover] &then &return Program stopped: temporary coverage [quote %temp_cov%] already exists &if [exists %temp_cov% -file] &then &return Program stopped: temporary coverage [quote %temp_cov%] exists as a file &describe %target_cov% &if %dsc$arcs% < 1 &then &return Program stopped: coverage [quote %target_cov%] has no arcs &describe %inter_cov% &if %dsc$arcs% < 1 &then &return Program stopped: coverage [quote %inter_cov%] has no arcs &s target_attr = [show columns info %target_cov%.aat] &if ^ [locase %target_attr%] cn [locase %target_item%] &then &return Program stopped: item %target_item% was not found in %target_cov% /* If there is a watch file open, get its name and close it; re-open later &s watch_sw = .false. &s watch_file = [show &watch] &if %watch_file% ne &OFF &then &do &s watch_sw = .true. &watch &off &end &return /**************************************************************************** /* Subroutine RUN_AWAY /**************************************************************************** &routine run_away &s ok [close -all] &return &inform Error condition in routine line_on_line.aml