[gmt] 01/04: Imported Upstream version 5.3.3+dfsg
Bas Couwenberg
sebastic at debian.org
Thu Mar 23 22:43:25 UTC 2017
This is an automated email from the git hooks/post-receive script.
sebastic pushed a commit to branch master
in repository gmt.
commit 1d7c24c24e7397759d44f2e0c41d8260c2ebeafd
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date: Thu Mar 23 22:46:29 2017 +0100
Imported Upstream version 5.3.3+dfsg
---
cmake/ConfigDefault.cmake | 6 +-
doc/rst/source/GMT_Docs.rst | 2 +-
doc/rst/source/grdimage.rst | 4 +-
doc/rst/source/pslegend.rst | 1 +
doc/rst/source/pswiggle.rst | 2 +-
doc/rst/source/xyz2grd.rst | 13 +++-
doc/scripts/GMT_legend.ps | 79 +++++++++++-----------
src/gmt.c | 8 ++-
src/gmt_agc_io.c | 14 ++--
src/gmt_api.c | 4 +-
src/gmt_customio.c | 17 ++---
src/gmt_init.c | 4 +-
src/gmt_internals.h | 4 +-
src/gmt_io.c | 36 ++++++----
src/gmt_memory.c | 4 +-
src/gmt_nc.c | 160 ++++++++++++++++++++++++--------------------
src/gmt_plot.c | 39 ++++++++---
src/gmt_plot.h | 3 +-
src/gmt_prototypes.h | 6 +-
src/gmt_support.c | 23 ++++---
src/gmt_vector.c | 15 ++---
src/gmtlogo.c | 6 +-
src/grdimage.c | 6 +-
src/grdmask.c | 4 +-
src/grdview.c | 4 +-
src/postscriptlight.c | 51 +++++++++++++-
src/potential/talwani3d.c | 80 +++++++++++-----------
src/psclip.c | 4 +-
src/pscoast.c | 5 +-
src/psimage.c | 6 +-
src/pslegend.c | 15 +++--
src/psrose.c | 4 +-
src/psscale.c | 4 +-
src/pssolar.c | 3 +-
src/psxy.c | 18 +++--
src/psxyz.c | 6 +-
src/sphdistance.c | 4 +-
src/spotter/backtracker.c | 12 +++-
38 files changed, 406 insertions(+), 270 deletions(-)
diff --git a/cmake/ConfigDefault.cmake b/cmake/ConfigDefault.cmake
index d438732..32b9c84 100644
--- a/cmake/ConfigDefault.cmake
+++ b/cmake/ConfigDefault.cmake
@@ -1,5 +1,5 @@
#
-# $Id: ConfigDefault.cmake 17595 2017-02-24 00:53:29Z jluis $
+# $Id: ConfigDefault.cmake 17744 2017-03-22 18:50:05Z jluis $
#
# Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
# See LICENSE.TXT file for copying and redistribution conditions.
@@ -42,13 +42,13 @@ set (GMT_VERSION_YEAR "2017")
# The GMT package version.
set (GMT_PACKAGE_VERSION_MAJOR 5)
set (GMT_PACKAGE_VERSION_MINOR 3)
-set (GMT_PACKAGE_VERSION_PATCH 2)
+set (GMT_PACKAGE_VERSION_PATCH 3)
# The subversion revision of the GMT source code.
# This is manually set when making GMT *public* releases.
# However, when making internal releases or just an ordinary developer build, leave it
# empty; if it is empty, the revision number is automatically populated for you on build.
-set (GMT_SOURCE_CODE_CONTROL_VERSION_STRING "17593")
+set (GMT_SOURCE_CODE_CONTROL_VERSION_STRING "17743")
# The GMT package version.
set (GMT_PACKAGE_VERSION "${GMT_PACKAGE_VERSION_MAJOR}.${GMT_PACKAGE_VERSION_MINOR}.${GMT_PACKAGE_VERSION_PATCH}")
diff --git a/doc/rst/source/GMT_Docs.rst b/doc/rst/source/GMT_Docs.rst
index 2fc0bfe..a14a7f2 100644
--- a/doc/rst/source/GMT_Docs.rst
+++ b/doc/rst/source/GMT_Docs.rst
@@ -5467,7 +5467,7 @@ that is stored in the HDF "format". We need to run the GDAL program
**gdalinfo** on the file because we first
must extract the necessary metadata from the file:
- ::
+.. code-block:: none
gdalinfo A20030012003365.L3m_YR_NSST_9
Driver: HDF4/Hierarchical Data Format Release 4
diff --git a/doc/rst/source/grdimage.rst b/doc/rst/source/grdimage.rst
index e66a769..8ac21b1 100644
--- a/doc/rst/source/grdimage.rst
+++ b/doc/rst/source/grdimage.rst
@@ -14,7 +14,9 @@ Synopsis
.. include:: common_SYN_OPTs.rst_
**grdimage** *grd_z* \| *grd_r grd_g grd_b*
-[ |-A|\ *out_img*\ [**=**\ *driver*] ] [ |-C|\ *cpt* ]
+[ |-A|\ *out_img*\ [**=**\ *driver*] ]
+[ |SYN_OPT-B| ]
+[ |-C|\ *cpt* ]
[ |-D|\ [**r**\ ] ] [ |-E|\ [\ **i**\ \|\ *dpi*] ] |-J|\ *parameters*
[ |-G|\ [**f**\ \|\ **b**]\ *color* ]
[ |-I|\ [*intensfile*\ \|\ *intensity*] ]
diff --git a/doc/rst/source/pslegend.rst b/doc/rst/source/pslegend.rst
index 13c1fd9..0da1fcb 100644
--- a/doc/rst/source/pslegend.rst
+++ b/doc/rst/source/pslegend.rst
@@ -15,6 +15,7 @@ Synopsis
**pslegend** [ *specfile* ]
|-D|\ *refpoint* ]
+[ |SYN_OPT-B| ]
[ |-C|\ *dx*/*dy* ]
[ |-F|\ *box* ]
[ |-J|\ *parameters* ]
diff --git a/doc/rst/source/pswiggle.rst b/doc/rst/source/pswiggle.rst
index d37e16a..0d34719 100644
--- a/doc/rst/source/pswiggle.rst
+++ b/doc/rst/source/pswiggle.rst
@@ -14,7 +14,7 @@ Synopsis
.. include:: common_SYN_OPTs.rst_
**pswiggle** [ *table* ] |-J|\ *parameters* |SYN_OPT-Rz| |-Z|\ *scale*\ [*units]
-[ |-A|\ [*azimuth*] ]
+[ |-A|\ [\ *azimuth*\ ] ]
[ |SYN_OPT-B| ]
[ |-C|\ *center* ]
[ |-G|\ [**+**\ \|\ **-**\ \|\ **=**]\ *fill* ]
diff --git a/doc/rst/source/xyz2grd.rst b/doc/rst/source/xyz2grd.rst
index 3e42c47..c593449 100644
--- a/doc/rst/source/xyz2grd.rst
+++ b/doc/rst/source/xyz2grd.rst
@@ -40,7 +40,9 @@ with data. Such unconstrained nodes are set to a value specified by the
user [Default is NaN]. Nodes with more than one value will be set to the
mean value. As an option (using **-Z**), a 1-column z-table may be read
assuming all nodes are present (z-tables can be in organized in a number
-of formats, see **-Z** below.)
+of formats, see **-Z** below.) Note: **xyz2grd** does not grid the data,
+it simply reformats existing data to a grid structure. For gridding,
+see **surface**, **greenspline**, **nearneighbor**, or **triangulate**.
Required Arguments
------------------
@@ -220,4 +222,11 @@ See Also
:doc:`gmt`,
:doc:`grd2xyz`,
:doc:`grdedit`,
-:doc:`grdconvert`
+:doc:`grdconvert`,
+:doc:`greenspline`,
+:doc:`nearneighbor`,
+:doc:`surface`,
+:doc:`triangulate`
+
+
+
diff --git a/doc/scripts/GMT_legend.ps b/doc/scripts/GMT_legend.ps
index 2c84467..920e56d 100644
--- a/doc/scripts/GMT_legend.ps
+++ b/doc/scripts/GMT_legend.ps
@@ -1,11 +1,11 @@
%!PS-Adobe-3.0
%%BoundingBox: 0 0 612 792
-%%HiResBoundingBox: 0 0 612 792
-%%Title: GMT v5.2.0_r14414 [64-bit] Document from pslegend
+%%HiResBoundingBox: 0 0 612 792
+%%Title: GMT v5.3.3_r17717 [64-bit] Document from pslegend
%%Creator: GMT5
%%For: pwessel
%%DocumentNeededResources: font Helvetica
-%%CreationDate: Sat Jun 27 22:36:24 2015
+%%CreationDate: Sat Mar 18 14:37:45 2017
%%LanguageLevel: 2
%%DocumentData: Clean7Bit
%%Orientation: Portrait
@@ -272,7 +272,6 @@ end
PSL_heights psl_k PSL_height put
} for
} def
-%%%%%%%%%%%%%%%%%%% CURVED BASELINE TEXT PLACEMENT FUNCTIONS
/PSL_curved_path_labels
{ /psl_bits exch def
/PSL_placetext psl_bits 2 and 2 eq def
@@ -523,7 +522,6 @@ end
{PSL_xp 0 get PSL_yp 0 get M
1 1 j { /ii exch def PSL_xp ii get PSL_yp ii get L} for
} def
-%%%%%%%%%%%%%%%%%%% DRAW BASELINE TEXT SEGMENT LINES
/PSL_draw_path_lines
{
/PSL_n_paths1 PSL_n_paths 1 sub def
@@ -549,7 +547,6 @@ end
} for
U
} def
-%%%%%%%%%%%%%%%%%%% STRAIGHT BASELINE TEXT PLACEMENT FUNCTIONS
/PSL_straight_path_labels
{
/psl_bits exch def
@@ -666,12 +663,35 @@ O0
1200 1200 TM
% PostScript produced by:
-%%GMT: pslegend -Dx0/0/5.6i/BL -C0.05i -L1.2 -F+p+gsnow1 -B0 table.txt -P --FONT_ANNOT_PRIMARY=12p --FONT_LABEL=12p
-%%PROJ: xy 0.00000000 5.60000000 0.00000000 3.60000000 0.000 5.600 0.000 3.600 +xy +a=6378137.000 +b=6356752.314245 +ellps=WGS84
+%@GMT: pslegend -Dx0/0 -C0.05i -L1.2 -F+p+gsnow1 -B0 table.txt -P --FONT_ANNOT_PRIMARY=12p --FONT_LABEL=12p
+%@PROJ: xy 0.00000000 5.60000000 0.00000000 3.60000000 0.000 5.600 0.000 3.600 +xy
%%BeginObject PSL_Layer_1
0 setlinecap
0 setlinejoin
3.32551 setmiterlimit
+25 W
+2 setlinecap
+N 0 4320 M 0 -4320 D S
+/PSL_A0_y 0 def
+/PSL_A1_y 0 def
+/PSL_LH 0 def /PSL_L_y PSL_A0_y PSL_A1_y mx def
+6720 0 T
+N 0 4320 M 0 -4320 D S
+/PSL_A0_y 0 def
+/PSL_A1_y 0 def
+/PSL_LH 0 def /PSL_L_y PSL_A0_y PSL_A1_y mx def
+-6720 0 T
+N 0 0 M 6720 0 D S
+/PSL_A0_y 0 def
+/PSL_A1_y 0 def
+/PSL_LH 0 def /PSL_L_y PSL_A0_y PSL_A1_y mx def
+0 4320 T
+N 0 0 M 6720 0 D S
+/PSL_A0_y 0 def
+/PSL_A1_y 0 def
+/PSL_LH 0 def /PSL_L_y PSL_A0_y PSL_A1_y mx def
+0 -4320 T
+0 setlinecap
{1 0.98 0.98 C} FS
4320 6720 3360 2160 Sr
17 W
@@ -733,8 +753,8 @@ O0
0 0 TM
% PostScript produced by:
-%%GMT: psxy -R0/5.6/0/3.6 -Jx1i -O -K -N -S @GMTAPI at -000002
-%%PROJ: xy 0.00000000 5.60000000 0.00000000 3.60000000 0.000 5.600 0.000 3.600 +xy +a=6378137.000 +b=6356752.314245 +ellps=WGS84
+%@GMT: psxy -R0/5.6/0/3.6 -Jx1i -O -K -N -S @GMTAPI at -000002
+%@PROJ: xy 0.00000000 5.60000000 0.00000000 3.60000000 0.000 5.600 0.000 3.600 +xy
%%BeginObject PSL_Layer_2
0 setlinecap
0 setlinejoin
@@ -768,17 +788,17 @@ O0
0 0 TM
% PostScript produced by:
-%%GMT: pstext -R0/5.6/0/3.6 -Jx1i -O -K -N -F+f+j @GMTAPI at -000001
-%%PROJ: xy 0.00000000 5.60000000 0.00000000 3.60000000 0.000 5.600 0.000 3.600 +xy +a=6378137.000 +b=6356752.314245 +ellps=WGS84
+%@GMT: pstext -R0/5.6/0/3.6 -Jx1i -O -K -N -F+f+j @GMTAPI at -000001
+%@PROJ: xy 0.00000000 5.60000000 0.00000000 3.60000000 0.000 5.600 0.000 3.600 +xy
%%BeginObject PSL_Layer_3
0 setlinecap
0 setlinejoin
3.32551 setmiterlimit
-3360 3885 M PSL_font_encode 4 get 0 eq {ISOLatin1+_Encoding /Times-Roman /Times-Roman PSL_reencode PSL_font_encode 4 1 put} if
-400 F4
+PSL_font_encode 4 get 0 eq {ISOLatin1+_Encoding /Times-Roman /Times-Roman PSL_reencode PSL_font_encode 4 1 put} if
+3360 3885 M 400 F4
(Eight Largest Cities in North America) bc Z
-1142 3470 M PSL_font_encode 0 get 0 eq {ISOLatin1+_Encoding /Helvetica /Helvetica PSL_reencode PSL_font_encode 0 1 put} if
-200 F0
+PSL_font_encode 0 get 0 eq {ISOLatin1+_Encoding /Helvetica /Helvetica PSL_reencode PSL_font_encode 0 1 put} if
+1142 3470 M 200 F0
(City Name) bc Z
2419 3470 M (Country) bc Z
3629 3470 M (Population) bc Z
@@ -842,8 +862,8 @@ O0
0 0 TM
% PostScript produced by:
-%%GMT: pstext -R0/5.6/0/3.6 -Jx1i -O -K -N -M -F+f+a+j @GMTAPI at -000003
-%%PROJ: xy 0.00000000 5.60000000 0.00000000 3.60000000 0.000 5.600 0.000 3.600 +xy +a=6378137.000 +b=6356752.314245 +ellps=WGS84
+%@GMT: pstext -R0/5.6/0/3.6 -Jx1i -O -K -N -M -F+f+a+j @GMTAPI at -000003
+%@PROJ: xy 0.00000000 5.60000000 0.00000000 3.60000000 0.000 5.600 0.000 3.600 +xy
%%BeginObject PSL_Layer_4
0 setlinecap
0 setlinejoin
@@ -1144,29 +1164,6 @@ PSL_x0 PSL_y0 T
0 0 M
1 PSL_textjustifier U
%%EndObject
-25 W
-2 setlinecap
-N 0 4320 M 0 -4320 D S
-/PSL_A0_y 0 def
-/PSL_A1_y 0 def
-/PSL_LH 0 def /PSL_L_y PSL_A0_y PSL_A1_y mx def
-6720 0 T
-N 0 4320 M 0 -4320 D S
-/PSL_A0_y 0 def
-/PSL_A1_y 0 def
-/PSL_LH 0 def /PSL_L_y PSL_A0_y PSL_A1_y mx def
--6720 0 T
-N 0 0 M 6720 0 D S
-/PSL_A0_y 0 def
-/PSL_A1_y 0 def
-/PSL_LH 0 def /PSL_L_y PSL_A0_y PSL_A1_y mx def
-0 4320 T
-N 0 0 M 6720 0 D S
-/PSL_A0_y 0 def
-/PSL_A1_y 0 def
-/PSL_LH 0 def /PSL_L_y PSL_A0_y PSL_A1_y mx def
-0 -4320 T
-0 setlinecap
%%EndObject
%%PageTrailer
U
diff --git a/src/gmt.c b/src/gmt.c
index ae88c6c..808df6c 100644
--- a/src/gmt.c
+++ b/src/gmt.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: gmt.c 17449 2017-01-16 21:27:04Z pwessel $
+ * $Id: gmt.c 17644 2017-03-12 02:09:29Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -30,6 +30,12 @@
#include "gmt_dev.h"
#if !(defined(WIN32) || defined(NO_SIGHANDLER))
+#if __APPLE__
+ /* Apple Xcode expects _Nullable to be defined but it is not if gcc */
+#ifndef _Nullable
+# define _Nullable
+# endif
+# endif
# include <signal.h>
# include "common_sighandler.h"
#endif
diff --git a/src/gmt_agc_io.c b/src/gmt_agc_io.c
index b0e01e2..4c470ee 100644
--- a/src/gmt_agc_io.c
+++ b/src/gmt_agc_io.c
@@ -1,4 +1,4 @@
-/* $Id: gmt_agc_io.c 17449 2017-01-16 21:27:04Z pwessel $
+/* $Id: gmt_agc_io.c 17647 2017-03-12 04:14:13Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -253,13 +253,13 @@ int gmt_agc_read_grd (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *header, floa
int first_col, last_col, j, col; /* First and last column to deal with */
int first_row, last_row, j_gmt, colend; /* First and last row to deal with */
unsigned int width_in; /* Number of items in one row of the subregion */
- unsigned int width_out; /* Width of row as return (may include padding) */
+ /* width_out is width of row as return (may include padding) */
unsigned int height_in; /* Number of columns in subregion */
unsigned int i; /* Misc. counters */
unsigned int *k = NULL; /* Array with indices */
unsigned int block, n_blocks, n_blocks_x, n_blocks_y; /* Misc. counters */
unsigned int datablockcol, datablockrow, rowstart, rowend, colstart, row;
- uint64_t ij, imag_offset;
+ uint64_t ij, imag_offset, width_out;
float z[ZBLOCKWIDTH][ZBLOCKHEIGHT];
FILE *fp = NULL; /* File pointer to data or pipe */
@@ -307,7 +307,7 @@ int gmt_agc_read_grd (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *header, floa
colend = MIN (colstart + ZBLOCKWIDTH, header->n_columns);
for (j = 0, col = colstart; col < colend; j++, col++) {
if (col < first_col || col > last_col) continue;
- ij = imag_offset + (((j_gmt - first_row) + pad[YHI]) * width_out + col - first_col) + pad[XLO];
+ ij = imag_offset + ((uint64_t)(((j_gmt - first_row) + pad[YHI])) * width_out + col - first_col) + pad[XLO];
grid[ij] = (z[j][i] == 0.0) ? GMT->session.f_NaN : z[j][i]; /* AGC uses exact zero as NaN flag */
if (gmt_M_is_fnan (grid[ij])) {
header->has_NaNs = GMT_GRID_HAS_NANS;
@@ -345,14 +345,14 @@ int gmt_agc_write_grd (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *header, flo
int first_col, last_col, col, colend = 0; /* First and last column to deal with */
int j_gmt, i, j, first_row, last_row; /* First and last row to deal with */
- unsigned int width_in; /* Number of items in one row of the subregion */
+ /* width_in is number of items in one row of the subregion */
unsigned int width_out; /* Width of row as return (may include padding) */
unsigned int height_out; /* Number of columns in subregion */
unsigned int i2, j2; /* Misc. counters */
unsigned int *k = NULL; /* Array with indices */
unsigned int block, n_blocks, n_blocks_x, n_blocks_y; /* Misc. counters */
unsigned int row, rowstart, rowend, colstart, datablockcol, datablockrow;
- uint64_t kk, ij, imag_offset;
+ uint64_t kk, ij, imag_offset, width_in;
float prez[PREHEADSIZE], postz[POSTHEADSIZE];
float outz[ZBLOCKWIDTH][ZBLOCKHEIGHT];
FILE *fp = NULL; /* File pointer to data or pipe */
@@ -416,7 +416,7 @@ int gmt_agc_write_grd (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *header, flo
colend = MIN (colstart + ZBLOCKWIDTH, header->n_columns);
for (j = 0, col = colstart; col < colend; j++, col++) {
if (col < first_col || col > last_col) continue;
- ij = imag_offset + ((j_gmt - first_row) + pad[YHI]) * width_in + (col - first_col) + pad[XLO];
+ ij = imag_offset + ((uint64_t)((j_gmt - first_row) + pad[YHI])) * width_in + (col - first_col) + pad[XLO];
outz[j][i] = grid[ij];
}
}
diff --git a/src/gmt_api.c b/src/gmt_api.c
index 29d5a38..596d407 100644
--- a/src/gmt_api.c
+++ b/src/gmt_api.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: gmt_api.c 17580 2017-02-23 06:35:24Z pwessel $
+ * $Id: gmt_api.c 17680 2017-03-14 19:09:34Z jluis $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -6626,7 +6626,7 @@ void *GMT_Read_Data (void *V_API, unsigned int family, unsigned int method, unsi
return_null (API, API->error);
}
if ((item = gmtapi_validate_id (API, family, in_ID, GMT_IN, GMTAPI_MODULE_INPUT)) == GMT_NOTSET)
- return_null (API, GMT_NOTSET); /* Some internal error... */
+ return_null (API, API->error); /* Some internal error... */
API->object[item]->selected = true;
}
gmtlib_free_list (API->GMT, filelist, n_files); /* Free the file list */
diff --git a/src/gmt_customio.c b/src/gmt_customio.c
index 4548ecf..96f7dab 100644
--- a/src/gmt_customio.c
+++ b/src/gmt_customio.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: gmt_customio.c 17543 2017-02-09 14:14:29Z jluis $
+ * $Id: gmt_customio.c 17670 2017-03-14 15:58:06Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -1965,7 +1965,7 @@ int gmt_gdal_read_grd (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *header, flo
}
int gmt_gdal_write_grd (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *header, float *grid, double wesn[], unsigned int *pad, unsigned int complex_mode) {
- uint64_t node = 0, ij, imag_offset;
+ uint64_t node = 0, ij, imag_offset, imsize;
int first_col, last_col; /* First and last column to deal with */
int first_row, last_row; /* First and last row to deal with */
unsigned int width_out; /* Width of row as return (may include padding) */
@@ -2015,11 +2015,12 @@ int gmt_gdal_write_grd (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *header, fl
/* Lazy implementation of nodata value update as it doesn't check and apply on a eventual sub-region on output only */
if (!isnan (header->nan_value)) {
- for (ij = 0; ij < (uint64_t)header->mx * header->my; ij++)
+ for (ij = 0; ij < header->size; ij++)
if (isnan (grid[ij]))
grid[ij] = header->nan_value;
}
+ imsize = gmt_M_get_nm (GMT, width_out, height_out);
if (!type[0] || gmt_strlcmp(type, "float32")) {
/* We have to shift the grid pointer in order to use the GDALRasterIO ability to extract a subregion. */
/* See: osgeo-org.1560.n6.nabble.com/gdal-dev-writing-a-subregion-with-GDALRasterIO-td4960500.html */
@@ -2033,7 +2034,7 @@ int gmt_gdal_write_grd (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *header, fl
return (GMT_NOERROR);
}
else if (gmt_strlcmp(type,"u8") || gmt_strlcmp(type,"u08")) {
- zu8 = gmt_M_memory(GMT, NULL, width_out * height_out, unsigned char);
+ zu8 = gmt_M_memory(GMT, NULL, imsize, unsigned char);
for (row = first_row; row < height_out; row++)
for (col = first_col, ij = gmt_M_ijp (header, row, 0)+imag_offset; col < width_out; col++, ij++)
zu8[node++] = (unsigned char)grid[ij];
@@ -2042,7 +2043,7 @@ int gmt_gdal_write_grd (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *header, fl
to_GDALW->type = strdup("uint8");
}
else if (gmt_strlcmp(type,"i16")) {
- zi16 = gmt_M_memory(GMT, NULL, width_out * height_out, short int);
+ zi16 = gmt_M_memory(GMT, NULL, imsize, short int);
for (row = first_row; row < height_out; row++)
for (col = first_col, ij = gmt_M_ijp (header, row, 0)+imag_offset; col < width_out; col++, ij++)
zi16[node++] = (short int)grid[ij];
@@ -2051,7 +2052,7 @@ int gmt_gdal_write_grd (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *header, fl
to_GDALW->type = strdup("int16");
}
else if (gmt_strlcmp(type,"u16")) {
- zu16 = gmt_M_memory(GMT, NULL, width_out * height_out, unsigned short int);
+ zu16 = gmt_M_memory(GMT, NULL, imsize, unsigned short int);
for (row = first_row; row < height_out; row++)
for (col = first_col, ij = gmt_M_ijp (header, row, 0)+imag_offset; col < width_out; col++, ij++)
zu16[node++] = (unsigned short int)grid[ij];
@@ -2060,7 +2061,7 @@ int gmt_gdal_write_grd (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *header, fl
to_GDALW->type = strdup("uint16");
}
else if (gmt_strlcmp(type,"i32")) {
- zi32 = gmt_M_memory(GMT, NULL, width_out * height_out, int);
+ zi32 = gmt_M_memory(GMT, NULL, imsize, int);
for (row = first_row; row < height_out; row++)
for (col = first_col, ij = gmt_M_ijp (header, row, 0)+imag_offset; col < width_out; col++, ij++)
zi32[node++] = (int)grid[ij];
@@ -2069,7 +2070,7 @@ int gmt_gdal_write_grd (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *header, fl
to_GDALW->type = strdup("int32");
}
else if (gmt_strlcmp(type,"u32")) {
- zu32 = gmt_M_memory(GMT, NULL, width_out * height_out, unsigned int);
+ zu32 = gmt_M_memory(GMT, NULL, imsize, unsigned int);
for (row = first_row; row < height_out; row++)
for (col = first_col, ij = gmt_M_ijp (header, row, 0)+imag_offset; col < width_out; col++, ij++)
zu32[node++] = (unsigned int)grid[ij];
diff --git a/src/gmt_init.c b/src/gmt_init.c
index 4ca12aa..26600f0 100644
--- a/src/gmt_init.c
+++ b/src/gmt_init.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: gmt_init.c 17543 2017-02-09 14:14:29Z jluis $
+ * $Id: gmt_init.c 17731 2017-03-20 19:48:52Z jluis $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -6071,7 +6071,7 @@ void gmt_mapscale_syntax (struct GMT_CTRL *GMT, char option, char *string) {
gmt_message (GMT, "\t-%c %s\n", option, string);
gmt_refpoint_syntax (GMT, "L", NULL, GMT_ANCHOR_MAPSCALE, 3);
gmt_message (GMT, "\t Use +c<slat> (with central longitude) or +c<slon>/<slat> to specify scale origin.\n");
- gmt_message (GMT, "\t Set scale length with +w<length> and append a unit from %s [km]. Use -%cf to draw a \"fancy\" scale [Default is plain].\n", GMT_LEN_UNITS2_DISPLAY, option);
+ gmt_message (GMT, "\t Set scale length with +w<length> and append a unit from %s [km].\n", GMT_LEN_UNITS2_DISPLAY);
gmt_message (GMT, "\t Several modifiers are optional:\n");
gmt_message (GMT, "\t Add +f to draw a \"fancy\" scale [Default is plain].\n");
gmt_message (GMT, "\t By default, the scale label equals the distance unit name and is placed on top [+at]. Use the +l<label>\n");
diff --git a/src/gmt_internals.h b/src/gmt_internals.h
index 078f7fd..2be5170 100644
--- a/src/gmt_internals.h
+++ b/src/gmt_internals.h
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: gmt_internals.h 17449 2017-01-16 21:27:04Z pwessel $
+ * $Id: gmt_internals.h 17736 2017-03-20 22:54:42Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -251,7 +251,7 @@ int gmtlib_read_image_info (struct GMT_CTRL *GMT, char *file, struct GMT_IMAGE *
#define gmt_M_axis_is_geo(C,axis) (C->current.io.col_type[GMT_IN][axis] & GMT_IS_GEO)
#define gmt_M_is_perspective(C) (C->current.proj.projection == GMT_ORTHO || C->current.proj.projection == GMT_GENPER)
-#define gmt_M_pole_is_point(C) ((C->current.proj.projection == GMT_OBLIQUE_MERC || C->current.proj.projection == GMT_OBLIQUE_MERC_POLE) || (C->current.proj.projection >= GMT_LAMBERT && C->current.proj.projection <= GMT_VANGRINTEN))
+#define gmt_M_pole_is_point(C) ((C->current.proj.projection == GMT_OBLIQUE_MERC || C->current.proj.projection == GMT_OBLIQUE_MERC_POLE) || (C->current.proj.projection >= GMT_LAMBERT && C->current.proj.projection <= GMT_VANGRINTEN && C->current.proj.projection != GMT_POLAR))
#define gmt_M_is_grdmapproject(C) (!strncmp (C->init.module_name, "grdproject", 10U) || !strncmp (C->init.module_name, "mapproject", 10U))
#endif /* _GMT_INTERNALS_H */
diff --git a/src/gmt_io.c b/src/gmt_io.c
index 686fe5c..4582b0d 100644
--- a/src/gmt_io.c
+++ b/src/gmt_io.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: gmt_io.c 17588 2017-02-23 23:35:14Z pwessel $
+ * $Id: gmt_io.c 17742 2017-03-22 02:45:40Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -2629,7 +2629,7 @@ GMT_LOCAL int gmtio_prep_ogr_output (struct GMT_CTRL *GMT, struct GMT_DATASET *D
}
gmtio_alloc_ogr_seg (GMT, T->segment[seg], T->ogr->n_aspatial); /* Copy over any feature-specific values */
T->segment[seg]->ogr->pol_mode = GMT_IS_PERIMETER;
- gmt_set_seg_minmax (GMT, T->ogr->geometry, T->segment[seg]); /* Make sure min/max are set per polygon */
+ gmt_set_seg_minmax (GMT, T->ogr->geometry, 0, T->segment[seg]); /* Make sure min/max are set per polygon */
}
/* OK, they are all polygons. Determine any polygon holes: if a point is fully inside another polygon (not on the edge) */
@@ -3111,16 +3111,21 @@ GMT_LOCAL void *gmtio_ascii_input (struct GMT_CTRL *GMT, FILE *fp, uint64_t *n,
/* If OGR input the also read next 1-2 records to pick up metadata */
if (GMT->current.io.ogr == GMT_OGR_TRUE) {
int c;
- p = gmt_fgets (GMT, line, GMT_BUFSIZ, fp);
- gmtio_ogr_parser (GMT, line); /* Parsed a GMT/OGR record */
- gmtio_build_text_from_ogr (GMT, NULL, GMT->current.io.segment_header); /* Fill in the buffer for -D, -G, Z etc */
- if (strstr (line, "@H")) strcat (GMT->current.io.segment_header, " -Ph"); /* Sometimes a @P or @H record instead */
- /* May also have a second comment record with just @P or @ H so check for this case */
if ((c = fgetc (fp)) == '#') { /* Possibly, this record starts with a comment character # */
line[0] = c; /* Since we ate the # already we place it here manually */
p = gmt_fgets (GMT, &line[1], GMT_BUFSIZ-1, fp); /* Start at position 1 since # placed already and required for gmtio_ogr_parser to work */
- gmtio_ogr_parser (GMT, line); /* Parse a possible GMT/OGR record (just returns if no OGR data there) */
- if (strstr (line, "@H")) strcat (GMT->current.io.segment_header, " -Ph"); /* Add the hole designation to the polygon option */
+ gmtio_ogr_parser (GMT, line); /* Parsed a GMT/OGR record */
+ gmtio_build_text_from_ogr (GMT, NULL, GMT->current.io.segment_header); /* Fill in the buffer for -D, -G, Z etc */
+ if (strstr (line, "@H")) strcat (GMT->current.io.segment_header, " -Ph"); /* Sometimes a @P or @H record instead */
+ /* May also have a second comment record with just @P or @ H so check for this case */
+ if ((c = fgetc (fp)) == '#') { /* Possibly, this record starts with a comment character # */
+ line[0] = c; /* Since we ate the # already we place it here manually */
+ p = gmt_fgets (GMT, &line[1], GMT_BUFSIZ-1, fp); /* Start at position 1 since # placed already and required for gmtio_ogr_parser to work */
+ gmtio_ogr_parser (GMT, line); /* Parse a possible GMT/OGR record (just returns if no OGR data there) */
+ if (strstr (line, "@H")) strcat (GMT->current.io.segment_header, " -Ph"); /* Add the hole designation to the polygon option */
+ }
+ else /* Not a comment record; put that character back on the stream and move on */
+ ungetc (c, fp);
}
else /* Not a comment record; put that character back on the stream and move on */
ungetc (c, fp);
@@ -4577,6 +4582,7 @@ void * gmtio_ascii_textinput (struct GMT_CTRL *GMT, FILE *fp, uint64_t *n, int *
*status = 0;
return (NULL);
}
+ /* Here we are done with any header records implied by -h */
if (!p) { /* Ran out of records */
GMT->current.io.status = GMT_IO_EOF;
*n = 0ULL;
@@ -6186,15 +6192,17 @@ struct GMT_TEXTTABLE * gmtlib_read_texttable (struct GMT_CTRL *GMT, void *source
}
/*! . */
-void gmt_set_seg_minmax (struct GMT_CTRL *GMT, unsigned int geometry, struct GMT_DATASEGMENT *S) {
- /* Determine the min/max values for each column in the segment */
+void gmt_set_seg_minmax (struct GMT_CTRL *GMT, unsigned int geometry, unsigned int n_cols, struct GMT_DATASEGMENT *S) {
+ /* Determine the min/max values for each column in the segment.
+ * If n_cols > 0 then we only update the first n_cols */
uint64_t row, col;
/* In case the creation of the segment did not allocate min/max do it now */
if (!S->min) S->min = gmt_M_memory (GMT, NULL, S->n_columns, double);
if (!S->max) S->max = gmt_M_memory (GMT, NULL, S->n_columns, double);
if (S->n_rows == 0) return; /* Nothing more we can do */
- for (col = 0; col < S->n_columns; col++) {
+ if (n_cols == 0) n_cols = S->n_columns; /* Set number of columns to work on */
+ for (col = 0; col < n_cols; col++) {
if (GMT->current.io.col_type[GMT_IN][col] == GMT_IS_LON) /* Requires separate quandrant assessment */
gmtlib_get_lon_minmax (GMT, S->data[col], S->n_rows, &(S->min[col]), &(S->max[col]));
else { /* Simple Cartesian-like arrangement */
@@ -6226,7 +6234,7 @@ void gmt_set_tbl_minmax (struct GMT_CTRL *GMT, unsigned int geometry, struct GMT
T->n_records = 0;
for (seg = 0; seg < T->n_segments; seg++) {
S = T->segment[seg];
- gmt_set_seg_minmax (GMT, geometry, S);
+ gmt_set_seg_minmax (GMT, geometry, 0, S);
if (S->n_rows == 0) continue;
for (col = 0; col < T->n_columns; col++) {
if (S->min[col] < T->min[col]) T->min[col] = S->min[col];
@@ -7118,7 +7126,7 @@ struct GMT_DATATABLE * gmtlib_read_table (struct GMT_CTRL *GMT, void *source, un
}
else { /* OK to populate segment and increment counters */
gmtlib_assign_segment (GMT, T->segment[seg], row, T->segment[seg]->n_columns); /* Allocate and place arrays into segment */
- gmt_set_seg_minmax (GMT, *geometry, T->segment[seg]); /* Set min/max */
+ gmt_set_seg_minmax (GMT, *geometry, 0, T->segment[seg]); /* Set min/max */
T->n_records += row; /* Total number of records so far */
T->segment[seg]->id = seg; /* Internal segment number */
}
diff --git a/src/gmt_memory.c b/src/gmt_memory.c
index 4eced8e..3a64124 100644
--- a/src/gmt_memory.c
+++ b/src/gmt_memory.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: gmt_memory.c 17449 2017-01-16 21:27:04Z pwessel $
+ * $Id: gmt_memory.c 17620 2017-03-05 23:41:05Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -463,7 +463,7 @@ void gmt_prep_tmp_arrays (struct GMT_CTRL *GMT, size_t row, size_t n_cols) {
/* Here we must allocate more rows, this is expected to happen rarely given the large initial allocation */
- while (row >= GMT->hidden.mem_rows) GMT->hidden.mem_rows <<= 1; /* Double up until enough */
+ while (row >= GMT->hidden.mem_rows) GMT->hidden.mem_rows = (size_t)lrint (1.5 * GMT->hidden.mem_rows); /* Increase by 50% */
for (col = 0; col < GMT->hidden.mem_cols; col++) /* Add more memory via realloc */
GMT->hidden.mem_coord[col] = gmt_M_memory (GMT, GMT->hidden.mem_coord[col], GMT->hidden.mem_rows, double);
diff --git a/src/gmt_nc.c b/src/gmt_nc.c
index 2325cc3..31ee580 100644
--- a/src/gmt_nc.c
+++ b/src/gmt_nc.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: gmt_nc.c 17449 2017-01-16 21:27:04Z pwessel $
+ * $Id: gmt_nc.c 17653 2017-03-13 04:21:20Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -123,8 +123,9 @@ static inline int io_nc_varm_float (int ncid, int varid, const size_t *startp,
/* Get number of chunked rows that fit into cache (32MiB) */
GMT_LOCAL int gmtnc_n_chunked_rows_in_cache (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *header, unsigned width, unsigned height, size_t *n_contiguous_chunk_rows, size_t *chunksize) {
- nc_type z_type; /* type of z variable */
- size_t z_size; /* size of z variable */
+ nc_type z_type; /* type of z variable */
+ size_t z_size; /* size of z variable */
+ size_t z_bytes; /* Number of bytes */
unsigned yx_dim[2] = {header->xy_dim[1], header->xy_dim[0]}; /* because xy_dim not row major */
int err, storage_in;
@@ -137,7 +138,8 @@ GMT_LOCAL int gmtnc_n_chunked_rows_in_cache (struct GMT_CTRL *GMT, struct GMT_GR
chunksize[yx_dim[1]] = width; /* all columns */
}
- if (height * width * z_size > NC_CACHE_SIZE) {
+ z_bytes = ((size_t)height) * ((size_t)width) * ((size_t)z_size);
+ if (z_bytes > NC_CACHE_SIZE) {
/* memory needed for subset exceeds the cache size */
unsigned int level;
size_t chunks_per_row = (size_t) ceil ((double)width / chunksize[yx_dim[1]]);
@@ -196,7 +198,7 @@ GMT_LOCAL int gmtnc_io_nc_grid (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *he
if (n_contiguous_chunk_rows) {
/* read/write grid in chunks to keep memory footprint low */
- unsigned remainder;
+ size_t remainder;
#ifdef NC4_DEBUG
unsigned row_num = 0;
GMT_Report (GMT->parent, GMT_MSG_NORMAL, "stride: %u width: %u\n",
@@ -205,11 +207,11 @@ GMT_LOCAL int gmtnc_io_nc_grid (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *he
/* adjust row count, so that it ends on the bottom of a chunk */
count[yx_dim[0]] = chunksize[yx_dim[0]] * n_contiguous_chunk_rows;
- remainder = (unsigned int)(start[yx_dim[0]] % chunksize[yx_dim[0]]);
+ remainder = start[yx_dim[0]] % chunksize[yx_dim[0]];
count[yx_dim[0]] -= remainder;
count[yx_dim[1]] = width;
- while ( start[yx_dim[0]] + count[yx_dim[0]] <= height && status == NC_NOERR) {
+ while ( (start[yx_dim[0]] + count[yx_dim[0]]) <= height && status == NC_NOERR) {
#ifdef NC4_DEBUG
GMT_Report (GMT->parent, GMT_MSG_NORMAL, "chunked row #%u start-y:%" PRIuS " height:%" PRIuS "\n",
++row_num, start[yx_dim[0]], count[yx_dim[0]]);
@@ -221,7 +223,7 @@ GMT_LOCAL int gmtnc_io_nc_grid (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *he
status = io_nc_vara_float (header->ncid, header->z_id, start, count, grid, io_mode);
/* advance grid location and set new origin */
- grid += count[yx_dim[0]] * (stride == 0 ? width : stride);
+ grid += count[yx_dim[0]] * ((size_t)(stride == 0 ? width : stride));
start[yx_dim[0]] += count[yx_dim[0]];
if (remainder) {
/* reset count to full chunk height */
@@ -339,7 +341,7 @@ GMT_LOCAL void gmtnc_set_optimal_chunksize (struct GMT_CTRL *GMT, struct GMT_GRI
/* here, chunk size is either k_netcdf_io_chunked_auto or the chunk size is
* larger than grid size */
- if ( (header->n_rows * header->n_columns) < min_chunk_pixels ) {
+ if ( header->nm < min_chunk_pixels ) {
/* the grid dimension is too small for chunking to make sense. switch to
* classic model */
GMT->current.setting.io_nc4_chunksize[0] = k_netcdf_io_classic;
@@ -531,14 +533,14 @@ GMT_LOCAL int gmtnc_grd_info (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *head
char *pch;
gmt_M_err_trap (nc_inq_attlen (ncid, gm_id, "spatial_ref", &len)); /* Get attrib length */
gmt_M_str_free (header->ProjRefWKT); /* Make sure we didn't have a previously allocated one */
- pch = gmt_M_memory(GMT, NULL, len+1, char); /* and allocate the needed space */
+ pch = gmt_M_memory (GMT, NULL, len+1, char); /* and allocate the needed space */
gmt_M_err_trap (nc_get_att_text (ncid, gm_id, "spatial_ref", pch));
- header->ProjRefWKT = strdup(pch); /* Turn it into a strdup allocation to be compatible with other instances elsewhere */
+ header->ProjRefWKT = strdup (pch); /* Turn it into a strdup allocation to be compatible with other instances elsewhere */
gmt_M_free (GMT, pch);
}
/* Create enough memory to store the x- and y-coordinate values */
- xy = gmt_M_memory (GMT, NULL, MAX(header->n_columns,header->n_rows), double);
+ xy = gmt_M_memory (GMT, NULL, MAX (header->n_columns, header->n_rows), double);
/* Get information about x variable */
gmtnc_get_units (GMT, ncid, ids[header->xy_dim[0]], header->x_units);
@@ -793,34 +795,36 @@ L100:
/* Shift columns in a grid to the right (n_shift < 0) or to the left (n_shift < 0) */
GMT_LOCAL void gmtnc_right_shift_grid (void *gridp, const unsigned n_cols, const unsigned n_rows, int n_shift, size_t cell_size) {
char *tmp, *grid = (char*)gridp;
- unsigned row, n_shift_abs = abs(n_shift);
+ size_t row, n_shift_abs = abs (n_shift), nm;
assert (n_shift_abs != 0 && n_cols > n_shift_abs && n_cols > 0 && n_rows > 0);
tmp = malloc (n_shift_abs * cell_size);
if (n_shift > 0) { /* right shift */
- for (row = 0; row < n_rows; ++row) {
+ for (row = 0; row < (size_t)n_rows; ++row) {
+ nm = row * ((size_t)n_cols);
/* copy last n_shift_abs cols into tmp buffer */
- memcpy (tmp, grid + (row * n_cols + n_cols - n_shift_abs) * cell_size, n_shift_abs * cell_size);
+ memcpy (tmp, grid + (nm + n_cols - n_shift_abs) * cell_size, n_shift_abs * cell_size);
/* right shift row */
- memmove (grid + (row * n_cols + n_shift_abs) * cell_size,
- grid + row * n_cols * cell_size,
+ memmove (grid + (nm + n_shift_abs) * cell_size,
+ grid + nm * cell_size,
(n_cols - n_shift_abs) * cell_size);
/* prepend tmp buffer */
- memcpy (grid + row * n_cols * cell_size, tmp, n_shift_abs * cell_size);
+ memcpy (grid + nm * cell_size, tmp, n_shift_abs * cell_size);
}
}
else { /* n_shift_abs < 0 */
for (row = 0; row < n_rows; ++row) {
+ nm = row * ((size_t)n_cols);
/* copy first n_shift_abs cols into tmp buffer */
- memcpy (tmp, grid + row * n_cols * cell_size, n_shift_abs * cell_size);
+ memcpy (tmp, grid + nm * cell_size, n_shift_abs * cell_size);
/* left shift row */
- memmove (grid + row * n_cols * cell_size,
- grid + (row * n_cols + n_shift_abs) * cell_size,
+ memmove (grid + nm * cell_size,
+ grid + (nm + n_shift_abs) * cell_size,
(n_cols - n_shift_abs) * cell_size);
/* append tmp buffer */
- memcpy (grid + (row * n_cols + n_cols - n_shift_abs) * cell_size, tmp, n_shift_abs * cell_size);
+ memcpy (grid + (nm + n_cols - n_shift_abs) * cell_size, tmp, n_shift_abs * cell_size);
}
}
gmt_M_str_free (tmp);
@@ -831,62 +835,67 @@ GMT_LOCAL void gmtnc_right_shift_grid (void *gridp, const unsigned n_cols, const
GMT_LOCAL void gmtnc_padding_copy (void *gridp, const unsigned n_cols, const unsigned n_rows, const unsigned *n_pad, size_t cell_size, bool periodic_cols) {
/* n_cols and n_rows are dimensions of the padded grid */
char *grid = (char*)gridp;
- unsigned row, cell;
+ size_t row, cell, nm, nm2;
assert (n_cols > n_pad[XLO] + n_pad[XHI] && n_rows > n_pad[YLO] + n_pad[YHI] &&
n_pad[XLO] + n_pad[XHI] + n_pad[YLO] + n_pad[YHI] > 0 && cell_size > 0);
if (periodic_cols) {
/* A periodic grid wraps around */
- for (row = n_pad[YHI]; row + n_pad[YLO] < n_rows; ++row) {
+ for (row = (size_t)n_pad[YHI]; (row + n_pad[YLO]) < (size_t)n_rows; ++row) {
+ nm = row * ((size_t)n_cols);
/* Iterate over rows that contain data */
- for (cell = 0; cell < n_pad[XLO]; ++cell) {
+ for (cell = 0; cell < (size_t)n_pad[XLO]; ++cell) {
/* Copy end of this row into first n_pad[XLO] columns:
* X X 0 1 2 3 4 5 X X -> 4 5 0 1 2 3 4 5 X X */
- memcpy (grid + (row * n_cols + cell) * cell_size,
- grid + (row * n_cols + n_cols + cell - n_pad[XLO] - n_pad[XHI]) * cell_size,
+ memcpy (grid + (nm + cell) * cell_size,
+ grid + (nm + (size_t)n_cols + cell - (size_t)n_pad[XLO] - (size_t)n_pad[XHI]) * cell_size,
cell_size);
}
- for (cell = 0; cell < n_pad[XHI]; ++cell) {
+ for (cell = 0; cell < (size_t)n_pad[XHI]; ++cell) {
/* Copy start of this row into last n_pad[XHI] columns:
* 4 5 0 1 2 3 4 5 X X -> 4 5 0 1 2 3 4 5 0 1 */
- memcpy (grid + (row * n_cols + n_cols - cell - 1) * cell_size,
- grid + (row * n_cols + n_pad[XLO] + n_pad[XHI] - cell - 1) * cell_size,
+ memcpy (grid + (nm + (size_t)n_cols - cell - 1) * cell_size,
+ grid + (nm + (size_t)n_pad[XLO] + (size_t)n_pad[XHI] - cell - 1) * cell_size,
cell_size);
}
}
}
else { /* !periodic_cols */
- for (row = n_pad[YHI]; row + n_pad[YLO] < n_rows; ++row) {
+ for (row = (size_t)n_pad[YHI]; (row + n_pad[YLO]) < (size_t)n_rows; ++row) {
+ nm = row * ((size_t)n_cols);
/* Iterate over rows that contain data */
- for (cell = 0; cell < n_pad[XLO]; ++cell) {
+ for (cell = 0; cell < (size_t)n_pad[XLO]; ++cell) {
/* Duplicate first n_pad[XLO] columns in this row:
* 4 5 0 1 2 3 4 5 X X -> 0 0 0 1 2 3 4 5 X X */
- memcpy (grid + (row * n_cols + cell) * cell_size,
- grid + (row * n_cols + n_pad[XLO]) * cell_size,
+ memcpy (grid + (nm + cell) * cell_size,
+ grid + (nm + (size_t)n_pad[XLO]) * cell_size,
cell_size);
}
- for (cell = 0; cell < n_pad[XHI]; ++cell) {
+ for (cell = 0; cell < (size_t)n_pad[XHI]; ++cell) {
/* Duplicate last n_pad[XHI] columns in this row:
* 0 0 0 1 2 3 4 5 X X -> 0 0 0 1 2 3 4 5 5 5 */
- memcpy (grid + (row * n_cols + n_cols - cell - 1) * cell_size,
- grid + (row * n_cols + n_cols - n_pad[XHI] - 1) * cell_size,
+ memcpy (grid + (nm + (size_t)n_cols - cell - 1) * cell_size,
+ grid + (nm + (size_t)n_cols - (size_t)n_pad[XHI] - 1) * cell_size,
cell_size);
}
}
}
- for (cell = 0; cell < n_pad[YHI]; ++cell) {
+ for (cell = 0; cell < (size_t)n_pad[YHI]; ++cell) {
+ nm = cell * ((size_t)n_cols);
/* Duplicate n_pad[YHI] rows in the beginning */
- memcpy(grid + cell * n_cols * cell_size,
- grid + n_pad[YHI] * n_cols * cell_size,
- n_cols * cell_size);
+ memcpy(grid + nm * cell_size,
+ grid + ((size_t)n_pad[YHI]) * ((size_t)n_cols) * cell_size,
+ ((size_t)n_cols) * cell_size);
}
- for (cell = 0; cell < n_pad[YLO]; ++cell) {
+ nm2 = ((size_t)(n_rows - n_pad[YLO] - 1)) * ((size_t)n_cols);
+ for (cell = 0; cell < (size_t)n_pad[YLO]; ++cell) {
+ nm = ((size_t)(n_rows - cell - 1)) * ((size_t)n_cols);
/* Duplicate last n_pad[YLO] rows */
- memcpy(grid + (n_rows - cell - 1) * n_cols * cell_size,
- grid + (n_rows - n_pad[YLO] - 1) * n_cols * cell_size,
- n_cols * cell_size);
+ memcpy(grid + nm * cell_size,
+ grid + nm2 * cell_size,
+ ((size_t)n_cols) * cell_size);
}
}
@@ -894,22 +903,23 @@ GMT_LOCAL void gmtnc_padding_copy (void *gridp, const unsigned n_cols, const uns
GMT_LOCAL void gmtnc_padding_zero (void *gridp, const unsigned n_cols, const unsigned n_rows, const unsigned *n_pad, size_t cell_size) {
/* n_cols and n_rows are dimensions of the padded grid */
char *grid = (char*)gridp;
- unsigned row;
+ size_t row, nm;
assert (n_cols > n_pad[XLO] + n_pad[XHI] && n_rows > n_pad[YLO] + n_pad[YHI] &&
n_pad[XLO] + n_pad[XHI] + n_pad[YLO] + n_pad[YHI] > 0 && cell_size > 0);
/* Iterate over rows that contain data */
- for (row = n_pad[YHI]; row + n_pad[YLO] < n_rows; ++row) {
+ for (row = (size_t)n_pad[YHI]; (row + n_pad[YLO]) < (size_t)n_rows; ++row) {
+ nm = row * ((size_t)n_cols);
/* Zero n cells at beginning of row */
- memset (grid + row * n_cols * cell_size, 0, n_pad[XLO] * cell_size);
+ memset (grid + nm * cell_size, 0, ((size_t)n_pad[XLO]) * cell_size);
/* Zero n cells at end of row */
- memset (grid + (row * n_cols + n_cols - n_pad[XHI]) * cell_size, 0, n_pad[XHI] * cell_size);
+ memset (grid + (nm + (size_t)n_cols - (size_t)n_pad[XHI]) * cell_size, 0, ((size_t)n_pad[XHI]) * cell_size);
}
/* Zero n_pad[YHI] rows in the beginning */
- memset(grid, 0, n_pad[YHI] * n_cols * cell_size);
+ memset (grid, 0, ((size_t)n_pad[YHI]) * ((size_t)n_cols) * cell_size);
/* Zero last n_pad[YLO] rows */
- memset(grid + (n_rows-n_pad[YLO]) * n_cols * cell_size, 0, n_pad[YLO] * n_cols * cell_size);
+ memset(grid + ((size_t)(n_rows-n_pad[YLO])) * ((size_t)n_cols) * cell_size, 0, ((size_t)n_pad[YLO]) * ((size_t)n_cols) * cell_size);
}
/* Fill mode for grid padding */
@@ -928,10 +938,10 @@ GMT_LOCAL void gmtnc_pad_grid (void *gridp, const unsigned n_cols, const unsigne
*
* Note: when grid is complex, we pass 2x n_rows */
char *grid = (char*)gridp;
- unsigned new_row;
- unsigned old_row = n_rows-1;
- unsigned n_new_cols = n_cols + n_pad[XLO] + n_pad[XHI];
- unsigned n_new_rows = n_rows + n_pad[YLO] + n_pad[YHI];
+ size_t new_row;
+ size_t old_row = n_rows-1;
+ size_t n_new_cols = n_cols + n_pad[XLO] + n_pad[XHI];
+ size_t n_new_rows = n_rows + n_pad[YLO] + n_pad[YHI];
#ifdef NC4_DEBUG
fprintf (stderr, "pad grid w:%u e:%u s:%u n:%u\n",
@@ -947,12 +957,12 @@ GMT_LOCAL void gmtnc_pad_grid (void *gridp, const unsigned n_cols, const unsigne
/* When padding W, E, and N (not necessary when padding S only). */
for (new_row = n_new_rows - n_pad[YLO] - 1; new_row + 1 > n_pad[YHI]; --new_row, --old_row) {
/* Copy original row to new row, bottom upwards */
- void *from = grid + old_row * n_cols * cell_size;
- void *to = grid + (new_row * n_new_cols + n_pad[XLO]) * cell_size;
+ void *from = grid + old_row * ((size_t)n_cols) * cell_size;
+ void *to = grid + (new_row * n_new_cols + ((size_t)n_pad[XLO])) * cell_size;
if (n_pad[YHI] == 0) /* rows overlap! */
- memmove (to, from, n_cols * cell_size);
+ memmove (to, from, ((size_t)n_cols) * cell_size);
else /* no overlap, memcpy is safe */
- memcpy (to, from, n_cols * cell_size);
+ memcpy (to, from, ((size_t)n_cols) * cell_size);
}
}
@@ -978,8 +988,8 @@ GMT_LOCAL void gmtnc_unpad_grid (void *gridp, const unsigned n_cols, const unsig
*
* Note: when grid is complex, we pass 2x n_rows */
char *grid = (char*)gridp;
- unsigned n_old_cols = n_cols + n_pad[XLO] + n_pad[XHI];
- unsigned row;
+ size_t n_old_cols = n_cols + n_pad[XLO] + n_pad[XHI];
+ size_t row;
#ifdef NC4_DEBUG
fprintf (stderr, "unpad grid w:%u e:%u s:%u n:%u\n",
@@ -991,15 +1001,15 @@ GMT_LOCAL void gmtnc_unpad_grid (void *gridp, const unsigned n_cols, const unsig
assert (n_cols > 0 && n_rows > 0 && cell_size > 0);
/* Reshape matrix */
- for (row = 0; row < n_rows; ++row) {
- unsigned old_row = row + n_pad[YHI];
- void *from = grid + (old_row * n_old_cols + n_pad[XLO]) * cell_size;
- void *to = grid + row * n_cols * cell_size;
+ for (row = 0; row < (size_t)n_rows; ++row) {
+ size_t old_row = row + n_pad[YHI];
+ void *from = grid + (old_row * n_old_cols + ((size_t)n_pad[XLO])) * cell_size;
+ void *to = grid + row * ((size_t)n_cols) * cell_size;
/* Copy original row to new row */
if (n_pad[YHI] == 0) /* rows overlap! */
- memmove (to, from, n_cols * cell_size);
+ memmove (to, from, ((size_t)n_cols) * cell_size);
else /* no overlap, memcpy is safe */
- memcpy (to, from, n_cols * cell_size);
+ memcpy (to, from, ((size_t)n_cols) * cell_size);
}
}
@@ -1008,11 +1018,12 @@ GMT_LOCAL void gmtnc_unpad_grid (void *gridp, const unsigned n_cols, const unsig
GMT_LOCAL void gmtnc_grid_fix_repeat_col (struct GMT_CTRL *GMT, void *gridp, const unsigned n_cols, const unsigned n_rows, size_t cell_size) {
/* Note: when grid is complex, pass 2x n_rows */
char *grid = (char*)gridp;
- unsigned row, n_conflicts = 0;
+ unsigned n_conflicts = 0;
+ size_t row;
- for (row = 0; row < n_rows; ++row) {
- char *first = grid + row * n_cols * cell_size; /* first element in row */
- char *last = grid + (row * n_cols + n_cols - 1) * cell_size; /* last element in row */
+ for (row = 0; row < (size_t)n_rows; ++row) {
+ char *first = grid + row * ((size_t)n_cols) * cell_size; /* first element in row */
+ char *last = grid + (row * (size_t)(n_cols) + ((size_t)n_cols) - 1) * cell_size; /* last element in row */
if ( memcmp(last, first, cell_size) ) {
/* elements differ: replace value of last element in row with value of first */
memcpy (last, first, cell_size);
@@ -1309,7 +1320,7 @@ int gmt_nc_read_grd (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *header, float
adj_nan_value = !isnan (header->nan_value);
header->has_NaNs = GMT_GRID_NO_NANS; /* We are about to check for NaNs and if none are found we retain 1, else 2 */
for (row = 0; row < height; ++row) {
- float *p_data = pgrid + row * (header->stride ? header->stride : width);
+ float *p_data = pgrid + ((size_t)row) * ((size_t)(header->stride ? header->stride : width));
unsigned col;
for (col = 0; col < width; col ++) {
if (adj_nan_value && p_data[col] == header->nan_value) {
@@ -1388,10 +1399,11 @@ int gmt_nc_write_grd (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *header, floa
int status = NC_NOERR;
bool adj_nan_value; /* if we need to change the fill value */
bool do_round = true; /* if we need to round to integral */
- unsigned n, width, height, *actual_col = NULL;
+ unsigned width, height, *actual_col = NULL;
unsigned dim[2], origin[2]; /* dimension and origin {y,x} of subset to write to netcdf */
int first_col, last_col, first_row, last_row;
uint64_t imag_offset;
+ size_t n;
double limit[2]; /* minmax of z variable */
float *pgrid = NULL;
@@ -1454,7 +1466,7 @@ int gmt_nc_write_grd (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *header, floa
header->z_max = -DBL_MAX;
adj_nan_value = !isnan (header->nan_value);
n = 0;
- while (n < width * height) {
+ while (n < (((size_t)width) * ((size_t)height))) {
if (adj_nan_value && isnan (pgrid[n]))
pgrid[n] = header->nan_value;
else if (!isnan (pgrid[n])) {
diff --git a/src/gmt_plot.c b/src/gmt_plot.c
index a933c70..c1f1a70 100644
--- a/src/gmt_plot.c
+++ b/src/gmt_plot.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: gmt_plot.c 17592 2017-02-24 00:40:55Z pwessel $
+ * $Id: gmt_plot.c 17670 2017-03-14 15:58:06Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -558,9 +558,13 @@ GMT_LOCAL void plot_x_grid (struct GMT_CTRL *GMT, struct PSL_CTRL *PSL, double s
double x1, y1, x2, y2;
for (i = 0; i < nx; i++) {
- gmt_geo_to_xy (GMT, x[i], s, &x1, &y1);
- gmt_geo_to_xy (GMT, x[i], n, &x2, &y2);
- PSL_plotsegment (PSL, x1, y1, x2, y2);
+ if (gmt_M_is_geographic (GMT, GMT_IN))
+ plot_map_lonline (GMT, PSL, x[i], s, n);
+ else {
+ gmt_geo_to_xy (GMT, x[i], s, &x1, &y1);
+ gmt_geo_to_xy (GMT, x[i], n, &x2, &y2);
+ PSL_plotsegment (PSL, x1, y1, x2, y2);
+ }
}
}
@@ -617,9 +621,13 @@ GMT_LOCAL void plot_y_grid (struct GMT_CTRL *GMT, struct PSL_CTRL *PSL, double w
double x1, y1, x2, y2;
for (i = 0; i < ny; i++) {
- gmt_geo_to_xy (GMT, w, y[i], &x1, &y1);
- gmt_geo_to_xy (GMT, e, y[i], &x2, &y2);
- PSL_plotsegment (PSL, x1, y1, x2, y2);
+ if (gmt_M_is_geographic (GMT, GMT_IN))
+ plot_map_latline (GMT, PSL, y[i], w, e);
+ else {
+ gmt_geo_to_xy (GMT, w, y[i], &x1, &y1);
+ gmt_geo_to_xy (GMT, e, y[i], &x2, &y2);
+ PSL_plotsegment (PSL, x1, y1, x2, y2);
+ }
}
}
@@ -5892,7 +5900,7 @@ void gmt_geo_wedge (struct GMT_CTRL *GMT, double xlon, double xlat, double radiu
return;
}
S->n_rows = n_new;
- gmt_set_seg_minmax (GMT, (mode == 3) ? GMT_IS_POLY : GMT_IS_LINE, S); /* Update min/max */
+ gmt_set_seg_minmax (GMT, (mode == 3) ? GMT_IS_POLY : GMT_IS_LINE, 2, S); /* Update min/max of x/y only */
gmt_geo_polygons (GMT, S);
@@ -6295,6 +6303,21 @@ void gmt_plane_perspective (struct GMT_CTRL *GMT, int plane, double level) {
GMT->current.proj.z_project.plane = plane;
}
+#if 0
+void gmt_vector_v4 (struct PSL_CTRL *PSL, double x0, double y0, double x1, double y1, double tailwidth, double headlength, double headwidth, double shape, struct GMT_FILL *fill, int outline)
+{
+ /* Plots the GMT4 vector symbol */
+
+ if (fill && fill->use_pattern) { /* Setup pattern first */
+ int rgb[3] = {-3, -3, -3};
+ rgb[1] = (int)ps_pattern (fill->pattern_no, fill->pattern, fill->inverse, fill->dpi, outline, fill->f_rgb, fill->b_rgb);
+ psl_vector_v4 (PSL, x0, y0, param, rgb, outline);
+ }
+ else /* Just draw as we please */
+ psl_vector_v4 (PSL, x0, y0, param, fill->rgb, outline);
+}
+#endif
+
/* All functions involved in reading, writing, duplicating GMT_POSTSCRIPT structs and their PostScript content */
/*! . */
diff --git a/src/gmt_plot.h b/src/gmt_plot.h
index 357a3c5..3e70b1e 100644
--- a/src/gmt_plot.h
+++ b/src/gmt_plot.h
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: gmt_plot.h 17449 2017-01-16 21:27:04Z pwessel $
+ * $Id: gmt_plot.h 17670 2017-03-14 15:58:06Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -55,6 +55,7 @@
#define GMT_SYMBOL_TRIANGLE ((int)'t')
#define GMT_SYMBOL_CUBE ((int)'u')
#define GMT_SYMBOL_VECTOR ((int)'v')
+#define GMT_SYMBOL_VECTOR_V4 999
#define GMT_SYMBOL_WEDGE ((int)'w')
#define GMT_SYMBOL_CROSS ((int)'x')
#define GMT_SYMBOL_YDASH ((int)'y')
diff --git a/src/gmt_prototypes.h b/src/gmt_prototypes.h
index 3a90aed..c669dfb 100644
--- a/src/gmt_prototypes.h
+++ b/src/gmt_prototypes.h
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: gmt_prototypes.h 17449 2017-01-16 21:27:04Z pwessel $
+ * $Id: gmt_prototypes.h 17733 2017-03-20 20:03:03Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -233,7 +233,7 @@ EXTERN_MSC struct GMT_VECTOR * gmt_create_vector (struct GMT_CTRL *GMT, uint64_t
EXTERN_MSC void gmt_free_vector (struct GMT_CTRL *GMT, struct GMT_VECTOR **V, bool free_vector);
EXTERN_MSC int gmt_load_aspatial_string (struct GMT_CTRL *GMT, struct GMT_OGR *G, uint64_t col, char out[GMT_BUFSIZ]);
EXTERN_MSC double gmt_get_aspatial_value (struct GMT_CTRL *GMT, int col, struct GMT_DATASEGMENT *S);
-EXTERN_MSC void gmt_set_seg_minmax (struct GMT_CTRL *GMT, unsigned int geometry, struct GMT_DATASEGMENT *S);
+EXTERN_MSC void gmt_set_seg_minmax (struct GMT_CTRL *GMT, unsigned int geometry, unsigned int n_cols, struct GMT_DATASEGMENT *S);
EXTERN_MSC void gmt_set_seg_polar (struct GMT_CTRL *GMT, struct GMT_DATASEGMENT *S);
EXTERN_MSC void gmt_skip_xy_duplicates (struct GMT_CTRL *GMT, bool mode);
EXTERN_MSC void gmt_duplicate_ogr_seg (struct GMT_CTRL *GMT, struct GMT_DATASEGMENT *S_to, struct GMT_DATASEGMENT *S_from);
@@ -264,7 +264,7 @@ EXTERN_MSC void gmt_init_fill (struct GMT_CTRL *GMT, struct GMT_FILL *fill, doub
EXTERN_MSC int gmt_intpol (struct GMT_CTRL *GMT, double *x, double *y, uint64_t n, uint64_t m, double *u, double *v, int mode);
EXTERN_MSC unsigned int gmt_inonout (struct GMT_CTRL *GMT, double x, double y, const struct GMT_DATASEGMENT *S);
EXTERN_MSC void gmt_just_to_lonlat (struct GMT_CTRL *GMT, int justify, bool geo, double *x, double *y);
-EXTERN_MSC struct GMT_REFPOINT * gmt_get_refpoint (struct GMT_CTRL *GMT, char *arg);
+EXTERN_MSC struct GMT_REFPOINT * gmt_get_refpoint (struct GMT_CTRL *GMT, char *arg, char option);
EXTERN_MSC void gmt_set_refpoint (struct GMT_CTRL *GMT, struct GMT_REFPOINT *A);
EXTERN_MSC void gmt_free_refpoint (struct GMT_CTRL *GMT, struct GMT_REFPOINT **Ap);
EXTERN_MSC void gmt_flip_azim_d (struct GMT_CTRL *GMT, double *azim);
diff --git a/src/gmt_support.c b/src/gmt_support.c
index 0e89b0a..214f85d 100644
--- a/src/gmt_support.c
+++ b/src/gmt_support.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: gmt_support.c 17571 2017-02-22 17:37:42Z pwessel $
+ * $Id: gmt_support.c 17733 2017-03-20 20:03:03Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -3309,11 +3309,11 @@ GMT_LOCAL int support_getscale_old (struct GMT_CTRL *GMT, char option, char *tex
}
ms->length = atof (txt_len);
- if (gave_xy) /* Set up ancher in plot units */
+ if (gave_xy) /* Set up anchor in plot units */
snprintf (string, GMT_LEN256, "x%s/%s", txt_a, txt_b);
else /* Set up ancher in geographical coordinates */
snprintf (string, GMT_LEN256, "g%s/%s", txt_a, txt_b);
- if ((ms->refpoint = gmt_get_refpoint (GMT, text)) == NULL) {
+ if ((ms->refpoint = gmt_get_refpoint (GMT, string, option)) == NULL) {
GMT_Report (GMT->parent, GMT_MSG_NORMAL, "Syntax error: Scale reference point was not accepted\n");
gmt_refpoint_syntax (GMT, "L", NULL, GMT_ANCHOR_MAPSCALE, 3);
return (1); /* Failed basic parsing */
@@ -3522,7 +3522,7 @@ GMT_LOCAL int support_getrose_old (struct GMT_CTRL *GMT, char option, char *text
snprintf (string, GMT_LEN256, "x%s/%s", txt_a, txt_b);
else /* Set up ancher in geographical coordinates */
snprintf (string, GMT_LEN256, "g%s/%s", txt_a, txt_b);
- if ((ms->refpoint = gmt_get_refpoint (GMT, text)) == NULL) {
+ if ((ms->refpoint = gmt_get_refpoint (GMT, string, option)) == NULL) {
GMT_Report (GMT->parent, GMT_MSG_NORMAL, "Syntax error: Map rose reference point was not accepted\n");
gmt_refpoint_syntax (GMT, "Td|m", NULL, GMT_ANCHOR_MAPROSE, 3);
return (1); /* Failed basic parsing */
@@ -10600,7 +10600,7 @@ int gmt_getinsert (struct GMT_CTRL *GMT, char option, char *in_text, struct GMT_
unsigned int last;
char *q[2] = {NULL, NULL};
size_t len;
- if ((B->refpoint = gmt_get_refpoint (GMT, text)) == NULL) {
+ if ((B->refpoint = gmt_get_refpoint (GMT, text, option)) == NULL) {
GMT_Report (GMT->parent, GMT_MSG_NORMAL, "Syntax error: Map insert reference point was not accepted\n");
gmt_refpoint_syntax (GMT, "D", NULL, GMT_ANCHOR_INSERT, 1);
return (1); /* Failed basic parsing */
@@ -10732,7 +10732,7 @@ int gmt_getscale (struct GMT_CTRL *GMT, char option, char *text, struct GMT_MAP_
ms->measure = 'k'; /* Default distance unit is km */
ms->alignment = 't'; /* Default label placement is on top */
- if ((ms->refpoint = gmt_get_refpoint (GMT, text)) == NULL) {
+ if ((ms->refpoint = gmt_get_refpoint (GMT, text, option)) == NULL) {
GMT_Report (GMT->parent, GMT_MSG_NORMAL, "Syntax error: Scale reference point was not accepted\n");
gmt_refpoint_syntax (GMT, "L", NULL, GMT_ANCHOR_MAPSCALE, 3);
return (1); /* Failed basic parsing */
@@ -10876,7 +10876,7 @@ int gmt_getrose (struct GMT_CTRL *GMT, char option, char *text, struct GMT_MAP_R
return (-1);
break;
}
- if ((ms->refpoint = gmt_get_refpoint (GMT, &text[1])) == NULL) {
+ if ((ms->refpoint = gmt_get_refpoint (GMT, &text[1], option)) == NULL) {
GMT_Report (GMT->parent, GMT_MSG_NORMAL, "Syntax error: Map rose reference point was not accepted\n");
gmt_refpoint_syntax (GMT, "Td|m", NULL, GMT_ANCHOR_MAPROSE, 3);
return (1); /* Failed basic parsing */
@@ -13450,7 +13450,7 @@ void gmt_free_refpoint (struct GMT_CTRL *GMT, struct GMT_REFPOINT **Ap) {
}
/*! . */
-struct GMT_REFPOINT * gmt_get_refpoint (struct GMT_CTRL *GMT, char *arg) {
+struct GMT_REFPOINT * gmt_get_refpoint (struct GMT_CTRL *GMT, char *arg, char option) {
/* Used to decipher option -D in psscale, pslegend, and psimage:
* -D[g|j|n|x]<refpoint>[/<remainder]
* where g means map coordinates, n means normalized coordinates, and x means plot coordinates.
@@ -13458,6 +13458,7 @@ struct GMT_REFPOINT * gmt_get_refpoint (struct GMT_CTRL *GMT, char *arg) {
* plot box coordinates; the <refpoint> point is the coordinate pair <x0>/<y0>.
* All -D flavors except -Dx require -R -J.
* Remaining arguments are returned as well via the string A->args.
+ * also used to parse refpoint in scales -L and -T hence the option argument.
*/
unsigned int n_errors = 0, k = 1; /* Assume 1st character tells us the mode */
int n, justify = 0;
@@ -13513,13 +13514,13 @@ struct GMT_REFPOINT * gmt_get_refpoint (struct GMT_CTRL *GMT, char *arg) {
mode = GMT_REFPOINT_JUST;
else { /* Must assume the user gave map coordinates */
mode = GMT_REFPOINT_MAP;
- GMT_Report (GMT->parent, GMT_MSG_VERBOSE, "Warning: Your -D option was interpreted to mean -D%c\n", kind[mode]);
+ GMT_Report (GMT->parent, GMT_MSG_VERBOSE, "Warning: Your -%c option was interpreted to mean -D%c\n", option, kind[mode]);
}
}
/* Here we know or have assumed the mode and can process coordinates accordingly */
if (mode != GMT_REFPOINT_PLOT && GMT->common.J.active == false && GMT->common.R.active == false) {
- GMT_Report (GMT->parent, GMT_MSG_NORMAL, "Error: Your -D%c reference point coordinates require both -R -J to be specified\n", kind[mode]);
+ GMT_Report (GMT->parent, GMT_MSG_NORMAL, "Error: Your -%c%c reference point coordinates require both -R -J to be specified\n", option, kind[mode]);
return NULL;
}
@@ -13545,7 +13546,7 @@ struct GMT_REFPOINT * gmt_get_refpoint (struct GMT_CTRL *GMT, char *arg) {
n_errors += gmt_verify_expectations (GMT, GMT->current.io.col_type[GMT_IN][GMT_X], gmt_scanf (GMT, txt_x, GMT->current.io.col_type[GMT_IN][GMT_X], &A->x), txt_x);
n_errors += gmt_verify_expectations (GMT, GMT->current.io.col_type[GMT_IN][GMT_Y], gmt_scanf (GMT, txt_y, GMT->current.io.col_type[GMT_IN][GMT_Y], &A->y), txt_y);
if (n_errors)
- GMT_Report (GMT->parent, GMT_MSG_NORMAL, "Error: Could not parse geographic coordinates %s and/or %s\n", txt_x, txt_y);
+ GMT_Report (GMT->parent, GMT_MSG_NORMAL, "Error -%c: Could not parse geographic coordinates %s and/or %s\n", option, txt_x, txt_y);
else
GMT_Report (GMT->parent, GMT_MSG_DEBUG, "Anchor point specified via map coordinates: %g, %g\n", A->x, A->y);
break;
diff --git a/src/gmt_vector.c b/src/gmt_vector.c
index 68a8e38..5cde1a9 100644
--- a/src/gmt_vector.c
+++ b/src/gmt_vector.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: gmt_vector.c 17528 2017-02-05 08:02:49Z pwessel $
+ * $Id: gmt_vector.c 17621 2017-03-06 00:01:29Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -1368,7 +1368,7 @@ uint64_t gmt_fix_up_path (struct GMT_CTRL *GMT, double **a_lon, double **a_lat,
*/
unsigned int k = 1;
- bool meridian;
+ bool meridian, boostable;
uint64_t i, j, n_new, n_step = 0;
double a[3], b[3], x[3], *lon = NULL, *lat = NULL;
double c, d, fraction, theta, minlon, maxlon;
@@ -1399,22 +1399,21 @@ uint64_t gmt_fix_up_path (struct GMT_CTRL *GMT, double **a_lon, double **a_lat,
* and hence the number of steps n_step will be small. This can lead to large jumps in
* longitude that can later confuse us as to when we cross a periodic boundary.
* We try to mitigate that by scaling up the number of steps by a boost factor that is 1
- * away from poles and from |lat| = 75 increases to 100 very close to the pole. */
-
+ * away from poles and from |lat| = 75 increases to 150 very close to the pole. */
+ boostable = !(gmt_M_is_linear (GMT) || gmt_M_pole_is_point (GMT)); /* Only boost for projections where poles are lines */
f_lat_a = fabs (lat[0]);
for (i = 1; i < n; i++) {
f_lat_b = fabs (lat[i]);
gmt_geo_to_cart (GMT, lat[i], lon[i], b, true); /* End point of current arc */
- boost = (MIN(f_lat_a, f_lat_b) > 75.0) ? 100.0 : 1.0; /* Enforce closer sampling close to poles */
- if (MIN(f_lat_a, f_lat_b) > 75.0) /* Enforce closer sampling close to poles */
- boost = 1.0 + 10.0 * (MAX(f_lat_a, f_lat_b) - 75.0); /* Crude way to get a boost from 1 at 80 to ~101 at the pole */
+ if (boostable && MIN(f_lat_a, f_lat_b) > 75.0) /* Enforce closer sampling close to poles */
+ boost = 1.0 + 10.0 * (MAX(f_lat_a, f_lat_b) - 75.0); /* Crude way to get a boost from 1 at 75 to ~151 at the pole */
else
boost = 1.0;
if (mode == GMT_STAIRS_Y) { /* First follow meridian, then parallel */
dlon = lon[i]-lon[i-1]; /* Beware of jumps due to sign differences */
- if (fabs (dlon) > 180.0) dlon += copysign (360.0, -dlon); /* Never more than 180 to next point */
+ if (fabs (dlon) > 180.0) dlon += copysign (360.0, -dlon); /* Never more than 180 to next point */
lon_i = lon[i-1] + dlon; /* Use lon_i instead of lon[i] in the marching since this avoids any jumping */
theta = fabs (dlon) * cosd (lat[i-1]);
n_step = lrint (theta / step);
diff --git a/src/gmtlogo.c b/src/gmtlogo.c
index bb49bb9..85a9175 100644
--- a/src/gmtlogo.c
+++ b/src/gmtlogo.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: gmtlogo.c 17449 2017-01-16 21:27:04Z pwessel $
+ * $Id: gmtlogo.c 17733 2017-03-20 20:03:03Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -116,7 +116,7 @@ GMT_LOCAL int parse (struct GMT_CTRL *GMT, struct GMTLOGO_CTRL *Ctrl, struct GMT
case 'D':
Ctrl->D.active = true;
- if ((Ctrl->D.refpoint = gmt_get_refpoint (GMT, opt->arg)) == NULL) n_errors++; /* Failed basic parsing */
+ if ((Ctrl->D.refpoint = gmt_get_refpoint (GMT, opt->arg, 'D')) == NULL) n_errors++; /* Failed basic parsing */
else { /* args are [+j<justify>][+o<dx>[/<dy>]] */
if (gmt_get_modifier (Ctrl->D.refpoint->args, 'j', string))
Ctrl->D.justify = gmt_just_decode (GMT, string, PSL_NO_DEF);
@@ -147,7 +147,7 @@ GMT_LOCAL int parse (struct GMT_CTRL *GMT, struct GMTLOGO_CTRL *Ctrl, struct GMT
}
}
if (!Ctrl->D.active) {
- Ctrl->D.refpoint = gmt_get_refpoint (GMT, "x0/0"); /* Default if no -D given */
+ Ctrl->D.refpoint = gmt_get_refpoint (GMT, "x0/0", 'D'); /* Default if no -D given */
Ctrl->D.active = true;
}
n_errors += gmt_M_check_condition (GMT, Ctrl->D.width < 0.0, "Syntax error -D option, +w modifier: Width cannot be zero or negative!\n");
diff --git a/src/grdimage.c b/src/grdimage.c
index f2addd4..82c442b 100644
--- a/src/grdimage.c
+++ b/src/grdimage.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: grdimage.c 17485 2017-01-23 13:20:10Z jluis $
+ * $Id: grdimage.c 17670 2017-03-14 15:58:06Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -1027,8 +1027,8 @@ int GMT_grdimage (void *V_API, int mode, void *args) {
if (!(bitimage_8[kk] == 0 || bitimage_8[kk] == 255)) P->is_bw = false;
if (P && P->is_bw && !Ctrl->A.active) { /* Can get away with a 1-bit image, but we must pack the original byte to 8 image bits */
- int nx8, shift, b_or_w, nx_pixels, k8;
- uint64_t imsize;
+ int nx8, shift, b_or_w, nx_pixels;
+ uint64_t imsize, k8;
unsigned char *bit = NULL;
GMT_Report (API, GMT_MSG_VERBOSE, "Creating 1-bit B/W image\n");
diff --git a/src/grdmask.c b/src/grdmask.c
index 134bad7..ce50f4b 100644
--- a/src/grdmask.c
+++ b/src/grdmask.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: grdmask.c 17449 2017-01-16 21:27:04Z pwessel $
+ * $Id: grdmask.c 17618 2017-03-05 22:58:12Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -361,7 +361,7 @@ int GMT_grdmask (void *V_API, int mode, void *args) {
Return (GMT_RUNTIME_ERROR);
}
S->n_rows = n_new;
- gmt_set_seg_minmax (GMT, D->geometry, S); /* Update min/max */
+ gmt_set_seg_minmax (GMT, D->geometry, 2, S); /* Update min/max or x/y only */
}
}
}
diff --git a/src/grdview.c b/src/grdview.c
index 985ac82..bb70acc 100644
--- a/src/grdview.c
+++ b/src/grdview.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: grdview.c 17449 2017-01-16 21:27:04Z pwessel $
+ * $Id: grdview.c 17625 2017-03-06 04:01:24Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -563,7 +563,7 @@ GMT_LOCAL int parse (struct GMT_CTRL *GMT, struct GRDVIEW_CTRL *Ctrl, struct GMT
case 'S': /* Smoothing of contours */
Ctrl->S.active = true;
sval = atoi (opt->arg);
- n_errors += gmt_M_check_condition (GMT, sval, "Syntax error -S option: smooth value must be positive\n");
+ n_errors += gmt_M_check_condition (GMT, sval <= 0, "Syntax error -S option: smooth value must be positive\n");
Ctrl->S.value = sval;
break;
case 'T': /* Tile plot */
diff --git a/src/postscriptlight.c b/src/postscriptlight.c
index cf771a4..4023282 100644
--- a/src/postscriptlight.c
+++ b/src/postscriptlight.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: postscriptlight.c 17507 2017-01-31 23:21:54Z pwessel $
+ * $Id: postscriptlight.c 17670 2017-03-14 15:58:06Z pwessel $
*
* Copyright (c) 2009-2017 by P. Wessel and R. Scharroo
*
@@ -2070,6 +2070,54 @@ static int psl_pattern_init (struct PSL_CTRL *PSL, int image_no, char *imagefile
return (image_no);
}
+#if 0
+void psl_vector_v4 (struct PSL_CTRL *PSL, double x, double y, double param[], double rgb[], int outline)
+{
+ /* Old GMT4 vector symbol:
+ * param[0] = xtip;
+ * param[1] = ytip;
+ * param[2] = tailwidth;
+ * param[3] = headlength;
+ * param[4] = headwidth;
+ * param[5] = headshape;
+ /* Will make sure that arrow has a finite width in PS coordinates */
+
+ double angle, xtail, ytail, tailwidth, headlength, headwidth, headshape;
+ int w2, length, hw, hl, hl2, hw2, l2;
+
+ xtail = x; ytail = y; xtip = param[0]; ytip = param[1];
+ length = psl_iz (PSL, hypot (xtail-xtip, ytail-ytip)); /* Vector length in PS units */
+ if (length == 0) return; /* NULL vector */
+
+ tailwidth = param[2];
+ headlength = param[3];
+ headwidth = param[4];
+ headshape = param[5];
+ if (outline & 8)
+ ps_setfill (rgb, outline - 8);
+ else
+ ps_setfill (rgb, outline);
+ angle = atan2 ((ytip-ytail),(xtip-xtail)) * R2D; /* Angle vector makes with horizontal, in radians */
+ fprintf (PSL->internal.fp, "V %ld %ld T ", (PSL_LONG)irint (xtail * PSL->internal.scale), (PSL_LONG)irint (ytail * PSL->internal.scale)); /* Temporarily set tail point the local origin (0, 0) */
+ if (angle != 0.0) fprintf (PSL->internal.fp, "%g R ", angle); /* Rotate so vector is horizontal in local coordinate system */
+ w2 = (PSL_LONG)irint (0.5 * tailwidth * PSL->internal.scale); if (w2 == 0) w2 = 1; /* Half-width of vector tail */
+ hw = (PSL_LONG)irint (headwidth * PSL->internal.scale); if (hw == 0) hw = 1; /* Width of vector head */
+ hl = (PSL_LONG)irint (headlength * PSL->internal.scale); /* Length of vector head */
+ hl2 = (PSL_LONG)irint (0.5 * headshape * headlength * PSL->internal.scale); /* Cut-in distance due to slanted back-side of arrow head */
+ hw2 = hw - w2; /* Distance from tail side to head side (vertically) */
+ if (outline & 8) { /* Double-headed vector */
+ l2 = length - 2 * hl + 2 * hl2; /* Inside length between start of heads */
+ fprintf (PSL->internal.fp, "%ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld Sv U\n",
+ hl2, hw2, -l2, hl2, -hw2, -hl, hw, hl, hw, -hl2, -hw2, l2, -hl2, hw2, hl, -hw);
+ }
+ else { /* Single-headed vector */
+ l2 = length - hl + hl2; /* Length from tail to start of slanted head */
+ fprintf (PSL->internal.fp, "%ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld SV U\n",
+ -l2, hl2, -hw2, -hl, hw, hl, hw, -hl2, -hw2, l2, -w2);
+ }
+}
+#endif
+
#define FIN_SLANT_COS 0.707106781187 /* I.e., 45 degrees slant */
#define FIN_LENGTH_SCALE 0.66666667 /* 2/3 the length of the vector */
#define FIN_HEIGHT_SCALE 0.5 /* 1/2 the width of the vector */
@@ -5419,6 +5467,7 @@ int PSL_command (struct PSL_CTRL *C, const char *format, ...) {
char tmp_buffer[PSL_BUFSIZ] = {""};
size_t len = vsnprintf (tmp_buffer, PSL_BUFSIZ, format, args);
psl_prepare_buffer (C, len);
+ C->internal.buffer[C->internal.n] = '\0'; /* Play safe before the strcat of next line. Otherwise trash in the middle may occur */
strncat (&(C->internal.buffer[C->internal.n]), tmp_buffer, len);
C->internal.n += len;
}
diff --git a/src/potential/talwani3d.c b/src/potential/talwani3d.c
index 5beeba6..fea0e9f 100644
--- a/src/potential/talwani3d.c
+++ b/src/potential/talwani3d.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: talwani3d.c 17580 2017-02-23 06:35:24Z pwessel $
+ * $Id: talwani3d.c 17603 2017-03-04 01:03:56Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -51,8 +51,8 @@
#define GMT_PROG_OPTIONS "-VRfhior" GMT_ADD_x_OPT
-#define TOL 1.0e-7
-#define DEG_TO_KM 111.319490793 /* For flat-Earth scaling of degrees to km */
+#define TOL 1.0e-7 /* Gotta leave a bit slack for these calculations */
+#define DEG_TO_KM 111.319490793 /* For flat-Earth scaling of degrees to km on WGS-84 Equator */
#define GAMMA 6.673 /* Gravitational constant for distances in km and mass in kg/m^3 */
#define G0 9.81 /* Normal gravity */
@@ -238,7 +238,7 @@ GMT_LOCAL int usage (struct GMTAPI_CTRL *API, int level) {
if (level == GMT_MODULE_PURPOSE) return (GMT_NOERROR);
GMT_Message (API, GMT_TIME_NONE, "usage: talwani3d <modelfile> [-A] [-D<rho>] [-Ff|n|v] [-G<outfile>] [%s]\n", GMT_I_OPT);
GMT_Message (API, GMT_TIME_NONE, "\t[-M[hz]] [-N<trktable>] [%s] [-Z<level>] [%s] \n", GMT_Rgeo_OPT, GMT_V_OPT, GMT_f_OPT);
- GMT_Message (API, GMT_TIME_NONE,"\t[%s]\n\t[%s] [%s] [%s]%s\n\n", GMT_h_OPT, GMT_i_OPT, GMT_o_OPT, GMT_r_OPT, GMT_x_OPT);
+ GMT_Message (API, GMT_TIME_NONE, "\t[-fg] [%s]\n\t[%s] [%s] [%s]%s\n\n", GMT_h_OPT, GMT_i_OPT, GMT_o_OPT, GMT_r_OPT, GMT_x_OPT);
if (level == GMT_SYNOPSIS) return (GMT_MODULE_SYNOPSIS);
@@ -749,15 +749,44 @@ int GMT_talwani3d (void *V_API, int mode, void *args) {
Return (API->error);
}
- /* Set up cake slice array and pointers */
+ if (Ctrl->Z.mode == 1) { /* Got grid with observation levels which also sets output locations; it could also set -fg so do this first */
+ if ((G = GMT_Read_Data (API, GMT_IS_GRID, GMT_IS_FILE, GMT_IS_SURFACE, GMT_GRID_ALL, NULL, Ctrl->Z.file, NULL)) == NULL)
+ Return (API->error);
+ }
+ else if (GMT->common.R.active) { /* Gave -R -I [-r] and possibly -fg indirectly via geographic coordinates in -R */
+ if ((G = GMT_Create_Data (API, GMT_IS_GRID, GMT_IS_SURFACE, GMT_GRID_ALL, NULL, NULL, Ctrl->I.inc,
+ GMT_GRID_DEFAULT_REG, GMT_NOTSET, NULL)) == NULL)
+ Return (API->error);
+ }
+ else { /* Got a dataset with output locations via -N */
+ gmt_disable_i_opt (GMT); /* Do not want any -i to affect the reading from the -N file */
+ if ((D = GMT_Read_Data (API, GMT_IS_DATASET, GMT_IS_FILE, GMT_IS_POINT, GMT_READ_NORMAL, NULL, Ctrl->N.file, NULL)) == NULL)
+ Return (API->error);
+ if (D->n_columns < 2) {
+ GMT_Report (API, GMT_MSG_NORMAL, "Input file %s has %d column(s) but at least 2 are needed\n", Ctrl->N.file, (int)D->n_columns);
+ Return (GMT_DIM_TOO_SMALL);
+ }
+ gmt_reenable_i_opt (GMT); /* Recover settings provided by user (if -i was used at all) */
+ }
- n_alloc1 = GMT_CHUNK;
- cake = gmt_M_memory (GMT, NULL, n_alloc1, struct CAKE);
+ flat_earth = gmt_M_is_geographic (GMT, GMT_IN); /* If true then input is in degrees and we must convert to km later on */
+
+ if (flat_earth && Ctrl->M.active[TALWANI3D_HOR]) {
+ GMT_Report (API, GMT_MSG_NORMAL, "Error -M: Cannot specify both geographic coordinates (degrees) AND -Mh\n");
+ Return (GMT_RUNTIME_ERROR);
+ }
+
+ if (Ctrl->A.active) Ctrl->Z.level = -Ctrl->Z.level;
/* Read polygon information from multiple segment file */
GMT_Report (API, GMT_MSG_VERBOSE, "All x/y-values are assumed to be given in %s\n", uname[Ctrl->M.active[TALWANI3D_HOR]]);
GMT_Report (API, GMT_MSG_VERBOSE, "All z-values are assumed to be given in %s\n", uname[Ctrl->M.active[TALWANI3D_VER]]);
+ /* Set up cake slice array and pointers */
+
+ n_alloc1 = GMT_CHUNK;
+ cake = gmt_M_memory (GMT, NULL, n_alloc1, struct CAKE);
+
/* Read the sliced model */
do { /* Keep returning records until we reach EOF */
if ((in = GMT_Get_Record (API, GMT_READ_DATA, NULL)) == NULL) { /* Read next record, get NULL if special case */
@@ -865,6 +894,7 @@ int GMT_talwani3d (void *V_API, int mode, void *args) {
gmt_M_free (GMT, cake);
Return (GMT_RUNTIME_ERROR);
}
+
/* Finish allocation and sort on layers */
cake = gmt_M_memory (GMT, cake, ndepths, struct CAKE);
@@ -872,40 +902,10 @@ int GMT_talwani3d (void *V_API, int mode, void *args) {
if (n_duplicate) GMT_Report (API, GMT_MSG_VERBOSE, "Ignored %u duplicate vertices\n", n_duplicate);
- if (Ctrl->Z.mode == 1) { /* Got grid with observation levels which also sets output locations */
- if ((G = GMT_Read_Data (API, GMT_IS_GRID, GMT_IS_FILE, GMT_IS_SURFACE, GMT_GRID_ALL, NULL, Ctrl->Z.file, NULL)) == NULL) {
- gmt_M_free (GMT, cake);
- Return (API->error);
- }
- }
- else if (GMT->common.R.active) { /* Gave -R -I [-r] */
- if ((G = GMT_Create_Data (API, GMT_IS_GRID, GMT_IS_SURFACE, GMT_GRID_ALL, NULL, NULL, Ctrl->I.inc,
- GMT_GRID_DEFAULT_REG, GMT_NOTSET, NULL)) == NULL) {
- gmt_M_free (GMT, cake);
- Return (API->error);
- }
- }
- else { /* Got a dataset with output locations via -N */
- gmt_disable_i_opt (GMT); /* Do not want any -i to affect the reading from -C,-F,-L files */
- if ((D = GMT_Read_Data (API, GMT_IS_DATASET, GMT_IS_FILE, GMT_IS_POINT, GMT_READ_NORMAL, NULL, Ctrl->N.file, NULL)) == NULL) {
- gmt_M_free (GMT, cake);
- Return (API->error);
- }
- if (D->n_columns < 2) {
- GMT_Report (API, GMT_MSG_NORMAL, "Input file %s has %d column(s) but at least 2 are needed\n", Ctrl->N.file, (int)D->n_columns);
- Return (GMT_DIM_TOO_SMALL);
- }
- gmt_reenable_i_opt (GMT); /* Recover settings provided by user (if -i was used at all) */
- }
-
- flat_earth = gmt_M_is_geographic (GMT, GMT_IN);
-
- if (Ctrl->A.active) Ctrl->Z.level = -Ctrl->Z.level;
-
/* Now we can write (if -V) to the screen the user's polygon model characteristics. */
GMT_Report (API, GMT_MSG_VERBOSE, "# of depths: %d\n", ndepths);
- if (gmt_M_is_verbose (GMT, GMT_MSG_LONG_VERBOSE)) {
+ if (gmt_M_is_verbose (GMT, GMT_MSG_LONG_VERBOSE)) { /* Give a listing of layers found */
for (k = 0; k < ndepths; k++) {
for (sl = cake[k].first_slice; sl; sl = sl->next)
GMT_Report (API, GMT_MSG_LONG_VERBOSE, "Depth: %lg Rho: %lg N-vertx: %4d\n",
@@ -919,7 +919,7 @@ int GMT_talwani3d (void *V_API, int mode, void *args) {
for (k = 0; k < ndepths; k++) depths[k] = cake[k].depth; /* Used by the parabolic integrator */
if (Ctrl->N.active) { /* Single loop over specified output locations */
unsigned int wmode = GMT_ADD_DEFAULT;
- double scl = (!(flat_earth || Ctrl->M.active[TALWANI3D_HOR])) ? METERS_IN_A_MILE : 1.0; /* Perhaps convert to km */
+ double scl = (!(flat_earth || Ctrl->M.active[TALWANI3D_HOR])) ? (1.0 / METERS_IN_A_KM) : 1.0; /* Perhaps convert to km */
double out[4];
/* Must register Ctrl->G.file first since we are going to writing rec-by-rec */
if (Ctrl->G.active) {
@@ -959,7 +959,7 @@ int GMT_talwani3d (void *V_API, int mode, void *args) {
* with OpenMP due to race condiations that would mess up the output order */
for (row = 0; row < (int64_t)S->n_rows; row++) { /* Calculate attraction at all output locations for this segment */
z_level = (S->n_columns == 3 && !Ctrl->Z.active) ? S->data[GMT_Z][row] : Ctrl->Z.level; /* Default observation z level unless provided in input file */
- GMT->hidden.mem_coord[GMT_X][row] = get_one_output3D (S->data[GMT_X][row]/ scl, S->data[GMT_Y][row]/ scl, z_level, cake, depths, ndepths, Ctrl->F.mode, flat_earth);
+ GMT->hidden.mem_coord[GMT_X][row] = get_one_output3D (S->data[GMT_X][row] * scl, S->data[GMT_Y][row] * scl, z_level, cake, depths, ndepths, Ctrl->F.mode, flat_earth);
}
/* This loop is not under OpenMP */
out[GMT_Z] = Ctrl->Z.level; /* Default observation z level unless provided in input file */
diff --git a/src/psclip.c b/src/psclip.c
index 3e93465..e856a49 100644
--- a/src/psclip.c
+++ b/src/psclip.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: psclip.c 17449 2017-01-16 21:27:04Z pwessel $
+ * $Id: psclip.c 17618 2017-03-05 22:58:12Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -283,7 +283,7 @@ int GMT_psclip (void *V_API, int mode, void *args) {
Return (GMT_RUNTIME_ERROR);
}
S->n_rows = n_new;
- gmt_set_seg_minmax (GMT, D->geometry, S); /* Update min/max */
+ gmt_set_seg_minmax (GMT, D->geometry, 2, S); /* Update min/max of x/y only */
GMT_Report (API, GMT_MSG_DEBUG, "Resample polygon, now has %d points\n", S->n_rows);
}
diff --git a/src/pscoast.c b/src/pscoast.c
index 5aa4432..e2fe2eb 100644
--- a/src/pscoast.c
+++ b/src/pscoast.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: pscoast.c 17560 2017-02-17 22:05:42Z pwessel $
+ * $Id: pscoast.c 17630 2017-03-07 20:45:58Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -497,6 +497,9 @@ GMT_LOCAL int parse (struct GMT_CTRL *GMT, struct PSCOAST_CTRL *Ctrl, struct GMT
}
}
+ /* If no -E modes were selected then we default to dump provided -M was given */
+ if (Ctrl->E.info.mode == 0 && Ctrl->M.active) Ctrl->E.info.mode = GMT_DCW_DUMP;
+
if (gmt_DCW_list (GMT, Ctrl->E.info.mode)) return 1;
if (Ctrl->C.active && !(Ctrl->G.active || Ctrl->S.active || Ctrl->W.active)) { /* Just lakes, fix -A */
diff --git a/src/psimage.c b/src/psimage.c
index 4f02bf9..6de810e 100644
--- a/src/psimage.c
+++ b/src/psimage.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: psimage.c 17460 2017-01-22 22:55:48Z pwessel $
+ * $Id: psimage.c 17733 2017-03-20 20:03:03Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -163,7 +163,7 @@ GMT_LOCAL int parse (struct GMT_CTRL *GMT, struct PSIMAGE_CTRL *Ctrl, struct GMT
case 'D':
Ctrl->D.active = true;
p = (string[0]) ? string : opt->arg; /* If -C was used the string is set */
- if ((Ctrl->D.refpoint = gmt_get_refpoint (GMT, p)) == NULL) { /* Failed basic parsing */
+ if ((Ctrl->D.refpoint = gmt_get_refpoint (GMT, p, 'D')) == NULL) { /* Failed basic parsing */
GMT_Report (GMT->parent, GMT_MSG_NORMAL, "Syntax error -D: Basic parsing of reference point in %s failed\n", opt->arg);
p_fail = true;
n_errors++;
@@ -283,7 +283,7 @@ GMT_LOCAL int parse (struct GMT_CTRL *GMT, struct PSIMAGE_CTRL *Ctrl, struct GMT
if (Ctrl->G.b_rgb[0] == -2) { Ctrl->G.b_rgb[0] = Ctrl->G.b_rgb[1] = Ctrl->G.b_rgb[2] = 1.0; }
if (!Ctrl->D.active) { /* Old syntax without reference point implies -Dx0/0 */
- Ctrl->D.refpoint = gmt_get_refpoint (GMT, "x0/0"); /* Default if no -D given */
+ Ctrl->D.refpoint = gmt_get_refpoint (GMT, "x0/0", 'D'); /* Default if no -D given */
Ctrl->D.active = true;
}
/* Check that the options selected are mutually consistent */
diff --git a/src/pslegend.c b/src/pslegend.c
index 98f9585..4f91a80 100644
--- a/src/pslegend.c
+++ b/src/pslegend.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: pslegend.c 17449 2017-01-16 21:27:04Z pwessel $
+ * $Id: pslegend.c 17733 2017-03-20 20:03:03Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -135,7 +135,7 @@ GMT_LOCAL int parse (struct GMT_CTRL *GMT, struct PSLEGEND_CTRL *Ctrl, struct GM
case 'D': /* Sets position and size of legend */
Ctrl->D.active = true;
if (strstr (opt->arg, "+w")) { /* New syntax: */
- if ((Ctrl->D.refpoint = gmt_get_refpoint (GMT, opt->arg)) == NULL) {
+ if ((Ctrl->D.refpoint = gmt_get_refpoint (GMT, opt->arg, 'D')) == NULL) {
n_errors++; /* Failed basic parsing */
break;
}
@@ -323,7 +323,8 @@ int GMT_pslegend (void *V_API, int mode, void *args) {
/* High-level function that implements the pslegend task */
unsigned int tbl, pos;
int i, justify = 0, n = 0, n_columns = 1, n_col, col, error = 0, column_number = 0, id, n_scan, status = 0;
- bool flush_paragraph = false, v_line_draw_now = false, gave_label, gave_mapscale_options, did_old = false, drawn = false;
+ bool flush_paragraph = false, v_line_draw_now = false, gave_label, gave_mapscale_options, did_old = false;
+ bool drawn = false, b_cpt = false;
uint64_t seg, row, n_fronts = 0, n_quoted_lines = 0;
size_t n_char = 0;
char txt_a[GMT_LEN256] = {""}, txt_b[GMT_LEN256] = {""}, txt_c[GMT_LEN256] = {""}, txt_d[GMT_LEN256] = {""};
@@ -435,6 +436,7 @@ int GMT_pslegend (void *V_API, int mode, void *args) {
if ((c = strchr (bar_height, '+')) != NULL) c[0] = 0; /* Chop off any modifiers so we can compute the height */
height += gmt_M_to_inch (GMT, bar_height) + GMT->current.setting.map_tick_length[0] + GMT->current.setting.map_annot_offset[0] + FONT_HEIGHT_PRIMARY * GMT->current.setting.font_annot[GMT_PRIMARY].size / PSL_POINTS_PER_INCH;
column_number = 0;
+ if (strstr (&line[2], "-B")) b_cpt = true; /* Passed -B options with the bar presecription */
break;
case 'A': /* Color change, no height implication */
@@ -608,6 +610,12 @@ int GMT_pslegend (void *V_API, int mode, void *args) {
if ((PSL = gmt_plotinit (GMT, options)) == NULL) Return (GMT_RUNTIME_ERROR);
gmt_plane_perspective (GMT, GMT->current.proj.z_project.view_plane, GMT->current.proj.z_level);
+ gmt_plotcanvas (GMT); /* Fill canvas if requested */
+ gmt_map_basemap (GMT); /* Plot basemap if requested */
+
+ if (GMT->current.map.frame.draw && b_cpt) /* Two conflicting -B settings, reset main -B since we just finished the frame */
+ gmt_M_memset (&(GMT->current.map.frame), 1, struct GMT_PLOT_FRAME);
+
/* Must reset any -X -Y to 0 so they are not used further in the GMT_modules we call below */
gmt_M_memset (GMT->current.setting.map_origin, 2, double);
@@ -1407,7 +1415,6 @@ int GMT_pslegend (void *V_API, int mode, void *args) {
PSL_setorigin (PSL, -x_orig, -y_orig, 0.0, PSL_INV); /* Reset */
Ctrl->D.refpoint->x = x_orig; Ctrl->D.refpoint->y = y_orig;
- gmt_map_basemap (GMT);
gmt_plotend (GMT);
for (id = 0; id < N_DAT; id++) {
diff --git a/src/psrose.c b/src/psrose.c
index 88cc3d9..2afacc2 100644
--- a/src/psrose.c
+++ b/src/psrose.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: psrose.c 17560 2017-02-17 22:05:42Z pwessel $
+ * $Id: psrose.c 17716 2017-03-18 22:13:17Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -652,6 +652,8 @@ int GMT_psrose (void *V_API, int mode, void *args) {
diameter = 2.0 * Ctrl->S.scale;
PSL_setorigin (PSL, x_origin, y_origin, 0.0, PSL_FWD);
gmt_plane_perspective (GMT, GMT->current.proj.z_project.view_plane, GMT->current.proj.z_level);
+ gmt_plotcanvas (GMT); /* Fill canvas if requested */
+
if (!Ctrl->S.normalize) Ctrl->S.scale /= max_radius;
if (do_fill) { /* Until psrose uses a polar projection we must bypass the basemap fill and do it ourself here */
diff --git a/src/psscale.c b/src/psscale.c
index 8215c9a..1f9b7db 100644
--- a/src/psscale.c
+++ b/src/psscale.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: psscale.c 17582 2017-02-23 21:04:54Z pwessel $
+ * $Id: psscale.c 17733 2017-03-20 20:03:03Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -252,7 +252,7 @@ GMT_LOCAL int parse (struct GMT_CTRL *GMT, struct PSSCALE_CTRL *Ctrl, struct GMT
break;
case 'D':
Ctrl->D.active = true;
- if ((Ctrl->D.refpoint = gmt_get_refpoint (GMT, opt->arg)) == NULL)
+ if ((Ctrl->D.refpoint = gmt_get_refpoint (GMT, opt->arg, 'D')) == NULL)
n_errors++; /* Failed basic parsing */
else if (strstr (Ctrl->D.refpoint->args, "+w")) { /* New syntax: */
/* Args are +w<length>/<width>[+e[b|f][<length>]][+h][+j<justify>][+ma|c|l|u][+n[<txt>]][+o<dx>[/<dy>]] */
diff --git a/src/pssolar.c b/src/pssolar.c
index d303e60..9de2217 100644
--- a/src/pssolar.c
+++ b/src/pssolar.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: pssolar.c 17560 2017-02-17 22:05:42Z pwessel $
+ * $Id: pssolar.c 17716 2017-03-18 22:13:17Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -541,6 +541,7 @@ int GMT_pssolar (void *V_API, int mode, void *args) {
}
if ((PSL = gmt_plotinit (GMT, options)) == NULL) Return (GMT_RUNTIME_ERROR);
gmt_plane_perspective (GMT, GMT->current.proj.z_project.view_plane, GMT->current.proj.z_level);
+ gmt_plotcanvas (GMT); /* Fill canvas if requested */
if (Ctrl->N.active) gmt_map_clip_on (GMT, GMT->session.no_rgb, 1); /* Must clip map */
for (n = 0; n < 4; n++) { /* Loop over the number of requested terminators */
diff --git a/src/psxy.c b/src/psxy.c
index 3374c48..7cddc25 100644
--- a/src/psxy.c
+++ b/src/psxy.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: psxy.c 17560 2017-02-17 22:05:42Z pwessel $
+ * $Id: psxy.c 17739 2017-03-21 06:25:59Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -726,7 +726,8 @@ GMT_LOCAL int parse (struct GMT_CTRL *GMT, struct PSXY_CTRL *Ctrl, struct GMT_OP
n_errors += gmt_M_check_condition (GMT, Ctrl->S.active && gmt_parse_symbol_option (GMT, Ctrl->S.arg, S, 0, true), "Syntax error -S option\n");
n_errors += gmt_M_check_condition (GMT, Ctrl->E.active && (S->symbol == GMT_SYMBOL_VECTOR || S->symbol == GMT_SYMBOL_GEOVECTOR || S->symbol == GMT_SYMBOL_MARC \
- || S->symbol == GMT_SYMBOL_ELLIPSE || S->symbol == GMT_SYMBOL_FRONT || S->symbol == GMT_SYMBOL_QUOTED_LINE || S->symbol == GMT_SYMBOL_DECORATED_LINE || S->symbol == GMT_SYMBOL_ROTRECT), "Syntax error -E option: Incompatible with -Se, -Sf, -Sj, -Sm|M, -Sq, -Sv|V, -S=\n");
+ || S->symbol == GMT_SYMBOL_ELLIPSE || S->symbol == GMT_SYMBOL_FRONT || S->symbol == GMT_SYMBOL_QUOTED_LINE || S->symbol == GMT_SYMBOL_DECORATED_LINE \
+ || S->symbol == GMT_SYMBOL_ROTRECT), "Syntax error -E option: Incompatible with -Se, -Sf, -Sj, -Sm|M, -Sq, -Sv|V, -S=\n");
n_errors += gmt_M_check_condition (GMT, !GMT->common.R.active, "Syntax error: Must specify -R option\n");
n_errors += gmt_M_check_condition (GMT, !GMT->common.J.active, "Syntax error: Must specify a map projection with the -J option\n");
n_errors += gmt_M_check_condition (GMT, GMT->common.b.active[GMT_IN] && S->symbol == GMT_SYMBOL_NOT_SET, "Syntax error: Binary input data cannot have symbol information\n");
@@ -929,7 +930,7 @@ int GMT_psxy (void *V_API, int mode, void *args) {
GMT->current.io.col_type[GMT_IN][pos2y] = GMT_IS_FLOAT; /* Just the users dy component, not length */
if (S.symbol == GMT_SYMBOL_VECTOR || S.symbol == GMT_SYMBOL_GEOVECTOR || S.symbol == GMT_SYMBOL_MARC ) { /* One of the vector symbols */
geovector = (S.symbol == GMT_SYMBOL_GEOVECTOR);
- if ((S.v.status & GMT_VEC_FILL) == 0) Ctrl->G.active = false; /* Want no fill so override -G*/
+ if ((S.v.status & GMT_VEC_FILL) == 0) Ctrl->G.active = false; /* Want no fill so override -G */
if (S.v.status & GMT_VEC_FILL) S.v.fill = current_fill; /* Override -G<fill> (if set) with specified head fill */
}
bcol = (S.read_size) ? ex2 : ex1;
@@ -1034,7 +1035,9 @@ int GMT_psxy (void *V_API, int mode, void *args) {
/* First establish the symbol type given at the end of the record */
gmt_chop (text_rec); /* Get rid of \n \r */
- i = (unsigned int)strlen (text_rec) - 1;
+ i = (unsigned int)strlen (text_rec);
+ if (i == 0) continue; /* A blank line snuck through */
+ i--;
while (text_rec[i] && !strchr (" \t", (int)text_rec[i])) i--;
if (S.read_symbol_cmd == 1) gmt_parse_symbol_option (GMT, &text_rec[i+1], &S, 0, false);
for (j = n_cols_start; j < 6; j++) GMT->current.io.col_type[GMT_IN][j] = GMT_IS_DIMENSION; /* Since these may have units appended */
@@ -1352,7 +1355,8 @@ int GMT_psxy (void *V_API, int mode, void *args) {
x_2 -= dx; y_2 -= dy;
}
}
- if (S.v.parsed_v4 && gmt_M_compat_check (GMT, 4)) { /* Got v_width directly from V4 syntax so no messing with it here if under compatibility */
+ if (S.v.parsed_v4) { /* Got v_width directly from V4 syntax so no messing with it here if under compatibility */
+ /* Now plot the old GMT V4 vector instead */
/* But have to improvise as far as outline|fill goes... */
if (outline_active) S.v.status |= PSL_VEC_OUTLINE; /* Choosing to draw head outline */
if (fill_active) S.v.status |= PSL_VEC_FILL; /* Choosing to fill head */
@@ -1521,7 +1525,7 @@ int GMT_psxy (void *V_API, int mode, void *args) {
Return (GMT_RUNTIME_ERROR);
}
L->n_rows = n_new;
- gmt_set_seg_minmax (GMT, D->geometry, L); /* Update min/max */
+ gmt_set_seg_minmax (GMT, D->geometry, 2, L); /* Update min/max of x/y only */
resampled = true; /* To avoid doing it twice */
}
if (gmt_trim_line (GMT, &L->data[GMT_X], &L->data[GMT_Y], &L->n_rows, ¤t_pen)) continue; /* Trimmed away completely */
@@ -1602,7 +1606,7 @@ int GMT_psxy (void *V_API, int mode, void *args) {
Return (GMT_RUNTIME_ERROR);
}
L->n_rows = n_new;
- gmt_set_seg_minmax (GMT, D->geometry, L); /* Update min/max */
+ gmt_set_seg_minmax (GMT, D->geometry, 2, L); /* Update min/max of x/y only */
}
if (polygon) { /* Want a closed polygon (with or without fill and with or without outline) */
diff --git a/src/psxyz.c b/src/psxyz.c
index fe49ea4..8d27251 100644
--- a/src/psxyz.c
+++ b/src/psxyz.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: psxyz.c 17560 2017-02-17 22:05:42Z pwessel $
+ * $Id: psxyz.c 17739 2017-03-21 06:25:59Z pwessel $
*
* Copyright (c) 1991-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -767,7 +767,9 @@ int GMT_psxyz (void *V_API, int mode, void *args) {
text_rec = (char *)record;
/* First establish the symbol type given at the end of the record */
gmt_chop (text_rec); /* Get rid of \n \r */
- i = strlen (text_rec) - 1;
+ i = (unsigned int)strlen (text_rec);
+ if (i == 0) continue; /* A blank line snuck through */
+ i--;
while (text_rec[i] && !strchr (" \t", (int)text_rec[i])) i--;
gmt_parse_symbol_option (GMT, &text_rec[i+1], &S, 1, false);
for (j = n_cols_start; j < 7; j++) GMT->current.io.col_type[GMT_IN][j] = GMT_IS_DIMENSION; /* Since these may have units appended */
diff --git a/src/sphdistance.c b/src/sphdistance.c
index 8486c15..9c7094e 100644
--- a/src/sphdistance.c
+++ b/src/sphdistance.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: sphdistance.c 17560 2017-02-17 22:05:42Z pwessel $
+ * $Id: sphdistance.c 17618 2017-03-05 22:58:12Z pwessel $
*
* Copyright (c) 2008-2017 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
* See LICENSE.TXT file for copying and redistribution conditions.
@@ -92,7 +92,7 @@ GMT_LOCAL void prepare_polygon (struct GMT_CTRL *GMT, struct GMT_DATASEGMENT *P)
uint64_t row;
double lon_sum = 0.0, lat_sum = 0.0, dlon;
- gmt_set_seg_minmax (GMT, GMT_IS_POLY, P); /* Set the domain of the segment */
+ gmt_set_seg_minmax (GMT, GMT_IS_POLY, 0, P); /* Set the domain of the segment */
/* Then loop over points to accumulate sums */
diff --git a/src/spotter/backtracker.c b/src/spotter/backtracker.c
index a19bfc7..8f9fb08 100644
--- a/src/spotter/backtracker.c
+++ b/src/spotter/backtracker.c
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------
- * $Id: backtracker.c 17560 2017-02-17 22:05:42Z pwessel $
+ * $Id: backtracker.c 17641 2017-03-12 01:32:05Z pwessel $
*
* Copyright (c) 1999-2017 by P. Wessel
*
@@ -376,6 +376,7 @@ int GMT_backtracker (void *V_API, int mode, void *args) {
int n_fields, error; /* Misc. signed counters */
int spotter_way = 0; /* Either SPOTTER_FWD or SPOTTER_BACK */
bool make_path = false; /* true means create continuous path, false works on discrete points */
+ bool E_first = true;
double *c = NULL; /* Array of track chunks returned by libeuler routines */
@@ -454,6 +455,7 @@ int GMT_backtracker (void *V_API, int mode, void *args) {
n_out = (Ctrl->S.active) ? 4 : 3; /* Append smt id number as 4th column when individual files are requested */
if (Ctrl->W.active) n_out = 5 + !(Ctrl->W.mode == 0);
geometry = (make_path) ? GMT_IS_LINE : GMT_IS_POINT;
+ gmt_M_memset (out, 10, double);
/* Specify input and output expected columns */
if ((error = gmt_set_cols (GMT, GMT_IN, n_expected_fields)) != GMT_NOERROR) {
@@ -503,12 +505,18 @@ int GMT_backtracker (void *V_API, int mode, void *args) {
/* Data record to process */
if (Ctrl->E.rot.single) { /* Simple reconstruction, then exit */
+ if (E_first) {
+ if ((error = gmt_set_cols (GMT, GMT_OUT, n_fields)) != GMT_NOERROR) {
+ Return (error);
+ }
+ E_first = false;
+ }
in[GMT_Y] = gmt_lat_swap (GMT, in[GMT_Y], GMT_LATSWAP_G2O); /* Convert to geocentric */
gmt_geo_to_cart (GMT, in[GMT_Y], in[GMT_X], x, true); /* Get x-vector */
gmt_matrix_vect_mult (GMT, 3U, R, x, y); /* Rotate the x-vector */
gmt_cart_to_geo (GMT, &out[GMT_Y], &out[GMT_X], y, true); /* Recover lon lat representation; true to get degrees */
out[GMT_Y] = gmt_lat_swap (GMT, out[GMT_Y], GMT_LATSWAP_O2G); /* Convert back to geodetic */
- gmt_M_memcpy (&out[GMT_Z], &in[GMT_Z], n_fields - 2, double);
+ if (n_fields > 2) gmt_M_memcpy (&out[GMT_Z], &in[GMT_Z], n_fields - 2, double);
GMT_Put_Record (API, GMT_WRITE_DATA, out);
continue;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/gmt.git
More information about the Pkg-grass-devel
mailing list