@@ -54,6 +54,7 @@ struct PSCOUPE_CTRL {
54
54
int fuseau ;
55
55
char proj_type ;
56
56
double p_width , p_length , dmin , dmax ;
57
+ double lon1 , lat1 , lon2 , lat2 ;
57
58
double xlonref , ylatref ;
58
59
struct GMT_PEN pen ;
59
60
struct nodal_plane PREF ;
@@ -114,7 +115,7 @@ struct PSCOUPE_CTRL {
114
115
struct GMT_FILL fill ;
115
116
struct GMT_FONT font ;
116
117
} S ;
117
- struct PSCOUPE_T { /* -Tnplane [/<pen>] */
118
+ struct PSCOUPE_T { /* -T<nplane> [/<pen>] */
118
119
bool active ;
119
120
unsigned int n_plane ;
120
121
struct GMT_PEN pen ;
@@ -123,7 +124,7 @@ struct PSCOUPE_CTRL {
123
124
bool active ;
124
125
struct GMT_PEN pen ;
125
126
} W ;
126
- struct PSCOUPE_A2 { /* -Fa[size[/ Psymbol[ Tsymbol]]] */
127
+ struct PSCOUPE_A2 { /* -Fa[< size>[/< Psymbol>[< Tsymbol> ]]] */
127
128
bool active ;
128
129
char P_symbol , T_symbol ;
129
130
double size ;
@@ -161,6 +162,7 @@ static void *New_Ctrl (struct GMT_CTRL *GMT) { /* Allocate and initialize a new
161
162
162
163
/* Initialize values whose defaults are not 0/false/NULL */
163
164
165
+ C -> A .PREF .dip = 90.0 ; /* Vertical is the default dip */
164
166
C -> L .pen = C -> T .pen = C -> P2 .pen = C -> T2 .pen = C -> W .pen = GMT -> current .setting .map_default_pen ;
165
167
/* Set width temporarily to -1. This will indicate later that we need to replace by W.pen */
166
168
C -> L .pen .width = C -> T .pen .width = C -> P2 .pen .width = C -> T2 .pen .width = -1.0 ;
@@ -453,11 +455,12 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
453
455
if (level == GMT_SYNOPSIS ) return (GMT_MODULE_SYNOPSIS );
454
456
455
457
GMT_Message (API , GMT_TIME_NONE , "\t-A Specify cross-section parameters. Choose between\n" );
456
- GMT_Message (API , GMT_TIME_NONE , "\t -Aa<lon1/lat1/lon2/lat2/dip/p_width/dmin/dmax>[+f]\n" );
457
- GMT_Message (API , GMT_TIME_NONE , "\t -Ab<lon1/lat1/strike/p_length/dip/p_width/dmin/dmax>[+f]\n" );
458
- GMT_Message (API , GMT_TIME_NONE , "\t -Ac<x1/y1/x2/y2/dip/p_width/dmin/dmax>[+f]\n" );
459
- GMT_Message (API , GMT_TIME_NONE , "\t -Ad<x1/y1/strike/p_length/dip/p_width/dmin/max>[+f]\n" );
460
- GMT_Message (API , GMT_TIME_NONE , "\t Add +f to get the frame from the cross-section parameters.\n" );
458
+ GMT_Message (API , GMT_TIME_NONE , "\t -Aa<lon1>/<lat1>/<lon2>/<lat2>[+d<dip>][+w<width>][+z<dmin>/<dmax>][+r]\n" );
459
+ GMT_Message (API , GMT_TIME_NONE , "\t -Ab<lon1>/<lat1>/<strike>/<length>[+d<dip>][+w<width>][+z<dmin>/<dmax>][+r]\n" );
460
+ GMT_Message (API , GMT_TIME_NONE , "\t -Ac<x1>/<y1>/<x2>/<y2>[+d<dip>][+w<width>][+z<dmin>/<dmax>][+r]\n" );
461
+ GMT_Message (API , GMT_TIME_NONE , "\t -Ad<x1>/<y1>/<strike>/<length>[+d<dip>][+w<width>][+z<dmin>/<dmax>][+r]\n" );
462
+ GMT_Message (API , GMT_TIME_NONE , "\t For -Aa|b, <width>, <p_length>, <dmin> and <dmax> must be given in km.\n" );
463
+ GMT_Message (API , GMT_TIME_NONE , "\t Append +r to determine the plot domain (-R) from the cross-section parameters.\n" );
461
464
GMT_Message (API , GMT_TIME_NONE , "\t-C Use CPT to assign colors based on depth-value in 3rd column.\n" );
462
465
GMT_Message (API , GMT_TIME_NONE , "\t-S Select format type and symbol size.\n" );
463
466
GMT_Message (API , GMT_TIME_NONE , "\t Append the format code for your input file:\n" );
@@ -509,11 +512,11 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
509
512
GMT_Message (API , GMT_TIME_NONE , "\t-N Do Not skip/clip symbols that fall outside map border [Default will ignore those outside].\n" );
510
513
GMT_Option (API , "O,P" );
511
514
GMT_Message (API , GMT_TIME_NONE , "\t-Q Do not print cross-section information to files\n" );
512
- GMT_Message (API , GMT_TIME_NONE , "\t-Tn [/<pen>] draw nodal planes and circumference only to provide a transparent beach ball\n" );
515
+ GMT_Message (API , GMT_TIME_NONE , "\t-T<n> [/<pen>] draw nodal planes and circumference only to provide a transparent beach ball\n" );
513
516
GMT_Message (API , GMT_TIME_NONE , "\t using the current pen (see -W) or sets pen attribute.\n" );
514
- GMT_Message (API , GMT_TIME_NONE , "\t n = 1 the only first nodal plane is plotted.\n" );
515
- GMT_Message (API , GMT_TIME_NONE , "\t n = 2 the only second nodal plane is plotted.\n" );
516
- GMT_Message (API , GMT_TIME_NONE , "\t n = 0 both nodal planes are plotted.\n" );
517
+ GMT_Message (API , GMT_TIME_NONE , "\t <n> = 1 the only first nodal plane is plotted.\n" );
518
+ GMT_Message (API , GMT_TIME_NONE , "\t <n> = 2 the only second nodal plane is plotted.\n" );
519
+ GMT_Message (API , GMT_TIME_NONE , "\t <n> = 0 both nodal planes are plotted.\n" );
517
520
GMT_Message (API , GMT_TIME_NONE , "\t If moment tensor is required, nodal planes overlay moment tensor.\n" );
518
521
GMT_Option (API , "U,V" );
519
522
GMT_Message (API , GMT_TIME_NONE , "\t-W Set pen attributes [%s]\n" , gmt_putpen (API -> GMT , & API -> GMT -> current .setting .map_default_pen ));
@@ -522,6 +525,26 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
522
525
return (GMT_MODULE_USAGE );
523
526
}
524
527
528
+ GMT_LOCAL unsigned int pscoupe_parse_old_A (struct GMT_CTRL * GMT , struct PSCOUPE_CTRL * Ctrl , char * arg ) {
529
+ int n ;
530
+ char * p = NULL ;
531
+ if ((p = strstr (arg , "+f" ))) { /* Get the frame from the cross-section parameters */
532
+ Ctrl -> A .frame = true;
533
+ p [0 ] = '\0' ; /* Chop off modifier */
534
+ }
535
+ else if (arg [strlen (arg )- 1 ] == 'f' ) /* Very deprecated GMT3-4 syntax */
536
+ Ctrl -> A .frame = true;
537
+ if (Ctrl -> A .proj_type == 'a' || Ctrl -> A .proj_type == 'c' ) {
538
+ n = sscanf (& arg [1 ], "%lf/%lf/%lf/%lf/%lf/%lf/%lf/%lf" ,
539
+ & Ctrl -> A .lon1 , & Ctrl -> A .lat1 , & Ctrl -> A .lon2 , & Ctrl -> A .lat2 , & Ctrl -> A .PREF .dip , & Ctrl -> A .p_width , & Ctrl -> A .dmin , & Ctrl -> A .dmax );
540
+ }
541
+ else {
542
+ n = sscanf (& arg [1 ], "%lf/%lf/%lf/%lf/%lf/%lf/%lf/%lf" ,
543
+ & Ctrl -> A .lon1 , & Ctrl -> A .lat1 , & Ctrl -> A .PREF .str , & Ctrl -> A .p_length , & Ctrl -> A .PREF .dip , & Ctrl -> A .p_width , & Ctrl -> A .dmin , & Ctrl -> A .dmax );
544
+ }
545
+ return (n != 8 ) ? 1 : GMT_NOERROR ;
546
+ }
547
+
525
548
static int parse (struct GMT_CTRL * GMT , struct PSCOUPE_CTRL * Ctrl , struct GMT_OPTION * options ) {
526
549
/* This parses the options provided to pscoupe and sets parameters in Ctrl.
527
550
* Note Ctrl has already been initialized and non-zero default values set.
@@ -531,7 +554,7 @@ static int parse (struct GMT_CTRL *GMT, struct PSCOUPE_CTRL *Ctrl, struct GMT_OP
531
554
*/
532
555
533
556
unsigned int n_errors = 0 ;
534
- char txt [GMT_LEN256 ] = {"" }, txt_b [GMT_LEN256 ] = {"" }, txt_c [GMT_LEN256 ] = {"" }, * p = NULL ;
557
+ char txt_a [GMT_LEN256 ] = {"" }, txt_b [GMT_LEN256 ] = {"" }, txt_c [ GMT_LEN256 ] = { "" }, txt_d [GMT_LEN256 ] = {"" }, * p = NULL ;
535
558
struct GMT_OPTION * opt = NULL ;
536
559
double lon1 , lat1 , lon2 , lat2 ;
537
560
@@ -548,38 +571,75 @@ static int parse (struct GMT_CTRL *GMT, struct PSCOUPE_CTRL *Ctrl, struct GMT_OP
548
571
case 'A' : /* Cross-section definition */
549
572
Ctrl -> A .active = true;
550
573
Ctrl -> A .proj_type = opt -> arg [0 ];
551
- if ((p = strstr (opt -> arg , "+f" ))) { /* Get the frame from the cross-section parameters */
552
- Ctrl -> A .frame = true;
553
- p [0 ] = '\0' ; /* Chop off modifier */
574
+ if (strstr (opt -> arg , "+f" ) || gmt_count_char (GMT , opt -> arg , '/' ) == 7 ) /* Old deprecated syntax */
575
+ n_errors += pscoupe_parse_old_A (GMT , Ctrl , opt -> arg );
576
+ else { /* New, modifier-equipped syntax */
577
+ if ((p = gmt_first_modifier (GMT , opt -> arg , "drwz" ))) { /* Process any modifiers */
578
+ if (gmt_get_modifier (p , 'd' , txt_a ))
579
+ Ctrl -> A .PREF .dip = atof (txt_a );
580
+ if (gmt_get_modifier (p , 'r' , txt_a ))
581
+ Ctrl -> A .frame = true;
582
+ if (gmt_get_modifier (p , 'w' , txt_a ))
583
+ Ctrl -> A .p_width = atof (txt_a );
584
+ if (gmt_get_modifier (p , 'z' , txt_a ))
585
+ sscanf (txt_a , "%lf/%lf" , & Ctrl -> A .dmin , & Ctrl -> A .dmax );
586
+ p [0 ] = '\0' ; /* Chop off modifiers */
587
+ }
588
+ /* Process the first 4 args */
589
+ if (sscanf (& opt -> arg [1 ], "%[^/]/%[^/]/%[^/]/%s" , txt_a , txt_b , txt_c , txt_d ) != 4 ) {
590
+ GMT_Report (GMT -> parent , GMT_MSG_ERROR , "-A requires 4 arguments before modifiers.\n" );
591
+ n_errors ++ ;
592
+ }
593
+ switch (Ctrl -> A .proj_type ) {
594
+ case 'a' :
595
+ n_errors += gmt_verify_expectations (GMT , GMT_IS_LON , gmt_scanf (GMT , txt_a , GMT_IS_LON , & Ctrl -> A .lon1 ), txt_a );
596
+ n_errors += gmt_verify_expectations (GMT , GMT_IS_LAT , gmt_scanf (GMT , txt_b , GMT_IS_LAT , & Ctrl -> A .lat1 ), txt_b );
597
+ n_errors += gmt_verify_expectations (GMT , GMT_IS_LON , gmt_scanf (GMT , txt_c , GMT_IS_LON , & Ctrl -> A .lon2 ), txt_c );
598
+ n_errors += gmt_verify_expectations (GMT , GMT_IS_LAT , gmt_scanf (GMT , txt_d , GMT_IS_LAT , & Ctrl -> A .lat2 ), txt_d );
599
+ break ;
600
+ case 'b' :
601
+ n_errors += gmt_verify_expectations (GMT , GMT_IS_LON , gmt_scanf (GMT , txt_a , GMT_IS_LON , & Ctrl -> A .lon1 ), txt_a );
602
+ n_errors += gmt_verify_expectations (GMT , GMT_IS_LAT , gmt_scanf (GMT , txt_b , GMT_IS_LAT , & Ctrl -> A .lat1 ), txt_b );
603
+ Ctrl -> A .PREF .str = atof (txt_c );
604
+ Ctrl -> A .p_length = atof (txt_d );
605
+ case 'c' :
606
+ n_errors += gmt_verify_expectations (GMT , GMT_IS_FLOAT , gmt_scanf (GMT , txt_a , GMT_IS_FLOAT , & Ctrl -> A .lon1 ), txt_a );
607
+ n_errors += gmt_verify_expectations (GMT , GMT_IS_FLOAT , gmt_scanf (GMT , txt_b , GMT_IS_FLOAT , & Ctrl -> A .lat1 ), txt_b );
608
+ n_errors += gmt_verify_expectations (GMT , GMT_IS_FLOAT , gmt_scanf (GMT , txt_c , GMT_IS_FLOAT , & Ctrl -> A .lon2 ), txt_c );
609
+ n_errors += gmt_verify_expectations (GMT , GMT_IS_FLOAT , gmt_scanf (GMT , txt_d , GMT_IS_FLOAT , & Ctrl -> A .lat2 ), txt_d );
610
+ break ;
611
+ case 'd' :
612
+ n_errors += gmt_verify_expectations (GMT , GMT_IS_LON , gmt_scanf (GMT , txt_a , GMT_IS_LON , & Ctrl -> A .lon1 ), txt_a );
613
+ n_errors += gmt_verify_expectations (GMT , GMT_IS_LAT , gmt_scanf (GMT , txt_b , GMT_IS_LAT , & Ctrl -> A .lat1 ), txt_b );
614
+ Ctrl -> A .PREF .str = atof (txt_c );
615
+ Ctrl -> A .p_length = atof (txt_d );
616
+ default :
617
+ GMT_Report (GMT -> parent , GMT_MSG_ERROR , "Option -A: Unrecognized mode %c.\n" , Ctrl -> A .proj_type );
618
+ n_errors ++ ;
619
+ break ;
620
+ }
554
621
}
555
- else if (opt -> arg [strlen (opt -> arg )- 1 ] == 'f' ) Ctrl -> A .frame = true; /* Deprecated syntax */
556
622
if (Ctrl -> A .proj_type == 'a' || Ctrl -> A .proj_type == 'c' ) {
557
- sscanf (& opt -> arg [1 ], "%lf/%lf/%lf/%lf/%lf/%lf/%lf/%lf" ,
558
- & lon1 , & lat1 , & lon2 , & lat2 , & Ctrl -> A .PREF .dip , & Ctrl -> A .p_width , & Ctrl -> A .dmin , & Ctrl -> A .dmax );
559
- pscoupe_distaz (lat1 , lon1 , lat2 , lon2 , & Ctrl -> A .p_length , & Ctrl -> A .PREF .str , Ctrl -> A .proj_type == 'a' ? COORD_DEG : COORD_KM );
623
+ pscoupe_distaz (Ctrl -> A .lat1 , Ctrl -> A .lon1 , Ctrl -> A .lat2 , Ctrl -> A .lon2 , & Ctrl -> A .p_length , & Ctrl -> A .PREF .str , Ctrl -> A .proj_type == 'a' ? COORD_DEG : COORD_KM );
560
624
sprintf (Ctrl -> A .newfile , "A%c%.1f_%.1f_%.1f_%.1f_%.0f_%.0f_%.0f_%.0f" ,
561
- Ctrl -> A .proj_type , lon1 , lat1 , lon2 , lat2 , Ctrl -> A .PREF .dip , Ctrl -> A .p_width , Ctrl -> A .dmin , Ctrl -> A .dmax );
625
+ Ctrl -> A .proj_type , Ctrl -> A . lon1 , Ctrl -> A . lat1 , Ctrl -> A . lon2 , Ctrl -> A . lat2 , Ctrl -> A .PREF .dip , Ctrl -> A .p_width , Ctrl -> A .dmin , Ctrl -> A .dmax );
562
626
sprintf (Ctrl -> A .extfile , "A%c%.1f_%.1f_%.1f_%.1f_%.0f_%.0f_%.0f_%.0f_map" ,
563
- Ctrl -> A .proj_type , lon1 , lat1 , lon2 , lat2 , Ctrl -> A .PREF .dip , Ctrl -> A .p_width , Ctrl -> A .dmin , Ctrl -> A .dmax );
627
+ Ctrl -> A .proj_type , Ctrl -> A . lon1 , Ctrl -> A . lat1 , Ctrl -> A . lon2 , Ctrl -> A . lat2 , Ctrl -> A .PREF .dip , Ctrl -> A .p_width , Ctrl -> A .dmin , Ctrl -> A .dmax );
564
628
}
565
629
else {
566
- sscanf (& opt -> arg [1 ], "%lf/%lf/%lf/%lf/%lf/%lf/%lf/%lf" ,
567
- & lon1 , & lat1 , & Ctrl -> A .PREF .str , & Ctrl -> A .p_length , & Ctrl -> A .PREF .dip , & Ctrl -> A .p_width , & Ctrl -> A .dmin , & Ctrl -> A .dmax );
568
630
sprintf (Ctrl -> A .newfile , "A%c%.1f_%.1f_%.0f_%.0f_%.0f_%.0f_%.0f_%.0f" ,
569
- Ctrl -> A .proj_type , lon1 , lat1 , Ctrl -> A .PREF .str , Ctrl -> A .p_length , Ctrl -> A .PREF .dip , Ctrl -> A .p_width , Ctrl -> A .dmin , Ctrl -> A .dmax );
631
+ Ctrl -> A .proj_type , Ctrl -> A . lon1 , Ctrl -> A . lat1 , Ctrl -> A .PREF .str , Ctrl -> A .p_length , Ctrl -> A .PREF .dip , Ctrl -> A .p_width , Ctrl -> A .dmin , Ctrl -> A .dmax );
570
632
sprintf (Ctrl -> A .extfile , "A%c%.1f_%.1f_%.0f_%.0f_%.0f_%.0f_%.0f_%.0f_map" ,
571
- Ctrl -> A .proj_type , lon1 , lat1 , Ctrl -> A .PREF .str , Ctrl -> A .p_length , Ctrl -> A .PREF .dip , Ctrl -> A .p_width , Ctrl -> A .dmin , Ctrl -> A .dmax );
633
+ Ctrl -> A .proj_type , Ctrl -> A . lon1 , Ctrl -> A . lat1 , Ctrl -> A .PREF .str , Ctrl -> A .p_length , Ctrl -> A .PREF .dip , Ctrl -> A .p_width , Ctrl -> A .dmin , Ctrl -> A .dmax );
572
634
}
573
- Ctrl -> A .PREF .rake = 0. ;
574
635
if (Ctrl -> A .proj_type == 'a' || Ctrl -> A .proj_type == 'b' )
575
- Ctrl -> A .fuseau = pscoupe_gutm (lon1 , lat1 , & Ctrl -> A .xlonref , & Ctrl -> A .ylatref , 0 );
636
+ Ctrl -> A .fuseau = pscoupe_gutm (Ctrl -> A . lon1 , Ctrl -> A . lat1 , & Ctrl -> A .xlonref , & Ctrl -> A .ylatref , 0 );
576
637
else {
577
638
Ctrl -> A .fuseau = -1 ;
578
- Ctrl -> A .xlonref = lon1 ;
579
- Ctrl -> A .ylatref = lat1 ;
639
+ Ctrl -> A .xlonref = Ctrl -> A . lon1 ;
640
+ Ctrl -> A .ylatref = Ctrl -> A . lat1 ;
580
641
}
581
642
Ctrl -> A .polygon = true;
582
- if (p ) p [0 ] = '+' ; /* Restore modifier */
583
643
break ;
584
644
585
645
case 'Z' : /* Backwards compatibility */
@@ -608,9 +668,9 @@ static int parse (struct GMT_CTRL *GMT, struct PSCOUPE_CTRL *Ctrl, struct GMT_OP
608
668
switch (opt -> arg [0 ]) {
609
669
case 'a' : /* plot axis */
610
670
Ctrl -> A2 .active = true;
611
- strncpy (txt , & opt -> arg [1 ], GMT_LEN256 - 1 );
612
- if ((p = strchr (txt , '/' )) != NULL ) p [0 ] = '\0' ;
613
- if (txt [0 ]) Ctrl -> A2 .size = gmt_M_to_inch (GMT , txt );
671
+ strncpy (txt_a , & opt -> arg [1 ], GMT_LEN256 - 1 );
672
+ if ((p = strchr (txt_a , '/' )) != NULL ) p [0 ] = '\0' ;
673
+ if (txt_a [0 ]) Ctrl -> A2 .size = gmt_M_to_inch (GMT , txt_a );
614
674
if (p ) {
615
675
p ++ ;
616
676
switch (strlen (p )) {
@@ -686,9 +746,9 @@ static int parse (struct GMT_CTRL *GMT, struct PSCOUPE_CTRL *Ctrl, struct GMT_OP
686
746
Ctrl -> S .justify = PSL_BC ;
687
747
opt -> arg [strlen (opt -> arg )- 1 ] = '\0' ;
688
748
}
689
- txt [0 ] = txt_b [0 ] = txt_c [0 ] = '\0' ;
690
- sscanf (& opt -> arg [2 ], "%[^/]/%[^/]/%s" , txt , txt_b , txt_c );
691
- if (txt [0 ]) Ctrl -> S .scale = gmt_M_to_inch (GMT , txt );
749
+ txt_a [0 ] = txt_b [0 ] = txt_c [0 ] = '\0' ;
750
+ sscanf (& opt -> arg [2 ], "%[^/]/%[^/]/%s" , txt_a , txt_b , txt_c );
751
+ if (txt_a [0 ]) Ctrl -> S .scale = gmt_M_to_inch (GMT , txt_a );
692
752
if (txt_b [0 ]) Ctrl -> S .font .size = gmt_convert_units (GMT , txt_b , GMT_PT , GMT_PT );
693
753
if (txt_c [0 ]) Ctrl -> S .offset [1 ] = gmt_convert_units (GMT , txt_c , GMT_PT , GMT_INCH );
694
754
if (Ctrl -> S .font .size < 0.0 ) Ctrl -> S .no_label = true;
@@ -824,9 +884,9 @@ static int parse (struct GMT_CTRL *GMT, struct PSCOUPE_CTRL *Ctrl, struct GMT_OP
824
884
Ctrl -> S .justify = PSL_BC ;
825
885
opt -> arg [strlen (opt -> arg )- 1 ] = '\0' ;
826
886
}
827
- txt [0 ] = txt_b [0 ] = txt_c [0 ] = '\0' ;
828
- sscanf (& opt -> arg [1 ], "%[^/]/%[^/]/%s" , txt , txt_b , txt_c );
829
- if (txt [0 ]) Ctrl -> S .scale = gmt_M_to_inch (GMT , txt );
887
+ txt_a [0 ] = txt_b [0 ] = txt_c [0 ] = '\0' ;
888
+ sscanf (& opt -> arg [1 ], "%[^/]/%[^/]/%s" , txt_a , txt_b , txt_c );
889
+ if (txt_a [0 ]) Ctrl -> S .scale = gmt_M_to_inch (GMT , txt_a );
830
890
if (txt_b [0 ]) Ctrl -> S .font .size = gmt_convert_units (GMT , txt_b , GMT_PT , GMT_PT );
831
891
if (txt_c [0 ]) Ctrl -> S .offset [1 ] = gmt_convert_units (GMT , txt_c , GMT_PT , GMT_INCH );
832
892
if (Ctrl -> S .font .size < 0.0 ) Ctrl -> S .no_label = true;
0 commit comments