/* mapper.c 3/15/89 updated 12/14/90 mpp1.bat = cl /AL mapper.c mouseg vmaputil vimage3 mapgraph textview graphlib exemod mapper.exe /stack 4000 mapper plotting software: by Russell A. Ambroziak, Ph. D. Reston, Virginia, Phone 703-648-6168 command line options: /e = EGA /v = VGA 640x480x16 colors /s = VGA 320x200x256 colors /y = Extended VGA 640x400x256 colors /x = Extended VGA 640x480x256 colors /l [path][file_name].[file_type] = output '.LAB' file of points /o [path][file_name].[file_type] = output run information file /a [path][file_name] = automatic map load on start /p [program_name] = passes control to program from point (S)earch /r creates a '.MPR' file with ranges of data for all files then stops /h help -- prints this message /grid [sample rate] = outputs 'grid.lab' entry for a grid of points /save [.map name] creates and saves a map in batch mode /screen puts vector screen coordinates in mapper.crd Any path name for data search can by added also, e.g. D:\DATA or \MAPPER\DATA\MAP cursor mode options: All Maps (G)raph Data Points -- see 'graph.c' for instructions (L)ocate Vectors -- labels line if '*.atr' file exists (S)earch for nearest point -- find and labels points if available e(x)it to picture -- lists '*.lbl' files of points if any Color Filled Maps All Modes (k)ey -- plots a small key on right side of screen (K)ey -- plots a large key on right side of screen (N)ame all -- prints polygon name at all label points (P)aint area -- fills a polygon with color entered and makes entry in '*.lab' file if /l option on Color Filled Maps Modes 'X', 'Y' and 'S' Only (n)ame 1 -- labels polygon at cursor location (p)aint mark -- makes entry in '*.lab' file if /l option on (R)emove lines -- removes polygon boundaries (E)dit colors -- changes map color and gives color info (C)olor table output -- outputs color table (f)lash -- makes color flash white then return (D)arker -- makes map fill colors darker but not lines (B)righter -- makes map fill colors brighter but not lines The following is the format of a map file. All comments (which are not part of the file) are in [square brackets]. p 0.5 18.3 -66.44 10.0 [ The 1st line has a character and 4 numbers ] [ char is projection ] [ p = plate carree or x-y projection (recomended) ] [ a = Albers equal area ] [ s = polarstereographic ] [ S = sinusoidal ] [ m = Mercator ] [ 0.5 is pixel size of center pixel in kilometers ] [ 18.3 is latitude of center pixel ] [-66.4 is longitude of center pixel ] [ 10.0 is a number of no use but it must be there ] begin_color [ You can define up to 16 VGA ] black = 0 0 0 [ (or EGA) colors here for use ] d_grey = 46 46 46 [ in line work. The format is ] l_grey = 128 128 128 [ a color name, =, then a red, ] white = 255 255 255 [ green, and blue color value. ] buff = 105 90 75 [ ] l_buff = 130 111 93 [ ] brown = 96 28 14 [ ] red = 255 0 0 [ ] orange = 255 128 0 [ ] yellow = 160 160 0 [ ] green = 0 200 0 [ ] d_green = 0 120 0 [ ] vd_green = 0 72 0 [ ] blue = 30 60 255 [ ] d_blue = 0 20 60 [ ] magenta = 255 0 255 [ ] end_color [ this must be here to mark end ] menu_background = d_grey [ The pull down menu can be made ] text = l_grey [ any color but something must ] highlight = white [ be given for each item. ] background = buff [ This is the blank screen color.] graticule = l_buff [ ] lat/lon = d_grey [ ] black = black [ ] begin_vector geology = 2 ON east_geo 3.0 0.0 d_grey west_geo 3.0 0.0 d_grey [ A list of the vector filenames must be given with group ] [ names. You can have up to 25 groups and up to 25 vectors in ] [ a group. The group names are used while the program is ] [ running to identify vectors for plotting or labeling. Each ] [ group name is followed by '=', the number of vectors in the ] [ group and the word 'ON' of 'OFF' to tell wheter to plot it ] [ the first time through. ] [ ] [ Each vector name is followed by a maximum pixel size, a ] [ minimum pixel size and the color (from above) to plot the ] [ vector. In this example we are going to color in geologic ] [ formations so the first vectors (lines) to be plotted are ] [ the polygons defining the formations on the map. They will ] [ be plotted when the pixel size is less than 3 km. ] fillin_IHS = 1 geology.blb 3.0 0.0 2 0.66 234 0.90 Thqdp 3 0.61 234 0.80 Tgp 1 0.83 254 0.33 TKgqm 4 0.81 234 0.50 Thdap end [ This entry tells how to fill in the polygons. It must be ] [ located after the polygons are plotted and before other lines] [ are plotted. The file 'geology.blb' was made from a file ] [ called 'geology.lab' which was made using this program and ] [ the /l option, and the cursor mode 'P' option, e.g. ] [ mapper /l geology.lab ] [ then running 'makeblb geology' on the '.lab' file to make ] [ the .blb file. ] [ ] [ The numbers give the pixel sizes to plot the fill. The next] [ 1 to 240 lines are polygon fill values (used with the 'P' ] [ option in cursor mode) followed by intensity (0-1.0), hue ] [ (1-255) and saturation (0-1.0). Use the cursor mode 'E' ] [ option to set and chose these colors. ] pattern 15 2 * * * 2 * * * * 2 * * 2 * * 2 * * 2 * 2 * 2 * * * * 2 2 2 * * 2 2 2 2 2 2 2 2 * * * 2 2 2 * * * * 2 * 2 * 2 * * 2 * * 2 * * 2 16 9 * * * 9 * * * * 9 * 9 * * * * * * 9 * * * * * * 9 * 9 * * * * 9 * * * 9 * * * * * * * * * * * * * * * * * * * * * * * * * * * end [ This entry tells how to pattern selected colors with one of ] [ the 16 overlay colors. It must be located just after the ] [ color definitions. This put a l_grey pattern in color 15 and] [ a yellow pattern in color 16. ] begin_names Epithermal_Qtz = OFF pr_25e.loc 3.0 0.0 blue ........... ...*****... ..*.....*.. .*.......*. [ the map and identify them you ] .*.......*. [ can use the names option. You ] .*.......*. [ can have up to 25 icons. This ] .*.......*. [ one draws a blue circle at each] .*.......*. [ point in file 'pr_25e.loc'. ] ..*.....*.. [ If you wish to plot icons on ] ...*****... [ The file contains 2 points as ] ........... [ follows: ] [ Boulder field_Topographic_high 42.39267 -70.80325 stn2_14.lbl] [ Fine_sediment_mixed_with_gravel 42.38796 -70.81313 stn3*.lbl ] [ If there is an image file the label is given after the ] [ location. It can be a single image or a group of images as ] [ is the case with the 2nd entry. All .lbl files starting with] [ 'stn3' will be available to be viewed. You must use the /a ] [ command line option with a saved map if you are going to view] [ images. ] Low-Sulfide_Au = OFF d:\prico\pr_36a.loc 3.0 0.0 white .....*..... .....*..... ....*.*.... ....*.*.... ...*...*... ...*...*... ..*.....*.. ..*.....*.. .*.......*. .*********. ........... end_names [ You can have up to 25 of these icons. This is a white ] [ triangel. The field must contain 121 entries (11,11). ] [ Periods are ignored and * are plotted on the map. The icon ] [ is centere over its center point (6,6) of [5][5] in c. ] faults = 3 ON eastf 10.0 0.0 black centf 10.0 0.0 black westf 10.0 0.0 black roads = 1 OFF road 100.0 0.0 green streams = 1 OFF stream 100.0 0.0 blue end_vector [ More vectors and an 'end_vector' statement ] */ #include #include #include #include #include "mapfont.h" #include "font.h" #include "mouseg.h" #include #include #include #define VGA 0 /*#define NUMBER9 9*/ #ifdef VGA #define MAX_X 640 #define MENUXC 550 #endif #ifdef NUMBER9 #define MAX_X 640 #define MENUXC 550 #endif #define DEG_RAD 0.01745329251 /* converts degrees to radians */ #define MAXDO 1000 #define MAX_COLORS 16 #define STR_LEN 100 #define MIN_PIX 0.000 #define TYPE 'p' #define BLACK 0 #define D_GREY 1 #define L_GREY 2 #define WHITE 3 #define BUFF 4 #define L_BUFF 5 #define BROWN 6 #define RED 7 #define ORANGE 8 #define YELLOW 9 #define GREEN 10 #define D_GREEN 11 #define VD_GREEN 12 #define BLUE 13 #define D_BLUE 14 #define MAGENTA 15 #define NUM_TYPE 25 #define NUM_SIZE 25 #define NUM_PSIZE 3 #define NUM_FILL 5 #define NUM_SYM 25 #define MENU_M 14 #define MENU_L 8 #define MENU_P 6 #define MENU_IV 2 #define SYM_SIZE 11 #define NUM_DP 100 #define B_LINES 48 #define F_SIZE 20 #define NAME_SIZE 100 #define S_SIZE 40 #define T_SIZE 15 #define MAX_NUM 300 #define NUM_IMAGE 2 extern int A_Flash; int No_Flash=0x4f; int Rxc,Ryc,Repeat=0; /* multiple screens if Repeat>1 */ char *UpDate="6/19/92"; int AttribOn=0; char *Menu_iv[MENU_IV]= {"zoom", "exit image" }; struct Color { unsigned char r, g, b; }lutc[256],luts[256]; int Black=0,White=191,Center=128,Num_Color=256; int D_Grey=46,L_Grey=191,M_Grey=128; struct Color Blk={ 0, 0, 0}; struct Color D_G={ 46, 46, 46}; struct Color M_G={127,127,127}; struct Color L_G={191,191,191}; struct Color Wht={255,255,255}; unsigned char ActiveLut; int Img=0,Sample=1,Xc=0,Yc=0,Speed=16,Row,Col,ZoomSample=1; char *SubType; struct equipment { int printers; /* number present */ int sprinter; /* serial printer installed? 0=no 1=yes */ int game; /* game adapter installed? */ int sports; /* number of serial ports */ int dma; /* DMA chip installed? */ int drives; /* number of disk drives */ int video; /* video mode 1=40 color 2=80 color 3=80 B/W */ int disk; /* any disk drives? */ int memory; /* memory size in Kbytes */ }; extern struct equipment Eq; extern int GF_Order[MAX_NUM]; extern char GF_String[MAX_NUM][S_SIZE]; struct file_id { char name[S_SIZE]; long size; unsigned date,time; }; extern struct file_id GF_File[MAX_NUM]; extern int Monitor; char DepthFile[100]={"colo.dpt"}; float D1[MAX_NUM],D2[MAX_NUM]; struct image_header { int row,col; int sample; int record_bytes,file_records; int record_col_header; int row_col_header; int header_bytes; int imbedded_header; int sample_bits; char infile[100],image[100],Lut[100],pal_type,label[100]; int vga_color[256]; struct Color lut[256],lutc[256]; }Hdr[NUM_IMAGE]; int Sym_Size=SYM_SIZE; char LastMap[STR_LEN],LastFile[STR_LEN],Auto=0,AutoGraph=0; char *Exit={"exit"}; float BackBright=1.0; int NumPath=1; char Path[NUM_DP][STR_LEN]; char String[STR_LEN]; char String[STR_LEN]; int RawOn; int FontSize=2; float PixScale; char Suffix[20]; FILE *FpLab,*FpGrd; char VideoType='X'; int MaxXs,MaxYs; char Disk_Dir[100]; char *Menu_V[NUM_TYPE+3]; char *Menu_P[NUM_SYM+3]; char *Menu_M[MENU_M]= { "zoom", /* 0 */ "overlays ON/OFF", /* 1 */ "reset", /* 2 */ "Change projection", /* 3 */ "Save map", /* 4 */ "Recall map", /* 5 */ "cursor mode", /* 6 */ "vector plot", /* 7 */ "annotate", /* 8 */ "draw lines", /* 9 */ "graticule", /* 10 */ "point plot", /* 11 */ "multiple maps", /* 12 */ "exit" }; int Mouse=0; struct menu Menu_Mouse1[8]= { {"Analyze",6,1, 0 }, { "Map",' ',1, 4, "Recall",5,1, "Save",4,1, "Multiple",12,1, "Mouse Off",100,1 }, { "Zoom",0,1, 0 }, { "Plot Data",' ',1, 2, "Points",11,1, "Lines",7,1 }, { "Projection",3,1, 6, "Lambert",31,1, "Albers",32,1, "Mercator",33,1, "P. Stereo.",34,1, "sinusoidal",35,1, "plt.carree",36,1 }, { "Draw",' ',1, 3, "Lines",9,1, "Text",8,1, "Graticule",10,1 }, { "QUIT",13,1, 0 }, { "*" } }; /* 0 -- red 18 -- orange 34 -- yellow-orange 50 -- yellow 68 -- yellow-green 85 -- green 95 -- green-cyan 105 -- cyan 125 -- blue-cyan 144 -- blue 167 -- blue-purple 190 -- purple 206 -- magenta-purple 223 -- magenta 240 -- red-magenta 255 -- red */ unsigned char MaxHues[256][3]= { 255, 0, 0,255, 32, 0,255, 42, 0,255, 53, 0,255, 60, 0,255, 68, 0, 255, 73, 0,255, 80, 0,255, 84, 0,255, 90, 0,255, 94, 0,255,100, 0, 255,103, 0,255,108, 0,255,112, 0,255,116, 0,255,121, 0,255,124, 0, 255,128, 0,255,132, 0,255,135, 0,255,139, 0,255,143, 0,255,146, 0, 255,150, 0,255,154, 0,255,157, 0,255,161, 0,255,164, 0,255,168, 0, 255,172, 0,255,176, 0,255,179, 0,255,183, 0,255,186, 0,255,190, 0, 255,194, 0,255,198, 0,255,202, 0,255,206, 0,255,210, 0,255,214, 0, 255,218, 0,255,222, 0,255,227, 0,255,231, 0,255,236, 0,255,241, 0, 255,245, 0,255,250, 0,254,255, 0,249,255, 0,244,255, 0,240,255, 0, 234,255, 0,229,255, 0,224,255, 0,220,255, 0,214,255, 0,209,255, 0, 204,255, 0,199,255, 0,194,255, 0,190,255, 0,184,255, 0,179,255, 0, 174,255, 0,169,255, 0,164,255, 0,158,255, 0,152,255, 0,147,255, 0, 141,255, 0,135,255, 0,130,255, 0,123,255, 0,116,255, 0,109,255, 0, 102,255, 0, 94,255, 0, 87,255, 0, 78,255, 0, 68,255, 0, 58,255, 0, 42,255, 0, 23,255, 0, 0,255, 36, 0,255, 58, 0,255, 73, 0,255, 87, 0,255,101, 0,255,113, 0,255,125, 0,255,135, 0,255,146, 0,255,156, 0,255,166, 0,255,176, 0,255,186, 0,255,196, 0,255,204, 0,255,214, 0,255,224, 0,255,233, 0,255,243, 0,255,252, 0,248,255, 0,239,255, 0,230,255, 0,222,255, 0,214,255, 0,207,255, 0,200,255, 0,194,255, 0,187,255, 0,181,255, 0,174,255, 0,169,255, 0,163,255, 0,157,255, 0,152,255, 0,146,255, 0,141,255, 0,136,255, 0,131,255, 0,126,255, 0,121,255, 0,116,255, 0,111,255, 0,106,255, 0,101,255, 0, 96,255, 0, 92,255, 0, 86,255, 0, 81,255, 0, 77,255, 0, 71,255, 0, 66,255, 0, 60,255, 0, 53,255, 0, 48,255, 0, 39,255, 0, 32,255, 0, 23,255, 0, 0,255, 16, 0,255, 23, 0,255, 28, 0,255, 32, 0,255, 36, 0,255, 39, 0,255, 42, 0,255, 45, 0,255, 48, 0,255, 50, 0,255, 53, 0,255, 58, 0,255, 60, 0,255, 62, 0,255, 64, 0,255, 66, 0,255, 68, 0,255, 70, 0,255, 73, 0,255, 75, 0,255, 77, 0,255, 78, 0,255, 81, 0,255, 83, 0,255, 84, 0,255, 87, 0,255, 89, 0,255, 92, 0,255, 93, 0,255, 94, 0,255, 97, 0,255, 98, 0,255,101, 0,255,103, 0,255,105, 0,255, 107, 0,255,109, 0,255,111, 0,255,113, 0,255,115, 0,255,117, 0,255, 119, 0,255,122, 0,255,124, 0,255,126, 0,255,129, 0,255,131, 0,255, 134, 0,255,135, 0,255,138, 0,255,140, 0,255,143, 0,255,145, 0,255, 148, 0,255,151, 0,255,154, 0,255,156, 0,255,160, 0,255,163, 0,255, 166, 0,255,169, 0,255,173, 0,255,176, 0,255,179, 0,255,183, 0,255, 188, 0,255,192, 0,255,196, 0,255,200, 0,255,204, 0,255,209, 0,255, 214, 0,255,220, 0,255,225, 0,255,231, 0,255,237, 0,255,244, 0,255, 250, 0,255,255, 0,252,255, 0,245,255, 0,238,255, 0,231,255, 0,224, 255, 0,217,255, 0,210,255, 0,203,255, 0,196,255, 0,190,255, 0,183, 255, 0,176,255, 0,170,255, 0,163,255, 0,156,255, 0,151,255, 0,144, 255, 0,137,255, 0,131,255, 0,125,255, 0,118,255, 0,112,255, 0,105, 255, 0, 98,255, 0, 90,255, 0, 83,255, 0, 77,255, 0, 68,255, 0, 60, 255, 0, 50,255, 0, 42,255, 0, 28,255, 0, 23 }; char T_Menu_L[NUM_TYPE+3][2][50]; char *T_Menu_P[MENU_P+3][2]; float MaxLat,MinLat,MaxLon,MinLon; FILE *Fpout; char SaveName[100]={"mapper.out"}; double ll[MAXDO][2]; int todo[2][MAXDO]; unsigned char MT_Buff[12][MAX_X],Mbuff[B_LINES][MAX_X],Buffer[MAX_X]; long MT_Buff_size=7680,Mbuff_size=30720; unsigned char Inbuff[BUFSIZ],Inbuff2[BUFSIZ],Outbuff[BUFSIZ]; int SaveVec=0,SNum=1; int ScreenXs,ScreenYs,ScrnX,ScrnY,Tx,Ty; struct board { int row,col,color; }B_Id; struct map_screen { int xc,yc,xs,ys; }map_pos; struct map_input { char *name,type; double indat[6]; }miv; struct symbol_name { char name[50],filename[50]; float max_pix,min_pix; int color; char on; char Symbol[SYM_SIZE][SYM_SIZE]; }PlaceFile[NUM_SYM]; int NumPicture=0,PictureOn[NUM_SYM]; int NumText=0,TextOn[NUM_SYM]; struct map { int KeyPlotted; char Fill_Name[256][20]; int Fill_In; int Fill_After; int Fill_Color[256][2]; int Max_Fill; int Fill_Color_RGB[256][3]; float Fill_Color_IHS[256][3]; int Fill_Order[256]; int Comp_Color[256]; int Num_Fill; float FI_min[NUM_FILL],FI_max[NUM_FILL]; char Fill_In_Name[NUM_FILL][STR_LEN]; int White,Num_Color; int screen_xs,screen_ys; int Num_Type,Out; float Pixsize,Clat,Clon,Space; int Mback,Text,High,Back,Grat; int GratOn; int LatLon,Black; char Color_Name[MAX_COLORS][30]; int Color_Val[MAX_COLORS][3]; int Type; int Ns[NUM_TYPE]; int Mm[NUM_TYPE]; int NumSymbol; int Range; int Pattern; char Group_Name[NUM_TYPE][30]; struct line_name { char filename[54]; float max_pix,min_pix; int color; }MapFile[NUM_TYPE][NUM_SIZE]; struct place_name { char *name,*filename; float max_pix,min_pix; int color; }PlaceFile[3][3]; /* size = 18*3*3 = 162 bytes */ struct Color lut[256]; }M; struct pattern { int status; char pattern[8][8]; }Pat[240]; int FileRange=0; struct file_range { float maxlat,minlat; float maxlon,minlon; }Fr[NUM_TYPE][NUM_SIZE]; unsigned char getpt(); char Saveit[50]; char Labelit[100]; int Grid=0; int fill_in(); int auto_fill_in(); void pix_loc(); int check_point(); int purge(); void remove_boundaries(); void set_lut(); int load_miv(); void screen_mm(); int do_menu(char *[],int,int,int,int,int,int,int,int [128][25]); int t_do_menu(); int plot_map(); void get_corners(); int tplot_line(); int unplot_line(); char Zoom(); int convert_bin(); int read_control(); int get_color(); FILE *open_to_read_binary(char *); FILE *open_to_read_text(char *); FILE *open_to_write_text(char *); FILE *open_to_write_binary(char *); multiple_maps(int xc,int yc,int xs,int ys,float pixsize, float clat,float clon,float space); int graph_plot(char *type); FILE *FpSc; int ScreenCoord=0; main(argc,argv) int argc; char *argv[]; { int i,j,k,p; char ans,ans2,cfile[100],string[100]; int mt=0,lbrite=64,nbrite=127,brite; int cx=256,cy=ScreenYs/2; int xc,yc,xs,ys,ix,iy,val,speed,isize=FontSize,color; float pixsize=12.0,clat=38.0,clon=-95.75,space=10.0; int m_num=0,plotmap=0; int row=ScreenYs/2,col=ScreenXs/2,mrow=5,mcol=30; FILE *fp,*fptest; int point=0,sx,sy; ix=ScreenXs/2; iy=ScreenYs/2; speed=16; if(mouse_initialize(4)) { printf("Mouse initialized.\n\n"); Mouse=4; /* sensitivity set to maximum (1 is minimum) */ } for(i=0;i0) val=read_control(cfile); else exit(0); if(val<0) { if(val==-1) printf("Could not open control file '%s'\n\n",cfile); if(val==-2) printf("Could not find 'begin_color in file '%s'\n\n",cfile); if(val==-3) printf("Could not find 'begin_vector in file '%s'\n\n",cfile); if(val==-4) printf("Too many vectors in a group in file '%s'\n\n",cfile); if(val==-5) printf("Bad color name in file '%s'\n\n",cfile); if(val==-6) printf ("Missing or bad pixel size, central lat and lon or graticule spacing\n"); exit(0); } if(FileRange==1) { set_range(cfile); exit(0); } video_on(); M.Pixsize*=PixScale; pixsize=M.Pixsize; clat=M.Clat; clon=M.Clon; space=M.Space; cy=ScreenYs/2; set_lut('c',0); plot_map(xc,yc,ScreenXs,ScreenYs,pixsize,clat,clon,space,0); check_points(); for(i=0;i0) { video_on(); strcat(LastMap,Suffix); if(unsave_map(LastMap)>0) { check_points(); plotmap=1; ix=ScreenXs/2; iy=ScreenYs/2; speed=16; m_num=6; pix_loc(ix,iy,&ix,&iy,&speed); } else SetVideoMode(0); } if(plotmap==0&&ScreenCoord==0) { if(Mouse==0) { printf(" Choose a map to start with\n"); printf("by using the up and down arrow\n"); printf("keys, 'Pg Up' or 'Pg Dn' keys,\n"); printf("or by typing the name of the\n"); printf("map. Hit 'Enter' to select a\n"); printf("map. If the map is not in this\n"); printf("directory and you have entered\n"); printf("command line path names, hit\n"); printf("'Esc' to continue on to other\n"); printf("paths.\n\n"); printf(" If you wish to draw a map\n"); printf("rather than load one that is\n"); printf("already drawn -- hit 'Esc'\n"); printf("until the menu contains '*.map'\n"); printf("files.\n\n"); printf(" If you copy drawn map\n"); printf("files from one disc to another,\n"); printf("the path names may be incorrect\n"); printf("and you may not be able to\n"); printf("zoom.\n"); printf("\nAs of %s\n",UpDate); } else { sprintf(string,"MOUSE is ON"); WriteStringAtxy(0,12,0,No_Flash,string); } plotmap=0; sprintf(string,"*%s",Suffix); if(search_list(string,cfile)>=0) { video_on(); unsave_map(cfile); check_points(); plotmap=1; } if(Mouse!=0) { sprintf(string,"MOUSE is ON"); WriteStringAtxy(0,12,0,No_Flash,string); sprintf(string,"Use it to move cursor or Disable it!"); WriteStringAtxy(0,13,0,No_Flash,string); sprintf(string,"To disable mouse use 'Mouse Off'"); WriteStringAtxy(0,14,0,No_Flash,string); sprintf(string,"Under 'Map' menu."); WriteStringAtxy(0,15,0,No_Flash,string); } } if(plotmap==0) { if(search_list("*.map",cfile)<0) { printf("No maps chosen.\n\n"); exit(0); } if(strlen(cfile)>0) val=read_control(cfile); else exit(0); if(val<0) { if(val==-1) printf("Could not open control file '%s'\n\n",cfile); if(val==-2) printf("Could not find 'begin_color in file '%s'\n\n",cfile); if(val==-3) printf("Could not find 'begin_vector in file '%s'\n\n",cfile); if(val==-4) printf("Too many vectors in a group in file '%s'\n\n",cfile); if(val==-5) printf("Bad color name in file '%s'\n\n",cfile); if(val==-6) printf ("Missing or bad pixel size, central lat and lon or graticule spacing\n"); exit(0); } if(FileRange==1) { set_range(cfile); exit(0); } video_on(); M.Pixsize*=PixScale; pixsize=M.Pixsize; clat=M.Clat; clon=M.Clon; space=M.Space; cy=ScreenYs/2; set_lut('c',0); plot_map(xc,yc,ScreenXs,ScreenYs,pixsize,clat,clon,space,0); check_points(); } do { if(Mouse==0) m_num=M_do_menu(Menu_M,MENU_M,MENUXC,25, m_num,M.Mback,M.Text,M.High,Font); else { full_screen(); m_num=mouse_menu(Menu_Mouse1,M.Mback,M.Text,M.High, M.Black, 0,ScreenXs-1,0,ScreenYs-1, row,col,&mrow,&mcol,Mouse,0,BUTTON_UP); return_screen(); } if(m_num==100) Mouse=0; if(m_num==0) { pixsize=M.Pixsize; clat=M.Clat; clon=M.Clon; space=M.Space; if(Mouse==0) ans=Zoom(xc,yc,ScreenXs,ScreenYs,&pixsize,&clat,&clon,&space); else ans=mouse_Zoom(xc,yc,ScreenXs,ScreenYs,&pixsize,&clat,&clon,&space); if(ans!=27) plot_map(xc,yc,ScreenXs,ScreenYs,pixsize,clat,clon,space,0); } if(m_num==1) { pixsize=M.Pixsize; clat=M.Clat; clon=M.Clon; space=M.Space; T_do_menu(T_Menu_L,M.Num_Type+3,25,25,m_num,M.Mback,M.Text,M.High, Font,M.Mm); plot_map(xc,yc,ScreenXs,ScreenYs,pixsize,clat,clon,space,0); } if(m_num==2) { xc=0;yc=0;xs=ScreenXs;ys=ScreenYs; pixsize=M.Pixsize; clat=M.Clat; clon=M.Clon; space=M.Space; plot_map(xc,yc,ScreenXs,ScreenYs,pixsize,clat,clon,space,0); } if(m_num==3||(m_num>=31&&m_num<=36)) { pixsize=M.Pixsize; clat=M.Clat; clon=M.Clon; space=M.Space; if(Mouse==0) { save_box(0,M.Black,Mbuff,0,MaxYs-40,MaxXs,40); sprintf(String,"Give new projection type. l=Lambert a=Albers"); if(VideoType=='S') plot_font_h(M.White,5,MaxYs-38,String,3,Font); else plot_font_h(M.White,5,MaxYs-38,String,2,Font); sprintf(String, "'m'=Mercator 's'=polar stereographic 'p'=plate carre S=sinusoidal"); if(VideoType=='S') plot_font_h(M.White,5,MaxYs-18,String,3,Font); else plot_font_h(M.White,5,MaxYs-18,String,2,Font); M.Type=getch(); } else { if(m_num==31)M.Type='l'; else if(m_num==32)M.Type='a'; else if(m_num==33)M.Type='m'; else if(m_num==34)M.Type='s'; else if(m_num==35)M.Type='S'; else if(m_num==36)M.Type='p'; } if(M.Type=='l'||M.Type=='a'|| M.Type=='m'||M.Type=='s'||M.Type=='p'||M.Type=='S') plot_map(xc,yc,ScreenXs,ScreenYs,pixsize,clat,clon,space,0); else { M.Type='p'; unsave_box(0,M.Black,Mbuff,0,MaxYs-40,MaxXs,40); } } if(m_num==4) { i=0; do { if(fp) fclose(fp); sprintf(string,"mapper%02d%s",i++,Suffix); fp=open_to_read_binary(string); }while(fp); if(fp) fclose(fp); save_map(string); } if(m_num==5) { sprintf(string,"*%s",Suffix); SetVideoMode(0); if(search_list(string,cfile)>=0) { video_on(); unsave_map(cfile); check_points(); } else { printf("No maps chosen.\n\n"); exit(0); } } if(m_num==6) { ix=ScreenXs/2; iy=ScreenYs/2; speed=16; pix_loc(ix,iy,&ix,&iy,&speed); } if(m_num==7) { pixsize=M.Pixsize; vector_plot(pixsize); } if(m_num==8) { ix=ScreenXs/2; iy=ScreenYs/2; isize=FontSize; color=M.White; while(annotate(&ix,&iy,&isize,&color)!=27); } if(m_num==9) { ix=ScreenXs/2; iy=ScreenYs/2; color=M.White; if(Mouse==0) while(draw_line(&ix,&iy,&color)!=27); else mouse_draw_line(&color); } if(m_num==10) add_graticule(); if(m_num==11) point=point_plot(M.Pixsize,point); if(m_num==12) { pixsize=M.Pixsize; clat=M.Clat; clon=M.Clon; space=M.Space; xc=0;yc=0; xs=ScreenXs;ys=ScreenYs; multiple_maps(xc,yc,xs,ys,pixsize,clat,clon,space); } }while(m_num!=MENU_M-1); SetVideoMode(0); if(Fpout) fclose(Fpout); if(FpLab) fclose(FpLab); if(FpGrd) fclose(FpGrd); } /********************************************************************** ** ** ** **********************************************************************/ int full_screen() { Tx=ScreenXs; Ty=ScreenYs; ScreenXs=ScrnX; ScreenYs=ScrnY; } /********************************************************************** ** ** ** **********************************************************************/ int return_screen() { ScreenXs=Tx; ScreenYs=Ty; } /*********************************************************************** ** ** ** ***********************************************************************/ int set_range(mapfile) char *mapfile; { int i,j,k; char string[100]; FILE *fphdr,*fpmpr; int numsec; float mll[4]; float mnln,mxln,mnlt,mxlt; long offset; strcpy(string,mapfile); for(k=0;kFr[i][j].maxlon) Fr[i][j].maxlon=mxln; if(mxlt>Fr[i][j].maxlat) Fr[i][j].maxlat=mxlt; } printf("Latitude[%2d][%2d]: %11.6f %11.6f\n", i,j,Fr[i][j].minlat,Fr[i][j].maxlat); if(Fpout) fprintf(Fpout,"Latitude[%2d][%2d]: %11.6f %11.6f\n", i,j,Fr[i][j].minlat,Fr[i][j].maxlat); printf("Longitude[%2d][%2d]: %11.6f %11.6f\n", i,j,Fr[i][j].minlon,Fr[i][j].maxlon); if(Fpout) fprintf(Fpout,"Longitude[%2d][%2d]: %11.6f %11.6f\n", i,j,Fr[i][j].minlon,Fr[i][j].maxlon); } else { printf("\nCould not find '%s'\n",string); if(Fpout) fprintf(Fpout,"\nCould not find '%s'\n",string); } if(fphdr) fclose(fphdr); } } if(fpmpr) fwrite((char *)Fr,sizeof(struct file_range),NUM_TYPE*NUM_SIZE,fpmpr); if(fpmpr) fclose(fpmpr); return(1); } /*********************************************************************** ** ** sets NumPicture, PictureOn[], NumText and TextOn[] ** ** Picture files have file type '.lbl' as last field ** Text files have file type '.txt' as last field ** ************************************************************************/ int check_points() { int i,j,k; FILE *fploc; char string[STR_LEN],id[STR_LEN],id1[STR_LEN],*result; char dsk,pth[STR_LEN],nam[10],typ[10],str[STR_LEN]; double lat,lon; NumPicture=NumText=0; for(i=0;i0) { if(PictureOn[i]==0&&strcmpi(typ,"lbl")==0) { PictureOn[i]=1; NumPicture+=1; } if(TextOn[i]==0&&strcmpi(typ,"lbl")==0) { TextOn[i]=1; NumText+=1; } } } if(fploc) fclose(fploc); } } } /************************************************************************** ** ** ** ************************************************************************* */ int vector_label(vi,ix,iy,size) int vi,ix,iy,size; { int i,j,k,ij; int boxsize=10; double x,y,maxlat,minlat,maxlon,minlon,mindist=100000000.0,rot,r; int v_num=0,val,cx,cy,hit=0,d1,d2=11/size,len; long attr,attrib; char string[100]; float pixsize=M.Pixsize; x=ix+boxsize; y=iy-boxsize; xy_ll(x,y,&maxlat,&maxlon); x=ix-boxsize; y=iy+boxsize; xy_ll(x,y,&minlat,&minlon); x=ix; y=iy; i=vi; if(i>=0&&ipixsize &&M.MapFile[i][j].min_pix*PixScale<=pixsize &&Fr[i][j].maxlon>MinLon &&Fr[i][j].minlonMinLat &&Fr[i][j].minlat0) { val=getch(); if(val==27) return(-2); } if(check_atr(M.MapFile[i][j].filename,&mindist,x,y,&cx,&cy, &attr,&r,(float)maxlat,(float)minlat, (float)maxlon,(float)minlon)>0) { attrib=attr; ij=j; ix=cx; iy=cy; hit+=1; rot=r; } } } } if(hit>0) { sprintf(string,"%ld",attrib); len=strlen(string)*15/size; d1=len/2; if(rot==0.0) { iy-=d2; ix-=d1; plot_font_h(M.White,ix,iy,string,size,Font); /* plot_font_h(M.MapFile[i][ij].color,ix,iy,string,size,Font);*/ } else if(rot==90.0) { iy+=d1; ix-=d2; plot_font_v(M.White,ix,iy,string,size,Font); /* plot_font_v(M.MapFile[i][ij].color,ix,iy,string,size,Font);*/ } else { r=rot*DEG_RAD; ix-=d1*cos(r)+d2*sin(r); iy+=d1*sin(r)-d2*cos(r); plot_font_rot(M.White,ix,iy,string,size,Font,rot); /* plot_font_rot(M.MapFile[i][ij].color,ix,iy,string,size,Font,rot);*/ } } } /*********************************************************************** ** ** ** ***********************************************************************/ int check_atr(region,mindist,cur_x,cur_y,cx,cy, attrib,rot,maxlat,minlat,maxlon,minlon) char *region; double *mindist,cur_x,cur_y; int *cx,*cy; long *attrib; double *rot; float maxlat,minlat,maxlon,minlon; { int i,i1,i2,j,k,m,n=0,p; double x,y,xo,yo; int ix,iy,ixo=-1,iyo=-1; double dx,dy,dist; int secnum,numpt,numsec,ival; FILE *fp,*fphdr,*fpatr; float latlon[2],mll[4],mnln,mxln,mnlt,mxlt; char string[40],pth[40],name[40],type[40]; int doit,numplot=0; int first_seg=-1,last_seg=-1,atr=1; long offset,attr; int changed=0,lag=2; float px[21],py[21],pi=-1,ox1,oy1,ox2,oy2; strcpy(string,region); strcat(string,".atr"); fpatr=open_to_read_binary(string); if(!fpatr) return(-1); strcpy(string,region); strcat(string,".hdr"); fphdr=open_to_read_binary(string); if(!fphdr) return(-1); strcpy(string,region); strcat(string,".bin"); fp=open_to_read_binary(string); if(!fp) return(-1); fread((char *)&numsec,sizeof(int),1,fphdr); fread((char *)&numsec,sizeof(int),1,fp); for(j=0;j0) { ival=getch(); if(ival==27) { if(fp) fclose(fp); if(fpatr) fclose(fpatr); if(fphdr) fclose(fphdr); return(-2); } } fread((char *)&offset,sizeof(long),1,fphdr); fread((char *)mll,sizeof(float),4,fphdr); fread((char *)&attr,sizeof(long),1,fpatr); doit=1; mnln=mll[0];mxln=mll[1];mnlt=mll[2];mxlt=mll[3]; if(mnln>maxlon||mnlt>maxlat||mxln90.0) *rot-=180.0; if(*rot<-90.0) *rot+=180.0; return(changed); } /*********************************************************************** ** ** ** ** ************************************************************************/ int picture_view(string) char *string; { int i,j,k; char filename[STR_LEN],str1[50],str2[50],str3[50],str4[50]; int ans; FILE *fp; char instring[STR_LEN],infile[STR_LEN]; if(sscanf(string,"%s%s%s%s",str1,str2,str3,str4)<4) return(-1); SetVideoMode(0); do { SetCursor(0,0); ans=get_file_name(str4,filename); if(ans<0) { video_on(); return(1); } strcpy(Hdr[Img].label,filename); for(k=0;k0) { video_on(); process_image(Img); SetVideoMode(0); } }while(ans>=0); video_on(); } /************************************************************************** ** ** ** ************************************************************************* */ int process_image(filenum) int filenum; { int num=0; int ix=ScreenXs/2,iy=ScreenYs/2,speed=16; int meni_iv=0; load_image(filenum); do { num=M_do_menu(Menu_iv,MENU_IV,MENUXC,25,num,D_Grey,L_Grey,White,Font); if(num==0) { load_image(filenum); } }while(num0) { offset=Hdr[filenum].header_bytes; fseek(fp,offset,SEEK_SET); } video_on(); do { Sample=sample+=1; Row=Hdr[filenum].row/sample; Col=Hdr[filenum].col/sample; offset=(sample-1); offset*=Hdr[filenum].col; }while(Col>ScreenXs||Row>ScreenYs); Hdr[filenum].sample=sample; if(Hdr[filenum].pal_type>0) IV_set_lut(Hdr[filenum].pal_type); else { if(IV_set_lut('P',Hdr[filenum].Lut)<0) IV_set_lut('G'); } plot_full_image(fp,sample,filenum); if(sample>1) { sample=ZoomSample; if(limit_area_fixed(&Xc,&Yc,&xs,&ys,&Speed,&sample)!=27) { ZoomSample=sample; plot_sub_image(fp,sample,filenum); } else { ZoomSample=Sample; } } if(fp) fclose(fp); } /******************************************************************** ** ** type g -- grey all lut[] files ** G -- grey only lut[] ** i -- initial header map ** r -- reset lut[] to lutc[] ** p -- positive (0-127) magenta, negative (128-255) green ** ********************************************************************* */ int IV_set_lut(type,filename) char type,*filename; { int i,k,hue,brite,j; int r,g,b; float color[3]; double dbrite,dval; float val,minval,sat,inten; float fval,fk; FILE *fplut; int end=0,scale,sum; char string[100]; long del,mindel,l1,l2,l3,l4; scale=1; if(Num_Color==16) scale=17; if(type=='P') { fplut=open_to_read_binary(filename); if(fplut) { i=0; do { i+=1; fscanf(fplut,"%s",string); }while(strcmpi(string,"end")!=0&&i<50); if(strcmpi(string,"end")!=0) rewind(fplut); for(i=0;i<256;i++) { fscanf(fplut,"%d%d%d%d",&k,&r,&g,&b); Hdr[Img].lut[i].r=r; Hdr[Img].lut[i].g=g; Hdr[Img].lut[i].b=b; } if(fplut) fclose(fplut); } else return(-1); if(VideoType=='V'||VideoType=='E') { for(i=0;i<256;i++) { sum=(int)Hdr[Img].lut[i].r*10; sum+=(int)Hdr[Img].lut[i].g*8; sum+=(int)Hdr[Img].lut[i].b*2; sum/=319; Hdr[Img].vga_color[i]=sum; } for(k=0;k0) offset+=Hdr[filenum].header_bytes; fseek(fp,offset,SEEK_SET); Row=ScreenYs; Col=ScreenXs; if((Yc*Sample+Row*sample)>Hdr[filenum].row) Row=(Hdr[filenum].row-Yc*Sample)/sample; if((Xc*Sample+Col*sample)>Hdr[filenum].col) Col=(Hdr[filenum].col-Xc*Sample)/sample; offset=Hdr[filenum].col; offset*=(sample-1); for(i=0;i1) for(j=0;j0) fseek(fp,offset,SEEK_SET); offset=(sample-1); offset*=Hdr[filenum].col; for(i=0;i0) fseek(fp,offset,SEEK_CUR); if(sample>1) for(j=0;j1) { fpsub=open_to_write_binary(string); if(fpsub) { fwrite((char *)&Row,sizeof(int),1,fpsub); fwrite((char *)&Col,sizeof(int),1,fpsub); for(i=0;i1)*speed/=2; else if(ans=='+'&&*speed1) *sample-=1; *xs=ScreenXs/Sample*(*sample); *ys=ScreenYs/Sample*(*sample); if(ans==0) { ans=getch(); if(ans==71) { *xc-=*speed; *yc-=*speed; } else if(ans==73) { *xc+=*speed; *yc-=*speed; } else if(ans==79) { *xc-=*speed; *yc+=*speed; } else if(ans==81) { *xc+=*speed; *yc+=*speed; } else if(ans==72) *yc-=*speed; else if(ans==80) *yc+=*speed; else if(ans==75) *xc-=*speed; else if(ans==77) *xc+=*speed; } if(*xs>ScreenXs)*xs=ScreenXs; if(*ys>ScreenYs)*ys=ScreenYs; if(*xs<2)*xs=2; if(*ys<2)*ys=2; if((*xc+*xs)>=ScreenXs)*xc=ScreenXs-*xs; if((*yc+*ys)>=ScreenYs)*yc=ScreenYs-*ys; if(*xc<0)*xc=0; if(*yc<0)*yc=0; tbox_val(3,*xc,*yc,*xs,*ys,Mbuff,Black,White,Center); }while(ans!=83&&ans!=27&&ans!=13); unbox(3,*xc,*yc,*xs,*ys,Mbuff); return(ans); } /************************************************************************** ** ** ** ************************************************************************* */ int read_lbl(label,filenum) char *label; int filenum; { int i,j,k; char string1[100],string2[100],string3[100]; FILE *fp; int status=1,numread; fp=open_to_read_binary(label); if(!fp) return(-1); Hdr[filenum].sample_bits=Hdr[filenum].record_bytes=0; Hdr[filenum].file_records=0; Hdr[filenum].pal_type=0; Hdr[filenum].row_col_header=0; while(fscanf(fp,"%s",string1)==1) { if(strcmpi(string1,"end")==0) { if(fp) fclose(fp); return(status); } if(strcmpi(string1,"image_lines")==0&&Hdr[filenum].file_records==0) { numread=fscanf(fp,"%s%s",string2,string3); if(strcmpi(string2,"end")==0||strcmpi(string3,"end")==0|| numread<2) { if(fp) fclose(fp); return(status); } sscanf(string3,"%d",&Hdr[filenum].row); printf("Row = %d\n",Hdr[filenum].row); } if(strcmpi(string1,"sample_bits")==0) { numread=fscanf(fp,"%s%s",string2,string3); if(strcmpi(string2,"end")==0||strcmpi(string3,"end")==0|| numread<2) { if(fp) fclose(fp); return(status); } sscanf(string3,"%d",&Hdr[filenum].sample_bits); printf("Sample_Bits = %d\n",Hdr[filenum].sample_bits); } if(strcmpi(string1,"file_records")==0) { numread=fscanf(fp,"%s%s",string2,string3); if(strcmpi(string2,"end")==0||strcmpi(string3,"end")==0|| numread<2) { if(fp) fclose(fp); return(status); } sscanf(string3,"%d",&Hdr[filenum].row); printf("Row = %d\n",Hdr[filenum].row); Hdr[filenum].file_records=Hdr[filenum].row; } if(strcmpi(string1,"line_samples")==0&&Hdr[filenum].record_bytes==0) { numread=fscanf(fp,"%s%s",string2,string3); if(strcmpi(string2,"end")==0||strcmpi(string3,"end")==0|| numread<2) { if(fp) fclose(fp); return(status); } sscanf(string3,"%d",&Hdr[filenum].col); printf("Col = %d\n",Hdr[filenum].col); } if(strcmpi(string1,"record_bytes")==0|| strcmpi(string1,"image_record_bytes")==0) { numread=fscanf(fp,"%s%s",string2,string3); if(strcmpi(string2,"end")==0||strcmpi(string3,"end")==0|| numread<2) { if(fp) fclose(fp); return(status); } sscanf(string3,"%d",&Hdr[filenum].col); printf("Col = %d\n",Hdr[filenum].col); Hdr[filenum].record_bytes=Hdr[filenum].col; } if(strcmpi(string1,"header_bytes")==0) { numread=fscanf(fp,"%s%s",string2,string3); if(strcmpi(string2,"end")==0||strcmpi(string3,"end")==0|| numread<2) { if(fp) fclose(fp); return(status); } sscanf(string3,"%d",&Hdr[filenum].header_bytes); printf("Header_Bytes = %d\n",Hdr[filenum].header_bytes); } if(strcmpi(string1,"image_pointer")==0) { numread=fscanf(fp,"%s%s",string2,string3); if(strcmpi(string2,"end")==0||strcmpi(string3,"end")==0|| numread<2) { if(fp) fclose(fp); return(status); } k=0; for(i=0;i5.0) { sp=10; plot_graticule(Font,M.Grat,M.LatLon,sp,M.GratOn); } if(pixsize>2.5&&pixsize<=5.0) { sp=5; plot_graticule(Font,M.Grat,M.LatLon,sp,M.GratOn); } if(pixsize<=2.5&&pixsize>0.5) { sp=1; plot_graticule(Font,M.Grat,M.LatLon,sp,M.GratOn); } if(pixsize<=0.5&&pixsize>0.25) { sp=0.5; plot_graticule_frac(Font,M.Grat,M.LatLon,sp,M.GratOn); } if(pixsize<=0.25&&pixsize>0.05) { sp=0.1; plot_graticule_frac(Font,M.Grat,M.LatLon,sp,M.GratOn); } if(pixsize<=0.05&&pixsize>0.025) { sp=0.05; plot_graticule_frac(Font,M.Grat,M.LatLon,sp,M.GratOn); } if(pixsize<=0.025&&pixsize>0.005) { sp=0.01; plot_graticule_frac(Font,M.Grat,M.LatLon,sp,M.GratOn); } if(pixsize<=0.005&&pixsize>0.0025) { sp=0.005; plot_graticule_frac(Font,M.Grat,M.LatLon,sp,M.GratOn); } if(pixsize<=0.0025) { sp=0.001; plot_graticule_frac(Font,M.Grat,M.LatLon,sp,M.GratOn); } } /*********************************************************************** ** ** ** ** ************************************************************************/ FILE *open_to_write_text(name) char *name; { int i,j,k; FILE *fp; char string[STR_LEN]; for(j=0;j0&&len0&&len0) sprintf(str,"%c:%s",dsk,pth); else sprintf(str,"%s",pth); if((dsk>0||strlen(pth)>0)&&NumPath0) { i-=1; string[i]='\0'; unsave_box(0,background,Mbuff,cxc,cyc,cxs,cys); save_box(0,background,Mbuff,cxc,cyc,cxs,cys); plot_font_h(*color,cxc,cyc,string,*size,MapFont); } if(ans>=0x20) { string[i]=ans; string[i+1]='\0'; plot_font_h(*color,cxc,cyc,string,*size,MapFont); i+=1; } if(ans==0) { ans2=getch(); if(ans2>=71&&ans2<=73) *color+=1; if(ans2>=79&&ans2<=81) *color-=1; if(*color>15) *color=0; if(*color<0) *color=15; if(*color==0) background=M.Back; else background=0; unsave_box(0,background,Mbuff,cxc,cyc,cxs,cys); if(ans2==75&&*size<4) *size+=1; if(ans2==77&&*size>1) *size-=1; cyc=ScreenYs-28/(*size); ys=cys=28/(*size); save_box(0,background,Mbuff,cxc,cyc,cxs,cys); plot_font_h(*color,cxc,cyc,string,*size,MapFont); } }while(ans!=27&&ans!=13); unsave_box(0,background,Mbuff,cxc,cyc,cxs,cys); if(ans==27) return(ans); xs=strlen(string)*15/(*size); if(Mouse==0) { if(limit_area(&xc,&yc,&xs,&ys,&speed,ScreenXs,0,Mbuff)!=27) plot_font_h(*color,xc,yc,string,*size,MapFont); } else { if(mouse_limit_area(&xc,&yc,&xs,&ys,&speed,ScreenXs,0,Mbuff)!=27) plot_font_h(*color,xc,yc,string,*size,MapFont); } *ix=xc; *iy=yc; return(ans); } /************************************************************************** ** ** ** ************************************************************************* */ int draw_line(ix,iy,color) int *ix,*iy,*color; { int i,j,k; char string[STR_LEN],ans,ans2; int x1=*ix,x2,y1=*iy,y2,speed=16,xo=*ix,yo=*iy; int val; val=getpt(0,x1,y1); tcursor(3,x1,y1,7,Mbuff); cursor(0,x1,y1,M.Comp_Color[val],7); do { ans=getch(); if(ans==0) { ans2=getch(); if(ans2==71) { x1-=speed; y1-=speed; } if(ans2==73) { x1+=speed; y1-=speed; } if(ans2==79) { x1-=speed; y1+=speed; } if(ans2==81) { x1+=speed; y1+=speed; } if(ans2==72) y1-=speed; if(ans2==80) y1+=speed; if(ans2==75) x1-=speed; if(ans2==77) x1+=speed; if(x1<0) x1=0; if(x1>=ScreenXs) x1=ScreenXs-1; if(y1<0) y1=0; if(y1>=ScreenYs) y1=ScreenYs-1; } if(ans=='-'&&speed>2) speed/=2; if(ans=='+'&&speed<128) speed*=2; uncursor(3,xo,yo,7,Mbuff); val=getpt(0,x1,y1); tcursor(3,x1,y1,7,Mbuff); cursor(0,x1,y1,M.Comp_Color[val],7); xo=x1; yo=y1; }while(ans!=27&&ans!=13); uncursor(3,xo,yo,7,Mbuff); if(ans==27) return(ans); xo=x2=x1;yo=y2=y1; tplotln_inv_dot(0,x1,y1,x2,y2,Mbuff,ScreenXs); tcursor(3,x2,y2,7,Buffer); cursor(0,x2,y2,*color,7); do { ans=getch(); if(ans==0) { ans2=getch(); if(ans2==71) { x2-=speed; y2-=speed; } if(ans2==73) { x2+=speed; y2-=speed; } if(ans2==79) { x2-=speed; y2+=speed; } if(ans2==81) { x2+=speed; y2+=speed; } if(ans2==72) y2-=speed; if(ans2==80) y2+=speed; if(ans2==75) x2-=speed; if(ans2==77) x2+=speed; if(x2<0) x2=0; if(x2>=ScreenXs) x2=ScreenXs-1; if(y2<0) y2=0; if(y2>=ScreenYs) y2=ScreenYs-1; } if(ans=='c') *color-=1; if(ans=='C') *color+=1; if(*color>15) *color=0; if(*color<0) *color=15; if(ans=='-'&&speed>2) speed/=2; if(ans=='+'&&speed<128) speed*=2; uncursor(0,xo,yo,7,Buffer); unplotln(0,x1,y1,xo,yo,Mbuff); xo=x2; yo=y2; tplotln_inv_dot(0,x1,y1,x2,y2,Mbuff,ScreenXs); plotln(0,x1,y1,x2,y2,*color); tcursor(0,x2,y2,7,Buffer); cursor(0,x2,y2,*color,7); }while(ans!=27&&ans!=13); uncursor(3,xo,yo,7,Buffer); unplotln(0,x1,y1,xo,yo,Mbuff); if(ans==27) return(ans); plotln(0,x1,y1,x2,y2,*color); *ix=x2; *iy=y2; return(ans); } /************************************************************************** ** ** ** ************************************************************************* */ int vector_plot(pixsize) float pixsize; { int i,j,k; int v_num=0,val; for(i=0;i=0&&ipixsize &&M.MapFile[i][j].min_pix*PixScale<=pixsize &&Fr[i][j].maxlon>MinLon &&Fr[i][j].minlonMinLat &&Fr[i][j].minlat0) { val=getch(); if(val==27) return(-2); } convert_bin(M.MapFile[i][j].color, M.MapFile[i][j].filename); } } } return(0); } /************************************************************************** ** ** ** ************************************************************************* */ int point_plot(pixsize,start) float pixsize; int start; { int i,j,k; int p_num=start,p_numo=start,val; for(i=0;i=0&&i=PlaceFile[i].min_pix&&pixsize=PlaceFile[i].min_pix&&pixsize0) { kbval=getch(); if(kbval==27) return(-2); } sprintf(String,"%s%s",Path[j],list); if(load_names(String)>0) val=get_file_name(String,string); else val=-1; if(val>=0) return(val); } return(val); } /************************************************************************** ** ** ** ************************************************************************* */ int save_map(name) char *name; { int i,j,k; FILE *fp; double lat,lon; ScreenXs=MaxXs; ScreenYs=MaxYs; xy_ll((double)(ScreenXs/2),(double)(ScreenYs/2),&lat,&lon); miv.indat[0]=M.Pixsize; miv.indat[1]=M.Clat=lat; miv.indat[2]=M.Clon=lon; miv.indat[3]=M.Clon; miv.indat[4]=M.Clat+10; miv.indat[5]=M.Clat-10; map_pos.xc=0; map_pos.yc=0; map_pos.xs=ScreenXs; map_pos.ys=ScreenYs; auto_set_cc(miv.type,miv.indat); fp=open_to_write_binary(name); if(!fp) return(-1); strcpy(LastMap,LastFile); M.screen_xs=ScreenXs; M.screen_ys=ScreenYs; fwrite((char *)&M,sizeof(struct map),1,fp); if(M.NumSymbol>0) fwrite((char *)PlaceFile,sizeof(struct symbol_name),M.NumSymbol,fp); if(M.Range==1&&fp) fwrite((char *)Fr,sizeof(struct file_range),NUM_TYPE*NUM_SIZE,fp); if(M.Pattern>0) fwrite((char *)Pat,sizeof(struct pattern),240,fp); for(i=0;i0) fread((char *)PlaceFile,sizeof(struct symbol_name),M.NumSymbol,fp); if(M.Range==1&&fp) fread((char *)Fr,sizeof(struct file_range),NUM_TYPE*NUM_SIZE,fp); if(M.Pattern>0) fread((char *)Pat,sizeof(struct pattern),240,fp); ScreenXs=M.screen_xs; ScreenYs=M.screen_ys; WritePalette(M.lut); for(i=0;iNUM_TYPE) { SetVideoMode(0); printf("Too many vector groups.\n"); exit(0); } for(i=0;i0&&strcmpi(string1,"begin_color")!=0); if(numread<1) return(-2); /* could not find 'begin_color' */ i=0; do { fscanf(fp,"%s",M.Color_Name[i]); if(strcmpi(M.Color_Name[i],"end_color")!=0) { numread=fscanf(fp,"%s%d%d%d", string1,&M.Color_Val[i][0],&M.Color_Val[i][1],&M.Color_Val[i][2]); if(strcmpi(M.Color_Name[i],"white")==0) { M.White=i; } if(strcmpi(M.Color_Name[i],"black")==0) { M.Black=i; } } if(numread==4&&M.Out==1&&Fpout) fprintf(Fpout,"%20s = %4d%4d%4d\n",M.Color_Name[i], M.Color_Val[i][0],M.Color_Val[i][1],M.Color_Val[i][2]); i+=1; }while(numread==4&&strcmpi(M.Color_Name[i-1],"end_color")!=0&&i=0&&val=0&&val=0&&val=0&&val=0&&val=0&&val=0&&val0&&strcmpi(string1,"begin_vector")!=0); if(numread<1) return(-3); /* could not find 'begin_vector' */ i=0; do { numread=fscanf(fp,"%s",M.Group_Name[i]); if(numread==1&&strcmpi(M.Group_Name[i],"begin_names")==0) { do { numread==fscanf(fp,"%s",String); if(strcmpi(String,"end_names")!=0) { strcpy(PlaceFile[p].name,String); fscanf(fp,"%s%s",string1,string2); { if(strcmpi(string2,"ON")==0) PlaceFile[p].on=1; else if(strcmpi(string2,"OFF")==0) PlaceFile[p].on=0; else { printf("'%s' is not marked ON or OFF\n\n", PlaceFile[p].name); exit(0); } } fscanf(fp,"%s%f%f%s", PlaceFile[p].filename, &PlaceFile[p].max_pix,&PlaceFile[p].min_pix, string3); val=get_color(string3); if(val>=0&&val=NUM_SYM) { printf("Too many symbols\n"); exit(0); } M.NumSymbol=p; } }while(strcmpi(String,"end_names")!=0); numread=3; } else if(numread==1&&strcmpi(M.Group_Name[i],"fillin_ihs")==0) { M.Fill_In=3; M.Fill_After=i-1; fscanf(fp,"%s%d",String,&M.Num_Fill); for(m=0;mM.Max_Fill) M.Max_Fill=k; M.Fill_Order[n++]=k; strcpy(M.Fill_Name[k],string3); } }while(strcmpi(string1,"end")!=0); numread=3; } else if(numread==1&&strcmpi(M.Group_Name[i],"pattern")==0) { do { fscanf(fp,"%s",string1); if(strcmpi(string1,"end")==0) { patend=1; } else { sscanf(string1,"%d",&numpat); if(numpat>0&&numpat<240) { Pat[numpat].status=1; if(VideoType!='E'&&VideoType!='V') M.Pattern=1; for(ii=0;ii<8;ii++) { for(jj=0;jj<8;jj++) { val=-1; fscanf(fp,"%s",string1); if(string1[0]>='0'&&string1[0]<='9') val=string1[0]-'0'; else if(string1[0]>='a'&&string1[0]<='f') val=string1[0]-'a'+10; else if(string1[0]>='A'&&string1[0]<='F') val=string1[0]-'A'+10; Pat[numpat].pattern[ii][jj]=val; } } } else { printf("error reading pattern in '.map' file.\n\n"); exit(0); } } }while(patend==0); numread=3; } else { if(numread==1&&strcmpi(M.Group_Name[i],"end_vector")!=0) { numread=fscanf(fp,"%s%d%s", string1,&M.Ns[i],string2); strcpy(T_Menu_L[i][0],M.Group_Name[i]); strcat(T_Menu_L[i][0]," OFF"); strcpy(T_Menu_L[i][1],M.Group_Name[i]); strcat(T_Menu_L[i][1]," ON"); if(M.Out==1&&Fpout) fprintf(Fpout,"\n%s = %d %s \n",M.Group_Name[i],M.Ns[i],string2); if(strcmpi(string2,"ON")==0) M.Mm[i]=1; else M.Mm[i]=0; if(M.Ns[i]==0||M.Ns[i]>NUM_SIZE) { printf("Bad M.Ns = %d\n",M.Ns[i]); return(-4); /* too many vectors in a group */ } } for(k=0;k=0&&valyc+ys-1)cur_iy=yc+ys-1; if(cur_ix>xc+xs-1)cur_ix=xc+xs-1; } } if(ans=='h'||ans=='H') { txs=ScreenXs; ScreenXs=MaxXs; unsave_box(0,M.Back,Mbuff,0,ScreenYs-32/lsize,ScreenXs,32/lsize); save_box(0,M.Back,Mbuff, 0,0,MaxXs,32/lsize); paint_box(0,M.Back,MT_Buff,0,0,ScreenXs,32/lsize); sprintf(String, "(s)maller (l)arger 'Enter'=plot 'Esc'=exit without plotting"); plot_font_h(M.White,1,1,String,FontSize,Font); ans=getch(); unsave_box(0,M.Back,Mbuff, 0,0,MaxXs,32/lsize); ScreenXs=txs; save_box(0,M.Back,Mbuff,0,ScreenYs-32/lsize,ScreenXs,32/lsize); } if(ans=='l')cur_ps*=cur_scale; if(ans=='s')cur_ps/=cur_scale; if(cur_ps1) speed/=2; else cur_scale=sqrt((double)cur_scale); } if(ans=='+'&&speed<256)speed*=2; unplotln(0,ix[0],iy[0]+1,ix[1],iy[1],MT_Buff[0]); unplotln(0,ix[1]+1,iy[1],ix[2],iy[2],MT_Buff[1]); unplotln(0,ix[2],iy[2]-1,ix[3],iy[3],MT_Buff[2]); unplotln(0,ix[3]-1,iy[3],ix[0],iy[0],MT_Buff[3]); xy_ll((double)cur_ix,(double)cur_iy,&dlat,&dlon); cur_clat=dlat;cur_clon=dlon; get_corners(xc,yc,xs,ys, m_ps,m_clat,m_clon,cur_ps,cur_clat,cur_clon,ix,iy); tplotln_val(0,ix[0],iy[0]+1,ix[1],iy[1],MT_Buff[0],M.White); tplotln_val(0,ix[1]+1,iy[1],ix[2],iy[2],MT_Buff[1],M.White); tplotln_val(0,ix[2],iy[2]-1,ix[3],iy[3],MT_Buff[2],M.White); tplotln_val(0,ix[3]-1,iy[3],ix[0],iy[0],MT_Buff[3],M.White); paint_box(0,M.Back,MT_Buff,0,ScreenYs-32/lsize,ScreenXs,32/lsize); if(cur_ps>1.0) sprintf(string, "Box Center: pixel size = %0.2f km lat = %9.5f lon = %10.5f", cur_ps,cur_clat,cur_clon); else if(cur_ps>0.01) sprintf(string, "Box Center: pixel size = %0.2f m lat = %9.5f lon = %10.5f", cur_ps*1000.0,cur_clat,cur_clon); else if(cur_ps>0.0001) sprintf(string, "Box Center: pixel size = %0.4f m lat = %9.5f lon = %10.5f", cur_ps*1000.0,cur_clat,cur_clon); else sprintf(string, "Box Center: pixel size = %0.6f m lat = %9.5f lon = %10.5f", cur_ps*1000.0,cur_clat,cur_clon); plot_font_h(M.White,2,ScreenYs-30/lsize,string,lsize,Font); }while(ans!=83&&ans!=27&&ans!=13); unplotln(0,ix[0],iy[0]+1,ix[1],iy[1],MT_Buff[0]); unplotln(0,ix[1]+1,iy[1],ix[2],iy[2],MT_Buff[1]); unplotln(0,ix[2],iy[2]-1,ix[3],iy[3],MT_Buff[2]); unplotln(0,ix[3]-1,iy[3],ix[0],iy[0],MT_Buff[3]); M.Pixsize=*pixsize=cur_ps; M.Clat=*clat=cur_clat; M.Clon=*clon=cur_clon; unsave_box(0,M.Back,Mbuff,0,ScreenYs-32/lsize,ScreenXs,32/lsize); if(cur_ps<20) { *space=30.0; return(ans); } if(cur_ps<10) { *space=15.0; return(ans); } if(cur_ps<2) { *space=5.0; return(ans); } *space=1.0; return(ans); } /******************************************************************** ** ** ** ********************************************************************* */ void get_corners(xc,yc,xs,ys,m_pixsize,m_clat,m_clon, cur_pixsize,cur_clat,cur_clon,x,y) int xc,yc,xs,ys; float m_pixsize,m_clat,m_clon,cur_pixsize,cur_clat,cur_clon; int x[4],y[4]; { int i,j,k; double lat[4],lon[4],dx,dy; miv.indat[0]=cur_pixsize; miv.indat[1]=cur_clat; miv.indat[2]=cur_clon; miv.indat[3]=cur_clon; miv.indat[4]=cur_clat+10; miv.indat[5]=cur_clat-10; map_pos.xc=xc; map_pos.yc=yc; map_pos.xs=xs; map_pos.ys=ys; auto_set_cc(miv.type,miv.indat); xy_ll((double)xc,(double)yc,lat+0,lon+0); xy_ll((double)xc,(double)yc+ys-1,lat+1,lon+1); xy_ll((double)xc+xs-1,(double)yc+ys-1,lat+2,lon+2); xy_ll((double)xc+xs-1,(double)yc,lat+3,lon+3); miv.indat[0]=m_pixsize; miv.indat[1]=m_clat; miv.indat[2]=m_clon; miv.indat[3]=m_clon; miv.indat[4]=m_clat+10; miv.indat[5]=m_clat-10; map_pos.xc=xc; map_pos.yc=yc; map_pos.xs=xs; map_pos.ys=ys; auto_set_cc(miv.type,miv.indat); for(i=0;i<4;i++) { ll_xy(&dx,&dy,lat[i],lon[i]); x[i]=dx; y[i]=dy; } } /******************************************************************** ** ** ** ********************************************************************* */ int plot_map(xc,yc,xs,ys,pixsize,clat,clon,space,iop) int xc,yc,xs,ys,iop; float pixsize,clat,clon,space; { int i,j,k,l,m; double sp=space; int num,val,filled=0; int ix=ScreenXs/2,iy=ScreenYs/2,speed=16; if(Fpout) { fprintf(Fpout,"\npixsize = %6.3f clat = %12.5f clon = %12.5f\n", pixsize,clat,clon); if(Repeat>1) { fprintf(Fpout,"Repeat = %d Rxc = %d Ryc = %d\n",Repeat,Rxc,Ryc); flushall(); } } miv.type=M.Type; miv.indat[0]=pixsize; miv.indat[1]=clat; miv.indat[2]=clon; miv.indat[3]=clon; miv.indat[4]=clat+10; miv.indat[5]=clat-10; map_pos.xc=xc; map_pos.yc=yc; map_pos.xs=xs; map_pos.ys=ys; auto_set_cc(miv.type,miv.indat); screen_mm(); if(iop==0) { paint_box(0,M.Back,MT_Buff,0,0,ScreenXs,ScreenYs); if(pixsize>5.0) { sp=10; if(M.Fill_In==0) plot_graticule(Font,M.Grat,M.LatLon,sp,M.GratOn); } if(pixsize>2.5&&pixsize<=5.0) { sp=5; if(M.Fill_In==0) plot_graticule(Font,M.Grat,M.LatLon,sp,M.GratOn); } if(pixsize<=2.5&&pixsize>0.5) { sp=1; if(M.Fill_In==0) plot_graticule(Font,M.Grat,M.LatLon,sp,M.GratOn); } if(pixsize<=0.5&&pixsize>0.25) { sp=0.5; if(M.Fill_In==0) plot_graticule_frac(Font,M.Grat,M.LatLon,sp,M.GratOn); } if(pixsize<=0.25&&pixsize>0.05) { sp=0.1; if(M.Fill_In==0) plot_graticule_frac(Font,M.Grat,M.LatLon,sp,M.GratOn); } if(pixsize<=0.05&&pixsize>0.025) { sp=0.05; if(M.Fill_In==0) plot_graticule_frac(Font,M.Grat,M.LatLon,sp,M.GratOn); } if(pixsize<=0.025&&pixsize>0.005) { sp=0.01; if(M.Fill_In==0) plot_graticule_frac(Font,M.Grat,M.LatLon,sp,M.GratOn); } if(pixsize<=0.005&&pixsize>0.0025) { sp=0.005; if(M.Fill_In==0) plot_graticule_frac(Font,M.Grat,M.LatLon,sp,M.GratOn); } if(pixsize<=0.0025) { sp=0.001; if(M.Fill_In==0) plot_graticule_frac(Font,M.Grat,M.LatLon,sp,M.GratOn); } if(Fpout) { fprintf(Fpout,"pixsize = %f\n",pixsize); fprintf(Fpout,"MaxLat=%f MinLat=%f MaxLon=%f MinLon=%f\n", MaxLat,MinLat,MaxLon,MinLon); } for(i=0;ipixsize &&M.MapFile[i][j].min_pix*PixScale<=pixsize &&M.Mm[i]==1 &&Fr[i][j].maxlon>MinLon &&Fr[i][j].minlonMinLat &&Fr[i][j].minlat0) { val=getch(); if(val==27) return(-1); } num=convert_bin(M.MapFile[i][j].color, M.MapFile[i][j].filename); if(num<-1) return(-2); if(M.Out==1&&Fpout) fprintf(Fpout,"%s -- color = %d plotted %d segments\n", M.MapFile[i][j].filename,M.MapFile[i][j].color,num); } } if(M.Fill_In>0&&i==M.Fill_After&&M.Mm[i]==1) { filled=0; for(m=0;mpixsize&& M.FI_min[m]*PixScale<=pixsize) { num=fill_in_area(M.Fill_In_Name[m]); if(num<-1) return(-2); filled=1; } } if(filled==1) { if(Saveit[0]==0) { save_box(0,M.Black,Mbuff,0,0,MaxXs,36/FontSize); if(Mouse==0) { sprintf(String, "You are in 'cursor mode', hit any key to continue or F1 for help."); plot_font_h(M.White,10/FontSize,5/FontSize,String,FontSize,Font); if(getch()==0) getch(); } unsave_box(0,M.Black,Mbuff,0,0,MaxXs,36/FontSize); pix_loc(ix,iy,&ix,&iy,&speed); } if(M.Pattern>0) make_pattern(0,ScreenXs-1); } } } for(i=0;i=PlaceFile[i].min_pix&&pixsize=0&&ix=0&&iy=0&&ix=0&&iyScreenXs)xc=ScreenXs-xs; if(yc+ys>ScreenYs)yc=ScreenYs-ys; if(xc<0||yc<0)return; for(i=0;iMaxLat)MaxLat=flat; if(flon>MaxLon)MaxLon=flon; if(flatMaxLat)MaxLat=flat; if(flon>MaxLon)MaxLon=flon; if(flatMaxLat)MaxLat=flat; if(flon>MaxLon)MaxLon=flon; if(flatMaxLat)MaxLat=flat; if(flon>MaxLon)MaxLon=flon; if(flatMaxLat)MaxLat=flat; if(flon>MaxLon)MaxLon=flon; if(flatMaxLat)MaxLat=flat; if(flon>MaxLon)MaxLon=flon; if(flatMaxLat)MaxLat=flat; if(flon>MaxLon)MaxLon=flon; if(flatMaxLat)MaxLat=flat; if(flon>MaxLon)MaxLon=flon; if(flat180.0) lon_l-=360.0; if(lon_r>180.0) lon_r-=360.0; lat=-89.999; /* south pole check */ ll_xy(&x,&y,lat,lon); if(x>=0.0&&x0.0&&y=0.0&&x0.0&&ylon_r) /* date line on screen */ { MinLon=-360.0; MaxLon= 360.0; } } /*********************************************************************** ** ** ** ***********************************************************************/ int auto_fill_in(hue,val,buffer,todo,cx,cy) int todo[2][MAXDO]; int hue,val; unsigned char *buffer; int cx,cy; { int i,j,k,m,n,l; int x=cx,y=cy,on=0; int lastup[2],lastdn[2]; int fillval,cval,kbval; double lat,lon,h=0.5; fillval=getpt(hue,x,y); if(fillval==val)return(-1); do { if(kbhit()>0) { kbval=getch(); if(kbval==27) return(-2); } lastup[0]=lastup[1]=lastdn[0]=lastdn[1]=-1; for(i=x;i=ScreenXs||getpt(hue,i,y)!=fillval) break; plotpt(hue,i,y,val); if(Grid>0&&FpGrd&&i%Grid==0&&y%Grid==0) { xy_ll((double)i+h,(double)y+h,&lat,&lon); fprintf(FpGrd," 0 0 %9.6lf %11.6lf %3d %3d\n", lat,lon,val,val-16); } on=check_point(hue,i,y,fillval,on,todo); if(y>0&&getpt(hue,i,y-1)==fillval) { lastup[0]=i; lastup[1]=y-1; } if(y=0&&on=0&&on0) { for(i=x-1;i>=0;i--) { if(i<0||getpt(hue,i,y)!=fillval) break; plotpt(hue,i,y,val); if(Grid>0&&FpGrd&&i%Grid==0&&y%Grid==0) { xy_ll((double)i+h,(double)y+h,&lat,&lon); fprintf(FpGrd," 0 0 %9.6lf %11.6lf %3d %3d\n", lat,lon,val,val-16); } on=check_point(hue,i,y,fillval,on,todo); if(y>0&&getpt(hue,i,y-1)==fillval) { lastup[0]=i; lastup[1]=y-1; } if(y=0&&on=0&&on0) { x=todo[0][on-1]; y=todo[1][on-1]; } }while(on>0); } /*********************************************************************** ** ** ** ***********************************************************************/ int auto_fill_in_2(hue,val1,val2,buffer,todo,cx,cy) int todo[2][MAXDO]; int hue,val1,val2; unsigned char *buffer; int cx,cy; { int i,j,k,m,n,l; int x=cx,y=cy,on=0; int lastup[2],lastdn[2]; int fillval,cval,kbval; fillval=getpt(hue,x,y); if(fillval==val1||fillval==val2) return(-1); do { if(kbhit()>0) { kbval=getch(); if(kbval==27) return(-2); } lastup[0]=lastup[1]=lastdn[0]=lastdn[1]=-1; for(i=x;i=ScreenXs||getpt(hue,i,y)!=fillval) break; if(((i+y)%2)==0) plotpt(hue,i,y,val1); else plotpt(hue,i,y,val2); on=check_point(hue,i,y,fillval,on,todo); if(y>0&&getpt(hue,i,y-1)==fillval) { lastup[0]=i; lastup[1]=y-1; } if(y=0&&on=0&&on0) { for(i=x-1;i>=0;i--) { if(i<0||getpt(hue,i,y)!=fillval) break; if(((i+y)%2)==0) plotpt(hue,i,y,val1); else plotpt(hue,i,y,val2); on=check_point(hue,i,y,fillval,on,todo); if(y>0&&getpt(hue,i,y-1)==fillval) { lastup[0]=i; lastup[1]=y-1; } if(y=0&&on=0&&on0) { x=todo[0][on-1]; y=todo[1][on-1]; } }while(on>0); } /*********************************************************************** ** ** ** ***********************************************************************/ int convert_bin(val,region) char *region; int val; { int i,j,k,m,n=0,p,oo=0; double x,y,xo,yo; int ix,iy,ixo=-1,iyo=-1; double dx,dy,dist; int secnum,numpt,numsec,ival; FILE *fp,*fphdr,*fpatr; float latlon[2],mll[4],mnln,mxln,mnlt,mxlt; char string[40],pth[40],name[40],type[40]; int doit,numplot=0; int first_seg=-1,last_seg=-1,atr=0; long offset,attrib=-1; strcpy(string,region); strcat(string,".bin"); fp=open_to_read_binary(string); if(!fp) { if(M.Out==1&&Fpout) fprintf(Fpout,"could not open '%s'\n",string); return(-1); } strcpy(string,region); strcat(string,".hdr"); fphdr=open_to_read_binary(string); if(!fphdr) { if(M.Out==1&&Fpout) fprintf(Fpout,"could not open '%s'\n",string); if(fp) fclose(fp); return(-1); } if(AttribOn==1) { strcpy(string,region); strcat(string,".atr"); fpatr=open_to_read_binary(string); if(fpatr) atr=1; } fread((char *)&numsec,sizeof(int),1,fphdr); fread((char *)&numsec,sizeof(int),1,fp); for(j=0;j0) { ival=getch(); if(ival==27) { if(fp) fclose(fp); if(fphdr) fclose(fphdr); return(-2); } } fread((char *)&offset,sizeof(long),1,fphdr); fread((char *)mll,sizeof(float),4,fphdr); doit=1; mnln=mll[0];mxln=mll[1];mnlt=mll[2];mxlt=mll[3]; if(mnln>MaxLon||mnlt>MaxLat||mxln=0&&ix=0&&iy0) plotln(0,ix,iy,ixo,iyo,val); ixo=ix;iyo=iy; xo=ix;yo=iy; if(atr==1&&i==0) { sprintf(string,"%ld",attrib); plot_font_h(M.White,ix+2,iy-3,string,2,Font); } } } if(ScreenCoord==1) fprintf(FpSc,"//\n"); } } if(fp) fclose(fp); if(fphdr) fclose(fphdr); if(atr!=0) fclose(fpatr); return(numplot); } /************************************************************************** ** ** ** ************************************************************************* */ int split(string,path,name,type) char *string,*path,*name,*type; { int i,j,k; int dot=-1,last_slash=-1,len=strlen(string),num=0; if(strlen(string)>STR_LEN) { SetVideoMode(0,&B_Id); printf("In split() -- string 1 too long!\n\n"); exit(0); } for(i=0;i0) { for(i=0;i0) num+=1; if(strlen(type)>0) num+=1; return(num); } /******************************************************************** ** ** ** ********************************************************************* */ void remove_boundaries(val) int val; { int i,j,k; int xc=0,yc=0,xs=ScreenXs,ys=ScreenYs; int x1=xc-1,x2=xc+xs; if(x1<0)x1=0; if(x2>ScreenXs-1)x2=ScreenXs-1; for(i=yc;i=MAXDO)return(on); if(y>0&&x>0&&x=MAXDO)return(on); if(y0&&x=PlaceFile[i].min_pix&&pixsize4) { string[strlen(string)-1]='\0'; if(sscanf(string,"%s%lf%lf%s",id1,&lat,&lon,id)!=4) { if(fploc) fclose(fploc); break; } ll_xy(&dx,&dy,lat,lon); ix=dx,iy=dy; if(ix>=0&&ix=0&&iymax)max=r; if(g>max)max=g; if(b>max)max=b; } if(255.0/maxwide) wide=strlen(M.Fill_Name[k]); wide=(wide+1)*15/size; twide=((M.Max_Fill-1)/(ScreenYs/high)+1)*wide; if(xc+twide>ScreenXs) x1=ScreenXs-twide; paint_box(0,M.Back,MT_Buff,x1,yc,twide,ScreenYs); x1o=x1; for(i=1;i<=M.Max_Fill;i++) { k=M.Fill_Order[i]; if(VideoType=='X'||VideoType=='S'||VideoType=='Y') { val[0]=val[1]=k+16; } else { val[0]=M.Fill_Color[k][0]; val[1]=M.Fill_Color[k][1]; } for(j=0;j0) plot_font_h(color,x1+marg,y1+marg, M.Fill_Name[k],size,MapFont); y1+=high; if(y1+high>ScreenYs) { y1=yc; x1+=wide; } } make_pattern(x1o,ScreenXs-1); ScreenXs-=twide; } /******************************************************************** ** ** type g -- grey all lut[] files ** G -- grey only lut[] ** i -- initial header map ** r -- reset lut[] to lutc[] ** ** iop == 1 don't print RGB etc. ** ** ********************************************************************* */ void set_lut(type,iop) char type; int iop; { int k,hue,brite,j,m,n; int color[3],h; double dbrite,dval; float val,minval,i,s,rgb[3]; int c1,c2; long mindist,dist,r,g,b,r0,g0,b0; long del,mindel,l1,l2,l3,l4; /* if(type=='g') { M.lut[ 0].r= 0; M.lut[ 0].g= 0; M.lut[ 0].b= 0; M.lut[ 1].r= 46; M.lut[ 1].g= 46; M.lut[ 1].b= 46; M.lut[ 2].r=128; M.lut[ 2].g=128; M.lut[ 2].b=128; M.lut[ 3].r=255; M.lut[ 3].g=255; M.lut[ 3].b=255; } */ if(type=='c') { for(k=0;k255.0) rgb[j]=255.0; if(Fpout&&iop!=1) fprintf(Fpout,"%3.0f ",rgb[j]); } r0=M.lut[k+16].r=rgb[0]; g0=M.lut[k+16].g=rgb[1]; b0=M.lut[k+16].b=rgb[2]; mindist=16777216; for(m=0;m171||M.lut[k].g>171||M.lut[k].b>220) M.Comp_Color[k]=M.Black; else M.Comp_Color[k]=M.White; } } WritePalette(M.lut); } /******************************************************************** ** ** WARNING!!!! YOU MUST CALL decode_font() or set_files() before using ** ** options: ** ** -1 -- remove menu but get no answer ** 0 -- return answer and set menu colors to greys ** 1 -- return answer but leave colors alone ** ********************************************************************* */ int M_do_menu(menu,num,xc,yc,start,back,words,boxs,font) char *menu[]; int num,xc,yc,start,back,words,boxs; int font[128][25]; { int i,j,k; char ans=-1,ans2; int len=0,l,size=FontSize,val,kval,valo=-1,kbh=0; int black=0,dgrey=back,lgrey=words,white=boxs; int wide; long lxs,lys,buffersize=(long)B_LINES*(long)MAX_X; int io=-1,times,jo=-1; int row,col,right,left; int rowo=-1,colo=-1; int top=yc,bot=yc+num*(30/size)-1; for(k=0;klen)len=l; if(len==0)return(-1); do { wide=(len+1)*15/size+1; if((ScreenXs-1-wide)buffersize) size+=1; if(size>4) { SetVideoMode(0); printf("Could not fit menu into buffer for 'save_box()'\n"); exit(0); } }while(lxs*lys>buffersize); if((xc+(len+1)*15/size+1)0) { MouseMove=1; mouse_vertical_range(yc,yc+num*(30/size)-1); mouse_horizontal_range(xc,xc+(len+1)*15/size); } save_box(0,dgrey,Mbuff, xc,yc,(len+1)*15/size+1,30/size*num+1); for(k=0;k0)val-=1; else val=num-1; } if(ans2=='P') { if(val255) { kval/=256; if(kval==72) row-=30/size; if(kval==80) row+=30/size; if(rowbot)row=bot; mouse_move_cursor(row,col); } } colo=col; rowo=row; do { kbh=0; if((kval=mouse_information(&right,&left,&row,&col))!=0) { kbh=1; if(kval>255) { kval/=256; if(kval==72) row-=30/size; if(kval==80) row+=30/size; if(rowbot)row=bot; mouse_move_cursor(row,col); } } if(row!=rowo||col!=colo) { colo=col; rowo=row; } val=row-yc; val/=30/size; if(val!=valo) { box(0,xc,yc+valo*(30/size),dgrey,(len+1)*15/size,30/size); valo=val; box(0,xc,yc,lgrey,(len+1)*15/size,30/size*num); box(0,xc,yc+val*(30/size),white,(len+1)*15/size,30/size); } if(left>0) { if(kbh==0) do { mouse_times_released(LEFT_BUTTON,×,&row,&col); }while(times==0); ans=13; } if(right>0) { val=num-1; ans=13; if(kbh==0) do { mouse_times_released(RIGHT_BUTTON,×,&row,&col); }while(times==0); } }while(ans!=13); MouseMove=4; mouse_vertical_range(0,ScreenYs-1); mouse_horizontal_range(0,ScreenXs-1); } } box(0,xc,yc,dgrey,(len+1)*15/size,30/size*num); box(0,xc,yc+val*(30/size),lgrey,(len+1)*15/size,30/size); unsave_box(0,dgrey,Mbuff, xc,yc,(len+1)*15/size+1,30/size*num+1); return(val); } /******************************************************************** ** ** WARNING!!!! YOU MUST CALL decode_font() or set_files() before using ** ** options: ** ** -1 -- remove menu but get no answer ** 0 -- return answer and set menu colors to greys ** 1 -- return answer but leave colors alone ** ********************************************************************* */ int T_do_menu(menu,num,xc,yc,start,back,words,boxs,font,off_on) char menu[][2][50]; int num,xc,yc,start,back,words,boxs; int font[128][25],*off_on; { int i,j,k; char ans,ans2; int len=0,l,size=FontSize,val,valo; int black=0,dgrey=back,lgrey=words,white=boxs; int wide; long lxs,lys,buffersize=(long)B_LINES*(long)MAX_X; for(k=0;klen)len=l; if(len==0)return(-1); do { wide=(len+1)*15/size+1; if((ScreenXs-1-wide)buffersize) size+=1; if(size>4) { SetVideoMode(0); printf("Could not fit menu into buffer for 'save_box()'\n"); exit(0); } }while(lxs*lys>buffersize); if((ScreenXs-1-wide)0)val-=1; else val=num-1; } if(ans2=='P') { if(val