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.02a
/
mapsub.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-04-23
|
27KB
|
978 lines
/* SeisView alone/client Copyright (C) 1992,2000 K.Koketsu
<history>
00-04-25 Remove unwanted debugging statements.
98-11-05 Remote auxiliary files.
98-11-03 Include panel definitions and remove CR.
Fix bugs for a region traversing the date line.
98-10-06 Some global variables are replaced by constants.
_setbkcolor(0) in the initialization.
98-02-25 Abandon DOS, but take Windows 95/NT.
93-06-02 version 2.00 */
#include <math.h>
#include "ctlname.h"
#include "seis.h"
#ifdef WIN32
extern HWND hwnd;
#endif
extern char *iseg[10]; /* work segments for selected events */
extern unsigned nseg; /* number of working segments */
extern short nmax, nmax2; /* maximum numbers of selected events */
extern int itot; /* total # selected events */
extern char z$[11], w$[81]; /* work string */
/***************************** variables for menu ****************************/
extern char em$[51]; /* error message on menu */
extern char mc$[42][9]; /* field strings */
extern short isr; /* initial cursor position */
extern short kd[13]; /* function key definitions*/
/******************** parameters for retrieving kernel **********************/
extern long lo1,lo2; /* longitude */
extern short lom1,lom2, la1,lam1,la2,lam2; /* lonmin, lat,latmin */
/**************************** variables for retrieval ************************/
extern char f2$[6];
extern char y1$[5], m1$[3], d1$[3], h1$[3], n1$[3], s1$[5];
extern char y2$[5], m2$[3], d2$[3], h2$[3], n2$[3], s2$[5];
extern char dst$[9];
extern char dp1$[6], dp2$[6], mg1$[5], mg2$[5];
extern char ynh$[2], ynm$[2];
/**************************** parameters for map ****************************/
extern int kx0, kx1, ky0, ky1;
extern char mps$[9], ync$[4];
extern double yln[181], dln[180]; /* some values for map projection */
extern double a1,a2, b1,b2; /* latitude, longitude */
extern double c1, c2;
extern double xm, ym, rrx, rry;
extern int cdp[7], icd[7];
extern double cmg[8], rmg[8];
extern int ndp, nmg;
extern short wrap; /* flag of wrap-around */
/**************************** variables for TIME *****************************/
extern int kyy1, km1, kd1, kh1, kn1;
extern int kyy2, km2, kd2, kh2, kn2;
/**************************** variables for taxis ****************************/
extern double st0, rt0, ut;
/********************* parameters for cross-section **************************/
long lo[5];
short lom[5], la[5], lam[5];
void map_retrv(), press_prompt(), map_sub_prep(), legend2(), ital(),
otparm();
int project_area();
double rtal(), delta();
/*** map subfunction-1 (find) ***/
int map_find()
{
int ip, iq, ic, id, ie, icy, p[2], q[2];
int i, itof, ly, printing;
double f;
ly = 21;
printing = 0;
clear( 0 );
j10:
dmap(mps$, 0);
epicenters();
gviewport(0, 0, 639, YPixels-1);
if(! printing) {
gprint(63, ly , "Move the cross ", 4);
gprint(63, ly+1, "to area center ", 4);
press_prompt(1, ly+2);
ip = (kx1+kx0)/2; iq = (ky1+ky0)/2;
gcursor(kx0, ky0, kx1, ky1, &ip, &iq, 1);
if(ip == -1) goto j10;
gprint(63, ly+1, "on circumference ", 4);
ie = ip + 3; id = (int)(iq - 2);
gcursor(kx0, ky0, kx1, ky1, &ie, &id, 0);
if(ie == -1) goto j10;
}
f = (ie-ip)*(ie-ip) + (id-iq)*(id-iq);
ic = (int)sqrt( f );
icy = ic;
_setcolor( 2 ); gcircle(0, ip, iq, ic);
press_prompt(2, ly);
gprint(63, ly+1, "a function key ", 4);
gprint(63, ly+2, "on the toolbar. ", 4);
i = fgkey(0, 0);
printing = 0;
if(i == -1) goto j10;
if(i == F1) { printing = 1; goto j10; }
if(i != cr) return(i);
/* retrieve */
p[0] = ip - ic; q[0] = iq + icy;
p[1] = ip + ic; q[1] = iq - icy;
map_sub_prep(p, q, 2);
clear( 0 );
_setcolor( 4 ); /* Paint the area. */
gcircle(1, ip, iq, ic);
map_retrv( &itof );
if(itof == 0) {
strcpy(em$, "No event was found.");
return(6 + F1 + 1);
}
return( table(1, itof) );
}
/*** map subfunction-2 (select) ***/
int map_select()
{
int p[4], q[4];
short i, j, ly, printing;
unsigned iw;
char *zseg;
ly = 21;
printing = 0;
clear( 0 );
j10:
dmap(mps$, 0);
epicenters();
gviewport(0, 0, 639, YPixels-1);
/* specify four corners of the area */
for(i=0; i<4; i++) {
if(i == 0) {
if(! printing) {
gprint(63, ly , "Move the cross ", 4);
gprint(63, ly+1, "to 1st area corner ", 4);
press_prompt(1, ly+2);
p[0] = (kx1+kx0)/2; q[0] = (ky1+ky0)/2;
gcursor(kx0, ky0, kx1, ky1, &p[i], &q[i], 1);
if(p[i] == -1) goto j10;
}
}
else {
if(! printing) {
switch( i ) {
case 1: gprint(63, ly+1, "to 2nd area corner ", 4); break;
case 2: gprint(63, ly+1, "to 3rd area corner ", 4); break;
case 3: gprint(63, ly+1, "to 4th area corner ", 4); break;
}
p[i] = p[i-1] + 3;
q[i] = q[i-1] - 2;
gcursor(kx0, ky0, kx1, ky1, &p[i], &q[i], 0);
if(p[i] == -1) goto j10;
}
_setcolor( 2 );
gmoveto(p[i-1], q[i-1]);
glineto(p[i ], q[i ]);
}
}
glineto(p[0], q[0]);
map_sub_prep(p, q, 4);
press_prompt(2, ly);
gprint(63, ly+1, "a function key ", 4);
gprint(63, ly+2, "on the toolbar. ", 4);
i = fgkey(0, 0);
printing = 0;
if(i == -1) goto j10;
if(i == F1) { printing = 1; goto j10; }
if(i != cr) return( i );
/* confirmation */
strcpy(mc$[24],dp1$); strcpy(mc$[25],dp2$); strcpy(mc$[26],ynh$);
strcpy(mc$[27],mg1$); strcpy(mc$[28],mg2$); strcpy(mc$[29],ynm$);
strcpy(mc$[30],"Y");
isr = 30;
i = panel( MAPS2 );
if(i==3 || i==6) return(i + F1 - 1);
if(!strcmp(mc$[30],"N")) return(6 + F1 - 1);
/* select */
clear( 0 );
_setcolor( 4 ); /* Paint the area. */
gfillpolygon(p, q, 4);
map_retrv( &itot );
iw = nmax/4095;
j = itot / 4095; if(itot%4095 != 0) j++;
for(i=0; i<j; i++) {
zseg = iseg[i];
iseg[i] = iseg[iw+i];
iseg[iw+i] = zseg;
}
strcpy(em$, "Memory contents were replaced.");
return(6 + F1 - 1);
}
/**** map subfunction-3 (cross-section) ****/
map_cross_section()
{
int p[4], q[4];
int i, j, k, ds, rx1, rx2, itof;
int rv1, rv2, ir, vlen, vorg;
int ixa, ixb, ixu, ixr, ixn;
int iwo, ic, im;
double uv, rva, ux, rc, rw;
double f, xx, yy, hh, rm;
i = project_area(p, q, &ds, &rw);
if(i != cr) return( i );
map_sub_prep(p, q, 4);
/* confirmation */
strcpy(mc$[18], " 0"); strcpy(mc$[19], jtoa(ds,w$,4));
strcpy(mc$[20], " 0"); strcpy(mc$[21], " 300");
isr = 18;
kd[6] = 6;
i = panel( MAPS3 );
if(i==3 || i==6) return(i + F1 - 1);
rx1 = atoi(mc$[18]); rx2 = atoi(mc$[19]);
rv1 = atoi(mc$[20]); rv2 = atoi(mc$[21]);
/* retrieve */
clear( 0 );
_setcolor( 4 ); /* Paint the area. */
gfillpolygon(p, q, 4);
map_retrv( &itof );
clear( 0 );
_setbkcolor( 0 );
j10: /* legend */
gprint(27, 1, "Distance (km)", 2);
vprint(8, "Depth ^kmv");
gprint(63, 1, "CROSS-", 4);
gprint(63, 2, "SECTION", 4);
gprint(63,10, "leftmost", 2);
gprint(63,12, "rightmost", 2);
legend2(ds, itof);
/* draw cross-section */
_setcolor( 7 );
vorg = (int)(RowPixels * 2.5);
vlen = YPixels - (int)(RowPixels*3.5);
gbox(0, 40, vorg, 490, vlen+vorg-RowPixels);
vaxis(3, rv1, rv2, &ir, &uv, &rva);
scale(rx1, rx2, &ixa, &ixb, &ixu);
ixr = ixb - ixa;
ixn = ixr / ixu;
ux = 418. / ixr;
_setcolor( 7 );
for(i=1; i<=ixn; i++) {
itoa(i*ixu+ixa, w$, 10);
j = 57 + (int)(i*ixu*ux);
k = _gettextextent( w$ ) / 2;
gmoveto(j, vorg-RowPixels/2); glineto(j, vorg);
if(ixn<9 || i%2==0) gfprint(j-k, RowPixels, w$, 7);
}
_setcolor( 3 );
j = 57 + (int)((rx1-ixa)*ux);
gmoveto(j, vorg-RowPixels/2); glineto(j, vorg);
j = 57 + (int)((rx2-ixa)*ux);
gmoveto(j, vorg-RowPixels/2); glineto(j, vorg);
rc = q[0] - p[0]*rw;
iwo = nmax / 4095;
for(i=0; i<itof; i++) {
eqparm(i, &xx, &yy, &hh, &rm, iwo);
if(hh>=rv1 && hh<=rv2) {
f = rtal(xx, yy, rw, rc, p, q);
if(f>=rx1 && f<=rx2) {
j = 57 + (int)((f-ixa)*ux);
k = ir - (int)((hh-rva)*uv);
for(ic=ndp-1; ic>0; ic--) if(hh >= cdp[ic]) break;
for(im=nmg-1; im>0; im--) if(rm >= cmg[im]) break;
im = (int)rmg[im];
_setcolor( icd[ic] );
gcircle(0, j, k, im);
}
}
}
i = fgkey(0, 1);
if(i==-1 || i==F1) goto j10;
return( i );
}
/**** map subfunction-4 (space-time) ****/
int map_space_time()
{
int p[4], q[4];
int i, j, k, ds, itof;
int rv1, rv2, ir, vlen, vorg;
int jtm;
double st1, st2;
int iwo, ic, im;
int jy, jm, jd, jh, jn;
double uv, rva, rc, rw, f;
double xx, yy, hh, rm, rjt;
i = project_area(p, q, &ds, &rw);
if(i != cr) return( i );
map_sub_prep(p, q, 4);
/* confirmation */
strcpy(mc$[18],y1$); strcpy(mc$[19],m1$); strcpy(mc$[20],d1$);
strcpy(mc$[21],h1$); strcpy(mc$[22],n1$); strcpy(mc$[23],s1$);
strcpy(mc$[24],y2$); strcpy(mc$[25],m2$); strcpy(mc$[26],d2$);
strcpy(mc$[27],h2$); strcpy(mc$[28],n2$); strcpy(mc$[29],s2$);
strcpy(mc$[30],"Y");
strcpy(mc$[31], " 0"); strcpy(mc$[32], jtoa(ds,w$,4));
isr = 18;
i = panel( MAPS4 );
if(i==3 || i==6) return(i + F1 - 1);
kyy1 = atoi(mc$[18]); kyy2 = atoi(mc$[24]);
km1 = atoi(mc$[19]); km2 = atoi(mc$[25]);
kd1 = atoi(mc$[20]); kd2 = atoi(mc$[26]);
kh1 = atoi(mc$[21]); kh2 = atoi(mc$[27]);
if(!strcmp(mc$[30],"H")) jtm = 3;
else if(!strcmp(mc$[30],"D")) jtm = 2;
else if(!strcmp(mc$[30],"M")) jtm = 1;
else jtm = 0;
rv1 = atoi(mc$[31]); rv2 = atoi(mc$[32]);
/* retrieve */
clear( 0 );
_setcolor( 4 ); /* Paint the area. */
gfillpolygon(p, q, 4);
map_retrv( &itof );
clear( 0 );
_setbkcolor( 0 );
j10: /* lengend */
i = 24;
vprint(8, "Distance ^kmv");
gprint(63, 1, "SPACE-", 4);
gprint(63, 2, "TIME", 4);
gprint(63,10, "bottom", 2);
gprint(63,12, "top", 2);
legend2(ds, itof);
/* draw space-time chart */
_setcolor( 7 );
vorg = 0;
vlen = YPixels - (int)(RowPixels*3.5);
gbox(0, 40, vorg, 490, vorg+vlen);
vaxis(1, rv1, rv2, &ir, &uv, &rva);
st1 = fncal(kyy1,km1,kd1); st2 = fncal(kyy2,km2,kd2);
taxis(1, jtm, st1, st2);
rc = q[0] - p[0]*rw;
iwo = nmax / 4095;
for(i=0; i<itof; i++) {
eqparm(i, &xx, &yy, &hh, &rm, iwo);
otparm(i, &jy, &jm, &jd, &jh, &jn, iwo);
f = rtal(xx, yy, rw, rc, p, q);
if(f>=rv1 && f<=rv2) {
rjt = fncal(jy,jm,jd);
if(rjt>=st1 && rjt<=st2) {
if(jtm == 3) {
if(rjt==st1 && jh<kh1) goto j135;
if(rjt==st2 && jh>kh2) goto j135;
j = 57 + (int)(((rjt-st1)*24.+jh+jn/60.-kh1)*ut);
}
else j = 57 + (int)(((rjt-st1+(jh+jn/60.)/24.)*ut));
k = ir - (int)((f-rva)*uv);
for(ic=ndp-1; ic>0; ic--) if(hh >= cdp[ic]) break;
for(im=nmg-1; im>0; im--) if(rm >= cmg[im]) break;
im = (int)rmg[im];
_setcolor( icd[ic] );
gsymbol(j, k, im, icd[ic]);
}
}
j135: continue;
}
i = fgkey(0, 1);
if(i==-1 || i==F1) goto j10;
return( i );
}
/*** map subfunction-5 (active faults) ***/
int map_active_faults()
{
int ifc[4], i, nplot;
char fname[9];
if(b1>123 && b2<150 && a1>23 && a2<50) strcpy(mc$[0],"JAPAN ");
else strcpy(mc$[0]," ");
strcpy(mc$[1],"5"); strcpy(mc$[2],"2");
strcpy(mc$[3],"3"); strcpy(mc$[4],"3");
isr = 0;
j31:
i = panel( MAPS5 );
if(i==3 || i==6) return(i + F1 - 1);
if(strcmp(mc$[0]," ") == 0) {
strcpy(em$, "Invalid dataset name!");
goto j31;
}
strxcpy(fname, mc$[0]);
for(i=0; i<4; i++) ifc[i] = atoi(mc$[i+1]);
clear( 0 );
j10:
i = dmap(fname, 1, ifc);
gviewport(0, 0, 639, YPixels-1);
if(! i) goto j31;
dmap(mps$, 0);
nplot = epicenters();
gviewport(0, 0, 639, YPixels-1);
if(atoi(ync$) > 0) nplot = - atoi( ync$ );
legend(mps$, nplot);
i = fgkey(0, 1);
if(i==-1 || i==F1) goto j10;
return(i);
}
/*** map subfunction-6 (stations) ***/
int map_stations()
{
int i, na, lx, ly, nplot;
char *iwseg, f$[13], a$[5];
double xx, yy;
strcpy(mc$[0], f2$); strcpy(mc$[1], "N");
isr = 0;
j31:
i = panel( MAPS6 );
if(i==3 || i==6) return(i + F1 - 1);
if(strcmp(mc$[0]," ") == 0) {
strcpy(em$, "Invalid dataset name!");
goto j31;
}
iwseg = iseg[nseg-1];
strxcpy(f$, mc$[0]); strlwr( f$ ); strcat(f$, ".s");
if(! rbload(iwseg, 0, f$)) goto j31;
clear( 0 );
j10:
dmap(mps$, 0);
nplot = epicenters();
rbload(iwseg, 0, f$);
pspen(5, 0);
_setcolor( 4 );
gsmall_font();
for(na=0; ; na+=16) {
for(i=0; i<4; i++) a$[i] = peek(na+i+6,iwseg);
if(a$[3] == ' ') a$[3] = 0; else a$[4] = 0;
xx = bin2deg(na+10, iwseg);
yy = bin2deg(na+13, iwseg);
if(fabs(xx) > 254.) break;
if(wrap && xx<0.) xx = xx + 360.; /* wrap! */
if(xx>b1 && xx<b2 && yy>a1 && yy<a2) {
lx = (int)((xx-b1) * rrx);
ly = (int)((c2-lat(yy)) * rry);
gsymbol(lx, ly, 3, 7);
if(*mc$[1] == 'Y') gfprint(lx+4, ly, a$, 4);
}
}
pspen(2, 0);
gviewport(0, 0, 639, YPixels-1);
if(atoi(ync$) > 0) nplot = - atoi( ync$ );
legend(mps$, nplot);
i = fgkey(0, 1);
if(i==-1 || i==F1) goto j10;
return(i);
}
void map_retrv( itt )
int *itt;
{
short lx, ly;
unsigned ra, is, iw, na;
double xf, yf;
int jy, jm, jd, jh, jn;
*itt = 0; ra = 0; na = 4;
is = 0; iw = nmax/4095;
/* `wrap' happens only if the region traverses the date line, and so
360 degrees must be added to a western longitude in case of wrap = 1.*/
if( wrap ) {
if(lo1 < 0) lo1 = lo1 + 360*256;
if(lo2 < 0) lo2 = lo2 + 360*256;
}
_getimage();
for(;;) {
ra = retrv(ra, *itt, is, iw);
if(ra == 0xffff) break;
if(ra > 0x7fff) {
is++; ra = 0; na = 4;
}
else {
xf = bin2deg(na+ 7, iseg[iw]);
yf = bin2deg(na+10, iseg[iw]);
if(wrap && xf<0.) xf = xf + 360.; /* wrap! */
yf = lat(yf);
lx = (int)((xf-b1)*rrx) + kx0+1;
ly = (int)((c2-yf)*rry) + ky0+1;
otparm(*itt, &jy, &jm, &jd, &jh, &jn, iw);
if(_getpixel(lx,ly)) { (*itt)++; na += 16; }
if((*itt) == nmax2) {
poke(0xff, 0xfff4, iseg[iw]);
poke(0xff, 0xfff5, iseg[iw]);
break;
}
if((*itt)>0 && (*itt)%4095==0) {
poke(0xfe, 0xfff4, iseg[iw]);
poke(0xff, 0xfff5, iseg[iw]);
iw++; na = 4;
}
ra++;
}
}
}
project_area(p, q, ds, rw)
int p[], q[], *ds;
double *rw;
{
int i, ly, printing;
double rb, rc, rd, re;
ly = 21;
printing = 0;
clear( 0 );
j10:
dmap(mps$, 0);
epicenters();
gviewport(0, 0, 639, YPixels-1);
/* specify two ends of the axis and a width point */
for(i=0; i<3; i++) {
if(i == 0) {
if(! printing) {
gprint(63, ly , "Move the cross ", 4);
gprint(63, ly+1, "to 1st axis end ", 4);
press_prompt(1, ly+2);
p[0] = (kx1+kx0)/2; q[0] = (ky1+ky0)/2;
gcursor(kx0, ky0, kx1, ky1, &p[i], &q[i], 1);
if(p[i] == -1) goto j10;
}
}
else {
if(! printing) {
switch( i ) {
case 1: gprint(63, ly+1, "to 2nd axis end ", 4); break;
case 2: gprint(63, ly+1, "to width point ", 4); break;
}
p[i] = p[i-1] + 3;
q[i] = q[i-1] - 2;
gcursor(kx0, ky0, kx1, ky1, &p[i], &q[i], 0);
if(p[i] == -1) goto j10;
}
if(i == 1) {
_setcolor( 2 );
gmoveto(p[0], q[0]);
glineto(p[i], q[i]);
}
}
ital(p[i], q[i], &lo[i], &lom[i], &la[i], &lam[i]);
}
/* calculate distance */
*ds = (int)delta(lo[1]+lom[1]/60., la[1]+lam[1]/60.);
/* y1=w*x1+f : y2=w*x2+f: yr=w*xr+c */
/* y2=-x2/w+d: y1=-x1/w+e */
if(p[1] == p[0]) {
p[3] = p[2];
q[2] = q[1];
q[3] = q[0];
*rw = -1.;
}
else if(q[1] == q[0]) {
q[3] = q[2];
p[2] = p[1];
p[3] = p[0];
*rw = -2.;
}
else {
*rw = q[1] - q[0];
*rw = (*rw) / (p[1]-p[0]);
rc = q[2] - (*rw)*p[2];
rd = q[1] + p[1]/(*rw);
re = q[0] + p[0]/(*rw);
rb = (*rw) + 1./(*rw);
rd = (rd-rc) / rb;
p[2] = (int)rd;
q[2] = (int)((*rw)*rd + rc);
rd = (re-rc) / rb;
p[3] = (int)rd;
q[3] = (int)((*rw)*rd + rc);
}
/* plot the 3rd and 4th points */
_setcolor( 2 );
for(i=2; i<4; i++) {
gmoveto(p[i-1], q[i-1]);
glineto(p[i ], q[i ]);
ital(p[i], q[i], &lo[i+1], &lom[i+1], &la[i+1], &lam[i+1]);
}
glineto(p[0], q[0]);
press_prompt(2, ly);
gprint(63, ly+1, "a function key ", 4);
gprint(63, ly+2, "on the toolbar. ", 4);
i = fgkey(0, 0);
printing = 0;
if(i == -1) goto j10;
if(i == F1) { printing = 1; goto j10; }
return( i );
}
void map_sub_prep(p, q, max)
int p[], q[], max;
{
int pp, qq;
long lo;
short lom, la, lam, p1, p2, i;
for(i=0; i<max; i++) {
ital(p[i], q[i], &lo, &lom, &la, &lam);
strcpy(mc$[i*6+0], jtoa(abs((int)lo),w$,-3));
strcpy(mc$[i*6+1], jtoa(lom,w$,-2));
if(lo < 0) strcpy(mc$[i*6+2], "W");
else strcpy(mc$[i*6+2], "E");
strcpy(mc$[i*6+3], jtoa(abs(la),w$,-2));
strcpy(mc$[i*6+4], jtoa(lam,w$,-2));
if(la < 0) strcpy(mc$[i*6+5], "S");
else strcpy(mc$[i*6+5], "N");
pp = p[i]; qq = q[i];
if(pp < kx0) pp = kx0;
if(pp > kx1) pp = kx1;
if(qq < ky0) qq = ky0;
if(qq > ky1) qq = ky1;
ital(pp, qq, &lo, &lom, &la, &lam);
lo = lo*256 + lom;
la = la*256 + lam;
if(i == 0) {
p1 = pp; p2 = pp;
lo1 = lo; lo2 = lo; la1 = la; la2 = la;
}
else {
if(pp < p1) { p1 = pp; lo1 = lo; }
if(pp > p2) { p2 = pp; lo2 = lo; }
if(la < la1) la1 = la; if(la > la2) la2 = la;
}
}
}
void ital(lx, ly, lo, lom, la, lam)
int lx, ly;
long *lo;
short *la, *lom, *lam;
{
short i;
double xxx, yyy;
xxx = (lx-kx0)/rrx + b1;
if(xxx > 180.) xxx = xxx - 360.;
*lo = (long)xxx;
if(xxx >= 0.) *lom = (short)((xxx-*lo) * 60.);
else *lom = (short)((*lo-xxx) * 60.);
yyy = ym+c1 - (ly-ky0)/rry;
for(i=0; i<=180; i++) if(yyy < yln[i]) break;
if(i > 90) {
*la = i - 91;
*lam = (short)((yyy-yln[i-1]) / dln[i-1] * 60.);
}
else {
*la = i - 90;
*lam = (short)((yln[i]-yyy) / dln[i-1] * 60.);
}
}
double delta(bo, ba)
double bo, ba;
{
double ao, aa, co, ca, dp, da, pi, rr;
double coa, soa, cob, sob, caa, saa, cab, sab;
pi = 3.14159;
ao = lo[0] + lom[0]/60.; aa = la[0] + lam[0]/60.;
co = ao/180.*pi; ca = aa/180.*pi; dp = bo/180.*pi; da = ba/180.*pi;
coa = cos(co); soa = sin(co); cob = cos(dp); sob = sin(dp);
caa = cos(ca); saa = sin(ca); cab = cos(da); sab = sin(da);
co = caa*coa - cab*cob;
ca = caa*soa - cab*sob;
dp = saa - sab;
rr = co*co + ca*ca + dp*dp;
return(6369. * 2.*asin(0.5*sqrt(rr)));
}
/* legend for cross-section & space-time */
void legend2(ds, nplot)
int ds, nplot;
{
short i, j;
char s[4];
pfromto(-3, nplot);
for(i=0; i<2; i++) {
j = 11 + i*2;
jtoa(abs((int)lo[i]), w$, -3);
strcat(w$, " "); strcat(w$, jtoa(lom[i],s,-2));
if(lo[i] < 0) strcat(w$, "W-");
else strcat(w$, "E-");
strcat(w$, jtoa(abs((int)la[i]),s,-2));
strcat(w$, " "); strcat(w$, jtoa(lam[i],s,-2));
if(la[i] < 0) strcat(w$, "S");
else strcat(w$, "N");
gprint(63, j, w$, 7);
}
gprint(63, 14, "length", 2);
itoa(ds, w$, 10); strcat(w$, "km");
gprint(66, 15, w$, 7);
mag_legend();
}
double rtal(xx, yy, rw, rc, p, q)
double xx, yy, rw, rc;
int p[], q[];
{
double yyy, rd, rtx, rty, rlo, rla;
short i;
yyy = lat(yy);
if(wrap && xx<0.) xx = xx + 360.;
rtx = (xx-b1)*rrx + kx0;
rty = (ym-yyy+c1)*rry + ky0;
if(rw == -1.) rtx = p[0];
else if(rw == -2.) rty = q[0];
else {
rd = rty + rtx/rw;
rtx = (rd-rc) / (rw+1./rw);
rty = rw*rtx + rc;
}
rlo = (rtx-kx0)/rrx + b1;
yyy = ym+c1 - (rty-ky0)/rry;
for(i=0; i<=180; i++) if(yyy < yln[i]) break;
if(i > 90) rla = i - 91 + (yyy-yln[i-1])/dln[i-1];
else rla = i - 90 + (yln[i]-yyy)/dln[i-1];
return( delta(rlo, rla) );
}
void otparm(ia, jy, jm, jd, jh, jn, iss)
int ia, iss;
int *jy, *jm, *jd, *jh, *jn;
{
char *is;
int ipag;
unsigned na;
ipag = ia / 4095;
is = iseg[iss+ipag];
na = (ia-ipag*4095)*16 + 4;
*jy = fnyear(na,is);
*jm = peek(na+1,is);
*jd = peek(na+2,is);
*jh = peek(na+3,is);
*jn = peek(na+4,is);
}
char *jtoa(i, s, n)
int i, n;
char *s;
{
unsigned j, nn;
char t[31];
nn = abs(n);
itoa(i, s, 10);
j = 0;
if(strlen(s) < nn) for(; j<nn-strlen(s); j++) {
if(n < 0) t[j] = '0'; else t[j] = ' ';
}
t[j] = 0;
strcat(t, s);
strcpy(s, t);
return( s );
}
void press_prompt(i, y)
int i, y;
{
switch( i ) {
case 1: gprint(63, y, "and press a button.", 4); break;
case 2: gprint(63, y, "Press Enter or ", 4); break;
}
}
char maps2_pan[] ="\
Request : MAP SELECT \
Type Y or N and press Enter. \
Points Longitude-deg,min- Latitude-deg,min- \
1st < >< >< > < >< >< > \
2nd < >< >< > < >< >< > \
3rd < >< >< > < >< >< > \
4th < >< >< > < >< >< > Undetermined? \
Depth -km- < > --> < > < > \
Magnitude < > --> < > < > \
\
Are these all right? <Y/N> ( ) \
\
16, 3, -3 \
23, 3, -2 \
29, 3, -1 \
37, 3, -3 \
43, 3, -2 \
49, 3, -1 \
16, 4, -3 \
23, 4, -2 \
29, 4, -1 \
37, 4, -3 \
43, 4, -2 \
49, 4, -1 \
16, 5, -3 \
23, 5, -2 \
29, 5, -1 \
37, 5, -3 \
43, 5, -2 \
49, 5, -1 \
16, 6, -3 \
23, 6, -2 \
29, 6, -1 \
37, 6, -3 \
43, 6, -2 \
49, 6, -1 \
21, 7, -5 \
42, 7, -5 \
59, 7, -1 \
21, 8, -4 \
42, 8, -4 \
59, 8, -1 \
34, 10, 1 ";
char maps3_pan[] ="\
Request : MAP CROSS-SECTION \
Change parameters in () as you like and press Enter. \
Points Longitude-deg,min- Latitude-deg,min- \
Projection Axis 1st < >< >< > < >< >< > \
2nd < >< >< > < >< >< > \
Width/Direction < >< >< > < >< >< > \
\
Drawing Range: \
X-axis <distance> : X1 ( ) \
X2 ( ) \
Y-axis <depth> : Y1 ( ) Events with unknown depths will \
Y2 ( ) be plotted at 0km. \
\
31, 3, -3 \
38, 3, -2 \
44, 3, -1 \
52, 3, -3 \
58, 3, -2 \
64, 3, -1 \
31, 4, -3 \
38, 4, -2 \
44, 4, -1 \
52, 4, -3 \
58, 4, -2 \
64, 4, -1 \
31, 5, -3 \
38, 5, -2 \
44, 5, -1 \
52, 5, -3 \
58, 5, -2 \
64, 5, -1 \
33, 8, 4 \
33, 9, 4 \
33, 10, 4 \
33, 11, 4 ";
char maps4_pan[] ="\
Request : MAP SPACE-TIME \
Change parameters in () as you like and press Enter. \
Points Longitude-deg,min- Latitude-deg,min- \
Projection Axis 1st < >< >< > < >< >< > \
2nd < >< >< > < >< >< > \
Width/Direction < >< >< > < >< >< > \
\
Drawing Range: \
X-axis <time> : From ( / / ) ( : : ) \
To ( / / ) ( : : ) \
Tick Unit ( ) <---Y/M/D/H <year/month/day/hour> \
Y-axis <distance> : Y1 ( ) \
Y2 ( ) \
\
31, 3, -3 \
38, 3, -2 \
44, 3, -1 \
52, 3, -3 \
58, 3, -2 \
64, 3, -1 \
31, 4, -3 \
38, 4, -2 \
44, 4, -1 \
52, 4, -3 \
58, 4, -2 \
64, 4, -1 \
31, 5, -3 \
38, 5, -2 \
44, 5, -1 \
52, 5, -3 \
58, 5, -2 \
64, 5, -1 \
33, 8, 4 \
41, 8, 2 \
46, 8, 2 \
53, 8, 2 \
58, 8, 2 \
63, 8, 4 \
33, 9, 4 \
41, 9, 2 \
46, 9, 2 \
53, 9, 2 \
58, 9, 2 \
63, 9, 4 \
33, 10, 1 \
33, 11, 4 \
33, 12, 4 ";
char maps5_pan[] ="\
Request : MAP ACTIVE-FAULTS \
Give the name of a fault dataset, specify colors corresponding \
to the activeness of fauls, and press Enter. \
Fault Dataset ( ) \
Activeness color | \
A ( ) | 1 : Blue \
B and A-B ( ) | 2 : Green \
C and B-C ( ) | 3 : Cyan \
unknown ( ) | 4 : Red \
| 5 : Magenta \
| 6 : Yellow \
| 7 : White \
29, 3, 8 \
29, 5, 1 \
29, 6, 1 \
29, 7, 1 \
29, 8, 1 ";
char maps6_pan[] ="\
Request : MAP STATIONS \
Give the name of a station dataset and press Enter. \
\
Station Dataset ( ) \
Do you like to get station codes to be printed? < Y/N > ( ) \
\
25, 3, 8 \
63, 4, 1 ";