librtree 1.0.6 → 1.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d23f82b41d0757dbca1d30fc447bd2573db6d1584727c3244c84bbae0bc6b83
4
- data.tar.gz: 36b7cda50a05140949537890a4ab99ebc555f08d7f7789cd7d4d0bd14c7b4c27
3
+ metadata.gz: 8f4355feb78dc5d06882ae60a9dccaa1a3aa3946e3bafd36c83bd156e0c75999
4
+ data.tar.gz: 2ba67193b74dffcc28c692651395378a07396815b8183622cf53e99ae85b0161
5
5
  SHA512:
6
- metadata.gz: 5ad5636536266f5ac027bd9f7ee59b359f4a3b00c07107057c7b83d378122be21343ebb54db36fe0e7683c926e674a7c8e4f3a6013b4a38c3019078851995c38
7
- data.tar.gz: 22292e552cd05823802107094df3ff12c0a0a04129e26dd0fe8a9dd1c1b966f47b1b1cf4a1ac046f0965710965235c5e3a195c4de87b5612aa968e042a3c38fb
6
+ metadata.gz: '070128ec3f09d7e7d9afdd72a1a1c883aa4acabde300b3a6093a5437a8c95b0a0d527339b48930f048f8925d10ef2d9aff34604bfe8e8c9545327b9082fdb584'
7
+ data.tar.gz: 9958de3a7289de82051876d54968e48cb1350d15e20257e87ce162875dbdabf9ea12501cc9502b345ff10a470248275682ed78f906c211aa2e14acda3446d027
data/CHANGELOG.md CHANGED
@@ -1,9 +1,18 @@
1
1
  Changelog
2
2
  ---------
3
3
 
4
+ ### 1.0.8, 12-10-2026
5
+
6
+ - Update to librtree 1.3.3
7
+
8
+ ### 1.0.7, 20-01-2026
9
+
10
+ - Spelling
11
+ - Tested on Ruby 3.4, 4.0
12
+
4
13
  ### 1.0.6, 07-04-2024
5
14
 
6
- - Update to librtree 1.3.0
15
+ - Update to librtree 1.3.2
7
16
  - Adds `#envelope` `#csv_write`, `#to_csv`
8
17
 
9
18
  ### 1.0.5, 16-01-2024
@@ -62,7 +71,7 @@ Changelog
62
71
  ### 0.8.8, 14-07-2021
63
72
 
64
73
  - De-nest C base-class for neater documentation
65
- - Adopt "standard" naming-convention for the benfit of Yard
74
+ - Adopt "standard" naming-convention for the benefit of Yard
66
75
  introspection
67
76
  - No functional changes
68
77
 
data/README.md CHANGED
@@ -54,12 +54,12 @@ this.
54
54
  If using [rbenv][4], then first set a local version of Ruby to use,
55
55
  then install the gems into your local cache
56
56
 
57
- rbenv local 3.2.0
57
+ rbenv local 4.0.2
58
58
  bundle install
59
59
 
60
60
  The repository's `.gitignore` ignores **rbenv**'s `.ruby-version` file,
61
61
  since we don't want to mandate a particular Ruby version for the package
62
- (although 3.0 is the minimal version for development at present).
62
+ (although 3.1 is the minimal version for development at present).
63
63
 
64
64
  If not using **rbenv** then just
65
65
 
@@ -83,6 +83,6 @@ run the tests:
83
83
 
84
84
 
85
85
  [1]: http://www.digip.org/jansson/
86
- [3]: http://soliton.vm.bytemark.co.uk/pub/jjg/en/code/librtree/
86
+ [3]: https://jjg.gitlab.io/en/code/librtree/
87
87
  [4]: https://github.com/rbenv/rbenv
88
88
  [5]: https://www.rubydoc.info/gems/librtree/RTree
@@ -70,7 +70,7 @@ static size_t first_unset(const unsigned long *words, size_t n_bits)
70
70
 
71
71
  for (size_t j = 0 ; j < n_words ; j++)
