librtree 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/rtree/rtree.c +53 -1
- data/lib/rtree.rb +42 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f559b211be3e93ded31a86b61c68ea28cdea151ef62d0c64a79aa38131fa5a7
|
4
|
+
data.tar.gz: 7df99f8990a461d60e2276a20891be62c1dc27e6279a2226f2fec6d63d30f5dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6c204e2ba3a7b26fe2ab8ba1148b159a21cc697061d672fa2ccff85924dc56c2a9f19b6241d68e5ec96e3b5f955ffc617ecfc26bc9db94cb0f2190e3178e693
|
7
|
+
data.tar.gz: c831af24c76a719bfae623a5b525840cf910065426833589d8c04160524e576daf4ad13daf2793387931599187ad80f6bc596aaf21b72334e5230a449cda818d
|
data/ext/rtree/rtree.c
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
typedef struct
|
10
10
|
{
|
11
|
-
|
11
|
+
rtree_t *rtree;
|
12
12
|
} lrt_t;
|
13
13
|
|
14
14
|
static void lrt_free(void *p)
|
@@ -341,6 +341,51 @@ static VALUE lrt_clone(VALUE self)
|
|
341
341
|
return obj;
|
342
342
|
}
|
343
343
|
|
344
|
+
static VALUE state_size_access(VALUE self, size_t (*f)(const state_t*))
|
345
|
+
{
|
346
|
+
lrt_t *lrt;
|
347
|
+
Data_Get_Struct(self, lrt_t, lrt);
|
348
|
+
return INT2NUM(f(lrt->rtree->state));
|
349
|
+
}
|
350
|
+
|
351
|
+
static VALUE lrt_dim(VALUE self)
|
352
|
+
{
|
353
|
+
return state_size_access(self, state_dims);
|
354
|
+
}
|
355
|
+
|
356
|
+
static VALUE lrt_page_size(VALUE self)
|
357
|
+
{
|
358
|
+
return state_size_access(self, state_page_size);
|
359
|
+
}
|
360
|
+
|
361
|
+
static VALUE lrt_node_size(VALUE self)
|
362
|
+
{
|
363
|
+
return state_size_access(self, state_node_size);
|
364
|
+
}
|
365
|
+
|
366
|
+
static VALUE lrt_rect_size(VALUE self)
|
367
|
+
{
|
368
|
+
return state_size_access(self, state_rect_size);
|
369
|
+
}
|
370
|
+
|
371
|
+
static VALUE lrt_branch_size(VALUE self)
|
372
|
+
{
|
373
|
+
return state_size_access(self, state_branch_size);
|
374
|
+
}
|
375
|
+
|
376
|
+
static VALUE lrt_branching_factor(VALUE self)
|
377
|
+
{
|
378
|
+
return state_size_access(self, state_branching_factor);
|
379
|
+
}
|
380
|
+
|
381
|
+
static VALUE lrt_unit_sphere_volume(VALUE self)
|
382
|
+
{
|
383
|
+
lrt_t *lrt;
|
384
|
+
Data_Get_Struct(self, lrt_t, lrt);
|
385
|
+
return DBL2NUM(state_unit_sphere_volume(lrt->rtree->state));
|
386
|
+
}
|
387
|
+
|
388
|
+
|
344
389
|
void Init_rtree(void)
|
345
390
|
{
|
346
391
|
VALUE cls = rb_const_get(rb_cObject, rb_intern("RTreeC"));
|
@@ -356,6 +401,13 @@ void Init_rtree(void)
|
|
356
401
|
rb_define_method(cls, "json_write", lrt_json_write, 1);
|
357
402
|
rb_define_method(cls, "bsrt_write", lrt_bsrt_write, 1);
|
358
403
|
rb_define_method(cls, "eq?", lrt_identical, 1);
|
404
|
+
rb_define_method(cls, "dim", lrt_dim, 0);
|
405
|
+
rb_define_method(cls, "page_size", lrt_page_size, 0);
|
406
|
+
rb_define_method(cls, "node_size", lrt_node_size, 0);
|
407
|
+
rb_define_method(cls, "rect_size", lrt_rect_size, 0);
|
408
|
+
rb_define_method(cls, "branch_size", lrt_branch_size, 0);
|
409
|
+
rb_define_method(cls, "branching_factor", lrt_branching_factor, 0);
|
410
|
+
rb_define_method(cls, "unit_sphere_volume", lrt_unit_sphere_volume, 0);
|
359
411
|
rb_define_singleton_method(cls, "json_read", lrt_json_read, 1);
|
360
412
|
rb_define_singleton_method(cls, "bsrt_read", lrt_bsrt_read, 1);
|
361
413
|
rb_define_singleton_method(cls, "csv_read", lrt_csv_read, 3);
|
data/lib/rtree.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# The C
|
1
|
+
# The Ruby/C interface, which is not documented in YARD.
|
2
2
|
class RTreeC ; end
|
3
3
|
|
4
4
|
# @author RTree J. J. Green
|
@@ -233,7 +233,7 @@ class RTree < RTreeC
|
|
233
233
|
# is much faster than rebuilding the R-tree; in this Ruby interface
|
234
234
|
# the callback must convert C floats to Ruby, yield them to the
|
235
235
|
# block and then convert the returned Ruby Floats to C; so we would
|
236
|
-
# expect that it loses much of its
|
236
|
+
# expect that it loses much of its competitive advantage when
|
237
237
|
# compared to an R-tree rebuild.
|
238
238
|
def update!
|
239
239
|
super
|
@@ -252,7 +252,7 @@ class RTree < RTreeC
|
|
252
252
|
end
|
253
253
|
|
254
254
|
# Serialise to JSON stream
|
255
|
-
# @param io [IO] a
|
255
|
+
# @param io [IO] a writable stream
|
256
256
|
# @return [self]
|
257
257
|
# @see .json_read
|
258
258
|
# @example Write to file
|
@@ -262,7 +262,7 @@ class RTree < RTreeC
|
|
262
262
|
end
|
263
263
|
|
264
264
|
# Serialise to BSRT (binary serialised R-tree) stream
|
265
|
-
# @param io [IO] a
|
265
|
+
# @param io [IO] a writable stream
|
266
266
|
# @return [self]
|
267
267
|
# @see .bsrt_read
|
268
268
|
# @example Write to file
|
@@ -292,7 +292,7 @@ class RTree < RTreeC
|
|
292
292
|
end
|
293
293
|
|
294
294
|
# Equality of RTrees. This is a rather strict equality,
|
295
|
-
# not only must the tree have the same
|
295
|
+
# not only must the tree have the same rectangles, they
|
296
296
|
# must be in the same order. Certainly {#clone} will produce
|
297
297
|
# an instance which is equal in this sense.
|
298
298
|
# @return [Boolean] true if the instances are identical
|
@@ -302,6 +302,42 @@ class RTree < RTreeC
|
|
302
302
|
|
303
303
|
alias_method(:==, :eq?)
|
304
304
|
|
305
|
+
# @return [Integer] the dimension of the R-tree
|
306
|
+
def dim
|
307
|
+
super
|
308
|
+
end
|
309
|
+
|
310
|
+
# @return [Integer] the bytes in a page of memory
|
311
|
+
def page_size
|
312
|
+
super
|
313
|
+
end
|
314
|
+
|
315
|
+
# @return [Integer] the size in bytes of a node
|
316
|
+
def node_size
|
317
|
+
super
|
318
|
+
end
|
319
|
+
|
320
|
+
# @return [Integer] the size in bytes of a rectangle
|
321
|
+
def rect_size
|
322
|
+
super
|
323
|
+
end
|
324
|
+
|
325
|
+
# @return [Integer] the size in bytes of a branch
|
326
|
+
def branch_size
|
327
|
+
super
|
328
|
+
end
|
329
|
+
|
330
|
+
# @return [Integer] the number of branches from each node
|
331
|
+
def branching_factor
|
332
|
+
super
|
333
|
+
end
|
334
|
+
|
335
|
+
# @return [Float] the volume of the unit sphere in the R-tree's
|
336
|
+
# dimension
|
337
|
+
def unit_sphere_volume
|
338
|
+
super
|
339
|
+
end
|
340
|
+
|
305
341
|
private
|
306
342
|
|
307
343
|
attr_reader :split, :node_page
|
@@ -334,6 +370,7 @@ class RTree < RTreeC
|
|
334
370
|
result
|
335
371
|
end
|
336
372
|
|
373
|
+
|
337
374
|
end
|
338
375
|
|
339
376
|
require 'rtree/rtree'
|
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: 0.8.
|
4
|
+
version: 0.8.2
|
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: 2021-05-
|
11
|
+
date: 2021-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|