爱情 (1) 安装 (2) 北斗 (1) 毕业 (1) 变量 (1) 测绘局 (1) 测量 (2) 插件 (1) 查询 (1) 常用 (1) 成果转化 (1) 词汇 (1) 慈善 (1) 答辩 (2) 代码 (2) 电台 (1) 发泄 (1) 感悟 (4) 高程 (1) 搞笑 (5) 共产党 (1) 古诗词 (1) 管理 (1) 函数 (3) 绘图 (1) 加密 (1) 交际 (1) 教程 (4) 教育 (2) 解决 (4) 解密 (1) 精度 (1) 酒桌 (2) 开源 (2) 科技 (1) 科学 (1) 刻录 (1) 老外 (1) 励志 (5) 连续剧 (1) 恋爱 (1) 列表 (1) 领导 (1) 美食 (2) 名人 (3) 命令 (4) 区别 (1) 日记 (2) 软件 (12) 商业 (3) 时政 (1) 视频 (1) 数据 (1) 算法 (1) 投影 (2) 图论 (1) 网络 (1) 网站 (1) 卫星 (3) 未成年 (1) 慰问 (1) 文本 (1) 文件 (2) 下载 (4) 笑话 (2) 学习 (9) 遥感 (1) 疑问 (5) 营销 (1) 娱乐 (3) 源代码 (2) 政策 (1) 指导 (3) 智慧 (5) 主成分分析 (2) 抓图 (1) 专家 (1) 资料 (5) 字符串 (1) 最短路径 (1) 坐标 (1) baidu (3) Bernese (1) blog (2) c# (9) China (3) Dijkstra (1) DNS (1) doris (1) dos (1) excel (1) firefox (3) GAMIT (8) gcc (1) GIS (3) GMT (1) GPS (5) ITRF (1) linux (5) mapx (1) matlab (6) movie (4) music (3) oracle (2) pic (1) PPT (3) PROJ.4 (2) python (2) QQ (2) rinex (1) shell (2) sql (1) teqc (3) tools (1) tps (1) ubuntu (5) USA (1) website (1)

博客归档

2010年6月26日星期六

psvelomeca.c ----c语言源代码

/*--------------------------------------------------------------------
 *    The GMT-system:    @(#)psvelomeca.c    2.6  09/20/93
 *
 *    Copyright (c) 1991 by P. Wessel and W. H. F. Smith
 *    See README file for copying and redistribution conditions.
 *--------------------------------------------------------------------*/
/*

psvelomeca will read pairs (or ) from inputfile and
plot symbols on a map. Focal mechanisms, velocity ellipses, strain
crosses, or strain wedges, may be specified, some of which require
additional columns of data.  Only one symbol may be plotted at a time.
PostScript code is written to stdout.


 Authors:     Genevieve Patau and Kurt Feigl
 Date:          20 Sept. 1993
 Version:     2.6
 Roots:       based on psxy.c   

 */

#include "gmt.h"        /* to have gmt environment */

#include "velomeca.h"

#define MECA 1
#define CINE 2
#define ANISO 3
#define WEDGE 4
#define CROSS 5

#define POINTSIZE 0.015
#define TIRET_WIDTH 3
#define veclen(x, y) sqrt((x) * (x) + (y) * (y))

     /* parameters for writing text */
#define ANGLE 0.0
#define FORM 0

int *plot_pen;

