home *** CD-ROM | disk | FTP | other *** search
/ GRIPS 2: Government Rast…rocessing Software & Data / GRIPS_2.cdr / dos / adrg / source / adrgmain.pas next >
Encoding:
Pascal/Delphi Source File  |  1990-04-10  |  3.7 KB  |  90 lines

  1. program adrg_main;
  2. {Program to extract a portion of the ADRG data from the CD-ROM and display
  3.  it on an EGA monitor.  After displaying the tiles, it will save the image
  4.  on an output file specified by the user.  Written in Turbo Pascal 5.0 on
  5.  a Zenith 248 with MS-DOS 3.21, BIOS 3.37.  The portion of the map to be
  6.  displayed is selected by entering geographic coords.  The CD-ROM drive
  7.  name is picked from the environment variable CDROMDSK
  8.  (before running the program, at the DOS prompt, type the following:
  9.  set CDROMDSK=letter_of_your_cd_rom_drive ).  This program will work for
  10.  ADRG production discs.  May not work for ADRG prototype discs.  The 24
  11.  bits/pixel ADRG is reduced to 4 bits/pixel equivalent using a minimum
  12.  distance algorithm.  The 16 colors were predetermined from a Peano curve
  13.  algorithm on an earlier prototype and adjusted (very roughly) by visual
  14.  means.
  15.  
  16.  Juan A. Perez, U. S. Army Engineer Topographic Laboratories
  17.  Digital Concepts and Analysis Center, Ft. Belvoir, VA 22060-5546
  18.  (202) 355-2864, AV 345-2864,   22 March 1990}
  19.  
  20. uses Crt,Graph,Dos;
  21. {$M 53248,0,655360}      {went overboard on the variables, so increased
  22.                           the stack size}
  23. const
  24.   screenrow = 349;   {349 for EGA, 479 for VGA}
  25.   screencol = 639;   {639 for both EGA/VGA}
  26.   dtilerow = 3;      {no. of rows of tiles that fit on the screen }
  27.                      {use 3 for EGA , or 4 for VGA}
  28.   dtilecol = 5;      {no. of colums of tiles that fit on the screen , use 5 }
  29.  
  30. var
  31.   file_name, user_file      : string;
  32.   no_of_cols_tiles          : integer;
  33.   ch                        : char;
  34.   start_tile, x_c, y_c,
  35.   nstartrow, nstartcol      : longint;
  36.   center_lat, center_lon,
  37.   dd_clat,dd_clon,asz, bs, lat0, lon0 : real;
  38.  
  39. {$I proxtrct.pas}
  40. {$I pcolors.pas}  { temporary solution of the different color tables for  }
  41. {$I savescrn.pas}                                 { different prototypes  }
  42. {$I dispcord.pas}
  43. {$I pdmstodd.pas}
  44. {$I lltopix.pas }
  45.  
  46. begin
  47.   { reads the "header" files from the CD-ROM looking for
  48.     very important info. that will be used to display the tiles.
  49.     Follows DMA's ADRG Specifications, First Edition
  50.     dated April 1989 (PS/2DJ/100). }
  51.  
  52.   proxtrct(file_name, no_of_cols_tiles, start_tile, nstartrow, nstartcol,
  53.           center_lat, center_lon, asz, bs, lat0, lon0);
  54.  
  55.   { Prompt user for output file name }
  56.   writeln('           Enter output file name ');
  57.   write  ('   (where image will be saved for future display) : ');
  58.   readln(user_file);
  59.  
  60.   { reads each tile of 128X128 pixels *3 (R-G-B), from the CD-ROM, then calls
  61.     the procedure that returns the cluster number closer to the R-G-B values
  62.     and assigns a color to the pixel.  Displays the tiles, pixel by pixel. }
  63.  
  64.   { the color table changes depending on the map, this one works ~OK for the
  65.     TLMs maps from Germany }
  66.   procolor(file_name, dtilerow, dtilecol, no_of_cols_tiles, start_tile);
  67.  
  68.   { display the latitude and longitude of the point the user selected }
  69.   pdmstodd(center_lat,dd_clat);
  70.   pdmstodd(center_lon,dd_clon);
  71.   disp_latlon(dd_clat,dd_clon);
  72.  
  73.   { put a marker at that location }
  74.   latlon_to_xyscreen(dd_clat, dd_clon, nstartrow, nstartcol, asz,bs,x_c, y_c);
  75.   setlinestyle(0,0,1);
  76.   setcolor(15);
  77.   Line(x_c - 7, y_c, x_c + 7, y_c);
  78.   Line(x_c - 7, y_c-1, x_c + 7, y_c-1);
  79.   Line(x_c, y_c + 6, x_c, y_c - 6);
  80.   Line(x_c-1, y_c + 6, x_c-1, y_c - 6);
  81.  
  82.   { When the EGA screen is full, collects the color values off the screen and
  83.     save them in an output file. }
  84.     savescrn(user_file, screenrow, screencol);
  85.     setcolor(14);
  86.     outtextxy(430,342,'  -> Hit a key to Continue' );
  87.  
  88.   ch := ReadKey;            {holds the image until the user hits a key}
  89.   closegraph;
  90. end.