home *** CD-ROM | disk | FTP | other *** search
/ ftp.eri.u-tokyo.ac.jp / 2014.03.ftp.eri.u-tokyo.ac.jp.zip / ftp.eri.u-tokyo.ac.jp / pub / seisv / src / 3.02 / map.c < prev    next >
C/C++ Source or Header  |  1999-11-10  |  19KB  |  664 lines

  1. /*  SeisView alone/client    Copyright (C) 1992,1998  K.Koketsu
  2.          <history>
  3.          98-11-04  Remote auxiliary files.
  4.          98-11-03  Include panel definitions and remove CR.
  5.          98-10-06  Some global variables are replaced by constants.
  6.          98-02-25  Abandon DOS, but take Windows 95/NT.
  7.          96-06-22  version 2.02
  8.          93-12-07  version 2.01                    */
  9.  
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include <ctype.h>
  13. #include <math.h>
  14. #include "ctlname.h"
  15. #include "seis.h"
  16.  
  17. extern char     *iseg[10];            /* work segments for  selected events  */
  18. extern unsigned nseg;                 /* number of working segments          */
  19. extern int    itot;                               /* total # selected events */
  20. extern char   z$[11], w$[81];                     /* work string             */
  21.  
  22. /***************************** variables for menu ****************************/
  23. extern char   em$[51];                            /* error message on menu   */
  24. extern char   mc$[42][9], md$[65];                /* field strings           */
  25. extern short  isr;                                /* initial cursor position */
  26. extern short  kd[13];                             /* function key definitions*/
  27.  
  28. /**************************** variables for retrieval ***********************/
  29. extern char   f2$[6];
  30. extern char   dst$[11];
  31. extern char   so1$[4], som1$[3], so2$[4], som2$[3];
  32. extern char   sa1$[3], sam1$[3], sa2$[3], sam2$[3];
  33. extern char   sew1$[2], sew2$[2], sns1$[2], sns2$[2];
  34.  
  35. /**************************** parameters for map ****************************/
  36. int     kx0, kx1, ky0, ky1;
  37. int     cdp[7], icd[7];
  38. double  cmg[8], rmg[8];
  39. int     ndp, nmg;
  40. double  ro, ru;
  41.  
  42. int    dmap(), epicenters();
  43. char    est$[11], mps$[9], yns$[2], ync$[4];
  44. char    to1$[4], tom1$[3], to2$[4], tom2$[3];
  45. char    ta1$[3], tam1$[3], ta2$[3], tam2$[3];
  46. char    tew1$[2], tew2$[2], tns1$[2], tns2$[2];
  47.  
  48. double  yln[181], dln[180];    /* some values for map projection    */
  49. double  a1,a2, b1,b2;        /* latitude,  longitude            */
  50. double  c1, c2;
  51. double  xm, ym, rrx, rry;
  52. short   ynmap;            /* flag wether a map is actually drawn    */
  53. short   wrap;            /* flag of wrap-around            */
  54. int    map1(), map2();
  55.  
  56. int map()
  57. {
  58.     double  tte, yko;
  59.     int     i, np, nplot;
  60.     short   tom1, tom2, tam1, tam2;
  61.  
  62.     if(itot == 0)  return( 3 );
  63.  
  64.     strcpy(est$,dst$);
  65.     strcpy(to1$,so1$);  strcpy(tom1$,som1$);  strcpy(tew1$,sew1$);
  66.     strcpy(to2$,so2$);  strcpy(tom2$,som2$);  strcpy(tew2$,sew2$);
  67.     strcpy(ta1$,sa1$);  strcpy(tam1$,sam1$);  strcpy(tns1$,sns1$);
  68.     strcpy(ta2$,sa2$);  strcpy(tam2$,sam2$);  strcpy(tns2$,sns2$);
  69.     strcpy(yns$,"N");
  70. j10:
  71.     strcpy(mc$[ 0],mps$);  strcpy(md$,est$);
  72.     strcpy(mc$[ 2],to1$);  strcpy(mc$[ 3],tom1$);  strcpy(mc$[ 4],tew1$);
  73.     strcpy(mc$[ 5],to2$);  strcpy(mc$[ 6],tom2$);  strcpy(mc$[ 7],tew2$);
  74.     strcpy(mc$[ 8],ta1$);  strcpy(mc$[ 9],tam1$);  strcpy(mc$[10],tns1$);
  75.     strcpy(mc$[11],ta2$);  strcpy(mc$[12],tam2$);  strcpy(mc$[13],tns2$);
  76.     strcpy(mc$[14],yns$);  strcpy(mc$[15],ync$);
  77.     if(*mps$ != 0)  isr = 0;
  78.     else if(*est$ != 0)  isr = 1;
  79.     else  isr = 2;
  80. j31:
  81.     np = panel(MAP);
  82.     if(np==3 || np==6)  return( 0 );
  83.  
  84.     strxcpy(mps$, mc$[0]);
  85.     strxcpy(est$, md$);
  86.     strcpy(to1$,mc$[ 2]);  strcpy(tom1$,mc$[ 3]);  strcpy(tew1$,mc$[ 4]);
  87.     strcpy(to2$,mc$[ 5]);  strcpy(tom2$,mc$[ 6]);  strcpy(tew2$,mc$[ 7]);
  88.     strcpy(ta1$,mc$[ 8]);  strcpy(tam1$,mc$[ 9]);  strcpy(tns1$,mc$[10]);
  89.     strcpy(ta2$,mc$[11]);  strcpy(tam2$,mc$[12]);  strcpy(tns2$,mc$[13]);
  90.     strcpy(yns$,mc$[14]);  strcpy(ync$ ,mc$[15]);
  91.     if( *est$ ) {
  92.     if(! dist(est$,1)) {
  93.         isr = 1;
  94.         strcpy(em$, "Invalid region name!");
  95.         goto j31;
  96.     }
  97.     }
  98.     tom1 = atoi(tom1$); tom2 = atoi(tom2$);
  99.     tam1 = atoi(tam1$); tam2 = atoi(tam2$);
  100.     if(tom1 > 59)  isr =  3;
  101.     if(tom2 > 59)  isr =  6;
  102.     if(tam1 > 59)  isr =  9;
  103.     if(tam2 > 59)  isr = 12;
  104.     if(isr > 2) {
  105.     strcpy(em$, "Minute values should be less than 60!");
  106.     goto j31;
  107.     }
  108.  
  109.     b1 = atoi(to1$) + tom1/60.;
  110.     b2 = atoi(to2$) + tom2/60.;
  111.     a1 = atoi(ta1$) + tam1/60.;
  112.     a2 = atoi(ta2$) + tam2/60.;
  113.     if(*tew1$ == 'W')  b1 = - b1;
  114.     if(*tew2$ == 'W')  b2 = - b2;
  115.     if(*tns1$ == 'S')  a1 = - a1;
  116.     if(*tns2$ == 'S')  a2 = - a2;
  117.     if(a1 > a2) {
  118.     strcpy(em$,"The second latitude should be in the north of the first!");
  119.     goto j31;
  120.     }
  121.     if(b1 >= b2) { wrap = 1;  b2 = b2 + 360.; }
  122.     else  wrap = 0;
  123.  
  124.     if(!strcmp(yns$,"Y")) {     /* Change  plotting parameters. */
  125.     switch( map1() ) {
  126.         case 3:  return( 0 );
  127.         case 6:  goto j10;
  128.     }
  129.     }
  130.     for(i=0; i<nmg; i++) {
  131.     if(i == 0)  rmg[i] = ro;
  132.     else        rmg[i] = rmg[i-1]*ru;
  133.     }
  134.  
  135.     clear( 0 );
  136.     c1 = fnyy(a1);  c2 = fnyy(a2);
  137.     xm = b2 - b1;   ym = c2 - c1;
  138.     ky1 = YPixels-1;
  139.     tte = ky1;
  140.     yko = tte * xm/ym;
  141.     if(yko > 490.) {
  142.         yko = 490.;  tte = yko * ym/xm;
  143.     }
  144.     kx0 = (int)(245   - yko/2);  kx1 = (int)(kx0 + yko);
  145.     ky0 = (int)(ky1/2 - tte/2);  ky1 = (int)(ky0 + tte);
  146.     rrx = (kx1-kx0) / xm;   rry = (ky1-ky0) / ym;
  147. j40:
  148.     ynmap = 1;
  149.     if(! dmap(mps$,0)) {
  150.     gviewport(0, 0, 639, YPixels-1);
  151.     goto j31;
  152.     }
  153.     nplot = epicenters();
  154.  
  155.     gviewport(0, 0, 639, YPixels-1);
  156.     if(atoi(ync$) > 0)  nplot = - atoi( ync$ );
  157.     legend(mps$, nplot);
  158.  
  159.     np = fgkey(1, 1);
  160.     if(np == F1)  goto j40;
  161.     if(np == F8)  np = map2();
  162.     if(np == F3)  return( 0 );
  163.     else { if(np != F6) beep(); goto j10; }
  164. }
  165.  
  166. int map1()
  167. {
  168.     int  i, k;
  169.  
  170.     for(i=0; i<7; i++) {
  171.     if(i < ndp) {
  172.         itoa(cdp[i], mc$[i*2  ], 10);
  173.         itoa(icd[i], mc$[i*2+1], 10);
  174.     }
  175.     else {
  176.         strcpy(mc$[i*2  ], "   ");
  177.         strcpy(mc$[i*2+1], " ");
  178.     }
  179.     }
  180.     for(i=0; i<8; i++) {
  181.     if(i < nmg)  hcvt(cmg[i], mc$[14+i]);
  182.     else  strcpy(mc$[14+i], "   ");
  183.     }
  184.     hcvt(ro, mc$[22]);
  185.     hcvt(ru, mc$[23]);
  186.  
  187.     if(k = panel(MAP1))  return( k );
  188.  
  189.     for(i=0; i<7; i++) {
  190.     if(!strcmp(mc$[i*2],"   ")) break;
  191.     cdp[i] = atoi( mc$[i*2  ] );
  192.     icd[i] = atoi( mc$[i*2+1] );
  193.     }
  194.     ndp = i;
  195.     for(i=0; i<8; i++) {
  196.     if(!strcmp(mc$[14+i],"    ")) break;
  197.     cmg[i] = atof( mc$[14+i] );
  198.     }
  199.     nmg = i;
  200.     ro = atof( mc$[22] );
  201.     ru = atof( mc$[23] );
  202. }
  203.  
  204. /*** subfunction selection (map2) ***/
  205. int map2()
  206. {
  207.     int   i, isf;
  208.     char  isf$[2];
  209.  
  210.     strcpy(isf$, "1");
  211. j50:
  212.     strcpy(md$,est$);
  213.     strcpy(mc$[ 1],to1$);  strcpy(mc$[ 2],tom1$);  strcpy(mc$[ 3],tew1$);
  214.     strcpy(mc$[ 4],to2$);  strcpy(mc$[ 5],tom2$);  strcpy(mc$[ 6],tew2$);
  215.     strcpy(mc$[ 7],ta1$);  strcpy(mc$[ 8],tam1$);  strcpy(mc$[ 9],tns1$);
  216.     strcpy(mc$[10],ta2$);  strcpy(mc$[11],tam2$);  strcpy(mc$[12],tns2$);
  217. j52:
  218.     strcpy(mc$[13],isf$);  strcpy(mc$[14],"N");
  219.     isr = 13;
  220.     kd[6] = 6;
  221.     i = panel( MAP2 );
  222.     if(i < 0)  i = 6;
  223.     if(i==3 || i==6)  return(i + F1 - 1);
  224.  
  225.     strcpy(isf$,mc$[13]);  isf = atoi( isf$ );
  226.     if(!strcmp(mc$[14],"Y") || isf>=5) ynmap = 1;  else ynmap = 0;
  227.     if(isf>0 && isf<7) {
  228.     switch( isf ) {
  229.         case 1: i = map_find();   break;
  230.         case 2: i = map_select(); break;
  231.         case 3: i = map_cross_section(); break;
  232.         case 4: i = map_space_time();    break;
  233.         case 5: i = map_active_faults(); break;
  234.         case 6: i = map_stations();         break;
  235.     }
  236.     if(i== F3)  return( i );
  237.     else  goto j50;
  238.     }
  239.     else {
  240.     strcpy(em$, "Invalid subfunction number!");
  241.     goto j52;
  242.     }
  243. }
  244.  
  245. int dmap(map$, flag, ifc)
  246. char *map$;
  247. int  flag, ifc[];
  248. {
  249.     char  *iwseg;
  250.     char   f$[13], a$[5], c, d[2];
  251.     unsigned short  na;
  252.     short  i, n, mp, lx, ly, ic, lxo, kx2;
  253.     long   bb[4], b3, am1, am2, bm1, lonoff, mp360;
  254.     long   xxm, xo, xp, c2ry;
  255.     double yym, yo, yp, rrxm;
  256.  
  257.     if(*map$ == 0) {
  258.     if(b1>=90. && b2<=180. && a1>=0. && a2<=90.)  strcpy(f$,"NWPAC");
  259.     else if(rrx < 4.0)  strcpy(f$,"EARTH");
  260.     else  strcpy(f$,"WORLD");
  261.     }
  262.     else  strcpy(f$, map$);
  263.     strlwr( f$ );
  264.     if(flag == 0)  strcat(f$, ".m");
  265.     else  strcat(f$, ".f");
  266.  
  267.     c2ry  = (long)(c2  * rry);
  268.     _setcolor( 7 );
  269.     _setbkcolor( 0 );
  270.     gbox(0, kx0, ky0, kx1, ky1);
  271.     gviewport(kx0+1, ky0+1, kx1-1, ky1-1);
  272.     kx2 = kx1 - kx0 -2;
  273.     if(flag==0 && !ynmap)  return( 1 );
  274.  
  275.     pspen(1, -1);
  276.     iwseg = iseg[nseg-1];
  277.     a$[4] = 0;
  278.     if(! rbload(iwseg, 0, f$)) return( 0 );
  279.     na = 0;
  280.     c = peek(na,iwseg); 
  281.     lonoff = (short)qeek(na+1,iwseg);
  282.     if(c == 'F')  mp = 1000;   else  mp = 100;
  283.     bm1   = (long)((b1-lonoff) * mp);
  284.     b3    = (long)(b2*mp - bm1);
  285.     am1   = (long)(a1 * mp);
  286.     am2   = (long)(a2 * mp);
  287.     rrxm  = rrx / mp;
  288.     mp360 = (long)mp * 360;
  289.     na += 3;
  290. j20:
  291.     c = peek(na++,iwseg);
  292.     d[0] = peek(na++,iwseg);
  293.     if(c == 'X') { pspen(2, 0); return( 1 ); }
  294.     if(c == 'Z') {
  295.     if(*d != '2')  f$[strlen(f$)-1] = 0;
  296.     d[1] = 0;  strcat(f$, d);
  297.     if(! rbload(iwseg, 0, f$)) return( 0 );
  298.     na = 0;
  299.     goto j20;
  300.     }
  301.     if(*d == '2') { n = qeek(na,iwseg); na += 2; }
  302.     else  n = peek(na++,iwseg);
  303.     for(i=0; i<4; i++) {
  304.     if(mp == 1000)  bb[i] = qeek(na,iwseg);
  305.     else  bb[i] = (short)qeek(na,iwseg);
  306.     na += 2;
  307.     if(i > 1) {
  308.         bb[i] = bb[i] - bm1;
  309.         if(wrap && bb[i]<0)  bb[i] = bb[i] + mp360;
  310.     }
  311.     }
  312.     if(bb[2] > bb[3]) {
  313.     xo    = bb[3];
  314.     bb[3] = bb[2];
  315.     bb[2] = xo;
  316.     }
  317.  
  318.     if(bb[0]>am2 || bb[1]<am1 || bb[2]>b3 || bb[3]<0) {
  319.         na = na + 4*n;    goto j20;
  320.     }
  321.     pspen(-1, 0);
  322.     switch( c ) {
  323.     case 'B': ic = 1; pspen(-1, 1); break;
  324.     case 'F': ic = ifc[0]; break;
  325.     case 'G': ic = ifc[1]; break;
  326.     case 'H': ic = ifc[2]; break;
  327.     case 'I': ic = ifc[3]; break;
  328.     default : ic = 3;
  329.     }
  330.     _setcolor( ic );
  331.  
  332.     for(i=0; i<n; i++) {
  333.     if(mp == 1000) {
  334.         yym = qeek(na  ,iwseg);
  335.         xxm = qeek(na+2,iwseg);
  336.     }
  337.     else {
  338.         yym = (short)qeek(na  ,iwseg);
  339.         xxm = (short)qeek(na+2,iwseg);
  340.     }
  341.     na += 4;
  342.     xxm = xxm - bm1;
  343.     if(wrap && xxm<0)  xxm = xxm + mp360;
  344.     yym = lat( yym/mp );
  345.     lx = (short)(xxm * rrxm);
  346.     ly = (short)(c2ry - yym*rry);
  347.     if(i == 0)  gmoveto(lx, ly);
  348.     else {
  349.         if((lxo<10 && lx>kx2-10) || (lxo>kx2-10 && lx<10)) {
  350.         if(lxo < 10)  xp = 0;
  351.         else  xp = b3;
  352.         yp = (xp-xo)*(yym-yo)/(xxm-xo) + yo;
  353.         lx = (short)(xp * rrxm);
  354.         ly = (short)(c2ry - yp*rry);
  355.         glineto(lx, ly);
  356.         if(lxo < 10)  xp = b3;
  357.         else  xp = 0;
  358.         lx = (short)(xp * rrxm);
  359.         gmoveto(lx, ly);
  360.         }
  361.         lx = (short)(xxm * rrxm);
  362.         ly = (short)(c2ry - yym*rry);
  363.         glineto(lx, ly);
  364.     }
  365.     lxo = lx;
  366.     xo = xxm;
  367.     yo = yym;
  368.     }
  369.     goto j20;
  370. }
  371.  
  372. /******************* EPICENTERS ****************** (Plot epicenters.) */
  373. int epicenters()
  374. {
  375.     int     i, ic, im, lx, ly, n;
  376.     double  xx, yy, hh, rm;
  377.  
  378.     n = 0;
  379.     for(i=0; i<itot; i++) {
  380.     eqparm(i, &xx, &yy, &hh, &rm, 0);
  381.     if(wrap && xx<b2-360.)  xx = xx + 360.;
  382.     if(xx>b1 && xx<b2 && yy>a1 && yy<a2) {
  383.         for(ic=ndp-1; ic>0; ic--)  if(hh >= cdp[ic]) break;
  384.         for(im=nmg-1; im>0; im--)  if(rm >= cmg[im]) break;
  385.         im = (int)rmg[im];
  386.         lx = (int)((xx-b1) * rrx);
  387.         ly = (int)((c2-lat(yy)) * rry);
  388.         _setcolor( icd[ic] );
  389.         gsymbol(lx, ly, im, icd[ic]);
  390.         n++;
  391.     }
  392.     }
  393.     return( n );
  394. }
  395.  
  396. /********* LEGEND ************ (Write legends for basic map.) */
  397. void legend(mps$, nplot)
  398. char  *mps$;
  399. int   nplot;
  400. {
  401.     char *c;
  402.     int  i, ja, j, ic, im, lx, ly;
  403.     double  xx, yy, hh, rm;
  404.  
  405.     if(nplot >=0) {
  406.     gprint(63, 1, "MAP", 4);
  407.     pfromto(-2, nplot);
  408.     gprint(63, 9, "depth ", 2);
  409.  
  410.     for(i=0; i<=ndp; i++) {
  411.         j = (int)((i+8.5) * RowPixels) + 1;
  412.         if(i == ndp) {
  413.         _setcolor( icd[0] );
  414.         strcpy(w$, "unknown");
  415.         }
  416.         else {
  417.         _setcolor( icd[i] );
  418.         itoa(cdp[i], w$, 10);
  419.         if(c = strchr(w$,'.')) *c = 0;
  420.         strcat(w$, " -");
  421.         }
  422.         gsymbol(554, j, 5, icd[i]);
  423.         gprint(72, i+9, w$, 7);
  424.     }
  425.  
  426.     mag_legend();
  427.     }
  428.     else {
  429.     pspen(1, 0);
  430.     _setcolor( 7 );
  431.     gbox(0, kx1+5, ky0+1, kx1+95, ky1-1);
  432.     gbox(0, kx0+1, ky1+5, kx1-1, ky1+95);
  433.     gsmall_font();
  434.     gfprint(kx1+ 3, ky1+ 1,  "0", 7);
  435.     gfprint(kx1+80, ky1+ 1, ync$, 7);
  436.     gfprint(kx1+ 3, ky1+85, ync$, 7);
  437.     gnormal_font();
  438.     pspen(2, 0);
  439.     for(i=0; i<itot; i++) {
  440.         eqparm(i, &xx, &yy, &hh, &rm, 0);
  441.         if(xx>b1 && xx<b2 && yy>a1 && yy<a2 && hh<=-nplot) {
  442.         for(ic=ndp-1; ic>0; ic--)  if(hh >= cdp[ic]) break;
  443.         for(im=nmg-1; im>0; im--)  if(rm >= cmg[im]) break;
  444.         im = (int)rmg[im];
  445.         lx = (int)((xx-b1) * rrx);
  446.         ly = (int)((c2-lat(yy)) * rry);
  447.         ja = (int)(hh * 90 / (-nplot));
  448.         _setcolor( icd[ic] );
  449.         gsymbol(ja+kx1+5, ly+ky0+1, im, icd[ic]);
  450.         gsymbol(lx+kx0+1, ja+ky1+5, im, icd[ic]);
  451.         }
  452.     }
  453.     }
  454. }
  455.  
  456. void mag_legend()
  457. {
  458.     int  ia, ja, j, k;
  459.  
  460.     gprint(63, 17, "magnitude ", 2);
  461.     ja = 1;
  462.     for(ia=0; ia<nmg; ia+=ja) {
  463.     j = (int)((ia/ja+17.5) * RowPixels);
  464.     if(ia == 8) { k = (int)rmg[0];  strcpy(w$, "unknown"); }
  465.     else {
  466.         k = (int)rmg[ia];
  467.         hcvt(cmg[ia], w$);
  468.         strcat(w$, " -");
  469.     }
  470.     gprint(72, ia/ja+18, w$, 7);
  471.     gcircle(0, 554, j, k);
  472.     }
  473. }
  474.  
  475. void map_init()
  476. {
  477.     short   i;
  478.     double  ri;
  479.  
  480.     for(i=0; i<=180; i++) {
  481.     ri = i - 90;
  482.     yln[i] = fnyy(ri);
  483.     }
  484.     for(i=0; i<=179; i++)  dln[i] = yln[i+1] - yln[i];
  485. }
  486.  
  487. void dpmg_init()
  488. {
  489.     int  i;
  490.  
  491.     ndp = 7;
  492.     cdp[0] =  0;  cdp[1] = 20;  cdp[2] = 40;  cdp[3] = 60;
  493.     cdp[4] = 80;  cdp[5] =200;  cdp[6] =600;
  494.     icd[0] =  4;  icd[1] =  5;  icd[2] =  6;  icd[3] =  2;
  495.     icd[4] =  3;  icd[5] =  1;  icd[6] =  7;
  496.     nmg = 8;
  497.     for(i=0; i<nmg; i++) cmg[i] = i;
  498.     ro = 1.50;  ru = 1.25;
  499.     strcpy(ync$, "000");
  500. }
  501.  
  502. double fnyy( pp )
  503. double pp;
  504. {
  505. /* Mercator */
  506. /*    return( log(tan((pp/2.+45.)/57.2958))*57.2958 ); */
  507. /* Miller */
  508.     return( 1.25*log(tan((pp*0.4+45.)/57.2958))*57.2958 );
  509. }
  510.  
  511. double lat( yy )
  512. double yy;
  513. {
  514.     int  lnn;
  515.     if(yy < -90)  lnn = 0;
  516.     else  lnn = (int)yy + 90;
  517.     return( yln[lnn] + dln[lnn]*(yy+90-lnn) );
  518. }
  519.  
  520. void eqparm(ia, xx, yy, hh, rm, iss)
  521. int     ia, iss;
  522. double *xx, *yy, *hh, *rm;
  523. {
  524.     int      ipag, mr;
  525.     unsigned na;
  526.     char     *is;
  527.  
  528.     ipag = ia / 4095;
  529.     is   = iseg[iss+ipag];
  530.     na   = (ia-ipag*4095)*16 + 4;
  531.     *xx  = bin2deg(na+ 7, is);
  532.     *yy  = bin2deg(na+10, is);
  533.     *hh  = (short)qeek(na+13,is)/10.;
  534.     if(peek(na,is) == 255)  *hh = 0.;
  535.     mr = peek(na+15,is);
  536.     if(mr == 0) *rm = -9999.;
  537.     else if(mr & 0x80) *rm = - (mr&0x7f)/10.;
  538.     else *rm = mr / 10.;
  539. }
  540.  
  541. double bin2deg(off, is)
  542. unsigned off;
  543. char    *is;
  544. {
  545.     short  min;
  546.     double v;
  547.  
  548.     min  =  peek(off+1,is);
  549.     if(min & 0x80)
  550.           v = - (peek(off,is) + (min & 0x7f)/60. + peek(off+2,is)/3600.);
  551.     else  v = peek(off,is) + min/60. + peek(off+2,is)/3600.;
  552.     return( v );
  553. }
  554.  
  555. /************************ Panel Definitions **********************/
  556. char map_pan[] = "\
  557.     Request : MAP                                                            \
  558.     Change parameters in () as you like and press Enter.                     \
  559.  1. Map Dataset         (          )                                         \
  560.  2. Region              (            )                                       \
  561.  or Longitude -deg,min- (     )(    ) (   ) --> (     )(    ) (   )          \
  562.     Latitude  -deg,min- (    )(    ) (   )  --> (    )(    ) (   )           \
  563.  3. Do you like to change symbol assignments? < Y/N >      (   )             \
  564.  4. Maximum depth for associated cross-section charts -km- (     )           \
  565.    |If you give 0km, no associated charts will be drawn.    Even if drawn,|  \
  566.    |one of them will appear incomplete, but complete in a PostScript copy.|  \
  567.                                                                              \
  568. 26,  2,  8 \
  569. 26,  3, 10 \
  570. 26,  4,  3 \
  571. 33,  4,  2 \
  572. 40,  4,  1 \
  573. 50,  4,  3 \
  574. 57,  4,  2 \
  575. 64,  4,  1 \
  576. 26,  5,  2 \
  577. 32,  5,  2 \
  578. 39,  5,  1 \
  579. 50,  5,  2 \
  580. 56,  5,  2 \
  581. 63,  5,  1 \
  582. 61,  6,  1 \
  583. 61,  7,  3 ";
  584.  
  585. char map1_pan[] = "\
  586.     Request : MAP                                                            \
  587.     Change color and size of symbols and their corresponding depth           \
  588.     and magnitude ranges in () as you like and press Enter.                  \
  589.        Depth      class     range         color     |                        \
  590.                   DEP0     (     ) -      (   )     |  1 : Blue (Cross)      \
  591.                   DEP1     (     ) -      (   )     |  2 : Green (Triangle)  \
  592.                   DEP2     (     ) -      (   )     |  3 : Cyan (Rv.Triangle)\
  593.                   DEP3     (     ) -      (   )     |  4 : Red (Circle)      \
  594.                   DEP4     (     ) -      (   )     |  5 : Magenta (Square)  \
  595.                   DEP5     (     ) -      (   )     |  6 : Yellow (Diamond)  \
  596.                   DEP6     (     ) -      (   )     |  7 : White (Plus)      \
  597.                   unknown   DEP0                                             \
  598.        Magnitude  class       range                                          \
  599.                   MAG0       (      ) -      Classes below a class with      \
  600.                   MAG1       (      ) -      a blank range will not work.    \
  601.                   MAG2       (      ) -                                      \
  602.                   MAG3       (      ) -                                      \
  603.                   MAG4       (      ) -                                      \
  604.                   MAG5       (      ) -                                      \
  605.                   MAG6       (      ) -                                      \
  606.                   MAG7       (      ) -                                      \
  607.                   unknown     MAG0                                           \
  608.        Size      base size <MAG0> : (      )pixels   factor : (      )       \
  609. 29,  4,  3 \
  610. 44,  4,  1 \
  611. 29,  5,  3 \
  612. 44,  5,  1 \
  613. 29,  6,  3 \
  614. 44,  6,  1 \
  615. 29,  7,  3 \
  616. 44,  7,  1 \
  617. 29,  8,  3 \
  618. 44,  8,  1 \
  619. 29,  9,  3 \
  620. 44,  9,  1 \
  621. 29, 10,  3 \
  622. 44, 10,  1 \
  623. 31, 13,  4 \
  624. 31, 14,  4 \
  625. 31, 15,  4 \
  626. 31, 16,  4 \
  627. 31, 17,  4 \
  628. 31, 18,  4 \
  629. 31, 19,  4 \
  630. 31, 20,  4 \
  631. 38, 22,  4 \
  632. 64, 22,  4 ";
  633.  
  634. char map2_pan[] = "\
  635.     Request : MAP SUBFUNCTIONS                                               \
  636.     Mapping Area:                                                            \
  637.     Region              <            >                                       \
  638.  or Longitude -deg,min- <     ><    > <   > --> <     ><    > <   >          \
  639.     Latitude  -deg,min- <    ><    > <   >  --> <    ><    > <   >           \
  640.                                                                              \
  641.     Specify a subfunction number and press Enter.                            \
  642.                          (   )    1 : Find          4 : Space-Time           \
  643.                                   2 : Select        5 : Active Faults        \
  644.                                   3 : Cross-Section 6 : Stations             \
  645.                                                                              \
  646.     Do you need epicenters to be overlaid with the map? < Y/N >  (   )       \
  647.    (For active faults or stations the map will be always overlaid.)          \
  648.                                                                              \
  649. 26,  2,-10 \
  650. 26,  3, -3 \
  651. 33,  3, -2 \
  652. 40,  3, -1 \
  653. 50,  3, -3 \
  654. 57,  3, -2 \
  655. 64,  3, -1 \
  656. 26,  4, -2 \
  657. 32,  4, -2 \
  658. 39,  4, -1 \
  659. 50,  4, -2 \
  660. 56,  4, -2 \
  661. 63,  4, -1 \
  662. 27,  7,  1 \
  663. 67, 11,  1 ";
  664.