@loaders.gl/flatgeobuf 4.0.4 → 4.1.0-alpha.10

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.
Files changed (190) hide show
  1. package/dist/LICENSE +9 -0
  2. package/dist/dist.dev.js +8719 -0
  3. package/dist/flatgeobuf/3.27.2/LICENSE +29 -0
  4. package/dist/flatgeobuf/3.27.2/README.md +45 -0
  5. package/dist/flatgeobuf/3.27.2/column-meta.d.ts +14 -0
  6. package/dist/flatgeobuf/3.27.2/column-meta.d.ts.map +1 -0
  7. package/dist/flatgeobuf/3.27.2/column-meta.js +2 -0
  8. package/dist/flatgeobuf/3.27.2/column-meta.js.map +1 -0
  9. package/dist/flatgeobuf/3.27.2/config.d.ts +10 -0
  10. package/dist/flatgeobuf/3.27.2/config.d.ts.map +1 -0
  11. package/dist/flatgeobuf/3.27.2/config.js +16 -0
  12. package/dist/flatgeobuf/3.27.2/config.js.map +1 -0
  13. package/dist/flatgeobuf/3.27.2/constants.d.ts +3 -0
  14. package/dist/flatgeobuf/3.27.2/constants.d.ts.map +1 -0
  15. package/dist/flatgeobuf/3.27.2/constants.js +3 -0
  16. package/dist/flatgeobuf/3.27.2/constants.js.map +1 -0
  17. package/dist/flatgeobuf/3.27.2/crs-meta.d.ts +9 -0
  18. package/dist/flatgeobuf/3.27.2/crs-meta.d.ts.map +1 -0
  19. package/dist/flatgeobuf/3.27.2/crs-meta.js +2 -0
  20. package/dist/flatgeobuf/3.27.2/crs-meta.js.map +1 -0
  21. package/dist/flatgeobuf/3.27.2/dumptree.d.ts +2 -0
  22. package/dist/flatgeobuf/3.27.2/dumptree.d.ts.map +1 -0
  23. package/dist/flatgeobuf/3.27.2/dumptree.js +61 -0
  24. package/dist/flatgeobuf/3.27.2/dumptree.js.map +1 -0
  25. package/dist/flatgeobuf/3.27.2/feature.d.ts +2 -0
  26. package/dist/flatgeobuf/3.27.2/feature.d.ts.map +1 -0
  27. package/dist/flatgeobuf/3.27.2/feature.js +3 -0
  28. package/dist/flatgeobuf/3.27.2/feature.js.map +1 -0
  29. package/dist/flatgeobuf/3.27.2/flat-geobuf/column-type.d.ts +18 -0
  30. package/dist/flatgeobuf/3.27.2/flat-geobuf/column-type.d.ts.map +1 -0
  31. package/dist/flatgeobuf/3.27.2/flat-geobuf/column-type.js +19 -0
  32. package/dist/flatgeobuf/3.27.2/flat-geobuf/column-type.js.map +1 -0
  33. package/dist/flatgeobuf/3.27.2/flat-geobuf/column.d.ts +39 -0
  34. package/dist/flatgeobuf/3.27.2/flat-geobuf/column.d.ts.map +1 -0
  35. package/dist/flatgeobuf/3.27.2/flat-geobuf/column.js +121 -0
  36. package/dist/flatgeobuf/3.27.2/flat-geobuf/column.js.map +1 -0
  37. package/dist/flatgeobuf/3.27.2/flat-geobuf/crs.d.ts +29 -0
  38. package/dist/flatgeobuf/3.27.2/flat-geobuf/crs.d.ts.map +1 -0
  39. package/dist/flatgeobuf/3.27.2/flat-geobuf/crs.js +79 -0
  40. package/dist/flatgeobuf/3.27.2/flat-geobuf/crs.js.map +1 -0
  41. package/dist/flatgeobuf/3.27.2/flat-geobuf/feature.d.ts +29 -0
  42. package/dist/flatgeobuf/3.27.2/flat-geobuf/feature.d.ts.map +1 -0
  43. package/dist/flatgeobuf/3.27.2/flat-geobuf/feature.js +95 -0
  44. package/dist/flatgeobuf/3.27.2/flat-geobuf/feature.js.map +1 -0
  45. package/dist/flatgeobuf/3.27.2/flat-geobuf/geometry-type.d.ts +21 -0
  46. package/dist/flatgeobuf/3.27.2/flat-geobuf/geometry-type.d.ts.map +1 -0
  47. package/dist/flatgeobuf/3.27.2/flat-geobuf/geometry-type.js +22 -0
  48. package/dist/flatgeobuf/3.27.2/flat-geobuf/geometry-type.js.map +1 -0
  49. package/dist/flatgeobuf/3.27.2/flat-geobuf/geometry.d.ts +75 -0
  50. package/dist/flatgeobuf/3.27.2/flat-geobuf/geometry.d.ts.map +1 -0
  51. package/dist/flatgeobuf/3.27.2/flat-geobuf/geometry.js +214 -0
  52. package/dist/flatgeobuf/3.27.2/flat-geobuf/geometry.js.map +1 -0
  53. package/dist/flatgeobuf/3.27.2/flat-geobuf/header.d.ts +59 -0
  54. package/dist/flatgeobuf/3.27.2/flat-geobuf/header.d.ts.map +1 -0
  55. package/dist/flatgeobuf/3.27.2/flat-geobuf/header.js +166 -0
  56. package/dist/flatgeobuf/3.27.2/flat-geobuf/header.js.map +1 -0
  57. package/dist/flatgeobuf/3.27.2/flat-geobuf.d.ts +6 -0
  58. package/dist/flatgeobuf/3.27.2/flat-geobuf.d.ts.map +1 -0
  59. package/dist/flatgeobuf/3.27.2/flat-geobuf.js +6 -0
  60. package/dist/flatgeobuf/3.27.2/flat-geobuf.js.map +1 -0
  61. package/dist/flatgeobuf/3.27.2/generic/feature.d.ts +19 -0
  62. package/dist/flatgeobuf/3.27.2/generic/feature.d.ts.map +1 -0
  63. package/dist/flatgeobuf/3.27.2/generic/feature.js +220 -0
  64. package/dist/flatgeobuf/3.27.2/generic/feature.js.map +1 -0
  65. package/dist/flatgeobuf/3.27.2/generic/featurecollection.d.ts +18 -0
  66. package/dist/flatgeobuf/3.27.2/generic/featurecollection.d.ts.map +1 -0
  67. package/dist/flatgeobuf/3.27.2/generic/featurecollection.js +162 -0
  68. package/dist/flatgeobuf/3.27.2/generic/featurecollection.js.map +1 -0
  69. package/dist/flatgeobuf/3.27.2/generic/geometry.d.ts +33 -0
  70. package/dist/flatgeobuf/3.27.2/generic/geometry.d.ts.map +1 -0
  71. package/dist/flatgeobuf/3.27.2/generic/geometry.js +81 -0
  72. package/dist/flatgeobuf/3.27.2/generic/geometry.js.map +1 -0
  73. package/dist/flatgeobuf/3.27.2/generic/header.d.ts +5 -0
  74. package/dist/flatgeobuf/3.27.2/generic/header.d.ts.map +1 -0
  75. package/dist/flatgeobuf/3.27.2/generic/header.js +27 -0
  76. package/dist/flatgeobuf/3.27.2/generic/header.js.map +1 -0
  77. package/dist/flatgeobuf/3.27.2/generic.d.ts +16 -0
  78. package/dist/flatgeobuf/3.27.2/generic.d.ts.map +1 -0
  79. package/dist/flatgeobuf/3.27.2/generic.js +9 -0
  80. package/dist/flatgeobuf/3.27.2/generic.js.map +1 -0
  81. package/dist/flatgeobuf/3.27.2/geojson/feature.d.ts +8 -0
  82. package/dist/flatgeobuf/3.27.2/geojson/feature.d.ts.map +1 -0
  83. package/dist/flatgeobuf/3.27.2/geojson/feature.js +13 -0
  84. package/dist/flatgeobuf/3.27.2/geojson/feature.js.map +1 -0
  85. package/dist/flatgeobuf/3.27.2/geojson/featurecollection.d.ts +8 -0
  86. package/dist/flatgeobuf/3.27.2/geojson/featurecollection.d.ts.map +1 -0
  87. package/dist/flatgeobuf/3.27.2/geojson/featurecollection.js +54 -0
  88. package/dist/flatgeobuf/3.27.2/geojson/featurecollection.js.map +1 -0
  89. package/dist/flatgeobuf/3.27.2/geojson/geometry.d.ts +13 -0
  90. package/dist/flatgeobuf/3.27.2/geojson/geometry.d.ts.map +1 -0
  91. package/dist/flatgeobuf/3.27.2/geojson/geometry.js +118 -0
  92. package/dist/flatgeobuf/3.27.2/geojson/geometry.js.map +1 -0
  93. package/dist/flatgeobuf/3.27.2/geojson.d.ts +17 -0
  94. package/dist/flatgeobuf/3.27.2/geojson.d.ts.map +1 -0
  95. package/dist/flatgeobuf/3.27.2/geojson.js +10 -0
  96. package/dist/flatgeobuf/3.27.2/geojson.js.map +1 -0
  97. package/dist/flatgeobuf/3.27.2/header-meta.d.ts +17 -0
  98. package/dist/flatgeobuf/3.27.2/header-meta.d.ts.map +1 -0
  99. package/dist/flatgeobuf/3.27.2/header-meta.js +46 -0
  100. package/dist/flatgeobuf/3.27.2/header-meta.js.map +1 -0
  101. package/dist/flatgeobuf/3.27.2/header.d.ts +2 -0
  102. package/dist/flatgeobuf/3.27.2/header.d.ts.map +1 -0
  103. package/dist/flatgeobuf/3.27.2/header.js +3 -0
  104. package/dist/flatgeobuf/3.27.2/header.js.map +1 -0
  105. package/dist/flatgeobuf/3.27.2/http-reader.d.ts +41 -0
  106. package/dist/flatgeobuf/3.27.2/http-reader.d.ts.map +1 -0
  107. package/dist/flatgeobuf/3.27.2/http-reader.js +193 -0
  108. package/dist/flatgeobuf/3.27.2/http-reader.js.map +1 -0
  109. package/dist/flatgeobuf/3.27.2/index.d.ts +14 -0
  110. package/dist/flatgeobuf/3.27.2/index.d.ts.map +1 -0
  111. package/dist/flatgeobuf/3.27.2/index.js +16 -0
  112. package/dist/flatgeobuf/3.27.2/index.js.map +1 -0
  113. package/dist/flatgeobuf/3.27.2/logger.d.ts +15 -0
  114. package/dist/flatgeobuf/3.27.2/logger.d.ts.map +1 -0
  115. package/dist/flatgeobuf/3.27.2/logger.js +65 -0
  116. package/dist/flatgeobuf/3.27.2/logger.js.map +1 -0
  117. package/dist/flatgeobuf/3.27.2/packedrtree.d.ts +43 -0
  118. package/dist/flatgeobuf/3.27.2/packedrtree.d.ts.map +1 -0
  119. package/dist/flatgeobuf/3.27.2/packedrtree.js +138 -0
  120. package/dist/flatgeobuf/3.27.2/packedrtree.js.map +1 -0
  121. package/dist/flatgeobuf/3.27.2/streams/utils.d.ts +7 -0
  122. package/dist/flatgeobuf/3.27.2/streams/utils.d.ts.map +1 -0
  123. package/dist/flatgeobuf/3.27.2/streams/utils.js +67 -0
  124. package/dist/flatgeobuf/3.27.2/streams/utils.js.map +1 -0
  125. package/dist/flatgeobuf/3.27.2/types/jsts.d.ts +23 -0
  126. package/dist/flatgeobuf/3.27.2/types/slice.d.ts +16 -0
  127. package/dist/flatgeobuf-loader.d.ts +3 -2
  128. package/dist/flatgeobuf-loader.d.ts.map +1 -1
  129. package/dist/flatgeobuf-loader.js +12 -2
  130. package/dist/flatgeobuf-loader.js.map +1 -1
  131. package/dist/flatgeobuf-worker.js +8908 -0
  132. package/dist/index.cjs +1658 -51
  133. package/dist/index.d.ts +2 -5
  134. package/dist/index.d.ts.map +1 -1
  135. package/dist/index.js +1 -10
  136. package/dist/index.js.map +1 -1
  137. package/dist/lib/binary-geometries.d.ts +1 -1
  138. package/dist/lib/binary-geometries.d.ts.map +1 -1
  139. package/dist/lib/binary-geometries.js.map +1 -1
  140. package/dist/lib/get-schema-from-fgb-header.d.ts +16 -0
  141. package/dist/lib/get-schema-from-fgb-header.d.ts.map +1 -0
  142. package/dist/lib/get-schema-from-fgb-header.js +90 -0
  143. package/dist/lib/get-schema-from-fgb-header.js.map +1 -0
  144. package/dist/lib/parse-flatgeobuf.d.ts +2 -1
  145. package/dist/lib/parse-flatgeobuf.d.ts.map +1 -1
  146. package/dist/lib/parse-flatgeobuf.js +29 -23
  147. package/dist/lib/parse-flatgeobuf.js.map +1 -1
  148. package/dist/workers/flatgeobuf-worker.js.map +1 -1
  149. package/package.json +17 -11
  150. package/src/LICENSE +9 -0
  151. package/src/flatgeobuf/3.27.2/LICENSE +29 -0
  152. package/src/flatgeobuf/3.27.2/README.md +45 -0
  153. package/src/flatgeobuf/3.27.2/column-meta.ts +14 -0
  154. package/src/flatgeobuf/3.27.2/config.ts +19 -0
  155. package/src/flatgeobuf/3.27.2/constants.ts +4 -0
  156. package/src/flatgeobuf/3.27.2/crs-meta.ts +8 -0
  157. package/src/flatgeobuf/3.27.2/dumptree.ts +82 -0
  158. package/src/flatgeobuf/3.27.2/feature.ts +3 -0
  159. package/src/flatgeobuf/3.27.2/flat-geobuf/column-type.ts +19 -0
  160. package/src/flatgeobuf/3.27.2/flat-geobuf/column.ts +170 -0
  161. package/src/flatgeobuf/3.27.2/flat-geobuf/crs.ts +114 -0
  162. package/src/flatgeobuf/3.27.2/flat-geobuf/feature.ts +140 -0
  163. package/src/flatgeobuf/3.27.2/flat-geobuf/geometry-type.ts +22 -0
  164. package/src/flatgeobuf/3.27.2/flat-geobuf/geometry.ts +382 -0
  165. package/src/flatgeobuf/3.27.2/flat-geobuf/header.ts +246 -0
  166. package/src/flatgeobuf/3.27.2/flat-geobuf.ts +7 -0
  167. package/src/flatgeobuf/3.27.2/generic/feature.ts +243 -0
  168. package/src/flatgeobuf/3.27.2/generic/featurecollection.ts +227 -0
  169. package/src/flatgeobuf/3.27.2/generic/geometry.ts +120 -0
  170. package/src/flatgeobuf/3.27.2/generic/header.ts +32 -0
  171. package/src/flatgeobuf/3.27.2/generic.ts +33 -0
  172. package/src/flatgeobuf/3.27.2/geojson/feature.ts +20 -0
  173. package/src/flatgeobuf/3.27.2/geojson/featurecollection.ts +101 -0
  174. package/src/flatgeobuf/3.27.2/geojson/geometry.ts +142 -0
  175. package/src/flatgeobuf/3.27.2/geojson.ts +37 -0
  176. package/src/flatgeobuf/3.27.2/header-meta.ts +66 -0
  177. package/src/flatgeobuf/3.27.2/header.ts +3 -0
  178. package/src/flatgeobuf/3.27.2/http-reader.ts +351 -0
  179. package/src/flatgeobuf/3.27.2/index.ts +19 -0
  180. package/src/flatgeobuf/3.27.2/logger.ts +51 -0
  181. package/src/flatgeobuf/3.27.2/packedrtree.ts +255 -0
  182. package/src/flatgeobuf/3.27.2/streams/utils.ts +80 -0
  183. package/src/flatgeobuf/3.27.2/types/jsts.d.ts +23 -0
  184. package/src/flatgeobuf/3.27.2/types/slice.d.ts +16 -0
  185. package/src/flatgeobuf-loader.ts +20 -2
  186. package/src/index.ts +5 -14
  187. package/src/lib/binary-geometries.ts +4 -3
  188. package/src/lib/get-schema-from-fgb-header.ts +122 -0
  189. package/src/lib/parse-flatgeobuf.ts +35 -27
  190. package/src/workers/flatgeobuf-worker.ts +4 -0
