@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
@@ -1,23 +1,27 @@
1
- // loaders.gl, MIT license
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
2
3
  // Copyright (c) vis.gl contributors
3
4
 
4
5
  import {Proj4Projection} from '@math.gl/proj4';
5
6
  import {transformGeoJsonCoords} from '@loaders.gl/gis';
6
7
 
7
8
  import type {FlatGeobufLoaderOptions} from '../flatgeobuf-loader';
8
- import type {GeoJSONTable, Feature, Table} from '@loaders.gl/schema';
9
+ import type {GeoJSONTable, Table, Schema} from '@loaders.gl/schema';
10
+
9
11
  import {fgbToBinaryGeometry} from './binary-geometries';
12
+ import {getSchemaFromFGBHeader} from './get-schema-from-fgb-header';
13
+
14
+ import * as fgb from '../flatgeobuf/3.27.2';
15
+ import * as geojson from '../flatgeobuf/3.27.2/geojson';
16
+ import * as generic from '../flatgeobuf/3.27.2/generic';
17
+ import {parseProperties as parsePropertiesBinary} from '../flatgeobuf/3.27.2/generic/feature';
10
18
 
11
- import {Feature as FBGFeature, HeaderMeta as FGBHeader} from 'flatgeobuf';
12
- import * as geojson from 'flatgeobuf/lib/mjs/geojson.js';
13
- import * as generic from 'flatgeobuf/lib/mjs/generic.js';
14
- import {parseProperties as parsePropertiesBinary} from 'flatgeobuf/lib/mjs/generic/feature';
15
19
  const deserializeGeoJson = geojson.deserialize;
16
20
  const deserializeGeneric = generic.deserialize;
17
21
  // const parsePropertiesBinary = FlatgeobufFeature.parseProperties;
18
22
 
19
23
  // TODO: reproject binary features
20
- function binaryFromFeature(feature: FBGFeature, header: FGBHeader) {
24
+ function binaryFromFeature(feature: fgb.Feature, header: fgb.HeaderMeta) {
21
25
  const geometry = feature.geometry();
22
26
 
23
27
  // FlatGeobuf files can only hold a single geometry type per file, otherwise
@@ -47,13 +51,7 @@ export function parseFlatGeobuf(
47
51
 
48
52
  switch (shape) {
49
53
  case 'geojson-table': {
50
- const features = parseFlatGeobufToGeoJSON(arrayBuffer, options);
51
- const table: GeoJSONTable = {
52
- shape: 'geojson-table',
53
- type: 'FeatureCollection',
54
- features
55
- };
56
- return table;
54
+ return parseFlatGeobufToGeoJSONTable(arrayBuffer, options);
57
55
  }
58
56
 
59
57
  case 'columnar-table': // binary + some JS arrays
@@ -79,25 +77,28 @@ function parseFlatGeobufToBinary(arrayBuffer: ArrayBuffer, options: FlatGeobufLo
79
77
  return deserializeGeneric(array, fgbToBinaryGeometry);
80
78
  }
81
79
 
82
- function parseFlatGeobufToGeoJSON(
80
+ function parseFlatGeobufToGeoJSONTable(
83
81
  arrayBuffer: ArrayBuffer,
84
82
  options: FlatGeobufLoaderOptions = {}
85
- ): Feature[] {
83
+ ): GeoJSONTable {
86
84
  if (arrayBuffer.byteLength === 0) {
87
- return [];
85
+ return {shape: 'geojson-table', type: 'FeatureCollection', features: []};
88
86
  }
89
87
 
90
88
  const {reproject = false, _targetCrs = 'WGS84'} = (options && options.gis) || {};
91
89
 
92
90
  const arr = new Uint8Array(arrayBuffer);
93
91
 
94
- let headerMeta;
92
+ let fgbHeader;
93
+ let schema: Schema | undefined;
94
+
95
95
  // @ts-expect-error this looks wrong
96
- const {features} = deserializeGeoJson(arr, undefined, (header) => {
97
- headerMeta = header;
96
+ let {features} = deserializeGeoJson(arr, undefined, (headerMeta) => {
97
+ fgbHeader = headerMeta;
98
+ schema = getSchemaFromFGBHeader(fgbHeader);
98
99
  });
99
100
 
100
- const crs = headerMeta && headerMeta.crs;
101
+ const crs = fgbHeader && fgbHeader.crs;
101
102
  let projection;
102
103
  if (reproject && crs) {
103
104
  // Constructing the projection may fail for some invalid WKT strings
@@ -109,10 +110,10 @@ function parseFlatGeobufToGeoJSON(
109
110
  }
110
111
 
111
112
  if (projection) {
112
- return transformGeoJsonCoords(features, (coords) => projection.project(coords));
113
+ features = transformGeoJsonCoords(features, (coords) => projection.project(coords));
113
114
  }
114
115
 
115
- return features;
116
+ return {shape: 'geojson-table', schema, type: 'FeatureCollection', features};
116
117
  }
117
118
 
118
119
  /*
@@ -143,13 +144,20 @@ function parseFlatGeobufInBatchesToBinary(stream, options: FlatGeobufLoaderOptio
143
144
  return iterator;
144
145
  }
145
146
 
147
+ /**
148
+ * @todo this does not return proper GeoJSONTable batches
149
+ * @param stream
150
+ * @param options
151
+ */
146
152
  // eslint-disable-next-line complexity
147
153
  async function* parseFlatGeobufInBatchesToGeoJSON(stream, options: FlatGeobufLoaderOptions) {
148
154
  const {reproject = false, _targetCrs = 'WGS84'} = (options && options.gis) || {};
149
155
 
150
- let headerMeta;
151
- const iterator = deserializeGeoJson(stream, undefined, (header) => {
152
- headerMeta = header;
156
+ let fgbHeader;
157
+ // let schema: Schema | undefined;
158
+ const iterator = deserializeGeoJson(stream, undefined, (headerMeta) => {
159
+ fgbHeader = headerMeta;
160
+ // schema = getSchemaFromFGBHeader(fgbHeader);
153
161
  });
154
162
 
155
163
  let projection;
@@ -157,7 +165,7 @@ async function* parseFlatGeobufInBatchesToGeoJSON(stream, options: FlatGeobufLoa
157
165
  // @ts-expect-error this looks wrong
158
166
  for await (const feature of iterator) {
159
167
  if (firstRecord) {
160
- const crs = headerMeta && headerMeta.crs;
168
+ const crs = fgbHeader && fgbHeader.crs;
161
169
  if (reproject && crs) {
162
170
  projection = new Proj4Projection({from: crs.wkt, to: _targetCrs});
163
171
  }
@@ -1,3 +1,7 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  import {createLoaderWorker} from '@loaders.gl/loader-utils';
2
6
  import {FlatGeobufLoader} from '../index';
3
7