@loaders.gl/flatgeobuf 4.0.0-beta.7 → 4.0.0

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.
package/LICENSE CHANGED
@@ -1,9 +1,6 @@
1
- Copyright (c) 2015 Uber Technologies, Inc.
2
-
3
- This software includes parts of PhiloGL (https://github.com/philogb/philogl)
4
- under MIT license. PhiloGL parts Copyright © 2013 Sencha Labs.
1
+ loaders.gl is licensed under the MIT license
5
2
 
6
- This software includes adaptations of postprocessing code from THREE.js (https://github.com/mrdoob/three.js/) under MIT license. Additional attribution given in specific source files. THREE.js parts Copyright © 2010-2018 three.js authors.
3
+ Copyright (c) vis.gl contributors
7
4
 
8
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
9
6
  of this software and associated documentation files (the "Software"), to deal
@@ -23,8 +20,12 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
21
  THE SOFTWARE.
25
22
 
23
+ ---
24
+
25
+ Copyright (c) 2015 Uber Technologies, Inc.
26
26
 
27
- loaders.gl includes certain files from Cesium (https://github.com/AnalyticalGraphicsInc/cesium) under the Apache 2 License:
27
+ loaders.gl includes certain files from Cesium (https://github.com/AnalyticalGraphicsInc/cesium)
28
+ under the Apache 2 License (found in the submodule: modules/3d-tiles):)
28
29
 
29
30
  Copyright 2011-2018 CesiumJS Contributors
30
31
 
@@ -38,4 +39,3 @@ distributed under the License is distributed on an "AS IS" BASIS,
38
39
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
39
40
  See the License for the specific language governing permissions and limitations under the License.
40
41
 
41
- Cesium-derived code can be found in the submodule: modules/3d-tiles
@@ -1 +1 @@
1
- {"version":3,"file":"binary-geometries.d.ts","sourceRoot":"","sources":["../../src/lib/binary-geometries.ts"],"names":[],"mappings":"AAEA,OAAO,E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E,UAAU,GAAG,IAAI,EAAE,IAAI,EAAE,YAAY;;;;;;;;;;;;;;;;;;SAGjF;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,WAAW,GAAG,IAAI,EAAE,IAAI,EAAE,YAAY;;;;;;;;;;;;;;;;;;SAkBnF"}
@@ -1 +1 @@
1
- {"version":3,"file":"binary-geometries.js","names":["fgbToBinaryFeature","geometry","type","fgbGeometry","fgbToBinaryGeometry","GeometryType","Point","MultiPoint","parsePoint","LineString","MultiLineString","parseLines","Polygon","parsePolygons","MultiPolygon","parseMultiPolygons","Error","xy","xyArray","z","zArray","positions","blitArrays","ends","endsArray","Array","from","length","unshift","pathIndices","value","Uint16Array","size","primitivePolygonIndices","polygonIndices","parsedParts","nPositions","nPrimitivePolygonIndices","nPolygonIndices","i","partsLength","part","parts","polygon","push","concatPositions","Float64Array","concatPrimitivePolygonIndices","Uint32Array","concatPolygonIndices","positionCounter","primitivePolygonIndicesCounter","polygonIndicesCounter","positionSize","parsedPart","set","subarray","map","x","totalLength","xyz"],"sources":["../../src/lib/binary-geometries.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {Geometry as FGBGeometry, Feature as FGBFeature} from 'flatgeobuf';\n// import {GeometryType} from 'flatgeobuf/generic';\n// Copy geometry type as it is hard to access the export\nexport declare enum GeometryType {\n Unknown = 0,\n Point = 1,\n LineString = 2,\n Polygon = 3,\n MultiPoint = 4,\n MultiLineString = 5,\n MultiPolygon = 6,\n GeometryCollection = 7,\n CircularString = 8,\n CompoundCurve = 9,\n CurvePolygon = 10,\n MultiCurve = 11,\n MultiSurface = 12,\n Curve = 13,\n Surface = 14,\n PolyhedralSurface = 15,\n TIN = 16,\n Triangle = 17\n}\n\nexport function fgbToBinaryFeature(geometry: FGBFeature | null, type: GeometryType) {\n const fgbGeometry: FGBGeometry | null = geometry?.geometry() || null;\n return fgbToBinaryGeometry(fgbGeometry, type);\n}\n\nexport function fgbToBinaryGeometry(geometry: FGBGeometry | null, type: GeometryType) {\n if (geometry === null) {\n return null;\n }\n switch (type) {\n case GeometryType.Point:\n case GeometryType.MultiPoint:\n return parsePoint(geometry);\n case GeometryType.LineString:\n case GeometryType.MultiLineString:\n return parseLines(geometry);\n case GeometryType.Polygon:\n return parsePolygons(geometry);\n case GeometryType.MultiPolygon:\n return parseMultiPolygons(geometry);\n default:\n throw new Error(`Unimplemented geometry type: ${type}`);\n }\n}\n\n// Parse Point to flat array\nfunction parsePoint(geometry: FGBGeometry) {\n const xy = geometry.xyArray();\n const z = geometry.zArray();\n // @ts-expect-error TODO handle null geometries\n const positions = blitArrays(xy, z);\n return {positions};\n}\n\nfunction parseLines(geometry: FGBGeometry) {\n const xy = geometry.xyArray();\n const z = geometry.zArray();\n const positions = blitArrays(xy!, z!);\n\n // If endsArray is null, a single LineString. Otherwise, contains the end\n // indices of each part of the MultiLineString. geometry.endsArray() omits the\n // initial 0 that we have in our internal format.\n // @ts-expect-error TODO handle null geometries\n const ends = (geometry.endsArray() && Array.from(geometry.endsArray())) || [xy.length / 2];\n ends.unshift(0);\n\n const pathIndices = {value: new Uint16Array(ends), size: 1};\n\n return {\n positions,\n pathIndices\n };\n}\n\nfunction parsePolygons(geometry: FGBGeometry) {\n const xy = geometry.xyArray();\n const z = geometry.zArray();\n // @ts-expect-error TODO handle null geometries\n const positions = blitArrays(xy, z);\n\n // If endsArray is null, a simple Polygon with no inner rings. Otherwise,\n // contains the end indices of each ring of the Polygon. geometry.endsArray()\n // omits the initial 0 that we have in our internal format.\n // @ts-expect-error TODO handle null geometries\n const ends = (geometry.endsArray() && Array.from(geometry.endsArray())) || [xy.length / 2];\n ends.unshift(0);\n\n const primitivePolygonIndices = {value: new Uint16Array(ends), size: 1};\n const polygonIndices = {value: new Uint16Array([0, xy!.length / 2]), size: 1};\n\n return {\n positions,\n primitivePolygonIndices,\n polygonIndices\n };\n}\n\n// eslint-disable-next-line max-statements\nfunction parseMultiPolygons(geometry: FGBGeometry) {\n // Create arrays for each geometry part, then concatenate\n const parsedParts: any[] = [];\n let nPositions = 0;\n let nPrimitivePolygonIndices = 1;\n let nPolygonIndices = 1;\n\n for (let i = 0; i < geometry.partsLength(); i++) {\n const part = geometry.parts(i);\n // @ts-expect-error TODO handle null geometries\n const polygon = parsePolygons(part);\n\n nPositions += polygon.positions.value.length;\n nPrimitivePolygonIndices += polygon.primitivePolygonIndices.value.length - 1;\n nPolygonIndices += polygon.polygonIndices.value.length - 1;\n\n parsedParts.push(polygon);\n }\n\n const concatPositions = new Float64Array(nPositions);\n const concatPrimitivePolygonIndices = new Uint32Array(nPrimitivePolygonIndices);\n const concatPolygonIndices = new Uint32Array(nPolygonIndices);\n\n let positionCounter = 0;\n let primitivePolygonIndicesCounter = 1;\n let polygonIndicesCounter = 1;\n\n // Assumes all parts of the multipolygon have the same size\n const positionSize = parsedParts[0].positions.size;\n\n for (const parsedPart of parsedParts) {\n concatPositions.set(parsedPart.positions.value, positionCounter * positionSize);\n\n // For indices, need to add positionCounter so that position indices are\n // correct in the concatenated positions\n concatPrimitivePolygonIndices.set(\n // eslint-disable-next-line\n parsedPart.primitivePolygonIndices.value.subarray(1).map((x) => x + positionCounter),\n primitivePolygonIndicesCounter\n );\n concatPolygonIndices.set(\n // eslint-disable-next-line\n parsedPart.polygonIndices.value.subarray(1).map((x) => x + positionCounter),\n polygonIndicesCounter\n );\n\n positionCounter += parsedPart.positions.value.length / positionSize;\n primitivePolygonIndicesCounter += parsedPart.primitivePolygonIndices.value.length - 1;\n polygonIndicesCounter += parsedPart.polygonIndices.value.length - 1;\n }\n\n return {\n positions: {value: concatPositions, size: positionSize},\n primitivePolygonIndices: {value: concatPrimitivePolygonIndices, size: 1},\n polygonIndices: {value: concatPolygonIndices, size: 1}\n };\n}\n\n// Combine xy and z arrays\nfunction blitArrays(xy: Float64Array, z: Float64Array): {value: Float64Array; size: number} {\n if (!z) {\n return {value: xy, size: 2};\n }\n\n if (z.length * 2 !== xy.length) {\n throw new Error('Z array must be half XY array\\'s length');\n }\n const totalLength = xy.length + z.length;\n\n const xyz = new Float64Array(totalLength);\n for (let i = 0; i < xy.length / 2; i++) {\n xyz[i * 3 + 0] = xy[i * 2 + 0];\n xyz[i * 3 + 1] = xy[i * 2 + 1];\n xyz[i * 3 + 2] = z[i];\n }\n return {value: xyz, size: 3};\n}\n"],"mappings":"AA0BA,OAAO,SAASA,kBAAkBA,CAACC,QAA2B,EAAEC,IAAkB,EAAE;EAClF,MAAMC,WAA+B,GAAG,CAAAF,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEA,QAAQ,CAAC,CAAC,KAAI,IAAI;EACpE,OAAOG,mBAAmB,CAACD,WAAW,EAAED,IAAI,CAAC;AAC/C;AAEA,OAAO,SAASE,mBAAmBA,CAACH,QAA4B,EAAEC,IAAkB,EAAE;EACpF,IAAID,QAAQ,KAAK,IAAI,EAAE;IACrB,OAAO,IAAI;EACb;EACA,QAAQC,IAAI;IACV,KAAKG,YAAY,CAACC,KAAK;IACvB,KAAKD,YAAY,CAACE,UAAU;MAC1B,OAAOC,UAAU,CAACP,QAAQ,CAAC;IAC7B,KAAKI,YAAY,CAACI,UAAU;IAC5B,KAAKJ,YAAY,CAACK,eAAe;MAC/B,OAAOC,UAAU,CAACV,QAAQ,CAAC;IAC7B,KAAKI,YAAY,CAACO,OAAO;MACvB,OAAOC,aAAa,CAACZ,QAAQ,CAAC;IAChC,KAAKI,YAAY,CAACS,YAAY;MAC5B,OAAOC,kBAAkB,CAACd,QAAQ,CAAC;IACrC;MACE,MAAM,IAAIe,KAAK,CAAE,gCAA+Bd,IAAK,EAAC,CAAC;EAC3D;AACF;AAGA,SAASM,UAAUA,CAACP,QAAqB,EAAE;EACzC,MAAMgB,EAAE,GAAGhB,QAAQ,CAACiB,OAAO,CAAC,CAAC;EAC7B,MAAMC,CAAC,GAAGlB,QAAQ,CAACmB,MAAM,CAAC,CAAC;EAE3B,MAAMC,SAAS,GAAGC,UAAU,CAACL,EAAE,EAAEE,CAAC,CAAC;EACnC,OA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AAE;IAC9B,MAAM,IAAIX,KAAK,CAAC,yCAAyC,CAAC;EAC5D;EACA,MAAM2C,WAAW,GAAG1C,EAAE,CAACU,MAAM,GAAGR,CAAC,CAACQ,MAAM;EAExC,MAAMiC,GAAG,GAAG,IAAId,YAAY,CAACa,WAAW,CAAC;EACzC,KAAK,IAAIpB,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGtB,EAAE,CAACU,MAAM,GAAG,CAAC,EAAEY,CAAC,EAAE,EAAE;IACtCqB,GAAG,CAACrB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAGtB,EAAE,CAACsB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC9BqB,GAAG,CAACrB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAGtB,EAAE,CAACsB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC9BqB,GAAG,CAACrB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAGpB,CAAC,CAACoB,CAAC,CAAC;EACvB;EACA,OAAO;IAACT,KAAK,EAAE8B,GAAG;IAAE5B,IAAI,EAAE;EAAC,CAAC;AAC9B"}
1
+ {"version":3,"file":"binary-geometries.js","names":["fgbToBinaryFeature","geometry","type","fgbGeometry","fgbToBinaryGeometry","GeometryType","Point","MultiPoint","parsePoint","LineString","MultiLineString","parseLines","Polygon","parsePolygons","MultiPolygon","parseMultiPolygons","Error","xy","xyArray","z","zArray","positions","blitArrays","ends","endsArray","Array","from","length","unshift","pathIndices","value","Uint16Array","size","primitivePolygonIndices","polygonIndices","parsedParts","nPositions","nPrimitivePolygonIndices","nPolygonIndices","i","partsLength","part","parts","polygon","push","concatPositions","Float64Array","concatPrimitivePolygonIndices","Uint32Array","concatPolygonIndices","positionCounter","primitivePolygonIndicesCounter","polygonIndicesCounter","positionSize","parsedPart","set","subarray","map","x","totalLength","xyz"],"sources":["../../src/lib/binary-geometries.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {Geometry as FGBGeometry, Feature as FGBFeature} from 'flatgeobuf';\n// import {GeometryType} from 'flatgeobuf/generic';\n// Copy geometry type as it is hard to access the export\nexport declare enum GeometryType {\n Unknown = 0,\n Point = 1,\n LineString = 2,\n Polygon = 3,\n MultiPoint = 4,\n MultiLineString = 5,\n MultiPolygon = 6,\n GeometryCollection = 7,\n CircularString = 8,\n CompoundCurve = 9,\n CurvePolygon = 10,\n MultiCurve = 11,\n MultiSurface = 12,\n Curve = 13,\n Surface = 14,\n PolyhedralSurface = 15,\n TIN = 16,\n Triangle = 17\n}\n\nexport function fgbToBinaryFeature(geometry: FGBFeature | null, type: GeometryType) {\n const fgbGeometry: FGBGeometry | null = geometry?.geometry() || null;\n return fgbToBinaryGeometry(fgbGeometry, type);\n}\n\nexport function fgbToBinaryGeometry(geometry: FGBGeometry | null, type: GeometryType) {\n if (geometry === null) {\n return null;\n }\n switch (type) {\n case GeometryType.Point:\n case GeometryType.MultiPoint:\n return parsePoint(geometry);\n case GeometryType.LineString:\n case GeometryType.MultiLineString:\n return parseLines(geometry);\n case GeometryType.Polygon:\n return parsePolygons(geometry);\n case GeometryType.MultiPolygon:\n return parseMultiPolygons(geometry);\n default:\n throw new Error(`Unimplemented geometry type: ${type}`);\n }\n}\n\n// Parse Point to flat array\nfunction parsePoint(geometry: FGBGeometry) {\n const xy = geometry.xyArray();\n const z = geometry.zArray();\n // @ts-expect-error TODO handle null geometries\n const positions = blitArrays(xy, z);\n return {positions};\n}\n\nfunction parseLines(geometry: FGBGeometry) {\n const xy = geometry.xyArray();\n const z = geometry.zArray();\n const positions = blitArrays(xy!, z!);\n\n // If endsArray is null, a single LineString. Otherwise, contains the end\n // indices of each part of the MultiLineString. geometry.endsArray() omits the\n // initial 0 that we have in our internal format.\n // @ts-expect-error TODO handle null geometries\n const ends = (geometry.endsArray() && Array.from(geometry.endsArray())) || [xy.length / 2];\n ends.unshift(0);\n\n const pathIndices = {value: new Uint16Array(ends), size: 1};\n\n return {\n positions,\n pathIndices\n };\n}\n\nfunction parsePolygons(geometry: FGBGeometry) {\n const xy = geometry.xyArray();\n const z = geometry.zArray();\n // @ts-expect-error TODO handle null geometries\n const positions = blitArrays(xy, z);\n\n // If endsArray is null, a simple Polygon with no inner rings. Otherwise,\n // contains the end indices of each ring of the Polygon. geometry.endsArray()\n // omits the initial 0 that we have in our internal format.\n // @ts-expect-error TODO handle null geometries\n const ends = (geometry.endsArray() && Array.from(geometry.endsArray())) || [xy.length / 2];\n ends.unshift(0);\n\n const primitivePolygonIndices = {value: new Uint16Array(ends), size: 1};\n const polygonIndices = {value: new Uint16Array([0, xy!.length / 2]), size: 1};\n\n return {\n positions,\n primitivePolygonIndices,\n polygonIndices\n };\n}\n\n// eslint-disable-next-line max-statements\nfunction parseMultiPolygons(geometry: FGBGeometry) {\n // Create arrays for each geometry part, then concatenate\n const parsedParts: any[] = [];\n let nPositions = 0;\n let nPrimitivePolygonIndices = 1;\n let nPolygonIndices = 1;\n\n for (let i = 0; i < geometry.partsLength(); i++) {\n const part = geometry.parts(i);\n // @ts-expect-error TODO handle null geometries\n const polygon = parsePolygons(part);\n\n nPositions += polygon.positions.value.length;\n nPrimitivePolygonIndices += polygon.primitivePolygonIndices.value.length - 1;\n nPolygonIndices += polygon.polygonIndices.value.length - 1;\n\n parsedParts.push(polygon);\n }\n\n const concatPositions = new Float64Array(nPositions);\n const concatPrimitivePolygonIndices = new Uint32Array(nPrimitivePolygonIndices);\n const concatPolygonIndices = new Uint32Array(nPolygonIndices);\n\n let positionCounter = 0;\n let primitivePolygonIndicesCounter = 1;\n let polygonIndicesCounter = 1;\n\n // Assumes all parts of the multipolygon have the same size\n const positionSize = parsedParts[0].positions.size;\n\n for (const parsedPart of parsedParts) {\n concatPositions.set(parsedPart.positions.value, positionCounter * positionSize);\n\n // For indices, need to add positionCounter so that position indices are\n // correct in the concatenated positions\n concatPrimitivePolygonIndices.set(\n // eslint-disable-next-line\n parsedPart.primitivePolygonIndices.value.subarray(1).map((x) => x + positionCounter),\n primitivePolygonIndicesCounter\n );\n concatPolygonIndices.set(\n // eslint-disable-next-line\n parsedPart.polygonIndices.value.subarray(1).map((x) => x + positionCounter),\n polygonIndicesCounter\n );\n\n positionCounter += parsedPart.positions.value.length / positionSize;\n primitivePolygonIndicesCounter += parsedPart.primitivePolygonIndices.value.length - 1;\n polygonIndicesCounter += parsedPart.polygonIndices.value.length - 1;\n }\n\n return {\n positions: {value: concatPositions, size: positionSize},\n primitivePolygonIndices: {value: concatPrimitivePolygonIndices, size: 1},\n polygonIndices: {value: concatPolygonIndices, size: 1}\n };\n}\n\n// Combine xy and z arrays\nfunction blitArrays(xy: Float64Array, z: Float64Array): {value: Float64Array; size: number} {\n if (!z) {\n return {value: xy, size: 2};\n }\n\n if (z.length * 2 !== xy.length) {\n throw new Error('Z array must be half XY array\\'s length');\n }\n const totalLength = xy.length + z.length;\n\n const xyz = new Float64Array(totalLength);\n for (let i = 0; i < xy.length / 2; i++) {\n xyz[i * 3 + 0] = xy[i * 2 + 0];\n xyz[i * 3 + 1] = xy[i * 2 + 1];\n xyz[i * 3 + 2] = z[i];\n }\n return {value: xyz, size: 3};\n}\n"],"mappings":"AA2BA,OAAO,SAASA,kBAAkBA,CAACC,QAA2B,EAAEC,IAAkB,EAAE;EAClF,MAAMC,WAA+B,GAAG,CAAAF,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEA,QAAQ,CAAC,CAAC,KAAI,IAAI;EACpE,OAAOG,mBAAmB,CAACD,WAAW,EAAED,IAAI,CAAC;AAC/C;AAEA,OAAO,SAASE,mBAAmBA,CAACH,QAA4B,EAAEC,IAAkB,EAAE;EACpF,IAAID,QAAQ,KAAK,IAAI,EAAE;IACrB,OAAO,IAAI;EACb;EACA,QAAQC,IAAI;IACV,KAAKG,YAAY,CAACC,KAAK;IACvB,KAAKD,YAAY,CAACE,UAAU;MAC1B,OAAOC,UAAU,CAACP,QAAQ,CAAC;IAC7B,KAAKI,YAAY,CAACI,U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,CAAC;AAC9B"}
@@ -1 +1 @@
1
- {"version":3,"file":"parse-flatgeobuf.d.ts","sourceRoot":"","sources":["../../src/lib/parse-flatgeobuf.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAwB,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAkCrE,wBAAgB,eAAe,CAC7B,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,uBAAuB,GAChC,KAAK,CA0BP;AAsDD,wBAAgB,wBAAwB,CAAC,MAAM,KAAA,EAAE,OAAO,EAAE,uBAAuB,4GAUhF"}
1
+ {"version":3,"file":"parse-flatgeobuf.d.ts","sourceRoot":"","sources":["../../src/lib/parse-flatgeobuf.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAwB,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAkCrE,wBAAgB,eAAe,CAC7B,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,uBAAuB,GAChC,KAAK,CA0BP;AAsDD,wBAAgB,wBAAwB,CAAC,MAAM,KAAA,EAAE,OAAO,EAAE,uBAAuB,4GAUhF"}
@@ -1 +1 @@
1
- {"version":3,"file":"parse-flatgeobuf.js","names":["Proj4Projection","transformGeoJsonCoords","fgbToBinaryGeometry","geojson","generic","parseProperties","parsePropertiesBinary","deserializeGeoJson","deserialize","deserializeGeneric","binaryFromFeature","feature","header","geometry","geometryType","type","parsedGeometry","properties","columns","parseFlatGeobuf","arrayBuffer","options","_options$flatgeobuf","shape","flatgeobuf","features","parseFlatGeobufToGeoJSON","table","binary","parseFlatGeobufToBinary","data","Error","arguments","length","undefined","array","Uint8Array","byteLength","reproject","_targetCrs","gis","arr","headerMeta","crs","projection","from","wkt","to","e","coords","project","parseFlatGeobufInBatches","stream","_options$flatgeobuf2","parseFlatGeobufInBatchesToBinary","parseFlatGeobufInBatchesToGeoJSON","iterator","firstRecord"],"sources":["../../src/lib/parse-flatgeobuf.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {Proj4Projection} from '@math.gl/proj4';\nimport {transformGeoJsonCoords} from '@loaders.gl/gis';\n\nimport type {FlatGeobufLoaderOptions} from '../flatgeobuf-loader';\nimport type {GeoJSONTable, Feature, Table} from '@loaders.gl/schema';\nimport {fgbToBinaryGeometry} from './binary-geometries';\n\nimport {Feature as FBGFeature, HeaderMeta as FGBHeader} from 'flatgeobuf';\nimport * as geojson from 'flatgeobuf/lib/mjs/geojson.js';\nimport * as generic from 'flatgeobuf/lib/mjs/generic.js';\nimport {parseProperties as parsePropertiesBinary} from 'flatgeobuf/lib/mjs/generic/feature';\nconst deserializeGeoJson = geojson.deserialize;\nconst deserializeGeneric = generic.deserialize;\n// const parsePropertiesBinary = FlatgeobufFeature.parseProperties;\n\n// TODO: reproject binary features\nfunction binaryFromFeature(feature: FBGFeature, header: FGBHeader) {\n const geometry = feature.geometry();\n\n // FlatGeobuf files can only hold a single geometry type per file, otherwise\n // GeometryType is GeometryCollection\n // I believe geometry.type() is null (0) except when the geometry type isn't\n // known in the header?\n const geometryType = header.geometryType || geometry?.type();\n const parsedGeometry = fgbToBinaryGeometry(geometry, geometryType!);\n // @ts-expect-error this looks wrong\n parsedGeometry.properties = parsePropertiesBinary(feature, header.columns);\n\n // TODO: wrap binary data either in points, lines, or polygons key\n return parsedGeometry;\n}\n\n/*\n * Parse FlatGeobuf arrayBuffer and return GeoJSON.\n *\n * @param arrayBuffer A FlatGeobuf arrayBuffer\n * @return A GeoJSON geometry object\n */\nexport function parseFlatGeobuf(\n arrayBuffer: ArrayBuffer,\n options?: FlatGeobufLoaderOptions\n): Table {\n const shape = options?.flatgeobuf?.shape;\n\n switch (shape) {\n case 'geojson-table': {\n const features = parseFlatGeobufToGeoJSON(arrayBuffer, options);\n const table: GeoJSONTable = {\n shape: 'geojson-table',\n type: 'FeatureCollection',\n features\n };\n return table;\n }\n\n case 'columnar-table': // binary + some JS arrays\n const binary = parseFlatGeobufToBinary(arrayBuffer, options);\n // @ts-expect-error\n return {shape: 'columnar-table', data: binary};\n\n case 'binary':\n // @ts-expect-error\n return parseFlatGeobufToBinary(arrayBuffer, options);\n\n default:\n throw new Error(shape);\n }\n}\n\nfunction parseFlatGeobufToBinary(arrayBuffer: ArrayBuffer, options: FlatGeobufLoaderOptions = {}) {\n // TODO: reproject binary features\n // const {reproject = false, _targetCrs = 'WGS84'} = (options && options.gis) || {};\n\n const array = new Uint8Array(arrayBuffer);\n // @ts-expect-error\n return deserializeGeneric(array, fgbToBinaryGeometry);\n}\n\nfunction parseFlatGeobufToGeoJSON(\n arrayBuffer: ArrayBuffer,\n options: FlatGeobufLoaderOptions = {}\n): Feature[] {\n if (arrayBuffer.byteLength === 0) {\n return [];\n }\n\n const {reproject = false, _targetCrs = 'WGS84'} = (options && options.gis) || {};\n\n const arr = new Uint8Array(arrayBuffer);\n\n let headerMeta;\n // @ts-expect-error this looks wrong\n const {features} = deserializeGeoJson(arr, undefined, (header) => {\n headerMeta = header;\n });\n\n const crs = headerMeta && headerMeta.crs;\n let projection;\n if (reproject && crs) {\n // Constructing the projection may fail for some invalid WKT strings\n try {\n projection = new Proj4Projection({from: crs.wkt, to: _targetCrs});\n } catch (e) {\n // no op\n }\n }\n\n if (projection) {\n return transformGeoJsonCoords(features, (coords) => projection.project(coords));\n }\n\n return features;\n}\n\n/*\n * Parse FlatGeobuf arrayBuffer and return GeoJSON.\n *\n * @param {ReadableStream} _ A FlatGeobuf arrayBuffer\n * @return A GeoJSON geometry object iterator\n */\n// eslint-disable-next-line complexity\nexport function parseFlatGeobufInBatches(stream, options: FlatGeobufLoaderOptions) {\n const shape = options.flatgeobuf?.shape;\n switch (shape) {\n case 'binary':\n return parseFlatGeobufInBatchesToBinary(stream, options);\n case 'geojson-table':\n return parseFlatGeobufInBatchesToGeoJSON(stream, options);\n default:\n throw new Error(shape);\n }\n}\n\nfunction parseFlatGeobufInBatchesToBinary(stream, options: FlatGeobufLoaderOptions) {\n // TODO: reproject binary streaming features\n // const {reproject = false, _targetCrs = 'WGS84'} = (options && options.gis) || {};\n\n // @ts-expect-error\n const iterator = deserializeGeneric(stream, binaryFromFeature);\n return iterator;\n}\n\n// eslint-disable-next-line complexity\nasync function* parseFlatGeobufInBatchesToGeoJSON(stream, options: FlatGeobufLoaderOptions) {\n const {reproject = false, _targetCrs = 'WGS84'} = (options && options.gis) || {};\n\n let headerMeta;\n const iterator = deserializeGeoJson(stream, undefined, (header) => {\n headerMeta = header;\n });\n\n let projection;\n let firstRecord = true;\n // @ts-expect-error this looks wrong\n for await (const feature of iterator) {\n if (firstRecord) {\n const crs = headerMeta && headerMeta.crs;\n if (reproject && crs) {\n projection = new Proj4Projection({from: crs.wkt, to: _targetCrs});\n }\n\n firstRecord = false;\n }\n\n if (reproject && projection) {\n // eslint-disable-next-line\n yield transformGeoJsonCoords([feature], (coords) => projection.project(coords));\n } else {\n yield feature;\n }\n }\n}\n"],"mappings":"AAEA,SAAQA,eAAe,QAAO,gBAAgB;AAC9C,SAAQC,sBAAsB,QAAO,iBAAiB;AAAC,SAI/CC,mBAAmB;AAG3B,OAAO,KAAKC,OAAO,MAAM,+BAA+B;AACxD,OAAO,KAAKC,OAAO,MAAM,+BAA+B;AACxD,SAAQC,eAAe,IAAIC,qBAAqB,QAAO,oCAAoC;AAC3F,MAAMC,kBAAkB,GAAGJ,OAAO,CAACK,WAAW;AAC9C,MAAMC,kBAAkB,GAAGL,OAAO,CAACI,WAAW;AAI9C,SAASE,iBAAiBA,CAACC,OAAmB,EAAEC,MAAiB,EAAE;EACjE,MAAMC,QAAQ,GAAGF,OAAO,CAACE,QAAQ,CAAC,CAAC;EAMnC,MAAMC,YAAY,GAAGF,MAAM,CAACE,YAAY,KAAID,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEE,IAAI,CAAC,CAAC;EAC5D,MAAMC,cAAc,G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;AACF"}
1
+ {"version":3,"file":"parse-flatgeobuf.js","names":["Proj4Projection","transformGeoJsonCoords","fgbToBinaryGeometry","geojson","generic","parseProperties","parsePropertiesBinary","deserializeGeoJson","deserialize","deserializeGeneric","binaryFromFeature","feature","header","geometry","geometryType","type","parsedGeometry","properties","columns","parseFlatGeobuf","arrayBuffer","options","_options$flatgeobuf","shape","flatgeobuf","features","parseFlatGeobufToGeoJSON","table","binary","parseFlatGeobufToBinary","data","Error","arguments","length","undefined","array","Uint8Array","byteLength","reproject","_targetCrs","gis","arr","headerMeta","crs","projection","from","wkt","to","e","coords","project","parseFlatGeobufInBatches","stream","_options$flatgeobuf2","parseFlatGeobufInBatchesToBinary","parseFlatGeobufInBatchesToGeoJSON","iterator","firstRecord"],"sources":["../../src/lib/parse-flatgeobuf.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {Proj4Projection} from '@math.gl/proj4';\nimport {transformGeoJsonCoords} from '@loaders.gl/gis';\n\nimport type {FlatGeobufLoaderOptions} from '../flatgeobuf-loader';\nimport type {GeoJSONTable, Feature, Table} from '@loaders.gl/schema';\nimport {fgbToBinaryGeometry} from './binary-geometries';\n\nimport {Feature as FBGFeature, HeaderMeta as FGBHeader} from 'flatgeobuf';\nimport * as geojson from 'flatgeobuf/lib/mjs/geojson.js';\nimport * as generic from 'flatgeobuf/lib/mjs/generic.js';\nimport {parseProperties as parsePropertiesBinary} from 'flatgeobuf/lib/mjs/generic/feature';\nconst deserializeGeoJson = geojson.deserialize;\nconst deserializeGeneric = generic.deserialize;\n// const parsePropertiesBinary = FlatgeobufFeature.parseProperties;\n\n// TODO: reproject binary features\nfunction binaryFromFeature(feature: FBGFeature, header: FGBHeader) {\n const geometry = feature.geometry();\n\n // FlatGeobuf files can only hold a single geometry type per file, otherwise\n // GeometryType is GeometryCollection\n // I believe geometry.type() is null (0) except when the geometry type isn't\n // known in the header?\n const geometryType = header.geometryType || geometry?.type();\n const parsedGeometry = fgbToBinaryGeometry(geometry, geometryType!);\n // @ts-expect-error this looks wrong\n parsedGeometry.properties = parsePropertiesBinary(feature, header.columns);\n\n // TODO: wrap binary data either in points, lines, or polygons key\n return parsedGeometry;\n}\n\n/*\n * Parse FlatGeobuf arrayBuffer and return GeoJSON.\n *\n * @param arrayBuffer A FlatGeobuf arrayBuffer\n * @return A GeoJSON geometry object\n */\nexport function parseFlatGeobuf(\n arrayBuffer: ArrayBuffer,\n options?: FlatGeobufLoaderOptions\n): Table {\n const shape = options?.flatgeobuf?.shape;\n\n switch (shape) {\n case 'geojson-table': {\n const features = parseFlatGeobufToGeoJSON(arrayBuffer, options);\n const table: GeoJSONTable = {\n shape: 'geojson-table',\n type: 'FeatureCollection',\n features\n };\n return table;\n }\n\n case 'columnar-table': // binary + some JS arrays\n const binary = parseFlatGeobufToBinary(arrayBuffer, options);\n // @ts-expect-error\n return {shape: 'columnar-table', data: binary};\n\n case 'binary':\n // @ts-expect-error\n return parseFlatGeobufToBinary(arrayBuffer, options);\n\n default:\n throw new Error(shape);\n }\n}\n\nfunction parseFlatGeobufToBinary(arrayBuffer: ArrayBuffer, options: FlatGeobufLoaderOptions = {}) {\n // TODO: reproject binary features\n // const {reproject = false, _targetCrs = 'WGS84'} = (options && options.gis) || {};\n\n const array = new Uint8Array(arrayBuffer);\n // @ts-expect-error\n return deserializeGeneric(array, fgbToBinaryGeometry);\n}\n\nfunction parseFlatGeobufToGeoJSON(\n arrayBuffer: ArrayBuffer,\n options: FlatGeobufLoaderOptions = {}\n): Feature[] {\n if (arrayBuffer.byteLength === 0) {\n return [];\n }\n\n const {reproject = false, _targetCrs = 'WGS84'} = (options && options.gis) || {};\n\n const arr = new Uint8Array(arrayBuffer);\n\n let headerMeta;\n // @ts-expect-error this looks wrong\n const {features} = deserializeGeoJson(arr, undefined, (header) => {\n headerMeta = header;\n });\n\n const crs = headerMeta && headerMeta.crs;\n let projection;\n if (reproject && crs) {\n // Constructing the projection may fail for some invalid WKT strings\n try {\n projection = new Proj4Projection({from: crs.wkt, to: _targetCrs});\n } catch (e) {\n // no op\n }\n }\n\n if (projection) {\n return transformGeoJsonCoords(features, (coords) => projection.project(coords));\n }\n\n return features;\n}\n\n/*\n * Parse FlatGeobuf arrayBuffer and return GeoJSON.\n *\n * @param {ReadableStream} _ A FlatGeobuf arrayBuffer\n * @return A GeoJSON geometry object iterator\n */\n// eslint-disable-next-line complexity\nexport function parseFlatGeobufInBatches(stream, options: FlatGeobufLoaderOptions) {\n const shape = options.flatgeobuf?.shape;\n switch (shape) {\n case 'binary':\n return parseFlatGeobufInBatchesToBinary(stream, options);\n case 'geojson-table':\n return parseFlatGeobufInBatchesToGeoJSON(stream, options);\n default:\n throw new Error(shape);\n }\n}\n\nfunction parseFlatGeobufInBatchesToBinary(stream, options: FlatGeobufLoaderOptions) {\n // TODO: reproject binary streaming features\n // const {reproject = false, _targetCrs = 'WGS84'} = (options && options.gis) || {};\n\n // @ts-expect-error\n const iterator = deserializeGeneric(stream, binaryFromFeature);\n return iterator;\n}\n\n// eslint-disable-next-line complexity\nasync function* parseFlatGeobufInBatchesToGeoJSON(stream, options: FlatGeobufLoaderOptions) {\n const {reproject = false, _targetCrs = 'WGS84'} = (options && options.gis) || {};\n\n let headerMeta;\n const iterator = deserializeGeoJson(stream, undefined, (header) => {\n headerMeta = header;\n });\n\n let projection;\n let firstRecord = true;\n // @ts-expect-error this looks wrong\n for await (const feature of iterator) {\n if (firstRecord) {\n const crs = headerMeta && headerMeta.crs;\n if (reproject && crs) {\n projection = new Proj4Projection({from: crs.wkt, to: _targetCrs});\n }\n\n firstRecord = false;\n }\n\n if (reproject && projection) {\n // eslint-disable-next-line\n yield transformGeoJsonCoords([feature], (coords) => projection.project(coords));\n } else {\n yield feature;\n }\n }\n}\n"],"mappings":"AAGA,SAAQA,eAAe,QAAO,gBAAgB;AAC9C,SAAQC,sBAAsB,QAAO,iBAAiB;AAAC,SAI/CC,mBAAmB;AAG3B,OAAO,KAAKC,OAAO,MAAM,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f,MAAMd,GAAG,GAAGD,UAAU,IAAIA,UAAU,CAACC,GAAG;MACxC,IAAIL,SAAS,IAAIK,GAAG,EAAE;QACpBC,UAAU,GAAG,IAAI5C,eAAe,CAAC;UAAC6C,IAAI,EAAEF,GAAG,CAACG,GAAG;UAAEC,EAAE,EAAER;QAAU,CAAC,CAAC;MACnE;MAEAkB,WAAW,GAAG,KAAK;IACrB;IAEA,IAAInB,SAAS,IAAIM,UAAU,EAAE;MAE3B,MAAM3C,sBAAsB,CAAC,CAACU,OAAO,CAAC,EAAGsC,MAAM,IAAKL,UAAU,CAACM,OAAO,CAACD,MAAM,CAAC,CAAC;IACjF,CAAC,MAAM;MACL,MAAMtC,OAAO;IACf;EACF;AACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@loaders.gl/flatgeobuf",
3
3
  "description": "Loader for FlatGeobuf",
4
- "version": "4.0.0-beta.7",
4
+ "version": "4.0.0",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "publishConfig": {
@@ -40,10 +40,10 @@
40
40
  "build-worker": "# esbuild src/workers/flatgeobuf-worker.ts --bundle --outfile=dist/flatgeobuf-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
41
41
  },
42
42
  "dependencies": {
43
- "@loaders.gl/gis": "4.0.0-beta.7",
44
- "@loaders.gl/loader-utils": "4.0.0-beta.7",
43
+ "@loaders.gl/gis": "4.0.0",
44
+ "@loaders.gl/loader-utils": "4.0.0",
45
45
  "@math.gl/proj4": "^4.0.0",
46
46
  "flatgeobuf": "3.27.0"
47
47
  },
48
- "gitHead": "5b6cab0ab5d73212cfa37fa5da6e25ad7ef83fe5"
48
+ "gitHead": "9b4211dc0ecd4134a1638ac0a29c5ea9008fd971"
49
49
  }
@@ -1,4 +1,5 @@
1
1
  // loaders.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
2
3
 
3
4
  import {Geometry as FGBGeometry, Feature as FGBFeature} from 'flatgeobuf';
4
5
  // import {GeometryType} from 'flatgeobuf/generic';
@@ -1,4 +1,5 @@
1
1
  // loaders.gl, MIT license
2
+ // Copyright (c) vis.gl contributors
2
3
 
3
4
  import {Proj4Projection} from '@math.gl/proj4';
4
5
  import {transformGeoJsonCoords} from '@loaders.gl/gis';