/* $Id: autocontour.aml,v 1.2 1995/04/17 21:14:07 ian Exp $ /*-------------------------------------------------------------------------- /* Environmental Systems Research Institute, Inc. /*-------------------------------------------------------------------------- /* Program: AUTOCONTOUR.AML /* Purpose: Codes elevation contours by adding a temporary "dropline". /* /*-------------------------------------------------------------------------- /* Usage: autocontour INIT {'position'} /* Usage: autocontour /* /* Arguments: routine - name of the routine to be called. /* position - (quoted string) opening menu position. /* /* Routines: APPLY - Executes the BREAKLINE command. /* BAILOUT - Handles any errors from this tool. /* CHECK_ANGLE - Checks for a proper rotation angle. /* CHECK_OPTION - Checks the options choice for selecting /* the pivot point. /* EXIT - Cleans up after this tool. /* HELP - Displays help for this tool. /* INIT - Initializes this tool. /* USAGE - Displays usage for this tool. /* /* Globals: .autocontour$* /* /*-------------------------------------------------------------------------- /* Notes: Assumes the following: /* 1) the contour coverage is a line coverage that is not closed /* by a box /* 2) line topology is present /*-------------------------------------------------------------------------- /* History: Michael R. Muller 4/92 - Original coding /* Larry Young - 7/21/92 - made into an Arc/Tool /* 12/27/94 - Further toolization /* Mark Hoel - /04/17/95 - updated for ArcTools editor /*========================================================================== /* &args routine arglist:rest /* &severity &error &routine bailout /* /* Check arguments &if [NULL %routine%] &then &call usage &else &call %routine% &return /*------------------- &routine INIT /*------------------- /* /* HOEL - check to see that the ArcTools module is EDIT, if otherwise display /* a message box. /* &if [show subsystem] ne ARCEDIT &then &do &run msinform init 'This tool only runs in the Edit module.' &return &end /* /* HOEL - check for an edit coverage and if an AAT exists within. /* &if [null [show editcover]] OR [null [show items [show editcover] arc]] &then &do &r msinform init 'EDITCOVERAGE has not been set or contains no AAT table.' &return &end &if [show editfeature] <> ARC &then &do &r msinform init 'Editfeature must be arc to use this tool.' &return &end /* /* Make an item list by removing not usable items. /* HOEL - use ARCEDIT show functions as opposed to AML functions so the tool /* will work on the edited coverage. /* &s .autocontour$itemlist = [after [quote [show items [show editcover] arc]] ~ [translate [entryname [show editcover]]]#] &s .autocontour$itemlist = [unquote %.autocontour$itemlist%] &s .autocontour$temp_intersects = [show intersectarcs] &s .autocontour$temp_arctype = [show arctype] &if [show intersectarcs] <> ADD &then INTERSECTARCS ADD &if [show arctype] <> LINE &then ARCTYPE LINE &set .autocontour$start := 100 &set .autocontour$inter := 10 &set .autocontour$incrdir := + &set .autocontour$cover := [translate [show editcover]] &set .autocontour$symbolize = .true. /* /* And now for the menu. /* &s position = [quote [unquote %arglist%]] &set modality = [extract 2 [unquote %arglist%]] &s stripe = 'Contour Labeling' &if [null %position%] or %position%_ = #_ &then &set position = &below &thread at$pulldown &if [null %modality%] or %modality%_ = #_ &then &s mode &else &do &if [upcase %modality%] = MODAL &then &s mode = &modal &else &s mode &end &if [show &thread &depth] = 2 and [extract 1 [show &thread &stack]] = tty &then &s launch = &thread &delete &self &else &s launch &if [show &thread &exists edit$autocontour] &then &thread &delete edit$autocontour &thread &create edit$autocontour %mode% ~ &menu autocontour.menu ~ &position [unquote %position%] ~ &stripe [quote [unquote %stripe%]] ~ &pinaction '&run autocontour exit' %launch% &return /*------------ &routine RESET /*------------ /* /* Reset the SYMBOL pseudo item for each arc currently set to 2 to 1. /* SELECT $SYMBOL = 2 /* HOEL - check to see if any arcs are selected before calcing (error check). &if [show number selected] = 0 &then &do &sv .autocontour$msg = No arcs to reset &return &end CALCULATE $SYMBOL = 1 UNSEL ALL &return /*------------ &routine APPLY /*------------ /* /* Allow the user to enter the dropline. At the same time, begin a /* transaction so that we can remove the line that is added and all /* the intersections with a single OOPS. /* Scroll through each line segment that was created when the line was /* intersected with the contours, and save the coordinates of the /* intersections. /* Select the contours that were intersected one at a time, using the /* coordinates of the intersections from above. After each contour is /* selected, assign the elevation value. /* After selecting the contour that was intersected, do ASELECT CONNECTs /* until we have selected all of the contour lines that connect to our /* currently selected contour. When we have all of the arcs selected, /* assign the elevation value. /* &if [null %.autocontour$item%] &then &do &r msinform 'Please select an item to calculate.' &return &end &if [null %.autocontour$start%] or [null %.autocontour$inter%] &then &do &r msinform 'Please specify a Start value and interval.' &return &end &s type [extract 3 [iteminfo [show editcoverage] -arc %.autocontour$item%]] TRANSACTION BEGIN ADD ONE &set numint := [show number select] /* HOEL - Smartened message up, and removed call to exit routine. /* &if %numint% eq 0 &then &do &sv .autocontour$msg = No arcs in coverage or you aborted adding arc /* &call exit &return &inform &end CURSOR OPEN &set pt1 := [show arc [show select 1] vertex 2] &if %numint% gt 2 &then &do i = 2 &to [calc %numint% - 1] CURSOR NEXT &set pt%i% := [show arc [show select 1] vertex ~ [show arc [show select 1] npnts]] &end TRANSACTION END OOPS &set numint := %numint% - 1 &set eddist := [show editdistance] EDITDISTANCE .01 &set elev := %.autocontour$start% &do i = 1 &to %numint% &flushpoint &push 1,[value pt%i%] SELECT OUTLINE &if [show number select] ne 0 &then &do &set cursel := [show number select] ASELECT CONNECT &set newsel := [show number select] &do &while %cursel% ne %newsel% &set cursel := %newsel% ASEL CONNECT &set newsel := [show number select] &end &if %type% eq C &then MOVEITEM %elev% to %.autocontour$item% &else CALCULATE %.autocontour$item% = %elev% &if %.autocontour$symbolize% &then CALCULATE $symbol = 2 &set elev := %elev% %.autocontour$incrdir% %.autocontour$inter% &end &end EDITDISTANCE %eddist% UNSELECT ALL &sv .autocontour$msg Contours successfully coded. &return /*------------------- &routine HELP /*------------------- /* /* Help for AUTOCONTOUR menu. /* &run disp_help autocontour &return /*------------------- &routine USAGE /*------------------- /* /* Usage for AUTOCONTOUR menu. /* &type Usage: autocontour INIT {'''position'''} &type Usage: autocontour &return &inform /*------------------- &routine EXIT /*------------------- /* /* Exit AUTOCONTOUR menu. /* INTERSECTARCS %.autocontour$temp_intersects% ARCTYPE %.autocontour$temp_arctype% &dv .autocontour$* &if [show &thread &exists edit$autocontour] &then ~ &thread &delete edit$autocontour &return /*------------------- &routine BAILOUT /*------------------- /* /* In case of an error, fall into here. /* &severity &error &ignore &severity &warning &ignore TRANSACTION END &call exit &return &warning An error has occurred in routine: %routine% (AUTOCONTOUR.AML).