gmt 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/gmt/gmt.c +53 -22
- data/ext/gmt/option.c +4 -4
- data/ext/gmt/option.h +2 -2
- data/lib/gmt.rb +12 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ad7de33d11e4ab6419c28a78a14ba7ae9d5e0418485ab794060f8ca7a5a6f21
|
4
|
+
data.tar.gz: 11e72187266c674aad88d7597f2f50a2b714c2443820564a470bef2a180a5fdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 921660bab096dd80e3908914ceca695090c83c9a7a644be6b594dc51c448c03ae1d6d33de02f5f02dc028ea32496bd672d8ac3ff980d98ee1ec7ed0170788f35
|
7
|
+
data.tar.gz: ffc9d3d9a51563c4e0295ccf7c621053db09fb5c302639dcabe0e516a01c09415670e8eab9f012857b0d4ecfe119a4a38a85c6962b178dc90451951a35a027a3
|
data/ext/gmt/gmt.c
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
#include <ruby.h>
|
2
|
+
#include <ruby/version.h>
|
3
|
+
|
2
4
|
#include <gmt.h>
|
3
5
|
#include <gmt_version.h>
|
4
6
|
|
7
|
+
#include <errno.h>
|
8
|
+
|
5
9
|
#include "option.h"
|
6
10
|
|
7
11
|
#define API_VER(major, minor, release) (10000 * major + 100 * minor + release)
|
@@ -15,17 +19,25 @@ typedef struct
|
|
15
19
|
|
16
20
|
/* helpers */
|
17
21
|
|
18
|
-
static void
|
19
|
-
{
|
20
|
-
if (gmt == NULL)
|
21
|
-
rb_raise(rb_eRuntimeError, "failed fetch of GMT class data");
|
22
|
-
}
|
22
|
+
static void gmt_free(void*);
|
23
23
|
|
24
|
-
static
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
static rb_data_type_t data_type = {
|
25
|
+
.wrap_struct_name = "ruby-gmt-wrap",
|
26
|
+
.function = {
|
27
|
+
.dmark = NULL,
|
28
|
+
.dfree = gmt_free,
|
29
|
+
.dsize = NULL,
|
30
|
+
#if RUBY_API_VERSION_CODE < 20700
|
31
|
+
.reserved = { NULL, NULL }
|
32
|
+
#else
|
33
|
+
.dcompact = NULL,
|
34
|
+
.reserved = { NULL }
|
35
|
+
#endif
|
36
|
+
},
|
37
|
+
.parent = NULL,
|
38
|
+
.data = NULL,
|
39
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY
|
40
|
+
};
|
29
41
|
|
30
42
|
/* ruby object interface */
|
31
43
|
|
@@ -38,13 +50,18 @@ static void gmt_free(void *p)
|
|
38
50
|
GMT_Destroy_Session(gmt->session);
|
39
51
|
gmt->session = NULL;
|
40
52
|
}
|
53
|
+
|
54
|
+
free(gmt);
|
41
55
|
}
|
42
56
|
|
43
|
-
static VALUE gmt_alloc(VALUE
|
57
|
+
static VALUE gmt_alloc(VALUE cls)
|
44
58
|
{
|
45
59
|
gmt_t *gmt;
|
46
60
|
|
47
|
-
|
61
|
+
if ((gmt = malloc(sizeof(gmt_t))) == NULL)
|
62
|
+
rb_raise(rb_eNoMemError, "failed to alloc GMT struct");
|
63
|
+
|
64
|
+
VALUE obj = TypedData_Wrap_Struct(cls, &data_type, gmt);
|
48
65
|
|
49
66
|
gmt->session = NULL;
|
50
67
|
|
@@ -55,7 +72,7 @@ static VALUE gmt_init(VALUE self)
|
|
55
72
|
{
|
56
73
|
gmt_t *gmt;
|
57
74
|
|
58
|
-
|
75
|
+
TypedData_Get_Struct(self, gmt_t, &data_type, gmt);
|
59
76
|
|
60
77
|
gmt->session =
|
61
78
|
GMT_Create_Session("Session name", 2, 0, NULL);
|
@@ -70,7 +87,7 @@ static VALUE gmt_release(VALUE self)
|
|
70
87
|
{
|
71
88
|
gmt_t *gmt;
|
72
89
|
|
73
|
-
|
90
|
+
TypedData_Get_Struct(self, gmt_t, &data_type, gmt);
|
74
91
|
|
75
92
|
if (gmt->session)
|
76
93
|
{
|
@@ -89,8 +106,10 @@ static VALUE gmt_simple(const char *name, int argc, VALUE *argv, VALUE self)
|
|
89
106
|
rb_scan_args(argc, argv, "*1", &files, &opts);
|
90
107
|
|
91
108
|
gmt_t *gmt;
|
92
|
-
|
93
|
-
|
109
|
+
TypedData_Get_Struct(self, gmt_t, &data_type, gmt);
|
110
|
+
|
111
|
+
if (gmt == NULL)
|
112
|
+
rb_raise(rb_eRuntimeError, "failed fetch of GMT class data");
|
94
113
|
|
95
114
|
void *session = gmt->session;
|
96
115
|
|
@@ -98,10 +117,22 @@ static VALUE gmt_simple(const char *name, int argc, VALUE *argv, VALUE self)
|
|
98
117
|
gmt_opts = ruby_array_to_gmt_options(opts, session);
|
99
118
|
gmt_opts = append_inputs_to_gmt_options(files, gmt_opts, session);
|
100
119
|
|
120
|
+
errno = 0;
|
101
121
|
int err = GMT_Call_Module(session, name, -1, gmt_opts);
|
122
|
+
int gmt_errno = errno;
|
102
123
|
|
103
124
|
GMT_Destroy_Options(session, &gmt_opts);
|
104
|
-
|
125
|
+
|
126
|
+
if (err != 0)
|
127
|
+
{
|
128
|
+
VALUE gmt_syserr;
|
129
|
+
|
130
|
+
if ((gmt_errno != 0) &&
|
131
|
+
((gmt_syserr = rb_syserr_new(gmt_errno, NULL)) != 0))
|
132
|
+
rb_exc_raise(gmt_syserr);
|
133
|
+
else
|
134
|
+
rb_raise(rb_eRuntimeError, "failed call to GMT module %s", name);
|
135
|
+
}
|
105
136
|
|
106
137
|
return Qtrue;
|
107
138
|
}
|
@@ -114,7 +145,7 @@ static VALUE gmt_simple(const char *name, int argc, VALUE *argv, VALUE self)
|
|
114
145
|
|
115
146
|
The "modern mode" modules (which have a slicker way of routing and
|
116
147
|
combining postscript output) will probably need a different treatment,
|
117
|
-
possibly a more attractive
|
148
|
+
possibly a more attractive one from the Ruby perspective; for now we
|
118
149
|
just limit ourselves to the classic mode.
|
119
150
|
*/
|
120
151
|
|
@@ -218,10 +249,6 @@ GMT_FUN(sphtriangulate)
|
|
218
249
|
|
219
250
|
/* Convert or extract subsets of data */
|
220
251
|
|
221
|
-
#if API_AT_LEAST(6, 2, 0)
|
222
|
-
GMT_FUN(gmtbinstats)
|
223
|
-
#endif
|
224
|
-
|
225
252
|
GMT_FUN(gmtconnect)
|
226
253
|
GMT_FUN(gmtconvert)
|
227
254
|
GMT_FUN(gmtselect)
|
@@ -241,6 +268,10 @@ GMT_FUN(grd2kml)
|
|
241
268
|
GMT_FUN(grd2rgb) /* https://github.com/GenericMappingTools/gmt/pull/425 */
|
242
269
|
#endif
|
243
270
|
|
271
|
+
#if API_AT_LEAST(6, 2, 0)
|
272
|
+
GMT_FUN(gmtbinstats)
|
273
|
+
#endif
|
274
|
+
|
244
275
|
/* trends in 1-D and 2-D data */
|
245
276
|
|
246
277
|
GMT_FUN(fitcircle)
|
data/ext/gmt/option.c
CHANGED
@@ -32,7 +32,7 @@ static gmt_option_t* append_option(void *session,
|
|
32
32
|
return GMT_Append_Option(session, gmt_opt, gmt_opts);
|
33
33
|
}
|
34
34
|
|
35
|
-
|
35
|
+
gmt_option_t* ruby_array_to_gmt_options(VALUE opts, void *session)
|
36
36
|
{
|
37
37
|
if (TYPE(opts) != T_ARRAY)
|
38
38
|
rb_raise(rb_eArgError, "options should be an array");
|
@@ -74,9 +74,9 @@ extern gmt_option_t* ruby_array_to_gmt_options(VALUE opts, void *session)
|
|
74
74
|
return gmt_opts;
|
75
75
|
}
|
76
76
|
|
77
|
-
|
78
|
-
|
79
|
-
|
77
|
+
gmt_option_t* append_inputs_to_gmt_options(VALUE files,
|
78
|
+
gmt_option_t *gmt_opts,
|
79
|
+
void *session)
|
80
80
|
{
|
81
81
|
if (TYPE(files) != T_ARRAY)
|
82
82
|
rb_raise(rb_eArgError, "inputs should be an array");
|
data/ext/gmt/option.h
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
typedef struct GMT_OPTION gmt_option_t;
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
gmt_option_t* ruby_array_to_gmt_options(VALUE, void*);
|
18
|
+
gmt_option_t* append_inputs_to_gmt_options(VALUE, gmt_option_t*, void*);
|
19
19
|
|
20
20
|
#endif
|
data/lib/gmt.rb
CHANGED
@@ -66,6 +66,18 @@
|
|
66
66
|
#
|
67
67
|
# using this format.
|
68
68
|
#
|
69
|
+
# One occasionally has need for multiple calls to the same option: the
|
70
|
+
# <code>-B</code> option being the usual culprit. In this case, use a single
|
71
|
+
# <code>:B</code> key and an array of the arguments:
|
72
|
+
#
|
73
|
+
# B: [
|
74
|
+
# 'xa%g+l%s' % [dx, x_label],
|
75
|
+
# 'ya%g+l%s' % [dy, y_label],
|
76
|
+
# 'nWeS'
|
77
|
+
# ], ...
|
78
|
+
#
|
79
|
+
# for example.
|
80
|
+
#
|
69
81
|
# == PostScript functions
|
70
82
|
#
|
71
83
|
# When creating complex PostScript plots one needs to make several calls to
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gmt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- J.J. Green
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -131,7 +131,7 @@ requirements:
|
|
131
131
|
- GMT5/6 development libraries (compile)
|
132
132
|
- GMT5/6 installation (test)
|
133
133
|
- ghostscript (test)
|
134
|
-
rubygems_version: 3.
|
134
|
+
rubygems_version: 3.2.3
|
135
135
|
signing_key:
|
136
136
|
specification_version: 4
|
137
137
|
summary: Generic Mapping Tools (GMT)
|