librtree 0.8.9 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/rtree/extconf.rb +2 -4
- data/ext/rtree/rtree.c +2 -1
- data/lib/rtree.rb +79 -69
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ea7105c3090ca70b99cec081b01ed6f46490208e79ee6ecdaf9045b827280ca
|
4
|
+
data.tar.gz: 7071f07e2e9ced00f34d48764e229057a9b69cec6e57b003babc27b5577e5372
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f96d9eb0c8d21ef03a8d716f544ec34d84dabe4f598e606af99184e7cfb951c5a80f55e058b0d20ebafd4d2f173bae76bf230fac8489d8e71cbbe2a57c5170fa
|
7
|
+
data.tar.gz: cd2d89976e36b6c0aadf7b0d95c823c4f39869d480886746aa8e1f2a402bdaf7e9f7e0b87695beacd75aad7655bfeaa8b65bca11fed80e9a15464de854da3a94
|
data/ext/rtree/extconf.rb
CHANGED
@@ -16,14 +16,12 @@ LIB_DIRS = [
|
|
16
16
|
'/usr/lib'
|
17
17
|
]
|
18
18
|
|
19
|
-
puts LIB_DIRS.inspect
|
20
|
-
|
21
19
|
dir_config('librtree', HEADER_DIRS, LIB_DIRS)
|
22
20
|
|
23
21
|
abort 'missing jansson.h' unless find_header('jansson.h')
|
24
22
|
abort 'missing rtree.h' unless find_header('rtree.h')
|
25
23
|
|
26
|
-
abort
|
27
|
-
abort
|
24
|
+
abort 'libjansson is missing' unless find_library('jansson', 'json_pack')
|
25
|
+
abort 'librtree is missing' unless find_library('rtree', 'rtree_new')
|
28
26
|
|
29
27
|
create_makefile 'rtree/rtree'
|
data/ext/rtree/rtree.c
CHANGED
@@ -24,7 +24,7 @@ static size_t rt_dsize(const void *p)
|
|
24
24
|
|
25
25
|
static VALUE rt_alloc(VALUE cls)
|
26
26
|
{
|
27
|
-
rtree_t *rtree
|
27
|
+
rtree_t *rtree;
|
28
28
|
if ((rtree = rtree_alloc()) == NULL)
|
29
29
|
rb_raise(rb_eNoMemError, "failed to alloc rtree");
|
30
30
|
return TypedData_Wrap_Struct(cls, &rtree_type, rtree);
|
@@ -534,6 +534,7 @@ void Init_rtree(void)
|
|
534
534
|
|
535
535
|
VALUE cRTreeStyleBase = rb_const_get(rb_cObject, rb_intern("RTreeStyleBase"));
|
536
536
|
|
537
|
+
rb_undef_alloc_func(cRTreeStyleBase);
|
537
538
|
rb_define_method(cRTreeStyleBase, "free", st_release, 0);
|
538
539
|
rb_define_singleton_method(cRTreeStyleBase, "json_read", st_json_read, 1);
|
539
540
|
}
|
data/lib/rtree.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# @!visibility private
|
2
4
|
#
|
3
5
|
class RTreeBase ; end
|
4
6
|
|
5
|
-
#
|
7
|
+
# @!visibility private
|
6
8
|
#
|
7
9
|
class RTreeStyleBase ; end
|
8
10
|
|
@@ -62,25 +64,78 @@ require 'fcntl'
|
|
62
64
|
#
|
63
65
|
class RTree < RTreeBase
|
64
66
|
|
67
|
+
# @!visibility private
|
68
|
+
#
|
65
69
|
module IOUtil
|
70
|
+
extend self
|
71
|
+
|
72
|
+
# @!visibility private
|
73
|
+
#
|
74
|
+
def deserialise(string, encoding)
|
75
|
+
raise TypeError unless string.is_a? String
|
76
|
+
rd, wr = IO.pipe(encoding)
|
77
|
+
if fork then
|
78
|
+
wr.close
|
79
|
+
unset_nonblock(rd)
|
80
|
+
begin
|
81
|
+
result = yield(rd)
|
82
|
+
ensure
|
83
|
+
rd.close
|
84
|
+
Process.wait
|
85
|
+
end
|
86
|
+
else
|
87
|
+
rd.close
|
88
|
+
begin
|
89
|
+
wr.write(string)
|
90
|
+
ensure
|
91
|
+
wr.close
|
92
|
+
exit!
|
93
|
+
end
|
94
|
+
end
|
95
|
+
result
|
96
|
+
end
|
97
|
+
|
98
|
+
# @!visibility private
|
99
|
+
#
|
100
|
+
def serialise(encoding)
|
101
|
+
rd, wr = IO.pipe(encoding)
|
102
|
+
if fork then
|
103
|
+
wr.close
|
104
|
+
unset_nonblock(rd)
|
105
|
+
begin
|
106
|
+
result = rd.read
|
107
|
+
ensure
|
108
|
+
rd.close
|
109
|
+
Process.wait
|
110
|
+
end
|
111
|
+
else
|
112
|
+
rd.close
|
113
|
+
begin
|
114
|
+
yield(wr)
|
115
|
+
ensure
|
116
|
+
wr.close
|
117
|
+
exit!
|
118
|
+
end
|
119
|
+
end
|
120
|
+
result
|
121
|
+
end
|
66
122
|
|
67
123
|
private
|
68
124
|
|
69
125
|
# In Ruby 3, the Fibres facility exploits non-blocking IO and so pipes
|
70
126
|
# are non-blocking by default, this buggers-up the deserialise method
|
71
127
|
# since there is short delay forking here -- so we reinstate blocking
|
72
|
-
# with some fairly low-level fcntl
|
128
|
+
# with some fairly low-level fcntl(2) magic.
|
73
129
|
|
74
130
|
def unset_nonblock(fd)
|
75
|
-
|
76
|
-
|
77
|
-
|
131
|
+
fd.fcntl(
|
132
|
+
Fcntl::F_SETFL,
|
133
|
+
fd.fcntl(Fcntl::F_GETFL, 0) & ~Fcntl::O_NONBLOCK
|
134
|
+
)
|
78
135
|
end
|
79
136
|
|
80
137
|
end
|
81
138
|
|
82
|
-
extend IOUtil
|
83
|
-
|
84
139
|
class << self
|
85
140
|
|
86
141
|
# Create a new RTree instance from JSON stream
|
@@ -201,29 +256,10 @@ class RTree < RTreeBase
|
|
201
256
|
|
202
257
|
private
|
203
258
|
|
204
|
-
def deserialise(
|
205
|
-
|
206
|
-
rd, wr = IO.pipe(encoding)
|
207
|
-
unset_nonblock(rd)
|
208
|
-
if fork then
|
209
|
-
wr.close
|
210
|
-
begin
|
211
|
-
result = yield(rd)
|
212
|
-
ensure
|
213
|
-
rd.close
|
214
|
-
Process.wait
|
215
|
-
end
|
216
|
-
else
|
217
|
-
rd.close
|
218
|
-
begin
|
219
|
-
wr.write(string)
|
220
|
-
ensure
|
221
|
-
wr.close
|
222
|
-
exit!
|
223
|
-
end
|
224
|
-
end
|
225
|
-
result
|
259
|
+
def deserialise(*args, &block)
|
260
|
+
RTree::IOUtil.deserialise(*args, &block)
|
226
261
|
end
|
262
|
+
|
227
263
|
end
|
228
264
|
|
229
265
|
# Initialize a new (empty) RTree
|
@@ -235,7 +271,7 @@ class RTree < RTreeBase
|
|
235
271
|
# @param node_page [Integer] the nodes-per-page value. This value can
|
236
272
|
# affect performance quite dramatically, particularly build time. A
|
237
273
|
# value which is too large would result in an infeasible branching
|
238
|
-
# factor for the R-tree and will
|
274
|
+
# factor for the R-tree and will cause the function to error with errno
|
239
275
|
# set to EINVAL. A value of zero is permitted and the default; in
|
240
276
|
# this case the function will choose a good value based on heuristics.
|
241
277
|
# You may get better performance for your use-case by manual
|
@@ -319,7 +355,7 @@ class RTree < RTreeBase
|
|
319
355
|
# @return [Boolean] true if the RTree is empty
|
320
356
|
#
|
321
357
|
def empty?
|
322
|
-
height
|
358
|
+
height.zero?
|
323
359
|
end
|
324
360
|
|
325
361
|
# Serialise to JSON stream
|
@@ -434,6 +470,7 @@ class RTree < RTreeBase
|
|
434
470
|
end
|
435
471
|
|
436
472
|
# Create a PostScript plot of the RTree
|
473
|
+
#
|
437
474
|
# @param io [IO] a writeable stream object
|
438
475
|
# @param style [RTree::Style] a style object describing the fill
|
439
476
|
# colour and stroke width and colour for each level of the tree.
|
@@ -475,21 +512,10 @@ class RTree < RTreeBase
|
|
475
512
|
node_page_flag | split_flag
|
476
513
|
end
|
477
514
|
|
478
|
-
def serialise(
|
479
|
-
|
480
|
-
if fork then
|
481
|
-
wr.close
|
482
|
-
result = rd.read
|
483
|
-
rd.close
|
484
|
-
Process.wait
|
485
|
-
else
|
486
|
-
rd.close
|
487
|
-
yield(wr)
|
488
|
-
wr.close
|
489
|
-
exit!
|
490
|
-
end
|
491
|
-
result
|
515
|
+
def serialise(*args, &block)
|
516
|
+
RTree::IOUtil.serialise(*args, &block)
|
492
517
|
end
|
518
|
+
|
493
519
|
end
|
494
520
|
|
495
521
|
# @author RTree::Style J. J. Green
|
@@ -499,8 +525,6 @@ end
|
|
499
525
|
#
|
500
526
|
class RTree::Style < RTreeStyleBase
|
501
527
|
|
502
|
-
extend RTree::IOUtil
|
503
|
-
|
504
528
|
class << self
|
505
529
|
|
506
530
|
# Create a new Style instance from JSON stream
|
@@ -521,27 +545,7 @@ class RTree::Style < RTreeStyleBase
|
|
521
545
|
# @see .json_read
|
522
546
|
#
|
523
547
|
def from_json(json)
|
524
|
-
|
525
|
-
rd, wr = IO.pipe(Encoding::UTF_8)
|
526
|
-
unset_nonblock(rd)
|
527
|
-
if fork then
|
528
|
-
wr.close
|
529
|
-
begin
|
530
|
-
result = json_read(rd)
|
531
|
-
ensure
|
532
|
-
rd.close
|
533
|
-
Process.wait
|
534
|
-
end
|
535
|
-
else
|
536
|
-
rd.close
|
537
|
-
begin
|
538
|
-
wr.write(json)
|
539
|
-
ensure
|
540
|
-
wr.close
|
541
|
-
exit!
|
542
|
-
end
|
543
|
-
end
|
544
|
-
result
|
548
|
+
deserialise(json, Encoding::UTF_8) { |io| json_read(io) }
|
545
549
|
end
|
546
550
|
|
547
551
|
# Create a new Style instance from array of Hash
|
@@ -570,5 +574,11 @@ class RTree::Style < RTreeStyleBase
|
|
570
574
|
|
571
575
|
alias_method :from_array, :from_a
|
572
576
|
|
577
|
+
private
|
578
|
+
|
579
|
+
def deserialise(*args, &block)
|
580
|
+
RTree::IOUtil.deserialise(*args, &block)
|
581
|
+
end
|
582
|
+
|
573
583
|
end
|
574
584
|
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: 0.
|
4
|
+
version: 0.9.1
|
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: 2023-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2'
|
19
|
+
version: '2.1'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2'
|
26
|
+
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
47
|
+
version: '3.10'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
54
|
+
version: '3.10'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: yard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,30 +70,30 @@ dependencies:
|
|
70
70
|
name: rubygems-tasks
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.2
|
75
|
+
version: '0.2'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.2
|
82
|
+
version: '0.2'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rake-compiler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '1'
|
89
|
+
version: '1.1'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '1'
|
96
|
+
version: '1.1'
|
97
97
|
description: |
|
98
98
|
A Ruby extension implementing the R-tree spatial-index of
|
99
99
|
Guttman-Green.
|
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
127
|
version: '0'
|
128
128
|
requirements:
|
129
129
|
- The librtree library (1.0.6 or later)
|
130
|
-
rubygems_version: 3.
|
130
|
+
rubygems_version: 3.1.6
|
131
131
|
signing_key:
|
132
132
|
specification_version: 4
|
133
133
|
summary: R-tree spatial index
|