/*-------------------------------------------------------------------- * $Id: pspolar.c,v 1.3.4.1 2002/02/27 17:41:10 pwessel Exp $ * * Copyright (c) 1996-2001 by G. Patau * See README file for copying and redistribution conditions. *--------------------------------------------------------------------*/ /* * pspolar will read azimuth, take-off angle of seismic ray and polarities * in stations and plots polarities on the inferior focal half-sphere. * A variety of symbols may be specified. * Only one event may be plotted at a time. * PostScript code is written to stdout. * * Author: Genevieve Patau * Date: 19-OCT-1995 (psprojstations) * Version: 3.4 * Roots: heavily based on psxy.c * Last modified : 02-APR-2001 * */ #include "gmt.h" /* to have gmt environment */ #include #define CROSS 2 #define POINT 3 #define CIRCLE 4 #define SQUARE 5 #define TRIANGLE 6 #define DIAMOND 7 #define STAR 8 #define HEXAGON 9 #define ITRIANGLE 10 #define POINTSIZE 0.005 main (int argc,char **argv) { int i, symbol = 0, n, n_files = 0, fno; int n_args; int form_s = 0, justify_s = 5, fontsize_s = 12; BOOLEAN error = FALSE, nofile = TRUE; BOOLEAN done, greenwich, label_s = FALSE; BOOLEAN change_position = FALSE; BOOLEAN get_position = FALSE, get_size = FALSE, get_symbol = FALSE; BOOLEAN outline_E = FALSE, outline_G = FALSE, outline_F = FALSE; BOOLEAN old_GMT_world_map, skip_if_outside = TRUE; BOOLEAN plot_polS = FALSE, vecS = FALSE, scolor = FALSE, outline_s = FALSE; BOOLEAN def_cpen = FALSE, def_fpen = FALSE, def_tpen = FALSE; BOOLEAN def_gpen = FALSE, def_epen = FALSE, def_spen = FALSE; BOOLEAN hypo = FALSE; double west = 0.0, east = 0.0, south = 0.0, north = 0.0; double plot_x, plot_y, symbol_size = 0.0, symbol_size2; double lon, lat, plot_x0, plot_y0; double new_lon, new_lat, new_plot_x0, new_plot_y0; double radius, ech = 0., azimut, ih, plongement; double c_pointsize = 0.015; double angle_s = 0.0; double azS, sizeS; double v_width, h_length, h_width, shape; double si, co; char line[BUFSIZ], symbol_type, col[4][50]; char pol; char txt_a[64],txt_b[64],txt_c[64], txt_d[64]; char stacode[32]; FILE *fp = NULL; struct GMT_PEN pen, cpen, fpen, gpen, epen, spen, tpen; struct GMT_FILL fill, ffill, gfill, efill, sfill; struct GMT_FILL black, nofill; argc = GMT_begin (argc, argv); GMT_init_pen (&pen, GMT_PENWIDTH); GMT_init_fill (&nofill, -1, -1, -1); GMT_init_fill (&black, 0, 0, 0); GMT_init_fill (&efill, 250, 250, 250); fill = nofill; ffill = nofill; sfill = nofill; gfill = black; /* Check and interpret the command line arguments */ for (i = 1; !error && i < argc; i++) { if (argv[i][0] == '-') { switch(argv[i][1]) { /* Common parameters */ case 'B': case 'H': case 'J': case 'K': case 'O': case 'P': case 'R': case 'U': case 'V': case 'X': case 'x': case 'Y': case 'y': case 'c': case '\0': error += GMT_get_common_args (argv[i], &west, &east, &south, &north); break; /* Supplemental parameters */ case 'C': /* New coordinates */ change_position = TRUE; sscanf(&argv[i][2], "%lf/%lf", &new_lon, &new_lat); if(strchr(argv[i], 'W')) { GMT_getpen (strchr(argv[i]+1, 'W')+1, &cpen); def_cpen = TRUE; } if(strchr(argv[i], 'P')) { sscanf(strchr(argv[i]+1, 'P')+1, "%lf", &c_pointsize); } break; case 'D': /* Coordinates */ get_position = TRUE; sscanf(&argv[i][2], "%lf/%lf", &lon, &lat); break; case 'E': /* Set color for station in extensive part */ GMT_getfill (&argv[i][2], &efill); break; case 'e': /* Outline station symbol in extensive part */ outline_E = TRUE; if(strlen(argv[i]) > 2) { GMT_getpen (&argv[i][2], &epen); def_epen = TRUE; } break; case 'F': /* Set background color of beach ball */ GMT_getfill (&argv[i][2], &ffill); break; case 'f': /* Outline beach ball */ outline_F = TRUE; if(strlen(argv[i]) > 2) { GMT_getpen (&argv[i][2], &fpen); def_fpen = TRUE; } break; case 'G': /* Set color for station in compressive part */ GMT_getfill (&argv[i][2], &gfill); break; case 'g': /* Outline station symbol in compressive part */ outline_G = TRUE; if(strlen(argv[i]) > 2) { GMT_getpen (&argv[i][2], &gpen); def_gpen = TRUE; } break; case 'h': /* Use HYPO71 format */ hypo = TRUE; break; case 'M': /* Focal sphere size */ get_size = TRUE; sscanf(&argv[i][2], "%s", txt_a); ech = GMT_convert_units (txt_a, GMT_INCH); break; case 'N': /* Do not skip points outside border */ skip_if_outside = FALSE; break; case 'S': /* Get symbol [and size] */ symbol_type = argv[i][2]; symbol_size = GMT_convert_units (&argv[i][3], GMT_INCH); get_symbol = TRUE; switch (symbol_type) { case 'a': symbol = STAR; break; case 'c': symbol = CIRCLE; break; case 'd': symbol = DIAMOND; break; case 'h': symbol = HEXAGON; break; case 'i': symbol = ITRIANGLE; break; case 'p': symbol = POINT; break; case 's': symbol = SQUARE; break; case 't': symbol = TRIANGLE; break; case 'x': symbol = CROSS; break; default: error = TRUE; fprintf (stderr, "%s: GMT SYNTAX ERROR -S option: Unrecognized symbol type %c\n", argv[0], symbol_type); break; } break; case 's': /* Get S polarity */ plot_polS = TRUE; strcpy(txt_a, &argv[i][3]); n=0; while (txt_a[n] && txt_a[n] != '/' && txt_a[n] != 'V' && txt_a[n] != 'G' && txt_a[n] != 'L') n++; txt_a[n]=0; sizeS = GMT_convert_units (txt_a, GMT_INCH); if(strchr(argv[i], 'V')) { vecS = TRUE; strcpy(txt_a,strchr(argv[i], 'V')); if(strncmp(txt_a,"VG",2) == 0 || strncmp(txt_a,"VL",2) == 0 || strlen(txt_a) == 1) { v_width = 0.03; h_length = 0.12; h_width = 0.1; shape = gmtdefs.vector_shape; if (!gmtdefs.measure_unit) { v_width = 0.075; h_length = 0.3; h_width = 0.25; shape = gmtdefs.vector_shape; } } else { strcpy(txt_a, strchr(argv[i], 'V')+1); strcpy(txt_b, strchr(txt_a+1, '/')+1); strcpy(txt_c, strchr(txt_b+1, '/')+1); strcpy(txt_d, strchr(txt_c+1, '/')+1); n=0; while (txt_a[n] && txt_a[n] != '/') n++; txt_a[n]=0; n=0; while (txt_b[n] && txt_b[n] != '/') n++; txt_b[n]=0; n=0; while (txt_c[n] && txt_c[n] != '/') n++; txt_c[n]=0; n=0; while (txt_d[n] && txt_d[n] != '/' && txt_d[n] != 'L' && txt_d[n] != 'G') n++; txt_d[n]=0; v_width = GMT_convert_units (txt_a, GMT_INCH); h_length = GMT_convert_units (txt_b, GMT_INCH); h_width = GMT_convert_units (txt_c, GMT_INCH); shape = atof(txt_d); } } if(strchr(argv[i], 'G')) { sscanf (strchr(argv[i]+1,'G')+1,"%d/%d/%d",&sfill.rgb[0],&sfill.rgb[1],&sfill.rgb[2]); sprintf(txt_a, "%d/%d/%d",sfill.rgb[0],sfill.rgb[1],sfill.rgb[2]); GMT_getfill (txt_a, &sfill); scolor = TRUE; } if(strchr(argv[i], 'L')) outline_s = TRUE; break; case 'T': /* Information about label printing */ label_s = TRUE; if (strlen(argv[i]) > 2) { sscanf (&argv[i][2], "%lf/%d/%d/%d/", &angle_s, &form_s, &justify_s, &fontsize_s); } break; case 't': /* Set color for station label */ GMT_getpen (&argv[i][2], &tpen); def_tpen = TRUE; break; case 'W': /* Set line attributes */ GMT_getpen (&argv[i][2], &pen); break; /* Illegal options */ default: /* Options not recognized */ error = TRUE; GMT_default_error (argv[i][1]); break; } } else n_files++; } /* Check that the options selected are consistant */ if (!project_info.region_supplied) { error++; } if(ech <= 0.) { error++; } if(get_position + get_size + get_symbol < 3) { error++; } if (argc == 1 || GMT_quick || error) { /* Display usage */ fprintf (stderr,"%s %s - Plot polarities on the inferior focal half-sphere on maps\n\n",argv[0], GMT_VERSION); fprintf (stderr,"usage: argv[0] -J -R\n"); fprintf (stderr, " -Dlongitude/latitude -Msize[i/c] -S[i/c]\n"); fprintf (stderr, " [-A] [-B] [-Clongitude/latitude[W][Ppointsize]] [-E]\n"); fprintf (stderr, " [-E] [-e[]] [-F] [-f[]] [-G] [-g[]] [-H] [-K] [-N] [-O] [-P]\n"); fprintf (stderr, " [-s/[V[][L]\n"); fprintf (stderr, " [-T[]] [-t] [-U[