#  This macro is a demonstration of the coutour processing capabilities of
#  LTPlus.  You must have the import file   cdemo.rdef2   in the default  
#  import directory for it to run.     JPD,  5/1/90
#
#  ****** NOTE ******   You must have the file demo_c.rdef2 in the default
#  import directory for this macro to run properly.
#


pause 8 To begin, a map is acquired or created.
acquire contour_demo
pause 5 Then the menu is switched to the contour_menu
menuset_get contour_menu
pause 8 Then the header information is set & a menu type is selected.
pause 3 The maptype is set to 'line'.
header  maptype = line
pause 3 The contour interval is set to '40'.
header  contour_interval = 40
pause 3 The map scale is set to '24000'.
header  scale = 24000
pause 3 The map height is set to 1.0 minute of latitude.
header  map_ht = 1.0
pause 3 The map width is set to 1.5 minutes of longitude.
header  map_wd = 1.5
pause 3 The menuset for this map is set to 'contour_menu'
menuset_get contour_menu


scan_input
pause 6 Next, the scanned data is imported.
import  rdef2  demo_c.rdef2  1

pause 8 After importing a scan, the data is registered.
pause 6 First the raster is registered.
register 0 i1=5.0 5.0 i2=5.0 395.0 i3=379.0 395.0 i4=379.0 5.0
pause 6 Next the geodetics are registered.
register 1 i1=45.000 120.000 i2=45.017 120.000 i3=45.017 119.975 i4=45.000 119.975


edit0
start_search
  pause 8 The first step in editing is to separate contours which touch.
view last 20 320
pause 8 Here, two lines touch in the scanned image which should be separate.
separate
start 20 320
goto coord 20 319
pause 5 The separate command allows quick separation of such lines.
continue 20 319
pause 5
view last 20 319
pause 5 Here are some more separations:
view last 159 280
start 158 279
goto coord 161 279
pause 1
continue 161 279
pause 1
view last 160 279
continue 161 279
view last 89 179
start 89 177
goto coord 94 178
pause 1
continue 94 178
pause 1
view last 94 178
pause 1
view last 207 286
pause 1
start 207 284
goto coord 211 288
pause 1
continue 211 288
pause 1
view last 211 288
pause 1


pause 8 Now lines will be drawn through the the elevation labels.
view last 68 366
pause 1
connect
start 63 352
goto coord 64 359
pause 8 This can be easily done using the connect input mode:
continue 64 359
pause 1
goto coord 69 368
pause 1
continue 69 368
pause 1
continue 75 380
pause 1
continue 75 380
pause 8 Now the rest of the connections will be done more quickly.
start 76 372
pause 1
continue 71 360
continue 69 356
continue 69 349
pause 1
view last 69 350
pause 1
view last 138 183
pause 1
start 125 187
continue 131 186
continue 140 183
continue 150 178
continue 154 175
pause 1
start 139 177
continue 152 173
pause 1
view last 152 173
pause 1
view last 315 171
pause 1
start 300 177
continue 306 177
continue 312 177
continue 317 179
pause 1
start 329 176
continue 322 175
continue 315 172
continue 307 171
continue 298 171
pause 1
start 321 168
continue 326 170
pause 1
view last 326 170
pause 8  Now the margin are of the map is erased.
erase_margin
pause 8 Then the lines are thinned to single pixel width.
thin_lines 0 0
pause 8 Then the map is framed.
frame_map d r
pause 8 All short spurs are automatically deleted.
del_spurs 8

pause 8 Now, all remaining spur end locations are found automatically.
log clear
log spurs
goto log +
pause 8 Here is a typical spur end.  It represent a break in line data.
view zoom 128 144
pause 3
bridge_gap
start 128 144
pause 8 The bridge_gap command allows it to be fixed quickly.
goto log +
pause 1
goto log +
pause 8 Unwanted data is left.  It will be automatically deleted later.
goto log +
pause 1
goto log +
pause 1
start 174 181
pause 1
goto log +
pause 1
goto log +
pause 1
start 187 238
pause 1
goto log +
pause 1
goto log +
pause 1
start 257 239
pause 1
goto log +
pause 1
goto log +
pause 1
start 351 304
pause 1
goto log +
pause 1
goto log +
pause 1
start 140 332
pause 1
goto log +
pause 1
goto log +
start 34 334
pause 1
goto log +
pause 1
goto log +
pause 1
goto log +
pause 1
goto log +
pause 1
start 160 389
pause 1
goto log +
pause 1
view map 0 0

pause 8 Now all remaining spurs and isolated points are deleted.
clear_mode
del_spurs 99999
del_points


pause 8 The border lines are now removed.
frame e r 


view map
clear_mode
pause 8 The edited raster is now assembled into vector lines.
assemble



pause 8 The original raster is now viewed with the vector lines for labeling.
disprstr_get b
graphics +r +n0 +h26
ckeys_get atrbt_keys
atrbt_contur  1  6000

pause 8 One elevation is entered, then all contours are labeled quickly relative to it.
pause 5 For example, the elevation 6000 has been entered.
pause 6 The first contour crossed will get the label 6000.
pause 8 Subsequent contours will increment or decrement (user input) from there:
goto coord 285 136
pause 1
start 285 136
goto coord 334 148
pause 1
increment 334 148
goto coord 374 168
pause 1
increment 374 168
pause 8 In this way the user defines a 'profile' which is used to assign elevations.

pause 8 Existing labels can be used as new starting points without numeric input:
goto coord 229 69
pause 1
start 229 69
goto coord 222 28
pause 1
increment 222 28
pause 1

goto coord 226 82
pause 1
start 266 82
pause 1
goto coord 281 74
pause 1
increment 281 74
pause 1
goto coord 347 38
pause 1
decrement 347 38
pause 1
goto coord 351 4
pause 1
decrement 351 4
pause 1

goto coord 319 17
pause 1
start 319 17
pause 1
goto coord 313 3
pause 1
decrement 313 3
pause 1

goto coord 197 62
start 197 62
pause 1
goto coord 135 114
pause 1
decrement 135 114
pause 1
goto coord 61 150
pause 1
decrement 61 150
pause 1
goto coord 15 194
pause 1
decrement 15 194
pause 1

goto coord 49 68
start 49 68
pause 1
goto coord 27 60
pause 1
decrement 27 60
pause 1
goto coord 5 21
pause 1
decrement 5 21
pause 1

goto coord 15 65
start 15 65
pause 1
goto coord 5 64
pause 1
decrement 5 64
pause 1

goto coord 18 302
start 18 302
pause 1
goto coord 4 301
pause 1
decrement 4 301
pause 1

goto coord 20 370
start 20 370
pause 1
goto coord 3 396
pause 1
increment 3 396
pause 1

goto coord 135 315
start 135 315
pause 1
goto coord 186 396
pause 1
increment 186 396
pause 1

goto coord 251 359
start 251 359
pause 1
goto coord 259 399
pause 1
increment 259 399
pause 1

goto coord 328 358
start 328 358
pause 1
goto coord 347 361
pause 1
increment 347 361
pause 1
goto coord 378 383
pause 1
increment 378 383
pause 1
clear_mode
pause 6 Interactive user labeling is almost that fast.



pause 8 At any time a line can be querried for its elevation, or
pause 8 the area viewed on the screen can be drawn in perspective:
graphics
pers_plot  left  1.50  0.45  0.30


pause 8 After the lines have been labeled, a DEM can be written automatically:
export dem cdemo.dem 2 30 30 2 1 2 -2000 3

#pause 8 Here is a the dem we just made in shaded relief.   

#dem_view  cdemo.dem 0

pause 3 This demonstration is over.