@@ -0,0 +1,82 @@
1
+ // tool to dump spatial index tree
2
+ // run with fx. TS_NODE_PROJECT=config/tsconfig.test.json node --loader ts-node/esm.mjs src/ts/dumptree.ts
3
+
4
+ import flatbuffers from 'flatbuffers';
5
+ import Envelope from 'jsts/org/locationtech/jts/geom/Envelope.js';
6
+ import GeometryFactory from 'jsts/org/locationtech/jts/geom/GeometryFactory.js';
7
+ import GeoJSONWriter from 'jsts/org/locationtech/jts/io/GeoJSONWriter.js';
8
+ import {readFileSync, writeFileSync} from 'fs';
9
+
10
+ import {magicbytes, SIZE_PREFIX_LEN} from './constants';
11
+ import {fromByteBuffer} from './header-meta';
12
+ import {calcTreeSize, generateLevelBounds} from './packedrtree';
13
+
14
+ const buffer = readFileSync('./test/data/tiger_roads.fgb');
15
+ const bytes = new Uint8Array(buffer);
16
+
17
+ if (!bytes.subarray(0, 3).every((v, i) => magicbytes[i] === v))
18
+ throw new Error('Not a FlatGeobuf file');
19
+
20
+ const bb = new flatbuffers.ByteBuffer(bytes);
21
+ const headerLength = bb.readUint32(magicbytes.length);
22
+ bb.setPosition(magicbytes.length + SIZE_PREFIX_LEN);
23
+
24
+ const headerMeta = fromByteBuffer(bb);
25
+
26
+ if (headerMeta.indexNodeSize === 0) throw new Error('No index found');
27
+
28
+ let offset = magicbytes.length + SIZE_PREFIX_LEN + headerLength;
29
+ const numItems = headerMeta.featuresCount;
30
+ const nodeSize = headerMeta.indexNodeSize;
31
+ const envelope = headerMeta.envelope;
32
+
33
+ console.log(`Number of items in tree: ${numItems}`);
34
+ console.log(`Envelope: ${envelope}`);
35
+ console.log(`Tree node index size: ${nodeSize}`);
36
+ console.log(`Offset: ${offset}`);
37
+
38
+ const treeSize = calcTreeSize(numItems, nodeSize);
39
+ const levelBounds = generateLevelBounds(numItems, nodeSize).reverse();
40
+
41
+ console.log('Level bounds:');
42
+ for (const levelBound of levelBounds) console.log(` ${levelBound}`);
43
+
44
+ console.log(`Size: ${treeSize}`);
45
+
46
+ const items: any[] = [];
47
+
48
+ function readNode(level: number) {
49
+ const minx = buffer.readDoubleLE(offset + 0);
50
+ const miny = buffer.readDoubleLE(offset + 8);
51
+ const maxx = buffer.readDoubleLE(offset + 16);
52
+ const maxy = buffer.readDoubleLE(offset + 24);
53
+ items.push([level, minx, miny, maxx, maxy]);
54
+ offset += 40;
55
+ }
56
+
57
+ let level = 0;
58
+ for (const levelBound of levelBounds) {
59
+ for (let i = levelBound[0]; i < levelBound[1]; i++) readNode(level);
60
+ level++;
61
+ }
62
+
63
+ const writer = new GeoJSONWriter();
64
+ const factory = new GeometryFactory();
65
+
66
+ const geojsonfeatures = items.map((i) => {
67
+ const geometry = factory.toGeometry(new Envelope(i[1], i[3], i[2], i[4]));
68
+ return {
69
+ type: 'Feature',
70
+ geometry: writer.write(geometry),
71
+ properties: {
72
+ level: i[0]
73
+ }
74
+ };
75
+ });
76
+
77
+ const geojson = {
78
+ type: 'FeatureCollection',
79
+ features: geojsonfeatures
80
+ };
81
+
82
+ writeFileSync('out.geojson', JSON.stringify(geojson));
@@ -0,0 +1,3 @@
1
+ // automatically generated by the FlatBuffers compiler, do not modify
2
+
3
+ export * as FlatGeobuf from './flat-geobuf';
@@ -0,0 +1,19 @@
1
+ // automatically generated by the FlatBuffers compiler, do not modify
2
+
3
+ export enum ColumnType {
4
+ Byte = 0,
5
+ UByte = 1,
6
+ Bool = 2,
7
+ Short = 3,
8
+ UShort = 4,
9
+ Int = 5,
10
+ UInt = 6,
11
+ Long = 7,
12
+ ULong = 8,
13
+ Float = 9,
14
+ Double = 10,
15
+ String = 11,
16
+ Json = 12,
17
+ DateTime = 13,
18
+ Binary = 14
19
+ }
@@ -0,0 +1,170 @@
1
+ // automatically generated by the FlatBuffers compiler, do not modify
2
+
3
+ import * as flatbuffers from 'flatbuffers';
4
+
5
+ import {ColumnType} from '../flat-geobuf/column-type';
6
+
7
+ export class Column {
8
+ bb: flatbuffers.ByteBuffer | null = null;
9
+ bb_pos = 0;
10
+ __init(i: number, bb: flatbuffers.ByteBuffer): Column {
11
+ this.bb_pos = i;
12
+ this.bb = bb;
13
+ return this;
14
+ }
15
+
16
+ static getRootAsColumn(bb: flatbuffers.ByteBuffer, obj?: Column): Column {
17
+ return (obj || new Column()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
18
+ }
19
+
20
+ static getSizePrefixedRootAsColumn(bb: flatbuffers.ByteBuffer, obj?: Column): Column {
21
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
22
+ return (obj || new Column()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
23
+ }
24
+
25
+ name(): string | null;
26
+ name(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null;
27
+ name(optionalEncoding?: any): string | Uint8Array | null {
28
+ const offset = this.bb!.__offset(this.bb_pos, 4);
29
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
30
+ }
31
+
32
+ type(): ColumnType {
33
+ const offset = this.bb!.__offset(this.bb_pos, 6);
34
+ return offset ? this.bb!.readUint8(this.bb_pos + offset) : ColumnType.Byte;
35
+ }
36
+
37
+ title(): string | null;
38
+ title(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null;
39
+ title(optionalEncoding?: any): string | Uint8Array | null {
40
+ const offset = this.bb!.__offset(this.bb_pos, 8);
41
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
42
+ }
43
+
44
+ description(): string | null;
45
+ description(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null;
46
+ description(optionalEncoding?: any): string | Uint8Array | null {
47
+ const offset = this.bb!.__offset(this.bb_pos, 10);
48
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
49
+ }
50
+
51
+ width(): number {
52
+ const offset = this.bb!.__offset(this.bb_pos, 12);
53
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : -1;
54
+ }
55
+
56
+ precision(): number {
57
+ const offset = this.bb!.__offset(this.bb_pos, 14);
58
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : -1;
59
+ }
60
+
61
+ scale(): number {
62
+ const offset = this.bb!.__offset(this.bb_pos, 16);
63
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : -1;
64
+ }
65
+
66
+ nullable(): boolean {
67
+ const offset = this.bb!.__offset(this.bb_pos, 18);
68
+ return offset ? Boolean(this.bb!.readInt8(this.bb_pos + offset)) : true;
69
+ }
70
+
71
+ unique(): boolean {
72
+ const offset = this.bb!.__offset(this.bb_pos, 20);
73
+ return offset ? Boolean(this.bb!.readInt8(this.bb_pos + offset)) : false;
74
+ }
75
+
76
+ primaryKey(): boolean {
77
+ const offset = this.bb!.__offset(this.bb_pos, 22);
78
+ return offset ? Boolean(this.bb!.readInt8(this.bb_pos + offset)) : false;
79
+ }
80
+
81
+ metadata(): string | null;
82
+ metadata(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null;
83
+ metadata(optionalEncoding?: any): string | Uint8Array | null {
84
+ const offset = this.bb!.__offset(this.bb_pos, 24);
85
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
86
+ }
87
+
88
+ static startColumn(builder: flatbuffers.Builder) {
89
+ builder.startObject(11);
90
+ }
91
+
92
+ static addName(builder: flatbuffers.Builder, nameOffset: flatbuffers.Offset) {
93
+ builder.addFieldOffset(0, nameOffset, 0);
94
+ }
95
+
96
+ static addType(builder: flatbuffers.Builder, type: ColumnType) {
97
+ builder.addFieldInt8(1, type, ColumnType.Byte);
98
+ }
99
+
100
+ static addTitle(builder: flatbuffers.Builder, titleOffset: flatbuffers.Offset) {
101
+ builder.addFieldOffset(2, titleOffset, 0);
102
+ }
103
+
104
+ static addDescription(builder: flatbuffers.Builder, descriptionOffset: flatbuffers.Offset) {
105
+ builder.addFieldOffset(3, descriptionOffset, 0);
106
+ }
107
+
108
+ static addWidth(builder: flatbuffers.Builder, width: number) {
109
+ builder.addFieldInt32(4, width, -1);
110
+ }
111
+
112
+ static addPrecision(builder: flatbuffers.Builder, precision: number) {
113
+ builder.addFieldInt32(5, precision, -1);
114
+ }
115
+
116
+ static addScale(builder: flatbuffers.Builder, scale: number) {
117
+ builder.addFieldInt32(6, scale, -1);
118
+ }
119
+
120
+ static addNullable(builder: flatbuffers.Builder, nullable: boolean) {
121
+ builder.addFieldInt8(7, Number(nullable), Number(true));
122
+ }
123
+
124
+ static addUnique(builder: flatbuffers.Builder, unique: boolean) {
125
+ builder.addFieldInt8(8, Number(unique), Number(false));
126
+ }
127
+
128
+ static addPrimaryKey(builder: flatbuffers.Builder, primaryKey: boolean) {
129
+ builder.addFieldInt8(9, Number(primaryKey), Number(false));
130
+ }
131
+
132
+ static addMetadata(builder: flatbuffers.Builder, metadataOffset: flatbuffers.Offset) {
133
+ builder.addFieldOffset(10, metadataOffset, 0);
134
+ }
135
+
136
+ static endColumn(builder: flatbuffers.Builder): flatbuffers.Offset {
137
+ const offset = builder.endObject();
138
+ builder.requiredField(offset, 4); // name
139
+ return offset;
140
+ }
141
+
142
+ static createColumn(
143
+ builder: flatbuffers.Builder,
144
+ nameOffset: flatbuffers.Offset,
145
+ type: ColumnType,
146
+ titleOffset: flatbuffers.Offset,
147
+ descriptionOffset: flatbuffers.Offset,
148
+ width: number,
149
+ precision: number,
150
+ scale: number,
151
+ nullable: boolean,
152
+ unique: boolean,
153
+ primaryKey: boolean,
154
+ metadataOffset: flatbuffers.Offset
155
+ ): flatbuffers.Offset {
156
+ Column.startColumn(builder);
157
+ Column.addName(builder, nameOffset);
158
+ Column.addType(builder, type);
159
+ Column.addTitle(builder, titleOffset);
160
+ Column.addDescription(builder, descriptionOffset);
161
+ Column.addWidth(builder, width);
162
+ Column.addPrecision(builder, precision);
163
+ Column.addScale(builder, scale);
164
+ Column.addNullable(builder, nullable);
165
+ Column.addUnique(builder, unique);
166
+ Column.addPrimaryKey(builder, primaryKey);
167
+ Column.addMetadata(builder, metadataOffset);
168
+ return Column.endColumn(builder);
169
+ }
170
+ }
@@ -0,0 +1,114 @@
1
+ // automatically generated by the FlatBuffers compiler, do not modify
2
+
3
+ import * as flatbuffers from 'flatbuffers';
4
+
5
+ export class Crs {
6
+ bb: flatbuffers.ByteBuffer | null = null;
7
+ bb_pos = 0;
8
+ __init(i: number, bb: flatbuffers.ByteBuffer): Crs {
9
+ this.bb_pos = i;
10
+ this.bb = bb;
11
+ return this;
12
+ }
13
+
14
+ static getRootAsCrs(bb: flatbuffers.ByteBuffer, obj?: Crs): Crs {
15
+ return (obj || new Crs()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
16
+ }
17
+
18
+ static getSizePrefixedRootAsCrs(bb: flatbuffers.ByteBuffer, obj?: Crs): Crs {
19
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
20
+ return (obj || new Crs()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
21
+ }
22
+
23
+ org(): string | null;
24
+ org(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null;
25
+ org(optionalEncoding?: any): string | Uint8Array | null {
26
+ const offset = this.bb!.__offset(this.bb_pos, 4);
27
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
28
+ }
29
+
30
+ code(): number {
31
+ const offset = this.bb!.__offset(this.bb_pos, 6);
32
+ return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
33
+ }
34
+
35
+ name(): string | null;
36
+ name(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null;
37
+ name(optionalEncoding?: any): string | Uint8Array | null {
38
+ const offset = this.bb!.__offset(this.bb_pos, 8);
39
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
40
+ }
41
+
42
+ description(): string | null;
43
+ description(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null;
44
+ description(optionalEncoding?: any): string | Uint8Array | null {
45
+ const offset = this.bb!.__offset(this.bb_pos, 10);
46
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
47
+ }
48
+
49
+ wkt(): string | null;
50
+ wkt(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null;
51
+ wkt(optionalEncoding?: any): string | Uint8Array | null {
52
+ const offset = this.bb!.__offset(this.bb_pos, 12);
53
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
54
+ }
55
+
56
+ codeString(): string | null;
57
+ codeString(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null;
58
+ codeString(optionalEncoding?: any): string | Uint8Array | null {
59
+ const offset = this.bb!.__offset(this.bb_pos, 14);
60
+ return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
61
+ }
62
+
63
+ static startCrs(builder: flatbuffers.Builder) {
64
+ builder.startObject(6);
65
+ }
66
+
67
+ static addOrg(builder: flatbuffers.Builder, orgOffset: flatbuffers.Offset) {
68
+ builder.addFieldOffset(0, orgOffset, 0);
69
+ }
70
+
71
+ static addCode(builder: flatbuffers.Builder, code: number) {
72
+ builder.addFieldInt32(1, code, 0);
73
+ }
74
+
75
+ static addName(builder: flatbuffers.Builder, nameOffset: flatbuffers.Offset) {
76
+ builder.addFieldOffset(2, nameOffset, 0);
77
+ }
78
+
79
+ static addDescription(builder: flatbuffers.Builder, descriptionOffset: flatbuffers.Offset) {
80
+ builder.addFieldOffset(3, descriptionOffset, 0);
81
+ }
82
+
83
+ static addWkt(builder: flatbuffers.Builder, wktOffset: flatbuffers.Offset) {
84
+ builder.addFieldOffset(4, wktOffset, 0);
85
+ }
86
+
87
+ static addCodeString(builder: flatbuffers.Builder, codeStringOffset: flatbuffers.Offset) {
88
+ builder.addFieldOffset(5, codeStringOffset, 0);
89
+ }
90
+
91
+ static endCrs(builder: flatbuffers.Builder): flatbuffers.Offset {
92
+ const offset = builder.endObject();
93
+ return offset;
94
+ }
95
+
96
+ static createCrs(
97
+ builder: flatbuffers.Builder,
98
+ orgOffset: flatbuffers.Offset,
99
+ code: number,
100
+ nameOffset: flatbuffers.Offset,
101
+ descriptionOffset: flatbuffers.Offset,
102
+ wktOffset: flatbuffers.Offset,
103
+ codeStringOffset: flatbuffers.Offset
104
+ ): flatbuffers.Offset {
105
+ Crs.startCrs(builder);
106
+ Crs.addOrg(builder, orgOffset);
107
+ Crs.addCode(builder, code);
108
+ Crs.addName(builder, nameOffset);
109
+ Crs.addDescription(builder, descriptionOffset);
110
+ Crs.addWkt(builder, wktOffset);
111
+ Crs.addCodeString(builder, codeStringOffset);
112
+ return Crs.endCrs(builder);
113
+ }
114
+ }
@@ -0,0 +1,140 @@
1
+ // automatically generated by the FlatBuffers compiler, do not modify
2
+
3
+ import * as flatbuffers from 'flatbuffers';
4
+
5
+ import {Column} from '../flat-geobuf/column';
6
+ import {Geometry} from '../flat-geobuf/geometry';
7
+
8
+ export class Feature {
9
+ bb: flatbuffers.ByteBuffer | null = null;
10
+ bb_pos = 0;
11
+ __init(i: number, bb: flatbuffers.ByteBuffer): Feature {
12
+ this.bb_pos = i;
13
+ this.bb = bb;
14
+ return this;
15
+ }
16
+
17
+ static getRootAsFeature(bb: flatbuffers.ByteBuffer, obj?: Feature): Feature {
18
+ return (obj || new Feature()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
19
+ }
20
+
21
+ static getSizePrefixedRootAsFeature(bb: flatbuffers.ByteBuffer, obj?: Feature): Feature {
22
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
23
+ return (obj || new Feature()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
24
+ }
25
+
26
+ geometry(obj?: Geometry): Geometry | null {
27
+ const offset = this.bb!.__offset(this.bb_pos, 4);
28
+ return offset
29
+ ? (obj || new Geometry()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!)
30
+ : null;
31
+ }
32
+
33
+ properties(index: number): number | null {
34
+ const offset = this.bb!.__offset(this.bb_pos, 6);
35
+ return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
36
+ }
37
+
38
+ propertiesLength(): number {
39
+ const offset = this.bb!.__offset(this.bb_pos, 6);
40
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
41
+ }
42
+
43
+ propertiesArray(): Uint8Array | null {
44
+ const offset = this.bb!.__offset(this.bb_pos, 6);
45
+ return offset
46
+ ? new Uint8Array(
47
+ this.bb!.bytes().buffer,
48
+ this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset),
49
+ this.bb!.__vector_len(this.bb_pos + offset)
50
+ )
51
+ : null;
52
+ }
53
+
54
+ columns(index: number, obj?: Column): Column | null {
55
+ const offset = this.bb!.__offset(this.bb_pos, 8);
56
+ return offset
57
+ ? (obj || new Column()).__init(
58
+ this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4),
59
+ this.bb!
60
+ )
61
+ : null;
62
+ }
63
+
64
+ columnsLength(): number {
65
+ const offset = this.bb!.__offset(this.bb_pos, 8);
66
+ return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
67
+ }
68
+
69
+ static startFeature(builder: flatbuffers.Builder) {
70
+ builder.startObject(3);
71
+ }
72
+
73
+ static addGeometry(builder: flatbuffers.Builder, geometryOffset: flatbuffers.Offset) {
74
+ builder.addFieldOffset(0, geometryOffset, 0);
75
+ }
76
+
77
+ static addProperties(builder: flatbuffers.Builder, propertiesOffset: flatbuffers.Offset) {
78
+ builder.addFieldOffset(1, propertiesOffset, 0);
79
+ }
80
+
81
+ static createPropertiesVector(
82
+ builder: flatbuffers.Builder,
83
+ data: number[] | Uint8Array
84
+ ): flatbuffers.Offset {
85
+ builder.startVector(1, data.length, 1);
86
+ for (let i = data.length - 1; i >= 0; i--) {
87
+ builder.addInt8(data[i]!);
88
+ }
89
+ return builder.endVector();
90
+ }
91
+
92
+ static startPropertiesVector(builder: flatbuffers.Builder, numElems: number) {
93
+ builder.startVector(1, numElems, 1);
94
+ }
95
+
96
+ static addColumns(builder: flatbuffers.Builder, columnsOffset: flatbuffers.Offset) {
97
+ builder.addFieldOffset(2, columnsOffset, 0);
98
+ }
99
+
100
+ static createColumnsVector(
101
+ builder: flatbuffers.Builder,
102
+ data: flatbuffers.Offset[]
103
+ ): flatbuffers.Offset {
104
+ builder.startVector(4, data.length, 4);
105
+ for (let i = data.length - 1; i >= 0; i--) {
106
+ builder.addOffset(data[i]!);
107
+ }
108
+ return builder.endVector();
109
+ }
110
+
111
+ static startColumnsVector(builder: flatbuffers.Builder, numElems: number) {
112
+ builder.startVector(4, numElems, 4);
113
+ }
114
+
115
+ static endFeature(builder: flatbuffers.Builder): flatbuffers.Offset {
116
+ const offset = builder.endObject();
117
+ return offset;
118
+ }
119
+
120
+ static finishFeatureBuffer(builder: flatbuffers.Builder, offset: flatbuffers.Offset) {
121
+ builder.finish(offset);
122
+ }
123
+
124
+ static finishSizePrefixedFeatureBuffer(builder: flatbuffers.Builder, offset: flatbuffers.Offset) {
125
+ builder.finish(offset, undefined, true);
126
+ }
127
+
128
+ static createFeature(
129
+ builder: flatbuffers.Builder,
130
+ geometryOffset: flatbuffers.Offset,
131
+ propertiesOffset: flatbuffers.Offset,
132
+ columnsOffset: flatbuffers.Offset
133
+ ): flatbuffers.Offset {
134
+ Feature.startFeature(builder);
135
+ Feature.addGeometry(builder, geometryOffset);
136
+ Feature.addProperties(builder, propertiesOffset);
137
+ Feature.addColumns(builder, columnsOffset);
138
+ return Feature.endFeature(builder);
139
+ }
140
+ }
@@ -0,0 +1,22 @@
1
+ // automatically generated by the FlatBuffers compiler, do not modify
2
+
3
+ export enum GeometryType {
4
+ Unknown = 0,
5
+ Point = 1,
6
+ LineString = 2,
7
+ Polygon = 3,
8
+ MultiPoint = 4,
9
+ MultiLineString = 5,
10
+ MultiPolygon = 6,
11
+ GeometryCollection = 7,
12
+ CircularString = 8,
13
+ CompoundCurve = 9,
14
+ CurvePolygon = 10,
15
+ MultiCurve = 11,
16
+ MultiSurface = 12,
17
+ Curve = 13,
18
+ Surface = 14,
19
+ PolyhedralSurface = 15,
20
+ TIN = 16,
21
+ Triangle = 17
22
+ }