main (argc, argv)
int argc;
char **argv; {

    int     i, j, symbol = 0, n, ix = 0, iy = 1, n_files = 0, fno;
    int    n_args;
        int     n_rec = 0;
   
    BOOLEAN    error = FALSE, nofile = TRUE, polygon = FALSE;
        BOOLEAN shade_uncert = FALSE, clip = TRUE;
    BOOLEAN    outline = FALSE;
        BOOLEAN rescale_sigma = FALSE;
    BOOLEAN done, no_size_needed, greenwich;
        BOOLEAN read_cmt = FALSE, read_aki = FALSE, read_planes = FALSE;
        BOOLEAN read_change_position = FALSE, write_change_position = FALSE;
    BOOLEAN read_vector = FALSE, read_ellipse = FALSE, read_rotated_ellipse = FALSE;
        BOOLEAN des_ellipse = TRUE, des_arrow = TRUE;
        BOOLEAN transparence = FALSE;
        BOOLEAN read_anisotropy = FALSE;
        BOOLEAN read_wedge = FALSE;
        BOOLEAN read_cross = FALSE;
   
    double xy[2], xynew[2], west = 0.0, east = 0.0, south = 0.0, north = 0.0;
    double plot_x, plot_y, scale = 0.0, y0;
        double plot_xnew, plot_ynew;
        double vxy[2], vxytip[2], plot_vx, plot_vy;
        double eps1,eps2,spin,spinsig,theta;
    double direction, small_axis, great_axis;
        double sigma_x, sigma_y, corr_xy;
        double confidence = 0., sigma_scale = 1.0, conrad = 1.0;
    double v_width = 0.01, h_length = 0.12, h_width = 0.03, vector_shape = 0.4;
        double wedge_amp = 1.e7;
    double t11 = 1.0, t12 = 0.0, t21 = 0.0, t22 = 1.0;
        double delaz;
        double hl,hw,vw;

        char station_name[20];
        char event_title[512];

    char line[512], symbol_type, col[12][40], EOL_flag = '>';
   
    FILE *fp = NULL;
   
    struct PEN pen, epen;
    struct FILL fill, efill;     /* efill is for uncertainty wedge */
        struct nodal_plane NP1, NP2;
        st_me meca;

        double fault;
        int justify, fontsize;
        double zero_360();
        double ps_mechanism();
        double ps_meca();
        double size;
        double computed_dip2();
        double computed_rake2();

    argc = gmt_begin (argc, argv);
   
    gmt_init_pen (&pen, 1);
    gmt_init_pen (&epen, 1);
    gmt_init_fill (&fill, gmtdefs.basemap_frame_rgb[0], gmtdefs.basemap_frame_rgb[1], gmtdefs.basemap_frame_rgb[2]);
    gmt_init_fill (&efill, 255-gmtdefs.basemap_frame_rgb[0], 255-gmtdefs.basemap_frame_rgb[1], 255-gmtdefs.basemap_frame_rgb[2]);
   
   
    /* 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 '#':
                case ':':
                case '\0':
                    error += get_common_args (argv[i], &west, &east, &south, &north);
                    break;
               
                /* Supplemental parameters */
           
                                case 'A':       /* Change size of arrow head */
                                        sscanf(&argv[i][3], "%lf/%lf/%lf", &v_width, &h_length, &h_width);
                                        break;
                                case 'C':       /* Change position */
                                        read_change_position = TRUE;
                                        break;
                                case 'D':       /* Rescale Sigmas */
                                        rescale_sigma = TRUE;
                    sscanf (&argv[i][2], "%lf",&sigma_scale);
                                        break;
                case 'E':        /* Set Gray shade for uncertainty polygon - currently only works for Sw */
                    gmt_getfill (&argv[i][2], &efill);
                    shade_uncert = TRUE;
                    break;
                case 'F':
                    sscanf (&argv[i][2], "%d/%d/%d",&gmtdefs.basemap_frame_rgb[0],
                        &gmtdefs.basemap_frame_rgb[1], &gmtdefs.basemap_frame_rgb[2]);
                    break;
                case 'G':        /* Set Gray shade for polygon */
                    gmt_getfill (&argv[i][2], &fill);
                    polygon = TRUE;
                    break;
                case 'L':        /* Draw the outline */
                    outline = TRUE;
                    break;
                case 'N':        /* Do not clip at boundary*/
                    clip = FALSE;
                    break;
                case 'S':        /* Get symbol [and size] */
                                        symbol_type = argv[i][2];
                                        if(symbol_type == 'c' || symbol_type == 'a' || symbol_type == 'p')
                                            sscanf(&argv[i][3], "%lf", &scale);
                                        if(symbol_type == 'e' || symbol_type == 'r') {
                                            sscanf(&argv[i][3], "%lf/%lf/%d", &scale, &confidence, &fontsize);
                        /* confidence scaling */
                        conrad = sqrt( -2.0 * log(1.0 - confidence));
                      }
                                        if(symbol_type == 'n' || symbol_type == 'x' )
                                            sscanf(&argv[i][3], "%lf", &scale);
                                        if(symbol_type == 'w')
                                            sscanf(&argv[i][3], "%lf/%lf", &scale, &wedge_amp);

                    switch (symbol_type) {
                                                case 'c':
                                                        symbol = MECA;
                                                        read_cmt = TRUE;
                                                        break;
                                                case 'a':
                                                        symbol = MECA;
                                                        read_aki = TRUE;
                                                        break;
                                                case 'p':
                                                        symbol = MECA;
                                                        read_planes = TRUE;
                                                        break;
                                                case 'e':
                                                        symbol = CINE;
                                                        read_ellipse = TRUE;
                                                        break;
                                                case 'r':
                                                        symbol = CINE;
                                                        read_rotated_ellipse = TRUE;
                                                        break;
                                                case 'n':
                                                        symbol = ANISO;
                                                        read_anisotropy = TRUE;
                                                        break;
                                                case 'w':
                                                        symbol = WEDGE;
                                                        read_wedge = TRUE;
                                                        break;
                                                case 'x':
                                                        symbol = CROSS;
                                                        read_cross = TRUE;
                                                        break;
                        default:
                            error = TRUE;
                            break;
                    }
                    break;
                                case 'T':
                                        transparence = TRUE;
                    break;
                case 'W':        /* Set line attributes */
                    gmt_getpen (&argv[i][2], &pen);
                    break;
                   
                /* Illegal options */
           
                default:        /* Options not recognized */
                    error = TRUE;
                    break;
            }
        }
        else
            n_files++;
    }
   
    /* Check that the options selected are mutually consistant */
   
    no_size_needed = (read_ellipse || read_rotated_ellipse || read_cmt || read_planes || read_aki || read_anisotropy || read_cross || read_wedge );
    error += check_region (west, east, south, north);
    error += check_rgb (pen.r, pen.g, pen.b)
          + check_rgb (fill.r, fill.g, fill.b)
          + check_rgb (efill.r, efill.g, efill.b)
          + check_rgb (gmtdefs.basemap_frame_rgb[0], gmtdefs.basemap_frame_rgb[1], gmtdefs.basemap_frame_rgb[2]);
        /* Only one allowed */
    if ((read_ellipse + read_rotated_ellipse + read_cmt +  read_aki + read_planes + read_anisotropy + read_cross + read_wedge ) > 1) error = TRUE;   
    if (!no_size_needed && (symbol > 1 && scale <= 0.0)) error = TRUE;
        if (rescale_sigma && ! (read_ellipse || read_wedge)) error = TRUE;

    if (argc == 1 || error) {    /* Display usage */
        fprintf (stderr,"psvelomeca plots symbols on maps\n\n");
        fprintf (stderr,"usage: psvelomeca -J -R [-B]\n");
        fprintf (stderr, "    [-F] [-G] [-H] [-K] [-L] [-M] [-N] [-O]\n");
        fprintf (stderr, "    [-P] [-S] [-U[/dx/dy/][

没有评论:

发表评论

浏览统计