/* watermask.aml /* /* Called by: watermask.menu /* Calls made: msg.menu /* /* Description: To produce correct topology of hydrology, where polygons /* are coded as either land or water. /* AML Setup /* --------- &args incover outcover first_polygon database_option &severity &warning &ignore &severity &error &routine BAILOUT &if [show &echo] eq &ON &then &messages &on &else &messages &off &all /* Prepare Covers /* -------------- /* Set counter for scratch covers &s n 0 /* Create working copy of input cover &s cover%n% [scratchname -prefix wm -directory] COPY %incover% [value cover%n%] /* Extract only arcs from working copy to scratch cover cover1 which is used /* in coding polygons &s cover[calc %n% + 1] [scratchname -prefix wm -directory] COPYFEATURES [value cover%n%] LINE [value cover[calc %n% + 1]] LINE ATTRIBUTES /* Drop polygon topology and label points from working cover if they exist &describe [value cover%n%] &if %dsc$polygons% > 0 &then DROPFEATURES [value cover%n%] POLY ATTRIBUTES &if %dsc$points% > 0 &then DROPFEATURES [value cover%n%] POINT GEOMETRY /* Begin splitting up procedure /* ---------------------------- /* Build polygon topology and createlabels for initial scratch cover cover1 BUILD [value cover[calc %n% + 1]] POLY CREATELABELS [value cover[calc %n% + 1]] 0 BUILD [value cover[calc %n% + 1]] POLY /* Start ARCEDIT ARCEDIT /* Repeat process until no more arcs are not part of the world polygon &do &until [show number select] = 0 /* Increment counter for scratch covers &s n [calc %n% + 1] /* Set editcover and edit feature to arcs EDITCOVER [value cover%n%] EDITFEATURE ARCS /* Select all arcs that are not part of the world polygon SELECT LPOLY# NE 1 AND RPOLY# NE 1 /* If arcs are selected then these are copied to the next scratch cover /* and are deleted from the current edit cover as they are not needed &if [show number select] > 0 &then &do /* Create next scratch cover and copy selected arcs &s cover[calc %n% + 1] [scratchname -prefix wm -directory] PUT [value cover[calc %n% + 1]] DELETE /* Quit ARCEDIT and save QUIT YES /* Build polygon topology and createlabels for the current scratch cover /* as well as the next scratch cover BUILD (![value cover%n%] [value cover[calc %n% + 1]]!) POLY CREATELABELS (![value cover%n%] [value cover[calc %n% + 1]]!) 0 BUILD (![value cover%n%] [value cover[calc %n% + 1]]!) POLY /* Start arcedit and code they label points in the current scratch cover ARCEDIT EDITCOVER [value cover%n%] &call CODE_LABELS &end /* then do &end /* do until /* If no more arcs are selected then code the label points in the current /* scratch cover &call CODE_LABELS QUIT YES /* Joining Scratch Covers Together /* ------------------------------ /* Create new scratch cover &s cover[calc %n% + 1] [scratchname -prefix wm -directory] /* Join all scratch covers together two at a time using the UPDATE command /* until none are left, and deleting the two scratch covers afterwards &do a = 1 &to %n% &by 1 &if [exists [value cover[calc %a% + 1]] -cover] &then &do UPDATE [value cover%a%] [value cover[calc %a% + 1]] ~ [value cover[calc %n% + 1]] KILL [value cover%a%] ALL KILL [value cover[calc %a% + 1]] ALL RENAME [value cover[calc %n% + 1]] [value cover[calc %a% + 1]] &end /* then do &else RENAME [value cover%a%] [value cover[calc %n% + 1]] &end /* do to by /* Create Outcover /* --------------- /* If conforming to GSC database standards, create PAT and add necessary items &if %database_option% &then &do BUILD %cover0% POINT ADDITEM %cover0%.PAT %cover0%.PAT HYD-SYM 4 4 I # ADDITEM %cover0%.PAT %cover0%.PAT HYD-PAT 4 4 I # ADDITEM %cover0%.PAT %cover0%.PAT HYD-LAYER 16 16 C # &end /* then do /* Copy coded labels from "new" scratch cover created above to working cover ARCEDIT EDITCOVER %cover0% EDITFEATURE LABELS GET [value cover[calc %n% + 1]] &if %database_option% &then &do SELECT %cover0%-ID = 1 &if [show number select] > 0 &then CALCULATE HYD-SYM = 1 NSELECT &if [show number select] > 0 &then CALCULATE HYD-SYM = 0 &end /* then do QUIT YES /* Build polygon topology BUILD %cover0% POLY /* Rename working copy to outcover RENAME %cover0% %outcover% /* Kill last scratch cover KILL [value cover[calc %n% + 1]] ALL /* Exit AML &s .gsc$cov [joinfile [show workspace] [locase %outcover%] -sub] &thread &focus &on &all &messages &on &return /* Routine CODE_LABELS /* &routine CODE_LABELS EDITFEATURE LABELS SELECT ALL &if %first_polygon% = WATER &then &do &if [mod %n% 2] = 0 &then /* code label as land CALCULATE [value cover%n%]-ID = 2 &else /* code label as water CALCULATE [value cover%n%]-ID = 1 &end /* then do &else &do /* first polygon is LAND &if [mod %n% 2] = 0 &then /* code label as water CALCULATE [value cover%n%]-ID = 1 &else /* code label as land CALCULATE [value cover%n%]-ID = 2 &end /* else do &return /* Routine BAILOUT /* /* This AML resets the severity, informs the user that the AML encountered an /* error and has crashed and returns program control to the calling level. /* &routine BAILOUT &severity &error &ignore /* lack of this line may cause an endless loop &messages &on &if [show program] eq ARCEDIT &then QUIT NO /* Kill any temporary covers &do a = 0 &to [calc %n% + 1] &by 1 &if [exists [value cover%a%] -cover] &then KILL [value cover%a%] ALL &end /* do to by &return; &return &error \Bailing out of AML - Error encountered!\