@tty-pt/islet 0.0.0-stage → 1.3.1

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.
@@ -0,0 +1,200 @@
1
+ #ifndef POINTCFG_H
2
+ #define POINTCFG_H
3
+
4
+ /**
5
+ * @file pointcfg.h
6
+ * @brief Configuration objects: one "static-method class" per point config.
7
+ *
8
+ * Each spatial config — width (bytes per lane) x dimension count — is one
9
+ * exported const object (a struct of function pointers, "a class with
10
+ * all-static methods"). Pick the object matching your coordinates and call
11
+ * its members:
12
+ *
13
+ * @code
14
+ * #include <ttypt/pointcfg.h>
15
+ *
16
+ * islet_init();
17
+ * uint32_t db = islet_open(NULL, NULL, 0xFF);
18
+ *
19
+ * int16_t p[3] = { 10, 20, 30 };
20
+ * Point3_2.put(db, p, 42); // store 42 at the cell
21
+ * uint32_t v = Point3_2.get(db, p); // read it back
22
+ *
23
+ * int16_t s[3] = { 0, 0, 0 };
24
+ * uint16_t l[3] = { 4, 4, 4 };
25
+ * uint32_t cur = Point3_2.iter(db, s, l);
26
+ * while (Point3_2.next(p, &v, cur)) // advance the box iterator
27
+ * ; // ... use (p, v)
28
+ * @endcode
29
+ *
30
+ * A language server offers autocomplete for every member of a config off a
31
+ * single symbol, so the whole operations set for that config is discoverable
32
+ * without leaving the type.
33
+ *
34
+ * Objects:
35
+ * Point1_2 Point2_2 Point3_2 Point4_2 int16 lanes (2 bytes), 1..4 dims
36
+ * Point2_4 int32 lanes (4 bytes), 2 dims
37
+ *
38
+ * @note The flat per-dimension functions (morton_set_N, islet_put_N,
39
+ * point_add_N, the islet_*_2_32 family, islet_ops[]) remain for ABI
40
+ * compatibility, tight codec/vector loops, and genuinely runtime
41
+ * dims; the config objects are the recommended ergonomic surface and
42
+ * point at the same implementations.
43
+ *
44
+ * @note One config per database: all configs share the uint64 key space
45
+ * with different layouts, and the file carries no config tag —
46
+ * never reopen a database with another config's functions.
47
+ *
48
+ * @see islet_core
49
+ */
50
+
51
+ #include <stdint.h>
52
+
53
+ #include <ttypt/islet.h>
54
+
55
+ /** @defgroup islet_pointcfg Config objects
56
+ * @brief Static-method interfaces, one object per point config.
57
+ * @{
58
+ */
59
+
60
+ /**
61
+ * @brief 2-byte-lane (int16) point config object type.
62
+ *
63
+ * One shared type for the 1..4 dimensional int16 configs; the dimension
64
+ * count lives in the object name (Point1_2..Point4_2) and is documented
65
+ * per member below. Box lengths are uint16_t; iterators advance via
66
+ * islet_next().
67
+ *
68
+ * Member-to-flat-function mapping (dimension N fixed per object):
69
+ * morton_set = morton_set_N morton_get = morton_get_N
70
+ * add/sub/min/max/copy/set/idx/debug/vol = point_*_N
71
+ * put/get/del/del_all/cell_count = islet_put/get/del/del_all/cell_count_N
72
+ * replace = islet_set_N (renamed: .set is the point broadcast)
73
+ * get_multi = islet_get_multi_N iter = islet_iter_N
74
+ * fill_bbox = rec_axis_fill_bbox_N
75
+ * next = islet_next
76
+ */
77
+ typedef struct islet_point2b {
78
+ /** Encode an N-lane point to its Morton code. m = morton_set_N(p). */
79
+ uint64_t (*morton_set)(int16_t *p);
80
+ /** Decode a Morton code back into an N-lane point. m = morton_get_N. */
81
+ void (*morton_get)(int16_t *p, uint64_t code);
82
+ /** Component-wise addition. m = point_add_N(tar, a, b). */
83
+ void (*add)(int16_t *tar, int16_t *a, int16_t *b);
84
+ /** Component-wise subtraction. m = point_sub_N(tar, a, b). */
85
+ void (*sub)(int16_t *tar, int16_t *a, int16_t *b);
86
+ /** Component-wise minimum. m = point_min_N(tar, a, b). */
87
+ void (*min)(int16_t *tar, int16_t *a, int16_t *b);
88
+ /** Component-wise maximum. m = point_max_N(tar, a, b). */
89
+ void (*max)(int16_t *tar, int16_t *a, int16_t *b);
90
+ /** Copy one point into another. m = point_copy_N(tar, src). */
91
+ void (*copy)(int16_t *tar, int16_t *src);
92
+ /** Volume (signed product of all lanes). m = point_vol_N(p). */
93
+ int32_t (*vol)(int16_t *p);
94
+ /** Broadcast one value to all N lanes. m = point_set_N(tar, v). */
95
+ void (*set)(int16_t *tar, int16_t v);
96
+ /** Print "label(p0, ..., pN-1)" to stderr. m = point_debug_N. */
97
+ void (*debug)(char *label, int16_t *p);
98
+ /** Row-major linear index of p within box [s, e). m = point_idx_N. */
99
+ uint64_t (*idx)(int16_t *p, int16_t *s, int16_t *e);
100
+
101
+ /** Append ref at a coordinate (multi-value cell). m = islet_put_N. */
102
+ void (*put)(uint32_t pdb_hd, int16_t *p, uint32_t ref);
103
+ /** First value at a coordinate, or ISLET_MISS. m = islet_get_N. */
104
+ uint32_t (*get)(uint32_t pdb_hd, int16_t *p);
105
+ /** Replace every value at a coordinate with ref. m = islet_set_N. */
106
+ void (*replace)(uint32_t pdb_hd, int16_t *p, uint32_t ref);
107
+ /** Delete the first value at a coordinate. m = islet_del_N. */
108
+ void (*del)(uint32_t pdb_hd, int16_t *p);
109
+ /** Delete every value, return count removed. m = islet_del_all_N. */
110
+ uint32_t (*del_all)(uint32_t pdb_hd, int16_t *p);
111
+ /** Count values at a coordinate. m = islet_cell_count_N. */
112
+ uint32_t (*cell_count)(uint32_t pdb_hd, int16_t *p);
113
+ /** Cursor over all values at a cell; islet_cell_next() drains
114
+ * it. m = islet_get_multi_N. */
115
+ uint32_t (*get_multi)(uint32_t pdb_hd, int16_t *p);
116
+ /** Region iterator over box [s, s+l). m = islet_iter_N. */
117
+ uint32_t (*iter)(uint32_t pdb_hd, int16_t *s, uint16_t *l);
118
+ /** Stream the box into a sealed recall set. m = rec_axis_fill_bbox_N. */
119
+ int (*fill_bbox)(uint32_t pdb_hd, int16_t *s, uint16_t *l,
120
+ rec_set_t *out);
121
+ /** Advance a box iterator. m = islet_next. */
122
+ int (*next)(int16_t *p, uint32_t *ref, uint32_t cur);
123
+ } islet_point2b_t;
124
+
125
+ /**
126
+ * @brief 4-byte-lane (int32) point config object type.
127
+ *
128
+ * The 2D x 32-bit dense config: 2 lanes of int32_t. Box lengths are also
129
+ * int32_t; iterators advance via islet_next32(). Everything else mirrors
130
+ * islet_point2b_t member-for-member on int32 lanes.
131
+ *
132
+ * Member-to-flat-function mapping:
133
+ * morton_set/morton_get = morton_set_2_32/morton_get_2_32
134
+ * add/sub/min/max/copy/set/idx/debug/vol = point_*_2_32
135
+ * put/get/del/del_all/cell_count = islet_put/get/del/del_all/cell_count_2_32
136
+ * replace = islet_set_2_32 (renamed: .set is the point broadcast)
137
+ * get_multi = islet_get_multi_2_32, iter = islet_iter_2_32
138
+ * fill_bbox = rec_axis_fill_bbox_2_32, next = islet_next32
139
+ */
140
+ typedef struct islet_point4b {
141
+ /** Encode the 2-lane point to its dense Morton code. */
142
+ uint64_t (*morton_set)(int32_t *p);
143
+ /** Decode a Morton code back into the 2-lane point. */
144
+ void (*morton_get)(int32_t *p, uint64_t code);
145
+ /** Component-wise addition (mod 2^32). */
146
+ void (*add)(int32_t *tar, int32_t *a, int32_t *b);
147
+ /** Component-wise subtraction (mod 2^32). */
148
+ void (*sub)(int32_t *tar, int32_t *a, int32_t *b);
149
+ /** Component-wise minimum. */
150
+ void (*min)(int32_t *tar, int32_t *a, int32_t *b);
151
+ /** Component-wise maximum. */
152
+ void (*max)(int32_t *tar, int32_t *a, int32_t *b);
153
+ /** Copy one point into another (exact 8-byte move). */
154
+ void (*copy)(int32_t *tar, int32_t *src);
155
+ /** Area (product of both lanes, unsigned, fits uint64_t). */
156
+ uint64_t (*vol)(int32_t *p);
157
+ /** Broadcast one value to both lanes. */
158
+ void (*set)(int32_t *tar, int32_t v);
159
+ /** Print "label(p0, p1)" to stderr. */
160
+ void (*debug)(char *label, int32_t *p);
161
+ /** Row-major linear index of p within box [s, e). */
162
+ uint64_t (*idx)(int32_t *p, int32_t *s, int32_t *e);
163
+
164
+ /** Append ref at a coordinate (multi-value cell). */
165
+ void (*put)(uint32_t pdb_hd, int32_t *p, uint32_t ref);
166
+ /** First value at a coordinate, or ISLET_MISS. */
167
+ uint32_t (*get)(uint32_t pdb_hd, int32_t *p);
168
+ /** Replace every value at a coordinate with ref. */
169
+ void (*replace)(uint32_t pdb_hd, int32_t *p, uint32_t ref);
170
+ /** Delete the first value at a coordinate. */
171
+ void (*del)(uint32_t pdb_hd, int32_t *p);
172
+ /** Delete every value, return count removed. */
173
+ uint32_t (*del_all)(uint32_t pdb_hd, int32_t *p);
174
+ /** Count values at a coordinate. */
175
+ uint32_t (*cell_count)(uint32_t pdb_hd, int32_t *p);
176
+ /** Cursor over all values at a cell; islet_cell_next() drains it. */
177
+ uint32_t (*get_multi)(uint32_t pdb_hd, int32_t *p);
178
+ /** Region iterator over box [s, s+l). */
179
+ uint32_t (*iter)(uint32_t pdb_hd, int32_t *s, int32_t *l);
180
+ /** Stream the box into a sealed recall set. */
181
+ int (*fill_bbox)(uint32_t pdb_hd, int32_t *s, int32_t *l,
182
+ rec_set_t *out);
183
+ /** Advance a box iterator. */
184
+ int (*next)(int32_t *p, uint32_t *ref, uint32_t cur);
185
+ } islet_point4b_t;
186
+
187
+ /** @brief 1D int16 config object (2-byte lanes). */
188
+ extern const islet_point2b_t Point1_2;
189
+ /** @brief 2D int16 config object (2-byte lanes). */
190
+ extern const islet_point2b_t Point2_2;
191
+ /** @brief 3D int16 config object (2-byte lanes). */
192
+ extern const islet_point2b_t Point3_2;
193
+ /** @brief 4D int16 config object (2-byte lanes). */
194
+ extern const islet_point2b_t Point4_2;
195
+ /** @brief 2D int32 config object (4-byte lanes, dense full-key codec). */
196
+ extern const islet_point4b_t Point2_4;
197
+
198
+ /** @} */
199
+
200
+ #endif
package/islet.pc ADDED
@@ -0,0 +1,10 @@
1
+ prefix=/usr/local
2
+ exec_prefix=${prefix}
3
+ libdir=${exec_prefix}/lib
4
+ includedir=${prefix}/include
5
+
6
+ Name: libislet
7
+ Description: Spatial database library using Morton code indexing
8
+ Version: 1.3.0
9
+ Libs: -L${libdir} -lstele -lcorm
10
+ Cflags: -I${includedir}
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@tty-pt/islet",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.3.1",
4
+ "type": "module",
5
+ "description": "Universal Node.js and Browser bindings for libislet Spatial Indexing & Morton Z-Order Curves",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "include",
11
+ "assets",
12
+ "*.pc",
13
+ "README.md",
14
+ "LICENSE"
15
+ ],
16
+ "scripts": {
17
+ "build:native": "mkdir -p build/Release && gcc -O3 -fPIC -shared -I/usr/include/node -I../include native/islet_napi.c -L../lib -Wl,-rpath,../lib -L/usr/lib -lislet -lcorm -o build/Release/islet_node.node 2>/dev/null || true",
18
+ "build:wasm": "make -C .. wasm",
19
+ "build": "npm run build:native && npm run build:wasm",
20
+ "test": "node --test tests/islet.test.mjs"
21
+ },
22
+ "peerDependencies": {
23
+ "@tty-pt/corm": ">=2.2.0",
24
+ "@tty-pt/stele": ">=1.5.0"
25
+ },
26
+ "devDependencies": {
27
+ "@tty-pt/corm": "^2.2.3",
28
+ "@tty-pt/stele": "^1.5.1"
29
+ },
30
+ "keywords": [
31
+ "islet",
32
+ "libislet",
33
+ "spatial",
34
+ "morton",
35
+ "z-order",
36
+ "quadtree",
37
+ "2d",
38
+ "3d",
39
+ "gis"
40
+ ],
41
+ "author": "Paulo Quirino",
42
+ "license": "BSD-2-Clause",
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "git+https://github.com/tty-pt/libislet.git",
46
+ "directory": "npm"
47
+ },
48
+ "homepage": "https://github.com/tty-pt/libislet/tree/main/npm#readme",
49
+ "bugs": {
50
+ "url": "https://github.com/tty-pt/libislet/issues"
51
+ }
52
+ }