home *** CD-ROM | disk | FTP | other *** search
- procedure proxtrct( var full_path_zdr:string; var n_cols_of_tiles1: integer;
- var start_tile, nstartrow, nstartcol: longint;
- var center_lat, center_lon, asz, bs, lat0, lon0 : real );
-
-
- { read files TRANSH01.THF and *.GEN from the CD-ROM and write a file
- with important information to compute geographic coordinates from
- pixel positions or pixel pos. from geo. coords.}
-
- type
-
- str2 = array[0..1] of char;
- str3 = array[0..2] of char;
- str5 = array[0..4] of char;
- str8 = array[0..7] of char;
- str10 = array[0..9] of char;
- str11 = array[0..10] of char;
- str21 = array[0..20] of char;
-
- var
- cdr : string[1];
- ch : char;
- wrtcnt : word;
- buf : array[0..1999] of char;
- asz_str, bs_str, pub_date : str8;
- lon_ul_zdr, lon_lr_zdr, lon0_zdr : str11;
- lat_ul_zdr, lat_lr_zdr, lat0_zdr : str10;
- chart_code : str2;
- n_rows_of_tiles, n_cols_of_tiles : str3;
- zdr_path, gen_path : str21;
- dir_skip : str5;
-
- asz1, bs1,
- lon_ul_zdr1, lat_ul_zdr1,
- lon_lr_zdr1, lat_lr_zdr1,
- lon0_zdr1, lat0_zdr1,
- lon_ul_dd, lat_ul_dd,
- lon_lr_dd, lat_lr_dd,
- clon, clat,
- slon_ul, slat_ul,
- slon_lr, slat_lr,
- r, c : real;
-
- n_rows_of_tiles1, code, i, ds_int, extra : integer;
-
- fael : file;
-
- dlon_ul,mlon_ul, dlat_ul,mlat_ul,
- dlon_lr,mlon_lr, dlat_lr,mlat_lr : longint;
-
-
- {$I pdmstodd.pas}
- {$I ddtodms.pas}
-
- begin {** procedure extract **}
- { get the drive name for the CD-ROM from the environment variable CDROMDSK
- (the same that terrabase uses) }
- cdr :=getenv('CDROMDSK');
-
- { The TRANSH01.THF file keeps the same name for all the ADRG discs,
- read this file to extract the pathname for the .GEN file and the
- ZDR image file. }
-
- assign(fael, cdr+':\TRANSH01.THF'); reset(fael,1);
-
- { read all the ASCII values as characters }
-
- blockread(fael, buf , 1281, wrtcnt);
- blockread(fael, pub_date , 8, wrtcnt);
- blockread(fael, buf , 1, wrtcnt);
- blockread(fael, chart_code , 2, wrtcnt);
- blockread(fael, buf ,1529, wrtcnt); {1844}
- blockread(fael, dir_skip , 5, wrtcnt);
- val(dir_skip, ds_int ,code);
- blockread(fael, buf ,ds_int+145, wrtcnt);
- blockread(fael, gen_path , 21, wrtcnt);
- blockread(fael, buf , 135, wrtcnt); {135}
- blockread(fael, zdr_path , 21, wrtcnt);
-
- { change the slash to a backslash to use the string as the pathname in DOS }
- for i := 0 to 20 do
- begin {for i loop}
- if (gen_path[i] = '/') then gen_path[i] := '\';
- if (zdr_path[i] = '/') then zdr_path[i] := '\';
- end; {for i loop}
-
- close(fael);
-
- { build the path to the full resolution image file }
- full_path_zdr := cdr+':\'+zdr_path;
-
- { read other important values from the .GEN file }
-
-
-
- assign(fael, cdr+':\'+gen_path); reset(fael,1);
- blockread(fael, buf ,1003, wrtcnt);
- blockread(fael, ch , 1, wrtcnt);
-
- extra := 0;
- ds_int := 0;
- if ( ch = 'T' ) then
- begin
- extra := 10;
- blockread(fael, buf , 6, wrtcnt);
- blockread(fael, dir_skip , 5, wrtcnt);
- val(dir_skip, ds_int ,code)
- end;
- blockread(fael, buf ,165+ds_int+129+extra, wrtcnt);
-
- blockread(fael, ch , 1, wrtcnt);
- extra := 56;
- if ( ch = 'T' ) then extra := 77;
-
- blockread(fael, buf , extra, wrtcnt);
-
- blockread(fael, lon_ul_zdr , 11, wrtcnt);
- blockread(fael, lat_ul_zdr , 10, wrtcnt);
- blockread(fael, buf , 21, wrtcnt);
- blockread(fael, lon_lr_zdr , 11, wrtcnt);
- blockread(fael, lat_lr_zdr , 10, wrtcnt);
- blockread(fael, buf , 17, wrtcnt);
- blockread(fael, asz_str , 8, wrtcnt);
- blockread(fael, bs_str , 8, wrtcnt);
- blockread(fael, lon0_zdr , 11, wrtcnt);
- blockread(fael, lat0_zdr , 10, wrtcnt);
- blockread(fael, buf , 89, wrtcnt);
- blockread(fael, n_rows_of_tiles, 3, wrtcnt);
- blockread(fael, n_cols_of_tiles, 3, wrtcnt);
-
- close(fael);
-
- { transform the characters to numeric values (integer or real) }
-
- val(asz_str,asz,code);
- val(bs_str,bs,code);
- val(lon_ul_zdr,lon_ul_zdr1,code);
- val(lon_lr_zdr,lon_lr_zdr1,code);
- val(lat_ul_zdr,lat_ul_zdr1,code);
- val(lat_lr_zdr,lat_lr_zdr1,code);
- val(lat0_zdr,lat0_zdr1,code);
- val(lon0_zdr,lon0_zdr1,code);
- val(n_rows_of_tiles,n_rows_of_tiles1,code);
- val(n_cols_of_tiles,n_cols_of_tiles1,code);
-
- { compute decimal degree value for latitude and longitude angles that were
- read in packed dms format }
-
- pdmstodd(lon_ul_zdr1, lon_ul_dd);
- pdmstodd(lat_ul_zdr1, lat_ul_dd);
- pdmstodd(lon_lr_zdr1, lon_lr_dd);
- pdmstodd(lat_lr_zdr1, lat_lr_dd);
- pdmstodd(lon0_zdr1, lon0);
- pdmstodd(lat0_zdr1, lat0);
-
- ddtodms(lon_ul_dd,dlon_ul,mlon_ul,slon_ul);
- ddtodms(lat_ul_dd,dlat_ul,mlat_ul,slat_ul);
- ddtodms(lon_lr_dd,dlon_lr,mlon_lr,slon_lr);
- ddtodms(lat_lr_dd,dlat_lr,mlat_lr,slat_lr);
-
- writeln;writeln;
- writeln(' Select portion of the ADRG data to be extracted' );
- writeln;
- writeln(' Values in this ZDR are in the range:');
- write(' ',dlat_ul,' ',mlat_ul,' ',slat_ul:4:0,' ');
- writeln(' ',dlon_ul,' ',mlon_ul,' ',slon_ul:4:0);
- write(' ',dlat_lr,' ',mlat_lr,' ',slat_lr:4:0,' ');
- writeln(' ',dlon_lr,' ',mlon_lr,' ',slon_lr:4:0);
- writeln;
- writeln(' Enter Latitude of Center Point in the format:');
- writeln(' ZDDMMSS. ');
- writeln(' where Z is the sign; DD = degrees; ');
- writeln(' MM = minutes; and SS. = seconds ');writeln;
-
- repeat
- write(' Enter Latitude: ');
- readln(center_lat);
- writeln
- until ((center_lat >= lat_lr_zdr1) and (center_lat <= lat_ul_zdr1));
-
- writeln(' Enter Longitude of Center Point in the format:');
- writeln(' ZDDDMMSS. ');
- writeln(' where Z is the sign; DDD = degrees; ');
- writeln(' MM = minutes; and SS. = seconds ');writeln;
- repeat
- write(' Enter Longitude: ');
- readln(center_lon);
- writeln
- until (( center_lon >= lon_ul_zdr1 ) and ( center_lon <= lon_lr_zdr1 ));
-
- pdmstodd(center_lat,clat);
- pdmstodd(center_lon, clon);
- r := bs * (lat0 - clat) / 360.0;
- c := asz * (clon - lon0) / 360.0;
- nstartrow := trunc(r/128) -1; {-1 for EGA/ -2 for VGA to get closer to center}
- nstartcol := trunc(c/128) -2; {-2 to get closer to the center}
- start_tile := nstartrow*n_cols_of_tiles1 + nstartcol;
- no_of_cols_tiles := n_cols_of_tiles1;
-
- end; {** procedure extract **}