72
72
  {
73
- unsigned long word = ~words[j];
73
+ unsigned long word = ~(words[j]);
74
74
 
75
75
  if (word)
76
76
  {
@@ -2,7 +2,7 @@
2
2
  The code here is to handle a void* buffer as an array of branch,
3
3
  we can't actually create an array of branch since its size is
4
4
  not known until runtime, so we have to perform those calculations
5
- ourselves. Note that we just do the arithmatic here, no error
5
+ ourselves. Note that we just do the arithmetic here, no error
6
6
  checking -- so a over-sized index to branches_get() will lead to
7
7
  a memory error, the caller is expected to do this check themselves
8
8
  */
data/ext/rtree/lib/bsrt.c CHANGED
@@ -45,17 +45,16 @@ static int write_version(FILE *stream)
45
45
 
46
46
  /* state, 12 bytes */
47
47
 
48
- static int write_state(state_t *state, FILE *stream)
48
+ static int write_state(const state_t *state, FILE *stream)
49
49
  {
50
- uint16_t v[6] =
51
- {
52
- htole16(state_dims(state)),
53
- htole16(state_page_size(state)),
54
- htole16(SIZEOF_RTREE_COORD_T),
55
- htole16(state_rect_size(state)),
56
- htole16(state_branch_size(state)),
57
- htole16(state_node_size(state))
58
- };
50
+ const uint16_t v[6] = {
51
+ htole16(state_dims(state)),
52
+ htole16(state_page_size(state)),
53
+ htole16(SIZEOF_RTREE_COORD_T),
54
+ htole16(state_rect_size(state)),
55
+ htole16(state_branch_size(state)),
56
+ htole16(state_node_size(state))
57
+ };
59
58
 
60
59
  if (fwrite(&v, 2, 6, stream) != 6)
61
60
  return RTREE_ERR_FWRITE;
@@ -94,7 +93,7 @@ static int write_id(rtree_id_t id, FILE *stream)
94
93
  #elif SIZEOF_RTREE_ID_T == 8
95
94
  uint64_t v = htole64(id);
96
95
  #else
97
- #error rtree_id_t size not handled
96
+ #error MSG_RTREE_COORD_SIZE
98
97
  #endif
99
98
 
100
99
  if (fwrite(&v, SIZEOF_RTREE_ID_T, 1, stream) != 1)
@@ -108,7 +107,7 @@ static int write_id(rtree_id_t id, FILE *stream)
108
107
  byte-order is big-endian, this saves time on little-endian
109
108
  hardware. Note that in the big-endian case, we call htole32()
110
109
  which converts from the host integer byte-order to little-endian,
111
- this will only be correct if integer and float endianess are
110
+ this will only be correct if integer and float endianness are
112
111
  the same, this is not true in general (!), there exists real
113
112
  hardware with big-endian floats and little-endian integers.
114
113
  So it would be better to use be32tole32() here, but that does
@@ -140,7 +139,7 @@ static int write_rect(const state_t *state,
140
139
  #elif SIZEOF_RTREE_COORD_T == 8
141
140
  *(uint64_t*)p = htole64(*(uint64_t*)p);
142
141
  #else
143
- #error rtree_coord_t size not handled
142
+ #error MSG_RTREE_COORD_SIZE
144
143
  #endif
145
144
 
146
145
  buffer[i] = *(rtree_coord_t*)p;
@@ -349,7 +348,7 @@ static int read_v1_rect(FILE *stream,
349
348
  #elif SIZEOF_RTREE_COORD_T == 8
350
349
  *(uint64_t*)p = le64toh(*(uint64_t*)p);
351
350
  #else
352
- #error rtree_coord_t size not handled
351
+ #error MSG_RTREE_COORD_SIZE
353
352
  #endif
354
353
 
355
354
  rect[i] = *(rtree_coord_t*)p;
@@ -377,7 +376,7 @@ static int read_v1_id(FILE *stream, rtree_id_t *id)
377
376
  #elif SIZEOF_RTREE_ID_T == 2
378
377
  *id = le16toh(*id);
379
378
  #else
380
- #error rtree_id_t size not handled
379
+ #error MSG_RTREE_COORD_SIZE
381
380
  #endif
382
381
 
383
382
  return 0;
data/ext/rtree/lib/csv.c CHANGED
@@ -5,6 +5,7 @@
5
5
  #include "private/csv.h"
6
6
  #include "private/rtree.h"
7
7
  #include "private/state.h"
8
+ #include "private/message.h"
8
9
 
9
10
  #include "rtree/error.h"
10
11
  #include "rtree/types.h"
@@ -37,7 +38,7 @@ static int parse(FILE *stream, rtree_t *rtree)
37
38
 
38
39
  while (fgets(line, LINE_LEN, stream) != NULL)
39
40
  {
40
- char *tok;
41
+ const char *tok;
41
42
 
42
43
  if ((tok = strtok(line, ",")) == NULL)
43
44
  continue;
@@ -91,12 +92,14 @@ static int write_internal_branch(const state_t *state,
91
92
  return write_node(state, branch_get_child(branch), arg);
92
93
  }
93
94
 
94
- #if SIZEOF_RTREE_COORD_T == 4
95
- #define PRECISION 6
95
+ #if SIZEOF_RTREE_COORD_T == 2
96
+ #define PRECISION 5
97
+ #elif SIZEOF_RTREE_COORD_T == 4
98
+ #define PRECISION 9
96
99
  #elif SIZEOF_RTREE_COORD_T == 8
97
- #define PRECISION 14
100
+ #define PRECISION 17
98
101
  #else
99
- #error "strange size for rtree_coord_t"
102
+ #error MSG_RTREE_COORD_SIZE
100
103
  #endif
101
104
 
102
105
  static int write_leaf_branch(const state_t *state,
@@ -13,32 +13,31 @@ const char* strerror_rtree(int err)
13
13
  {
14
14
  int err;
15
15
  const char *msg;
16
- } *m, mtab[] =
17
- {
18
- { RTREE_OK, "Success" },
19
- { RTREE_ERR_INVAL, "Invalid argument" },
20
- { RTREE_ERR_DOM, "Argument outside domain" },
21
- { RTREE_ERR_NOMEM, "Out of memory" },
22
- { RTREE_ERR_CSVPARSE, "Error parsing CSV" },
23
- { RTREE_ERR_NOCSV, "Compiled without CSV support" },
24
- { RTREE_ERR_JANSSON, "Error from the Jansson library" },
25
- { RTREE_ERR_NOJSON, "Compiled without JSON support" },
26
- { RTREE_ERR_NOBSRT, "Compiled without BSRT support" },
27
- { RTREE_ERR_GETBRANCH, "Error getting branch" },
28
- { RTREE_ERR_GETCHILD, "Error getting child node" },
29
- { RTREE_ERR_NODECLONE, "Error cloning node" },
30
- { RTREE_ERR_PICKBRANCH, "Error picking branch" },
31
- { RTREE_ERR_ADDRECT, "Error adding rectangle" },
32
- { RTREE_ERR_NOSUCHSPLIT, "No such splitting method" },
33
- { RTREE_ERR_DIMS, "Bad R-tree dimension" },
34
- { RTREE_ERR_EMPTY, "Empty R-tree" },
35
- { RTREE_ERR_BUFFER, "Buffer to small" },
36
- { RTREE_ERR_POSTSCRIPT, "Error generating PostScript" },
37
- { RTREE_ERR_USER, "User abort" },
38
- { RTREE_ERR_FWRITE, "Failed write" },
39
- { RTREE_ERR_SPLIT, "Error in split" },
40
- { -1, NULL }
41
- };
16
+ } *m, mtab[] = {
17
+ { RTREE_OK, "Success" },
18
+ { RTREE_ERR_INVAL, "Invalid argument" },
19
+ { RTREE_ERR_DOM, "Argument outside domain" },
20
+ { RTREE_ERR_NOMEM, "Out of memory" },
21
+ { RTREE_ERR_CSVPARSE, "Error parsing CSV" },
22
+ { RTREE_ERR_NOCSV, "Compiled without CSV support" },
23
+ { RTREE_ERR_JANSSON, "Error from the Jansson library" },
24
+ { RTREE_ERR_NOJSON, "Compiled without JSON support" },
25
+ { RTREE_ERR_NOBSRT, "Compiled without BSRT support" },
26
+ { RTREE_ERR_GETBRANCH, "Error getting branch" },
27
+ { RTREE_ERR_GETCHILD, "Error getting child node" },
28
+ { RTREE_ERR_NODECLONE, "Error cloning node" },
29
+ { RTREE_ERR_PICKBRANCH, "Error picking branch" },
30
+ { RTREE_ERR_ADDRECT, "Error adding rectangle" },
31
+ { RTREE_ERR_NOSUCHSPLIT, "No such splitting method" },
32
+ { RTREE_ERR_DIMS, "Bad R-tree dimension" },
33
+ { RTREE_ERR_EMPTY, "Empty R-tree" },
34
+ { RTREE_ERR_BUFFER, "Buffer too small" },
35
+ { RTREE_ERR_POSTSCRIPT, "Error generating PostScript" },
36
+ { RTREE_ERR_USER, "User abort" },
37
+ { RTREE_ERR_FWRITE, "Failed write" },
38
+ { RTREE_ERR_SPLIT, "Error in split" },
39
+ { -1, NULL }
40
+ };
42
41
 
43
42
  for (m = mtab ; m->msg ; m++)
44
43
  if (m->err == err) return m->msg;
data/ext/rtree/lib/json.c CHANGED
@@ -197,7 +197,7 @@ static bool jr_value_equal(json_t *object, const char *key, size_t value)
197
197
  return (int_value >= 0) && ((size_t)int_value == value);
198
198
  }
199
199
 
200
- static bool jr_state_is_consistent(json_t *json_state, state_t *state)
200
+ static bool jr_state_is_consistent(json_t *json_state, const state_t *state)
201
201
  {
202
202
  return
203
203
  jr_value_equal(json_state, "dims", state_dims(state)) &&
data/ext/rtree/lib/node.c CHANGED
@@ -206,7 +206,7 @@ int node_branch_each_level(const state_t *state, const node_t *node,
206
206
  {
207
207
  for (size_t i = 0 ; i < node_count(node) ; i++)
208
208
  {
209
- branch_t *branch = node_get_branch(state, node, i);
209
+ const branch_t *branch = node_get_branch(state, node, i);
210
210
  const node_t *child = branch_get_child(branch);
211
211
  int err = node_branch_each_level(state, child, level, f, arg);
212
212
  if (err != 0) return err;
@@ -236,7 +236,7 @@ size_t node_bytes(const state_t *state, const node_t *node)
236
236
 
237
237
  for (size_t i = 0 ; i < node_count(node) ; i++)
238
238
  {
239
- branch_t *branch = node_get_branch(state, node, i);
239
+ const branch_t *branch = node_get_branch(state, node, i);
240
240
  const node_t *child = branch_get_child(branch);
241
241
  bytes += node_bytes(state, child);
242
242
  }
@@ -261,7 +261,8 @@ int node_detach_branch(const state_t *state, node_t *node, size_t i)
261
261
 
262
262
  if (i + 1 != node_count(node))
263
263
  {
264
- branch_t *branch_end = node_get_branch(state, node, node_count(node) - 1);
264
+ const branch_t
265
+ *branch_end = node_get_branch(state, node, node_count(node) - 1);
265
266
 
266
267
  if (branch_end == NULL)
267
268
  return RTREE_ERR_GETBRANCH;
@@ -282,8 +283,8 @@ static node_t* node_split(const state_t *state, node_t *node, branch_t *branch)
282
283
 
283
284
  /*
284
285
  add branch to node, which may split the node: if so the new node
285
- argumemnt is returned, so comparing the node argument and return
286
- value is the way to detect that splitting has occured.
286
+ argument is returned, so comparing the node argument and return
287
+ value is the way to detect that splitting has occurred.
287
288
  */
288
289
 
289
290
  node_t* node_add_branch(const state_t *state, node_t *node, branch_t *branch)
@@ -306,7 +307,7 @@ node_t* node_add_branch(const state_t *state, node_t *node, branch_t *branch)
306
307
 
307
308
  /*
308
309
  Pick a branch. Pick the one that will need the smallest increase
309
- in volume to accomodate the new (hyper-)rectangle. This will result
310
+ in volume to accommodate the new (hyper-)rectangle. This will result
310
311
  in the least total volume for the covering rectangles in the current
311
312
  node.
312
313
 
@@ -315,7 +316,7 @@ node_t* node_add_branch(const state_t *state, node_t *node, branch_t *branch)
315
316
  */
316
317
 
317
318
  static int node_pick_branch(const state_t *state,
318
- node_t *node,
319
+ const node_t *node,
319
320
  const rtree_coord_t *rect,
320
321
  size_t *index)
321
322
  {
@@ -330,7 +331,7 @@ static int node_pick_branch(const state_t *state,
330
331
 
331
332
  for (size_t i = 0 ; i < n ; i++)
332
333
  {
333
- branch_t *branch;
334
+ const branch_t *branch;
334
335
 
335
336
  if ((branch = node_get_branch(state, node, i)) == NULL)
336
337
  return RTREE_ERR_GETBRANCH;
@@ -472,7 +473,9 @@ static node_t* node_add_rect2(const state_t *state,
472
473
  */
473
474
 
474
475
  node_t* node_add_rect(const state_t *state,
475
- rtree_id_t id, rtree_coord_t *rect, node_t *root,
476
+ rtree_id_t id,
477
+ const rtree_coord_t *rect,
478
+ node_t *root,
476
479
  node_level_t level)
477
480
  {
478
481
  const size_t dims = state_dims(state);
@@ -538,9 +541,12 @@ node_t* node_add_rect(const state_t *state,
538
541
  {
539
542
  branch_set_child(branch, sibling);
540
543
  branch_set_rect(state, branch, envelope);
541
- node_add_branch(state, new_root, branch);
544
+ n = node_add_branch(state, new_root, branch);
542
545
 
543
- return new_root;
546
+ if (n != new_root)
547
+ node_destroy(state, n);
548
+ else
549
+ return new_root;
544
550
  }
545
551
  }
546
552
  }
@@ -5,7 +5,7 @@
5
5
 
6
6
  #include "rtree/package.h"
7
7
 
8
- const char rtree_package_version[] = "1.3.1";
8
+ const char rtree_package_version[] = "1.3.3";
9
9
  const char rtree_package_name[] = "librtree";
10
10
  const char rtree_package_url[] = "https://gitlab.com/jjg/librtree";
11
11
  const char rtree_package_bugreport[] = "j.j.green@gmx.co.uk";
@@ -252,10 +252,10 @@ void postscript_style_destroy(postscript_style_t *style)
252
252
  free(style);
253
253
  }
254
254
 
255
- static int pw_header(FILE *stream, uint32_t *bbox, const char *title)
255
+ static int pw_header(FILE *stream, const uint32_t *bbox, const char *title)
256
256
  {
257
257
  time_t t; time(&t);
258
- struct tm *tm = gmtime(&t);
258
+ const struct tm *tm = gmtime(&t);
259
259
  size_t n = 1024;
260
260
  char time_string[n];
261
261
  if (strftime(time_string, n, "%a, %d %b %Y %T %z", tm) == 0)
@@ -341,7 +341,7 @@ typedef struct
341
341
  static int rect_proc(const branch_t *branch, const char *proc, rect_data_t *data)
342
342
  {
343
343
  const rtree_coord_t *rect = branch_get_rect(branch);
344
- page_t *page = data->page;
344
+ const page_t *page = data->page;
345
345
  float scale = page->scale;
346
346
  fprintf(data->stream,
347
347
  "%.2f %.2f %.2f %.2f %s\n",
@@ -434,6 +434,7 @@ static int pw_state(const rtree_postscript_t *opts, ps_t *ps)
434
434
  page->body.height = body_height;
435
435
  page->body.width = body_width;
436
436
  page->scale = scale;
437
+ page->margin = margin;
437
438
  page->offset.x = rect[0] - margin / scale;
438
439
  page->offset.y = rect[1] - margin / scale;
439
440
 
@@ -0,0 +1,33 @@
1
+ /*
2
+ private/generic.h
3
+ Copyright (c) J.J. Green 2026
4
+ */
5
+
6
+ #ifndef PRIVATE_GENERIC_H
7
+ #define PRIVATE_GENERIC_H
8
+
9
+ #include "config.h"
10
+ #include "private/message.h"
11
+
12
+ /*
13
+ the functions fabs() and so on, while having formal double
14
+ arguments are generic, will call fabsf() for float arguments
15
+ and so on. But does not handle float16, so in that case we use
16
+ an explicit fabsf() which will case the float16 to float32 ...
17
+ */
18
+
19
+ #if (SIZEOF_RTREE_COORD_T == 2) || (SIZEOF_RTREE_COORD_T == 4)
20
+ # define FABS(x) fabsf(x)
21
+ # define POW(x, y) powf(x, y)
22
+ # define FMIN(x, y) fminf(x, y)
23
+ # define FMAX(x, y) fmaxf(x, y)
24
+ #elif SIZEOF_RTREE_COORD_T == 8
25
+ # define FABS(x) fabs(x)
26
+ # define POW(x, y) pow(x, y)
27
+ # define FMIN(x, y) fmin(x, y)
28
+ # define FMAX(x, y) fmax(x, y)
29
+ #else
30
+ # error MSG_RTREE_COORD_SIZE
31
+ #endif
32
+
33
+ #endif
@@ -0,0 +1,11 @@
1
+ /*
2
+ private/message.h
3
+ Copyright (c) J.J. Green 2026
4
+ */
5
+
6
+ #ifndef PRIVATE_MESSAGE_H
7
+ #define PRIVATE_MESSAGE_H
8
+
9
+ #define MSG_RTREE_COORD_SIZE "unhandled rtree_coord_t size"
10
+
11
+ #endif
@@ -45,7 +45,7 @@ size_t node_num_branch(size_t, size_t);
45
45
  int node_detach_branch(const state_t*, node_t*, size_t);
46
46
  node_t* node_add_branch(const state_t*, node_t*, branch_t*);
47
47
  int node_envelope(const state_t*, const node_t*, rtree_coord_t*);
48
- node_t* node_add_rect(const state_t*, rtree_id_t, rtree_coord_t*,
48
+ node_t* node_add_rect(const state_t*, rtree_id_t, const rtree_coord_t*,
49
49
  node_t*, node_level_t);
50
50
  int node_update(const state_t*, const node_t*, rtree_update_t*, void*);
51
51
  bool node_identical(const state_t*, const node_t*, const node_t*);
@@ -3,6 +3,8 @@
3
3
  #endif
4
4
 
5
5
  #include "private/rectf.h"
6
+ #include "private/generic.h"
7
+ #include "private/message.h"
6
8
 
7
9
  #ifdef HAVE_TGMATH_H
8
10
  #include <tgmath.h>
@@ -29,7 +31,7 @@
29
31
 
30
32
  rtree_coord_t rectf_rsv1(size_t dims, const rtree_coord_t *rect)
31
33
  {
32
- return 0.5 * fabs(rect[1] - rect[0]);
34
+ return 0.5 * FABS(rect[1] - rect[0]);
33
35
  }
34
36
 
35
37
  rtree_coord_t rectf_rsv2(size_t dims, const rtree_coord_t *rect)
@@ -56,7 +58,7 @@ rtree_coord_t rectf_rsvd(size_t dims, const rtree_coord_t *rect)
56
58
  r2 += hx * hx;
57
59
  }
58
60
 
59
- return pow(0.25 * r2, 0.5 * dims);
61
+ return POW(0.25 * r2, 0.5 * dims);
60
62
  }
61
63
 
62
64
  rectf_rsv_t* rectf_spherical_volume(size_t dims)
@@ -100,15 +102,19 @@ void rectf_rcd(size_t dims,
100
102
  x0 = rect0[i], x1 = rect1[i],
101
103
  y0 = rect0[j], y1 = rect1[j];
102
104
 
103
- rect2[i] = fmin(x0, x1);
104
- rect2[j] = fmax(y0, y1);
105
+ rect2[i] = FMIN(x0, x1);
106
+ rect2[j] = FMAX(y0, y1);
105
107
  }
106
108
  }
107
109
 
108
110
  #pragma GCC diagnostic push
109
111
  #pragma GCC diagnostic ignored "-Wunused-parameter"
110
112
 
111
- #if SIZEOF_RTREE_COORD_T == 4
113
+ #if SIZEOF_RTREE_COORD_T == 2
114
+
115
+ /* https://gitlab.com/jjg/librtree/-/work_items/83 */
116
+
117
+ #elif SIZEOF_RTREE_COORD_T == 4
112
118
 
113
119
  #ifdef HAVE_SSE2
114
120
 
@@ -127,7 +133,6 @@ void rectf_rc2(size_t dims,
127
133
  _mm_storeu_ps(rect2, res);
128
134
  }
129
135
 
130
-
131
136
  #endif
132
137
 
133
138
  #ifdef HAVE_AVX
@@ -188,7 +193,7 @@ void rectf_rc2(size_t dims,
188
193
  #endif
189
194
 
190
195
  #else
191
- #error "strange size for rtree_coord_t"
196
+ #error MSG_RTREE_COORD_SIZE
192
197
  #endif
193
198
 
194
199
  #pragma GCC diagnostic pop
@@ -198,7 +203,9 @@ rectf_rc_t* rectf_combine(size_t dims)
198
203
  switch (dims)
199
204
  {
200
205
 
201
- #if SIZEOF_RTREE_COORD_T == 4
206
+ #if SIZEOF_RTREE_COORD_T == 2
207
+ /* https://gitlab.com/jjg/librtree/-/work_items/83 */
208
+ #elif SIZEOF_RTREE_COORD_T == 4
202
209
  # ifdef HAVE_SSE2
203
210
  case 2: return rectf_rc2;
204
211
  # endif
@@ -211,7 +218,7 @@ rectf_rc_t* rectf_combine(size_t dims)
211
218
  case 2: return rectf_rc2;
212
219
  # endif
213
220
  #else
214
- # error "strange size for rtree_coord_t"
221
+ # error MSG_RTREE_COORD_SIZE
215
222
  #endif
216
223
 
217
224
  default: return rectf_rcd;
@@ -134,7 +134,7 @@ rtree_t* rtree_bsrt_read(FILE *stream)
134
134
  return bsrt_rtree_read(stream);
135
135
  }
136
136
 
137
- int rtree_add_rect(rtree_t *rtree, rtree_id_t id, rtree_coord_t *rect)
137
+ int rtree_add_rect(rtree_t *rtree, rtree_id_t id, const rtree_coord_t *rect)
138
138
  {
139
139
  node_t *node = node_add_rect(rtree->state, id, rect, rtree->root, 0);
140
140
 
@@ -31,7 +31,7 @@ rtree_t* rtree_clone(const rtree_t*);
31
31
  void rtree_destroy(rtree_t*);
32
32
  rtree_height_t rtree_height(const rtree_t*);
33
33
  int rtree_search(const rtree_t*, const rtree_coord_t*, rtree_search_t*, void*);
34
- int rtree_add_rect(rtree_t*, rtree_id_t, rtree_coord_t*);
34
+ int rtree_add_rect(rtree_t*, rtree_id_t, const rtree_coord_t*);
35
35
  int rtree_update(rtree_t*, rtree_update_t*, void*);
36
36
  bool rtree_identical(const rtree_t*, const rtree_t*);
37
37
  int rtree_csv_write(const rtree_t*, FILE*);
@@ -6,6 +6,7 @@
6
6
  #include "private/branch.h"
7
7
  #include "private/branches.h"
8
8
  #include "private/node.h"
9
+ #include "private/generic.h"
9
10
  #include "private/split.h"
10
11
 
11
12
  #include "rtree/error.h"
@@ -44,7 +45,7 @@ static int split_classify(size_t i, size_t group,
44
45
  const state_t *state, split_t *split)
45
46
  {
46
47
  partition_t *part = &(split->partition);
47
- branch_t *branch = branches_get(state, split->branches, i);
48
+ const branch_t *branch = branches_get(state, split->branches, i);
48
49
  const rtree_coord_t *rect = branch_get_rect(branch);
49
50
 
50
51
  int err;
@@ -87,7 +88,7 @@ static int split_seed_linear(const state_t *state, split_t *split)
87
88
 
88
89
  for (size_t i = 1 ; i < nbuf ; i++)
89
90
  {
90
- branch_t
91
+ const branch_t
91
92
  *b0 = branches_get(state, split->branches, greatest_lower[dim]),
92
93
  *b1 = branches_get(state, split->branches, i),
93
94
  *b2 = branches_get(state, split->branches, least_upper[dim]);
@@ -111,7 +112,7 @@ static int split_seed_linear(const state_t *state, split_t *split)
111
112
 
112
113
  for (size_t dim = 0 ; dim < dims ; dim++)
113
114
  {
114
- branch_t
115
+ const branch_t
115
116
  *bl = branches_get(state, split->branches, least_upper[dim]),
116
117
  *bh = branches_get(state, split->branches, greatest_lower[dim]);
117
118
  const rtree_coord_t
@@ -143,7 +144,7 @@ static int split_seed_linear(const state_t *state, split_t *split)
143
144
  /*
144
145
  Picks two rectangles to be the first (seed) elements of the
145
146
  partition groups. They are the two that waste the most area
146
- if convered by a single rectangle.
147
+ if covered by a single rectangle.
147
148
 
148
149
  Note that this is as implemented in the Guttman-Green version
149
150
  quadratic splitting, but is quadratic only in the page-size,
@@ -161,7 +162,7 @@ static int split_seed_quadratic(const state_t *state, split_t *split)
161
162
 
162
163
  for (size_t i = 0 ; i < total ; i++)
163
164
  {
164
- branch_t *branch = branches_get(state, split->branches, i);
165
+ const branch_t *branch = branches_get(state, split->branches, i);
165
166
  const rtree_coord_t *rect = branch_get_rect(branch);
166
167
  area[i] = rect_spherical_volume(state, rect);
167
168
  }
@@ -172,12 +173,12 @@ static int split_seed_quadratic(const state_t *state, split_t *split)
172
173
 
173
174
  for (size_t i = 0 ; i < total - 1 ; i++)
174
175
  {
175
- branch_t *bi = branches_get(state, split->branches, i);
176
+ const branch_t *bi = branches_get(state, split->branches, i);
176
177
  const rtree_coord_t *ri = branch_get_rect(bi);
177
178
 
178
179
  for (size_t j = i + 1 ; j < total ; j++)
179
180
  {
180
- branch_t *bj = branches_get(state, split->branches, j);
181
+ const branch_t *bj = branches_get(state, split->branches, j);
181
182
  const rtree_coord_t *rj = branch_get_rect(bj);
182
183
  rtree_coord_t rect[2 * dims];
183
184
 
@@ -238,7 +239,7 @@ static int split_linear(const state_t *state, split_t *split)
238
239
  continue;
239
240
  }
240
241
 
241
- branch_t *branch = branches_get(state, split->branches, i);
242
+ const branch_t *branch = branches_get(state, split->branches, i);
242
243
  const rtree_coord_t *rect = branch_get_rect(branch);
243
244
 
244
245
  for (size_t group = 0 ; group < 2 ; group++)
@@ -312,9 +313,8 @@ static int split_quadratic(const state_t *state, split_t *split)
312
313
  total = part->total,
313
314
  minfill = part->minfill,
314
315
  *count = part->count;
315
- rtree_coord_t
316
- **cover = part->cover,
317
- *area = part->area;
316
+ rtree_coord_t **cover = part->cover;
317
+ const rtree_coord_t *area = part->area;
318
318
 
319
319
  while ( (count[0] + count[1] < total) &&
320
320
  (count[0] + minfill < total) &&
@@ -327,7 +327,7 @@ static int split_quadratic(const state_t *state, split_t *split)
327
327
  i < total ;
328
328
  i = bindex_next_unset(part->taken, i + 1))
329
329
  {
330
- branch_t *branch = branches_get(state, split->branches, i);
330
+ const branch_t *branch = branches_get(state, split->branches, i);
331
331
  const rtree_coord_t *rect = branch_get_rect(branch);
332
332
  rtree_coord_t r0[2 * dims], r1[2 * dims];
333
333
 
@@ -395,7 +395,7 @@ typedef struct
395
395
  #elif SIZEOF_RTREE_COORD_T == 8
396
396
  uint64_t id;
397
397
  #else
398
- #error rtree_id_t size not handled
398
+ #error MSG_RTREE_COORD_SIZE
399
399
  #endif
400
400
  rtree_coord_t min;
401
401
  } pair_t;
@@ -428,7 +428,7 @@ static int split_greene(const state_t *state, split_t *split)
428
428
  if ((err = split_seed_quadratic(state, split)) != RTREE_OK)
429
429
  return err;
430
430
 
431
- branch_t
431
+ const branch_t
432
432
  *b0 = branches_get(state, split->branches, 0),
433
433
  *b1 = branches_get(state, split->branches, 1);
434
434
  const rtree_coord_t
@@ -442,9 +442,9 @@ static int split_greene(const state_t *state, split_t *split)
442
442
  rtree_coord_t
443
443
  s0 = r0[dim] - r1[dim + dims],
444
444
  s1 = r1[dim] - r0[dim + dims],
445
- s2 = fmax(s0, s1),
446
- n0 = fmin(r0[dim], r1[dim]),
447
- n1 = fmax(r0[dim + dims], r1[dim + dims]),
445
+ s2 = FMAX(s0, s1),
446
+ n0 = FMIN(r0[dim], r1[dim]),
447
+ n1 = FMAX(r0[dim + dims], r1[dim + dims]),
448
448
  n2 = n1 - n0,
449
449
  sep = s2 / n2;
450
450
 
@@ -461,13 +461,13 @@ static int split_greene(const state_t *state, split_t *split)
461
461
 
462
462
  /* order by lower boumd in this dimension */
463
463
 
464
- partition_t *part = &(split->partition);
464
+ const partition_t *part = &(split->partition);
465
465
  const size_t total = part->total;
466
466
  pair_t pairs[total];
467
467
 
468
468
  for (size_t i = 0 ; i < total ; i++)
469
469
  {
470
- branch_t *b = branches_get(state, split->branches, i);
470
+ const branch_t *b = branches_get(state, split->branches, i);
471
471
  const rtree_coord_t *r = branch_get_rect(b);
472
472
  pairs[i].id = i;
473
473
  pairs[i].min = r[axis];
@@ -587,7 +587,7 @@ static node_t* split_load(const state_t *state, node_t *node, split_t *split)
587
587
  {
588
588
  branch_t *branch = branches_get(state, split->branches, i);
589
589
  size_t group = bindex_get(part->choice, i);
590
- node_t *result;
590
+ const node_t *result;
591
591
 
592
592
  switch (group)
593
593
  {
@@ -654,7 +654,7 @@ static node_t* split_cover(const state_t *state, node_t *node, split_t *split)
654
654
 
655
655
  split->rect = split_rect;
656
656
 
657
- branch_t *b = branches_get(state, split->branches, 0);
657
+ const branch_t *b = branches_get(state, split->branches, 0);
658
658
  const rtree_coord_t *r;
659
659
 
660
660
  if ((r = branch_get_rect(b)) != NULL)
@@ -697,7 +697,7 @@ node_t* split_node(const state_t *state, node_t *node, branch_t *branch)
697
697
 
698
698
  for (size_t i = 0 ; i < n ; i++)
699
699
  {
700
- branch_t *b = branches_get(state, branches, i);
700
+ const branch_t *b = branches_get(state, branches, i);
701
701
  branches_set(state, split.branches, i, b);
702
702
  }
703
703
 
data/lib/rtree.rb CHANGED
@@ -16,7 +16,7 @@ require 'fcntl'
16
16
  #
17
17
  # A Ruby native extension implementing the R-tree spatial index of
18
18
  # Guttman-Green. The code is an embedded version of
19
- # {http://soliton.vm.bytemark.co.uk/pub/jjg/en/code/librtree librtree}.
19
+ # {https://jjg.gitlab.io/en/code/librtree librtree}.
20
20
  #
21
21
  # Use
22
22
  #
@@ -346,7 +346,7 @@ class RTree < RTreeBase
346
346
  if block_given? then
347
347
  super
348
348
  else
349
- ids = []
349
+ ids = [] #: Array[Integer]
350
350
  super(coords) { |id| ids << id }
351
351
  ids
352
352
  end
@@ -482,10 +482,10 @@ class RTree < RTreeBase
482
482
  super
483
483
  end
484
484
 
485
- # @return [Array[float]] the bounding rectangle
486
- # @note Ruturns the bounding rectangle (in the same format
487
- # as the rectangle input) for all rectangles in the tree.
488
- # In the case that the input is empty, returns nil.
485
+ # The bounding rectangle (in the same format as the rectangle
486
+ # input) for all rectangles in the tree. In the case that the
487
+ # input is empty, returns nil.
488
+ # @return [Array<Float>] the bounding rectangle
489
489
  #
490
490
  def envelope
491
491
  super
@@ -627,11 +627,11 @@ class RTree::Style < RTreeStyleBase
627
627
  # ]
628
628
  # )
629
629
  #
630
- def from_a(array)
630
+ def from_array(array)
631
631
  from_json(array.to_json)
632
632
  end
633
633
 
634
- alias_method :from_array, :from_a
634
+ alias_method :from_a, :from_array
635
635
 
636
636
  private
637
637
 
metadata CHANGED
@@ -1,139 +1,153 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: librtree
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - J.J. Green
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-07 00:00:00.000000000 Z
11
+ date: 2026-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
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
26
  version: '2.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
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
54
  version: '3.10'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: simplecov
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0.22'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.22'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: yard
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0.9'
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
82
  version: '0.9'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubygems-tasks
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0.2'
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
96
  version: '0.2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: ostruct
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0.6'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0.6'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rake-compiler
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - "~>"
115
+ - - ">="
102
116
  - !ruby/object:Gem::Version
103
117
  version: '1.1'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - "~>"
122
+ - - ">="
109
123
  - !ruby/object:Gem::Version
110
124
  version: '1.1'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: steep
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
- - - "~>"
129
+ - - ">="
116
130
  - !ruby/object:Gem::Version
117
- version: '1.4'
131
+ version: '1.8'
118
132
  type: :development
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
- - - "~>"
136
+ - - ">="
123
137
  - !ruby/object:Gem::Version
124
- version: '1.4'
138
+ version: '1.8'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: rbs
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
- - - "~>"
143
+ - - ">="
130
144
  - !ruby/object:Gem::Version
131
145
  version: '3.2'
132
146
  type: :development
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
- - - "~>"
150
+ - - ">="
137
151
  - !ruby/object:Gem::Version
138
152
  version: '3.2'
139
153
  description: |
@@ -172,7 +186,9 @@ files:
172
186
  - ext/rtree/lib/private/constants.h
173
187
  - ext/rtree/lib/private/csv.h
174
188
  - ext/rtree/lib/private/endianness.h
189
+ - ext/rtree/lib/private/generic.h
175
190
  - ext/rtree/lib/private/json.h
191
+ - ext/rtree/lib/private/message.h
176
192
  - ext/rtree/lib/private/node.h
177
193
  - ext/rtree/lib/private/page.h
178
194
  - ext/rtree/lib/private/postscript.h
@@ -205,7 +221,7 @@ homepage: https://gitlab.com/jjg/librtree-ruby
205
221
  licenses:
206
222
  - MIT
207
223
  metadata: {}
208
- post_install_message:
224
+ post_install_message:
209
225
  rdoc_options: []
210
226
  require_paths:
211
227
  - lib
@@ -214,7 +230,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
214
230
  requirements:
215
231
  - - ">="
216
232
  - !ruby/object:Gem::Version
217
- version: '2.0'
233
+ version: '3.0'
218
234
  required_rubygems_version: !ruby/object:Gem::Requirement
219
235
  requirements:
220
236
  - - ">="
@@ -222,8 +238,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
238
  version: '0'
223
239
  requirements:
224
240
  - The Jansson library
225
- rubygems_version: 3.3.7
226
- signing_key:
241
+ rubygems_version: 3.5.11
242
+ signing_key:
227
243
  specification_version: 4
228
244
  summary: R-tree spatial index
229
245
  test_files: []