librtree 1.0.1 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/ext/rtree/rtree.c CHANGED
@@ -84,7 +84,7 @@ static VALUE rt_add_rect(VALUE self, VALUE id_obj, VALUE coord_obj)
84
84
  id = FIX2ULONG(id_obj);
85
85
  size_t
86
86
  len = RARRAY_LEN(coord_obj),
87
- dim = state_dims(rtree->state);
87
+ dim = rtree_dims(rtree);
88
88
 
89
89
  if (len != 2 * dim)
90
90
  rb_raise(rb_eArgError, "expected array length %zi, got %zi", 2 * dim, len);
@@ -138,7 +138,7 @@ static VALUE rt_update(VALUE self)
138
138
  rtree_t *rtree;
139
139
  TypedData_Get_Struct(self, rtree_t, &rtree_type, rtree);
140
140
 
141
- size_t len = 2 * state_dims(rtree->state);
141
+ size_t len = 2 * rtree_dims(rtree);
142
142
  int err = rtree_update(rtree, update_cb, &len);
143
143
 
144
144
  if (err != 0)
@@ -176,7 +176,7 @@ static VALUE rt_search(VALUE self, VALUE coord_obj)
176
176
 
177
177
  size_t
178
178
  len = RARRAY_LEN(coord_obj),
179
- dim = state_dims(rtree->state);
179
+ dim = rtree_dims(rtree);
180
180
 
181
181
  if (len != 2 * dim)
182
182
  rb_raise(rb_eArgError, "expected array length %zi, got %zi", 2 * dim, len);
@@ -322,48 +322,48 @@ static VALUE rt_clone(VALUE self)
322
322
  return TypedData_Wrap_Struct(CLASS_OF(self), &rtree_type, clone);
323
323
  }
324
324
 
325
- static VALUE state_size_access(VALUE self, size_t (*f)(const state_t*))
325
+ static VALUE state_size_access(VALUE self, size_t (*f)(const rtree_t*))
326
326
  {
327
327
  rtree_t *rtree;
328
328
  TypedData_Get_Struct(self, rtree_t, &rtree_type, rtree);
329
- return INT2NUM(f(rtree->state));
329
+ return INT2NUM(f(rtree));
330
330
  }
331
331
 
332
332
  static VALUE rt_dim(VALUE self)
333
333
  {
334
- return state_size_access(self, state_dims);
334
+ return state_size_access(self, rtree_dims);
335
335
  }
336
336
 
337
337
  static VALUE rt_page_size(VALUE self)
338
338
  {
339
- return state_size_access(self, state_page_size);
339
+ return state_size_access(self, rtree_page_size);
340
340
  }
341
341
 
342
342
  static VALUE rt_node_size(VALUE self)
343
343
  {
344
- return state_size_access(self, state_node_size);
344
+ return state_size_access(self, rtree_node_size);
345
345
  }
346
346
 
347
347
  static VALUE rt_rect_size(VALUE self)
348
348
  {
349
- return state_size_access(self, state_rect_size);
349
+ return state_size_access(self, rtree_rect_size);
350
350
  }
351
351
 
352
352
  static VALUE rt_branch_size(VALUE self)
353
353
  {
354
- return state_size_access(self, state_branch_size);
354
+ return state_size_access(self, rtree_branch_size);
355
355
  }
356
356
 
357
357
  static VALUE rt_branching_factor(VALUE self)
358
358
  {
359
- return state_size_access(self, state_branching_factor);
359
+ return state_size_access(self, rtree_branching_factor);
360
360
  }
361
361
 
362
362
  static VALUE rt_unit_sphere_volume(VALUE self)
363
363
  {
364
364
  rtree_t *rtree;
365
365
  TypedData_Get_Struct(self, rtree_t, &rtree_type, rtree);
366
- return DBL2NUM(state_unit_sphere_volume(rtree->state));
366
+ return DBL2NUM(rtree_unit_sphere_volume(rtree));
367
367
  }
368
368
 
