/* ------------------------------------------------------------------------- /* GIS Laboratory /* Division of Geological and Planetary Sciences /* Caltech /* ------------------------------------------------------------------------- /* Program : DLG-RD-COV_TO_GMT.AML /* Purpose : Read road arcs and attributes from the DLG coverage and /* write the coordinates of specific road features out to /* a series of files that can be read by GMT. /* ------------------------------------------------------------------------- /* Calls : none /* Called by: none /* ------------------------------------------------------------------------- /* Arguments: cov - the name of the DLG coverage which contains the /* road arcs /* Globals : none /* ------------------------------------------------------------------------- /* Notes : This program writes arcs out to five files: /* dlg_prim.xy (source: Minor1 0201 to 0204) /* dlg_sec.xy (source: Minor1 0205 to 0208) /* dlg_road.xy (source: Minor1 0209 to 0210) /* dlg_trl.xy (source: Minor1 0211 to 0212) /* dlg_othr.xy (source: Minor1 0213 to 0222) /* /* DLG Class Codes (Major1,Minor1) for Roads /* Major1 Minor1 Description /* 170 0201 Primary route, class 1, symbol undivided /* 0202 Primary route, class 1, symbol divided by /* centerline /* 0203 Primary route, class 1, divided, /* lanes separated /* 0204 Primary route, class 1, one way, other /* than divided highway /* 0205 Secondary route, class 2, symbol undivided /* 0206 Secondary route, class 2, symbol divided /* by centerline /* 0207 Secondary route, class 2, symbol divided, /* lanes separated /* 0208 Secondary route, class 2, one way, other /* then divided highway /* 0209 Road or street, class 3 /* 0210 Road or street, class 4 /* 0211 Trail, class 5, other than four-wheel /* drive vehicle /* 0212 Trail, class 5, four-wheel-drive vehicle /* 0213 Footbridge /* 0214 Ferry crossing /* 0215 Perimeter of parking area /* 0216 Arbitrary extension of line (join or closure) /* 0217 Road or street, class 3, symbol and trails /* divided by centerline /* 0218 Road or street, class 3, divided lanes /* separated /* 0221 Road in street, class 3, one way /* 0222 Road in transition /* /* ------------------------------------------------------------------------- /* History : 04/06/98 - Tony Soeller; program created /* ========================================================================= &args cov /*. &s amlname = dlg_to_gmt.aml &severity &error &routine run_away &if [null %cov%] &then &return &inform Usage: &r dlg-rd_cov_to_gmt /* Set up environment &if [show program] ne ARCEDIT &then ARCEDIT &if ^ [exists %cov% -cover] &then &do &type Coverage %cov% does not exist. Terminating... &return &end editc %cov% ef arc /* Define the selection set for "Primary routes" &s file_name = dlg_prim sel all resel major1 = 170 and minor1 = 201 asel major1 = 170 and minor1 = 202 asel major1 = 170 and minor1 = 203 asel major1 = 170 and minor1 = 204 asel major1 = 173 /* U.S. Route number &call arc_extract /* Define the selection set for "Secondary routes" &s file_name = dlg_sec sel all resel major1 = 170 and minor1 = 205 asel major1 = 170 and minor1 = 206 asel major1 = 170 and minor1 = 207 asel major1 = 170 and minor1 = 208 &call arc_extract /* Define the selection set for "Roads or Streets" &s file_name = dlg_road sel all resel major1 = 170 and minor1 = 209 asel major1 = 170 and minor1 = 210 asel major1 = 179 /* coincident features &call arc_extract /* Define the selection set for "Trails" &s file_name = dlg_trl sel all resel major1 = 170 and minor1 = 211 asel major1 = 170 and minor1 = 212 &call arc_extract /* Define the selection set for "Other Roads" &s file_name = dlg_othr sel all resel major1 = 170 and minor1 = 213 asel major1 = 170 and minor1 = 214 asel major1 = 170 and minor1 = 215 asel major1 = 170 and minor1 = 216 asel major1 = 170 and minor1 = 217 asel major1 = 170 and minor1 = 218 asel major1 = 170 and minor1 = 221 asel major1 = 170 and minor1 = 222 &call arc_extract quit &return /************************************************************************ /* Routine ARC_EXTRACT /************************************************************************ /* Extract the data for each of the arcs in the selected set &routine arc_extract /* Open the GMT file and verify openness &s outfile = %file_name%.xy &if [exists %outfile% -file] &then &do &ty GMT file %outfile% already exists. &goto base &end &s num_arcs = [show number select] &if %num_arcs% = 0 &then &do &ty No records to process for %outfile%. &goto base &end &ty Writing coordinates to %outfile% ... &s fileunit = [open %outfile% status -w] &if %status% ne 0 &then &do &ty Could not open file %outfile%. &goto base &end &do arc_num = 1 &to %num_arcs% /*&type Processing arc %arc_num% of %num_arcs% /* Write out the name of the road (if any exists) &s rec_no = [show select %arc_num%] &s writestat = [write %fileunit% [quote > ]] /* Extract the vertex locations and write them out &s npnts = [show arc %rec_no% npnts] &do vert_num = 1 &to %npnts% &s coord = [show arc %rec_no% vertex %vert_num%] &s x = [extract 1 %coord%] &s y = [extract 2 %coord%] &s writestat = [write %fileunit% [quote %x% %y%]] &end &end /* end of arc_num loop &s status = [close %fileunit%] &label base &return /**************************************************************************** &routine run_away &s .error_flag 1 &s ok [close -all] &return &inform Error condition in routine (%amlname%)