369
369
  static VALUE rt_size(VALUE self)
@@ -398,8 +398,8 @@ static VALUE rt_postscript(VALUE self,
398
398
  rtree_t *rtree;
399
399
  TypedData_Get_Struct(self, rtree_t, &rtree_type, rtree);
400
400
 
401
- style_t *style;
402
- TypedData_Get_Struct(style_obj, style_t, &style_type, style);
401
+ postscript_style_t *style;
402
+ TypedData_Get_Struct(style_obj, postscript_style_t, &style_type, style);
403
403
 
404
404
  Check_Type(io_obj, T_FILE);
405
405
  rb_io_t *io;
@@ -453,13 +453,13 @@ static rb_data_type_t rtree_type = {
453
453
 
454
454
  static void st_dfree(void *p)
455
455
  {
456
- postscript_style_destroy((style_t*)p);
456
+ postscript_style_destroy((postscript_style_t*)p);
457
457
  }
458
458
 
459
459
  static VALUE st_release(VALUE self)
460
460
  {
461
- style_t *style;
462
- TypedData_Get_Struct(self, style_t, &style_type, style);
461
+ postscript_style_t *style;
462
+ TypedData_Get_Struct(self, postscript_style_t, &style_type, style);
463
463
  postscript_style_destroy(style);
464
464
  return self;
465
465
  }
@@ -474,7 +474,7 @@ static VALUE st_json_read(VALUE cls, VALUE io_obj)
474
474
  rb_io_check_readable(io);
475
475
  FILE *fp = rb_io_stdio_file(io);
476
476
 
477
- style_t *style;
477
+ postscript_style_t *style;
478
478
  errno = 0;
479
479
 
480
480
  if ((style = postscript_style_read(fp)) == NULL)
data/lib/rtree.rb CHANGED
@@ -103,7 +103,7 @@ class RTree < RTreeBase
103
103
  wr.close
104
104
  unset_nonblock(rd)
105
105
  begin
106
- result = rd.read
106
+ result = rd.read || raise(IOError, 'reading from pipe')
107
107
  ensure
108
108
  rd.close
109
109
  Process.wait
@@ -233,19 +233,12 @@ class RTree < RTreeBase
233
233
  # https://stackoverflow.com/questions/68122256/ It's still not
234
234
  # clear to me why this qualification is needed, but that's a
235
235
  # problem with my understanding of the Ruby Eigenclass, it is
236
- # the expected behaviour
236
+ # the expected behaviour. Note that self.const_get(:FOO) is
237
+ # the same as self::FOO, but the latter gives a spurious
238
+ # type-warning from steep
237
239
  #
238
240
  def split_flag(split)
239
- case split
240
- when :quadratic
241
- self::SPLIT_QUADRATIC
242
- when :linear
243
- self::SPLIT_LINEAR
244
- when :greene
245
- self::SPLIT_GREENE
246
- else
247
- raise ArgumentError, "bad split value: #{split}"
248
- end
241
+ self.const_get(split_symbol(split))
249
242
  end
250
243
 
251
244
  # @!visibility private
@@ -256,10 +249,22 @@ class RTree < RTreeBase
256
249
 
257
250
  private
258
251
 
259
- def deserialise(*args, &block)
260
- RTree::IOUtil.deserialise(*args, &block)
252
+ def deserialise(string, encoding, &block)
253
+ RTree::IOUtil.deserialise(string, encoding, &block)
261
254
  end
262
255
 
256
+ def split_symbol(split)
257
+ case split
258
+ when :quadratic
259
+ :SPLIT_QUADRATIC
260
+ when :linear
261
+ :SPLIT_LINEAR
262
+ when :greene
263
+ :SPLIT_GREENE
264
+ else
265
+ raise ArgumentError, "bad split value: #{split}"
266
+ end
267
+ end
263
268
  end
264
269
 
265
270
  # Initialize a new (empty) RTree
@@ -512,8 +517,8 @@ class RTree < RTreeBase
512
517
  node_page_flag | split_flag
513
518
  end
514
519
 
515
- def serialise(*args, &block)
516
- RTree::IOUtil.serialise(*args, &block)
520
+ def serialise(encoding, &block)
521
+ RTree::IOUtil.serialise(encoding, &block)
517
522
  end
518
523
 
519
524
  end
@@ -576,8 +581,8 @@ class RTree::Style < RTreeStyleBase
576
581
 
577
582
  private
578
583
 
579
- def deserialise(*args, &block)
580
- RTree::IOUtil.deserialise(*args, &block)
584
+ def deserialise(string, encoding, &block)
585
+ RTree::IOUtil.deserialise(string, encoding, &block)
581
586
  end
582
587
 
583
588
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: librtree
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
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: 2023-03-16 00:00:00.000000000 Z
11
+ date: 2023-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,6 +108,34 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.1'
111
+ - !ruby/object:Gem::Dependency
112
+ name: steep
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.4'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.4'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rbs
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '3.2'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '3.2'
111
139
  description: |
112
140
  A Ruby extension implementing the R-tree spatial-index of
113
141
  Guttman-Green.
@@ -126,7 +154,9 @@ files:
126
154
  - ext/rtree/lib/bindex.h
127
155
  - ext/rtree/lib/bounds.h
128
156
  - ext/rtree/lib/branch.c
157
+ - ext/rtree/lib/branch.h
129
158
  - ext/rtree/lib/branches.c
159
+ - ext/rtree/lib/branches.h
130
160
  - ext/rtree/lib/bsrt.c
131
161
  - ext/rtree/lib/bsrt.h
132
162
  - ext/rtree/lib/constants.h
@@ -140,32 +170,34 @@ files:
140
170
  - ext/rtree/lib/mk/MakeDepend
141
171
  - ext/rtree/lib/mk/Obj.mk
142
172
  - ext/rtree/lib/node.c
173
+ - ext/rtree/lib/node.h
143
174
  - ext/rtree/lib/package.c
144
175
  - ext/rtree/lib/page.c
145
176
  - ext/rtree/lib/page.h
146
177
  - ext/rtree/lib/postscript.c
147
178
  - ext/rtree/lib/rect.c
179
+ - ext/rtree/lib/rect.h
148
180
  - ext/rtree/lib/rectf.c
149
181
  - ext/rtree/lib/rtree-base.c
150
182
  - ext/rtree/lib/rtree.h
151
183
  - ext/rtree/lib/rtree/branch.h
152
- - ext/rtree/lib/rtree/branches.h
153
184
  - ext/rtree/lib/rtree/error.h
154
185
  - ext/rtree/lib/rtree/extent.h
155
186
  - ext/rtree/lib/rtree/node.h
156
187
  - ext/rtree/lib/rtree/package.h
157
188
  - ext/rtree/lib/rtree/postscript.h
158
- - ext/rtree/lib/rtree/rect.h
159
189
  - ext/rtree/lib/rtree/rectf.h
160
190
  - ext/rtree/lib/rtree/search.h
161
191
  - ext/rtree/lib/rtree/state.h
162
192
  - ext/rtree/lib/rtree/types.h
163
193
  - ext/rtree/lib/search.c
194
+ - ext/rtree/lib/search.h
164
195
  - ext/rtree/lib/split.c
165
196
  - ext/rtree/lib/split.h
166
197
  - ext/rtree/lib/spvol.c
167
198
  - ext/rtree/lib/spvol.h
168
199
  - ext/rtree/lib/state.c
200
+ - ext/rtree/lib/state.h
169
201
  - ext/rtree/rtree.c
170
202
  - lib/rtree.rb
171
203
  homepage: https://gitlab.com/jjg/librtree-ruby
@@ -189,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
221
  version: '0'
190
222
  requirements:
191
223
  - The Jansson library
192
- rubygems_version: 3.1.6
224
+ rubygems_version: 3.3.7
193
225
  signing_key:
194
226
  specification_version: 4
195
227
  summary: R-tree spatial index