@loaders.gl/geospatial 0.0.0-stage → 5.0.0-alpha.13
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/README.md +8 -2
- package/dist/dbf-worker.js +17055 -0
- package/dist/dbf.d.ts +2 -0
- package/dist/dbf.d.ts.map +1 -0
- package/dist/dbf.js +5 -0
- package/dist/dbf.js.map +1 -0
- package/dist/flatgeobuf/bundled.d.ts +3 -0
- package/dist/flatgeobuf/bundled.d.ts.map +1 -0
- package/dist/flatgeobuf/bundled.js +5 -0
- package/dist/flatgeobuf/bundled.js.map +1 -0
- package/dist/flatgeobuf/flatgeobuf-format.d.ts +12 -0
- package/dist/flatgeobuf/flatgeobuf-format.d.ts.map +1 -0
- package/dist/flatgeobuf/flatgeobuf-format.js +15 -0
- package/dist/flatgeobuf/flatgeobuf-format.js.map +1 -0
- package/dist/flatgeobuf/flatgeobuf-loader-types.d.ts +104 -0
- package/dist/flatgeobuf/flatgeobuf-loader-types.d.ts.map +1 -0
- package/dist/flatgeobuf/flatgeobuf-loader-types.js +36 -0
- package/dist/flatgeobuf/flatgeobuf-loader-types.js.map +1 -0
- package/dist/flatgeobuf/flatgeobuf-loader.d.ts +59 -0
- package/dist/flatgeobuf/flatgeobuf-loader.d.ts.map +1 -0
- package/dist/flatgeobuf/flatgeobuf-loader.js +38 -0
- package/dist/flatgeobuf/flatgeobuf-loader.js.map +1 -0
- package/dist/flatgeobuf/flatgeobuf-source-loader.d.ts +105 -0
- package/dist/flatgeobuf/flatgeobuf-source-loader.d.ts.map +1 -0
- package/dist/flatgeobuf/flatgeobuf-source-loader.js +240 -0
- package/dist/flatgeobuf/flatgeobuf-source-loader.js.map +1 -0
- package/dist/flatgeobuf/flatgeobuf-table-query-capabilities.d.ts +4 -0
- package/dist/flatgeobuf/flatgeobuf-table-query-capabilities.d.ts.map +1 -0
- package/dist/flatgeobuf/flatgeobuf-table-query-capabilities.js +12 -0
- package/dist/flatgeobuf/flatgeobuf-table-query-capabilities.js.map +1 -0
- package/dist/flatgeobuf/index.cjs +5552 -0
- package/dist/flatgeobuf/index.cjs.map +6 -0
- package/dist/flatgeobuf/index.d.ts +9 -0
- package/dist/flatgeobuf/index.d.ts.map +1 -0
- package/dist/flatgeobuf/index.js +11 -0
- package/dist/flatgeobuf/index.js.map +1 -0
- package/dist/flatgeobuf/lib/flatgeobuf-reader.d.ts +97 -0
- package/dist/flatgeobuf/lib/flatgeobuf-reader.d.ts.map +1 -0
- package/dist/flatgeobuf/lib/flatgeobuf-reader.js +577 -0
- package/dist/flatgeobuf/lib/flatgeobuf-reader.js.map +1 -0
- package/dist/flatgeobuf/lib/flatgeobuf-worker-transport.d.ts +8 -0
- package/dist/flatgeobuf/lib/flatgeobuf-worker-transport.d.ts.map +1 -0
- package/dist/flatgeobuf/lib/flatgeobuf-worker-transport.js +44 -0
- package/dist/flatgeobuf/lib/flatgeobuf-worker-transport.js.map +1 -0
- package/dist/flatgeobuf/lib/parse-flatgeobuf.d.ts +36 -0
- package/dist/flatgeobuf/lib/parse-flatgeobuf.d.ts.map +1 -0
- package/dist/flatgeobuf/lib/parse-flatgeobuf.js +269 -0
- package/dist/flatgeobuf/lib/parse-flatgeobuf.js.map +1 -0
- package/dist/flatgeobuf/unbundled.d.ts +3 -0
- package/dist/flatgeobuf/unbundled.d.ts.map +1 -0
- package/dist/flatgeobuf/unbundled.js +5 -0
- package/dist/flatgeobuf/unbundled.js.map +1 -0
- package/dist/flatgeobuf-worker.js +31367 -0
- package/dist/flatgeobuf.d.ts +3 -0
- package/dist/flatgeobuf.d.ts.map +1 -0
- package/dist/flatgeobuf.js +5 -0
- package/dist/flatgeobuf.js.map +1 -0
- package/dist/geopackage/bundled.d.ts +3 -0
- package/dist/geopackage/bundled.d.ts.map +1 -0
- package/dist/geopackage/bundled.js +5 -0
- package/dist/geopackage/bundled.js.map +1 -0
- package/dist/geopackage/geopackage-format.d.ts +11 -0
- package/dist/geopackage/geopackage-format.d.ts.map +1 -0
- package/dist/geopackage/geopackage-format.js +14 -0
- package/dist/geopackage/geopackage-format.js.map +1 -0
- package/dist/geopackage/geopackage-loader-options.d.ts +5 -0
- package/dist/geopackage/geopackage-loader-options.d.ts.map +1 -0
- package/dist/geopackage/geopackage-loader-options.js +12 -0
- package/dist/geopackage/geopackage-loader-options.js.map +1 -0
- package/dist/geopackage/geopackage-loader-types.d.ts +72 -0
- package/dist/geopackage/geopackage-loader-types.d.ts.map +1 -0
- package/dist/geopackage/geopackage-loader-types.js +30 -0
- package/dist/geopackage/geopackage-loader-types.js.map +1 -0
- package/dist/geopackage/geopackage-loader.d.ts +26 -0
- package/dist/geopackage/geopackage-loader.d.ts.map +1 -0
- package/dist/geopackage/geopackage-loader.js +12 -0
- package/dist/geopackage/geopackage-loader.js.map +1 -0
- package/dist/geopackage/geopackage-source-loader.d.ts +99 -0
- package/dist/geopackage/geopackage-source-loader.d.ts.map +1 -0
- package/dist/geopackage/geopackage-source-loader.js +258 -0
- package/dist/geopackage/geopackage-source-loader.js.map +1 -0
- package/dist/geopackage/index.cjs +4443 -0
- package/dist/geopackage/index.cjs.map +6 -0
- package/dist/geopackage/index.d.ts +7 -0
- package/dist/geopackage/index.d.ts.map +1 -0
- package/dist/geopackage/index.js +7 -0
- package/dist/geopackage/index.js.map +1 -0
- package/dist/geopackage/lib/geopackage-tile-metadata.d.ts +22 -0
- package/dist/geopackage/lib/geopackage-tile-metadata.d.ts.map +1 -0
- package/dist/geopackage/lib/geopackage-tile-metadata.js +105 -0
- package/dist/geopackage/lib/geopackage-tile-metadata.js.map +1 -0
- package/dist/geopackage/lib/parse-geopackage.d.ts +39 -0
- package/dist/geopackage/lib/parse-geopackage.d.ts.map +1 -0
- package/dist/geopackage/lib/parse-geopackage.js +485 -0
- package/dist/geopackage/lib/parse-geopackage.js.map +1 -0
- package/dist/geopackage/lib/types.d.ts +216 -0
- package/dist/geopackage/lib/types.d.ts.map +1 -0
- package/dist/geopackage/lib/types.js +5 -0
- package/dist/geopackage/lib/types.js.map +1 -0
- package/dist/geopackage/unbundled.d.ts +3 -0
- package/dist/geopackage/unbundled.d.ts.map +1 -0
- package/dist/geopackage/unbundled.js +5 -0
- package/dist/geopackage/unbundled.js.map +1 -0
- package/dist/geopackage.d.ts +3 -0
- package/dist/geopackage.d.ts.map +1 -0
- package/dist/geopackage.js +5 -0
- package/dist/geopackage.js.map +1 -0
- package/dist/gpx.d.ts +2 -0
- package/dist/gpx.d.ts.map +1 -0
- package/dist/gpx.js +5 -0
- package/dist/gpx.js.map +1 -0
- package/dist/index.cjs +15221 -0
- package/dist/index.cjs.map +6 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/kml/bundled.d.ts +13 -0
- package/dist/kml/bundled.d.ts.map +1 -0
- package/dist/kml/bundled.js +10 -0
- package/dist/kml/bundled.js.map +1 -0
- package/dist/kml/gpx-loader-types.d.ts +61 -0
- package/dist/kml/gpx-loader-types.d.ts.map +1 -0
- package/dist/kml/gpx-loader-types.js +25 -0
- package/dist/kml/gpx-loader-types.js.map +1 -0
- package/dist/kml/gpx-loader.d.ts +56 -0
- package/dist/kml/gpx-loader.d.ts.map +1 -0
- package/dist/kml/gpx-loader.js +62 -0
- package/dist/kml/gpx-loader.js.map +1 -0
- package/dist/kml/index.cjs +11444 -0
- package/dist/kml/index.cjs.map +6 -0
- package/dist/kml/index.d.ts +18 -0
- package/dist/kml/index.d.ts.map +1 -0
- package/dist/kml/index.js +13 -0
- package/dist/kml/index.js.map +1 -0
- package/dist/kml/kml-format.d.ts +50 -0
- package/dist/kml/kml-format.d.ts.map +1 -0
- package/dist/kml/kml-format.js +62 -0
- package/dist/kml/kml-format.js.map +1 -0
- package/dist/kml/kml-loader-types.d.ts +61 -0
- package/dist/kml/kml-loader-types.d.ts.map +1 -0
- package/dist/kml/kml-loader-types.js +25 -0
- package/dist/kml/kml-loader-types.js.map +1 -0
- package/dist/kml/kml-loader.d.ts +56 -0
- package/dist/kml/kml-loader.d.ts.map +1 -0
- package/dist/kml/kml-loader.js +60 -0
- package/dist/kml/kml-loader.js.map +1 -0
- package/dist/kml/kml-parser.d.ts +98 -0
- package/dist/kml/kml-parser.d.ts.map +1 -0
- package/dist/kml/kml-parser.js +461 -0
- package/dist/kml/kml-parser.js.map +1 -0
- package/dist/kml/kml-writer.d.ts +64 -0
- package/dist/kml/kml-writer.d.ts.map +1 -0
- package/dist/kml/kml-writer.js +202 -0
- package/dist/kml/kml-writer.js.map +1 -0
- package/dist/kml/kmz-archive.d.ts +19 -0
- package/dist/kml/kmz-archive.d.ts.map +1 -0
- package/dist/kml/kmz-archive.js +72 -0
- package/dist/kml/kmz-archive.js.map +1 -0
- package/dist/kml/kmz-loader-types.d.ts +58 -0
- package/dist/kml/kmz-loader-types.d.ts.map +1 -0
- package/dist/kml/kmz-loader-types.js +24 -0
- package/dist/kml/kmz-loader-types.js.map +1 -0
- package/dist/kml/kmz-loader.d.ts +29 -0
- package/dist/kml/kmz-loader.d.ts.map +1 -0
- package/dist/kml/kmz-loader.js +41 -0
- package/dist/kml/kmz-loader.js.map +1 -0
- package/dist/kml/kmz-source.d.ts +62 -0
- package/dist/kml/kmz-source.d.ts.map +1 -0
- package/dist/kml/kmz-source.js +177 -0
- package/dist/kml/kmz-source.js.map +1 -0
- package/dist/kml/lib/feature-collection-to-arrow.d.ts +90 -0
- package/dist/kml/lib/feature-collection-to-arrow.d.ts.map +1 -0
- package/dist/kml/lib/feature-collection-to-arrow.js +181 -0
- package/dist/kml/lib/feature-collection-to-arrow.js.map +1 -0
- package/dist/kml/sports-track-parser.d.ts +6 -0
- package/dist/kml/sports-track-parser.d.ts.map +1 -0
- package/dist/kml/sports-track-parser.js +411 -0
- package/dist/kml/sports-track-parser.js.map +1 -0
- package/dist/kml/tcx-loader-types.d.ts +61 -0
- package/dist/kml/tcx-loader-types.d.ts.map +1 -0
- package/dist/kml/tcx-loader-types.js +25 -0
- package/dist/kml/tcx-loader-types.js.map +1 -0
- package/dist/kml/tcx-loader.d.ts +56 -0
- package/dist/kml/tcx-loader.d.ts.map +1 -0
- package/dist/kml/tcx-loader.js +62 -0
- package/dist/kml/tcx-loader.js.map +1 -0
- package/dist/kml/unbundled.d.ts +13 -0
- package/dist/kml/unbundled.d.ts.map +1 -0
- package/dist/kml/unbundled.js +10 -0
- package/dist/kml/unbundled.js.map +1 -0
- package/dist/kml.d.ts +3 -0
- package/dist/kml.d.ts.map +1 -0
- package/dist/kml.js +5 -0
- package/dist/kml.js.map +1 -0
- package/dist/kmz.d.ts +2 -0
- package/dist/kmz.d.ts.map +1 -0
- package/dist/kmz.js +5 -0
- package/dist/kmz.js.map +1 -0
- package/dist/shapefile/bundled.d.ts +7 -0
- package/dist/shapefile/bundled.d.ts.map +1 -0
- package/dist/shapefile/bundled.js +7 -0
- package/dist/shapefile/bundled.js.map +1 -0
- package/dist/shapefile/dbf-format.d.ts +12 -0
- package/dist/shapefile/dbf-format.d.ts.map +1 -0
- package/dist/shapefile/dbf-format.js +15 -0
- package/dist/shapefile/dbf-format.js.map +1 -0
- package/dist/shapefile/dbf-loader-types.d.ts +15 -0
- package/dist/shapefile/dbf-loader-types.d.ts.map +1 -0
- package/dist/shapefile/dbf-loader-types.js +34 -0
- package/dist/shapefile/dbf-loader-types.js.map +1 -0
- package/dist/shapefile/dbf-loader.d.ts +48 -0
- package/dist/shapefile/dbf-loader.d.ts.map +1 -0
- package/dist/shapefile/dbf-loader.js +39 -0
- package/dist/shapefile/dbf-loader.js.map +1 -0
- package/dist/shapefile/index.cjs +5750 -0
- package/dist/shapefile/index.cjs.map +6 -0
- package/dist/shapefile/index.d.ts +16 -0
- package/dist/shapefile/index.d.ts.map +1 -0
- package/dist/shapefile/index.js +18 -0
- package/dist/shapefile/index.js.map +1 -0
- package/dist/shapefile/lib/parsers/build-geoarrow-geometry-arrow.d.ts +18 -0
- package/dist/shapefile/lib/parsers/build-geoarrow-geometry-arrow.d.ts.map +1 -0
- package/dist/shapefile/lib/parsers/build-geoarrow-geometry-arrow.js +129 -0
- package/dist/shapefile/lib/parsers/build-geoarrow-geometry-arrow.js.map +1 -0
- package/dist/shapefile/lib/parsers/build-wkb-geometry-arrow.d.ts +12 -0
- package/dist/shapefile/lib/parsers/build-wkb-geometry-arrow.d.ts.map +1 -0
- package/dist/shapefile/lib/parsers/build-wkb-geometry-arrow.js +206 -0
- package/dist/shapefile/lib/parsers/build-wkb-geometry-arrow.js.map +1 -0
- package/dist/shapefile/lib/parsers/parse-dbf-to-arrow.d.ts +26 -0
- package/dist/shapefile/lib/parsers/parse-dbf-to-arrow.d.ts.map +1 -0
- package/dist/shapefile/lib/parsers/parse-dbf-to-arrow.js +347 -0
- package/dist/shapefile/lib/parsers/parse-dbf-to-arrow.js.map +1 -0
- package/dist/shapefile/lib/parsers/parse-dbf.d.ts +14 -0
- package/dist/shapefile/lib/parsers/parse-dbf.d.ts.map +1 -0
- package/dist/shapefile/lib/parsers/parse-dbf.js +352 -0
- package/dist/shapefile/lib/parsers/parse-dbf.js.map +1 -0
- package/dist/shapefile/lib/parsers/parse-shapefile.d.ts +50 -0
- package/dist/shapefile/lib/parsers/parse-shapefile.d.ts.map +1 -0
- package/dist/shapefile/lib/parsers/parse-shapefile.js +306 -0
- package/dist/shapefile/lib/parsers/parse-shapefile.js.map +1 -0
- package/dist/shapefile/lib/parsers/parse-shp-geometry.d.ts +50 -0
- package/dist/shapefile/lib/parsers/parse-shp-geometry.d.ts.map +1 -0
- package/dist/shapefile/lib/parsers/parse-shp-geometry.js +384 -0
- package/dist/shapefile/lib/parsers/parse-shp-geometry.js.map +1 -0
- package/dist/shapefile/lib/parsers/parse-shp-header.d.ts +26 -0
- package/dist/shapefile/lib/parsers/parse-shp-header.d.ts.map +1 -0
- package/dist/shapefile/lib/parsers/parse-shp-header.js +43 -0
- package/dist/shapefile/lib/parsers/parse-shp-header.js.map +1 -0
- package/dist/shapefile/lib/parsers/parse-shp-to-arrow.d.ts +5 -0
- package/dist/shapefile/lib/parsers/parse-shp-to-arrow.d.ts.map +1 -0
- package/dist/shapefile/lib/parsers/parse-shp-to-arrow.js +130 -0
- package/dist/shapefile/lib/parsers/parse-shp-to-arrow.js.map +1 -0
- package/dist/shapefile/lib/parsers/parse-shp.d.ts +24 -0
- package/dist/shapefile/lib/parsers/parse-shp.d.ts.map +1 -0
- package/dist/shapefile/lib/parsers/parse-shp.js +194 -0
- package/dist/shapefile/lib/parsers/parse-shp.js.map +1 -0
- package/dist/shapefile/lib/parsers/parse-shx.d.ts +10 -0
- package/dist/shapefile/lib/parsers/parse-shx.d.ts.map +1 -0
- package/dist/shapefile/lib/parsers/parse-shx.js +28 -0
- package/dist/shapefile/lib/parsers/parse-shx.js.map +1 -0
- package/dist/shapefile/lib/parsers/types.d.ts +85 -0
- package/dist/shapefile/lib/parsers/types.d.ts.map +1 -0
- package/dist/shapefile/lib/parsers/types.js +5 -0
- package/dist/shapefile/lib/parsers/types.js.map +1 -0
- package/dist/shapefile/lib/shapefile-worker-transport.d.ts +10 -0
- package/dist/shapefile/lib/shapefile-worker-transport.d.ts.map +1 -0
- package/dist/shapefile/lib/shapefile-worker-transport.js +46 -0
- package/dist/shapefile/lib/shapefile-worker-transport.js.map +1 -0
- package/dist/shapefile/lib/streaming/binary-chunk-reader.d.ts +2 -0
- package/dist/shapefile/lib/streaming/binary-chunk-reader.d.ts.map +1 -0
- package/dist/shapefile/lib/streaming/binary-chunk-reader.js +5 -0
- package/dist/shapefile/lib/streaming/binary-chunk-reader.js.map +1 -0
- package/dist/shapefile/lib/streaming/binary-reader.d.ts +32 -0
- package/dist/shapefile/lib/streaming/binary-reader.d.ts.map +1 -0
- package/dist/shapefile/lib/streaming/binary-reader.js +55 -0
- package/dist/shapefile/lib/streaming/binary-reader.js.map +1 -0
- package/dist/shapefile/lib/streaming/zip-batch-iterators.d.ts +11 -0
- package/dist/shapefile/lib/streaming/zip-batch-iterators.d.ts.map +1 -0
- package/dist/shapefile/lib/streaming/zip-batch-iterators.js +67 -0
- package/dist/shapefile/lib/streaming/zip-batch-iterators.js.map +1 -0
- package/dist/shapefile/shapefile-arrow-loader.d.ts +8 -0
- package/dist/shapefile/shapefile-arrow-loader.d.ts.map +1 -0
- package/dist/shapefile/shapefile-arrow-loader.js +316 -0
- package/dist/shapefile/shapefile-arrow-loader.js.map +1 -0
- package/dist/shapefile/shapefile-loader-types.d.ts +80 -0
- package/dist/shapefile/shapefile-loader-types.d.ts.map +1 -0
- package/dist/shapefile/shapefile-loader-types.js +29 -0
- package/dist/shapefile/shapefile-loader-types.js.map +1 -0
- package/dist/shapefile/shapefile-loader.d.ts +57 -0
- package/dist/shapefile/shapefile-loader.d.ts.map +1 -0
- package/dist/shapefile/shapefile-loader.js +29 -0
- package/dist/shapefile/shapefile-loader.js.map +1 -0
- package/dist/shapefile/shp-format.d.ts +27 -0
- package/dist/shapefile/shp-format.d.ts.map +1 -0
- package/dist/shapefile/shp-format.js +31 -0
- package/dist/shapefile/shp-format.js.map +1 -0
- package/dist/shapefile/shp-loader-types.d.ts +28 -0
- package/dist/shapefile/shp-loader-types.d.ts.map +1 -0
- package/dist/shapefile/shp-loader-types.js +31 -0
- package/dist/shapefile/shp-loader-types.js.map +1 -0
- package/dist/shapefile/shp-loader.d.ts +53 -0
- package/dist/shapefile/shp-loader.d.ts.map +1 -0
- package/dist/shapefile/shp-loader.js +38 -0
- package/dist/shapefile/shp-loader.js.map +1 -0
- package/dist/shapefile/unbundled.d.ts +7 -0
- package/dist/shapefile/unbundled.d.ts.map +1 -0
- package/dist/shapefile/unbundled.js +7 -0
- package/dist/shapefile/unbundled.js.map +1 -0
- package/dist/shapefile.d.ts +3 -0
- package/dist/shapefile.d.ts.map +1 -0
- package/dist/shapefile.js +5 -0
- package/dist/shapefile.js.map +1 -0
- package/dist/shp-worker.js +20183 -0
- package/dist/shp.d.ts +2 -0
- package/dist/shp.d.ts.map +1 -0
- package/dist/shp.js +5 -0
- package/dist/shp.js.map +1 -0
- package/dist/tcx.d.ts +2 -0
- package/dist/tcx.d.ts.map +1 -0
- package/dist/tcx.js +5 -0
- package/dist/tcx.js.map +1 -0
- package/dist/workers/dbf-worker.d.ts +2 -0
- package/dist/workers/dbf-worker.d.ts.map +1 -0
- package/dist/workers/dbf-worker.js +7 -0
- package/dist/workers/dbf-worker.js.map +1 -0
- package/dist/workers/flatgeobuf-worker.d.ts +2 -0
- package/dist/workers/flatgeobuf-worker.d.ts.map +1 -0
- package/dist/workers/flatgeobuf-worker.js +7 -0
- package/dist/workers/flatgeobuf-worker.js.map +1 -0
- package/dist/workers/geopackage-worker.d.ts +2 -0
- package/dist/workers/geopackage-worker.d.ts.map +1 -0
- package/dist/workers/geopackage-worker.js +7 -0
- package/dist/workers/geopackage-worker.js.map +1 -0
- package/dist/workers/shp-worker.d.ts +2 -0
- package/dist/workers/shp-worker.d.ts.map +1 -0
- package/dist/workers/shp-worker.js +7 -0
- package/dist/workers/shp-worker.js.map +1 -0
- package/package.json +286 -4
- package/src/dbf.ts +5 -0
- package/src/flatgeobuf/LICENSE +9 -0
- package/src/flatgeobuf/bundled.ts +9 -0
- package/src/flatgeobuf/flatgeobuf-format.ts +17 -0
- package/src/flatgeobuf/flatgeobuf-loader-types.ts +70 -0
- package/src/flatgeobuf/flatgeobuf-loader.ts +66 -0
- package/src/flatgeobuf/flatgeobuf-source-loader.ts +338 -0
- package/src/flatgeobuf/flatgeobuf-table-query-capabilities.ts +14 -0
- package/src/flatgeobuf/index.ts +24 -0
- package/src/flatgeobuf/lib/flatgeobuf-reader.ts +719 -0
- package/src/flatgeobuf/lib/flatgeobuf-worker-transport.ts +63 -0
- package/src/flatgeobuf/lib/parse-flatgeobuf.ts +383 -0
- package/src/flatgeobuf/unbundled.ts +6 -0
- package/src/flatgeobuf.ts +6 -0
- package/src/geopackage/bundled.ts +6 -0
- package/src/geopackage/geopackage-format.ts +16 -0
- package/src/geopackage/geopackage-loader-options.ts +13 -0
- package/src/geopackage/geopackage-loader-types.ts +58 -0
- package/src/geopackage/geopackage-loader.ts +21 -0
- package/src/geopackage/geopackage-source-loader.ts +364 -0
- package/src/geopackage/index.ts +16 -0
- package/src/geopackage/lib/geopackage-tile-metadata.ts +156 -0
- package/src/geopackage/lib/parse-geopackage.ts +679 -0
- package/src/geopackage/lib/types.ts +293 -0
- package/src/geopackage/unbundled.ts +6 -0
- package/src/geopackage.ts +6 -0
- package/src/gpx.ts +5 -0
- package/src/index.ts +30 -0
- package/src/kml/bundled.ts +21 -0
- package/src/kml/gpx-loader-types.ts +50 -0
- package/src/kml/gpx-loader.ts +101 -0
- package/src/kml/index.ts +39 -0
- package/src/kml/kml-format.ts +70 -0
- package/src/kml/kml-loader-types.ts +46 -0
- package/src/kml/kml-loader.ts +98 -0
- package/src/kml/kml-parser.ts +593 -0
- package/src/kml/kml-writer.ts +252 -0
- package/src/kml/kmz-archive.ts +92 -0
- package/src/kml/kmz-loader-types.ts +37 -0
- package/src/kml/kmz-loader.ts +56 -0
- package/src/kml/kmz-source.ts +234 -0
- package/src/kml/lib/feature-collection-to-arrow.ts +231 -0
- package/src/kml/sports-track-parser.ts +426 -0
- package/src/kml/tcx-loader-types.ts +50 -0
- package/src/kml/tcx-loader.ts +101 -0
- package/src/kml/unbundled.ts +21 -0
- package/src/kml.ts +6 -0
- package/src/kmz.ts +5 -0
- package/src/shapefile/bundled.ts +18 -0
- package/src/shapefile/dbf-format.ts +17 -0
- package/src/shapefile/dbf-loader-types.ts +51 -0
- package/src/shapefile/dbf-loader.ts +79 -0
- package/src/shapefile/index.ts +25 -0
- package/src/shapefile/lib/parsers/build-geoarrow-geometry-arrow.ts +172 -0
- package/src/shapefile/lib/parsers/build-wkb-geometry-arrow.ts +340 -0
- package/src/shapefile/lib/parsers/parse-dbf-to-arrow.ts +429 -0
- package/src/shapefile/lib/parsers/parse-dbf.ts +422 -0
- package/src/shapefile/lib/parsers/parse-shapefile.ts +417 -0
- package/src/shapefile/lib/parsers/parse-shp-geometry.ts +527 -0
- package/src/shapefile/lib/parsers/parse-shp-header.ts +64 -0
- package/src/shapefile/lib/parsers/parse-shp-to-arrow.ts +184 -0
- package/src/shapefile/lib/parsers/parse-shp.ts +245 -0
- package/src/shapefile/lib/parsers/parse-shx.ts +39 -0
- package/src/shapefile/lib/parsers/types.ts +96 -0
- package/src/shapefile/lib/shapefile-worker-transport.ts +72 -0
- package/src/shapefile/lib/streaming/binary-chunk-reader.ts +8 -0
- package/src/shapefile/lib/streaming/binary-reader.ts +60 -0
- package/src/shapefile/lib/streaming/zip-batch-iterators.ts +78 -0
- package/src/shapefile/shapefile-arrow-loader.ts +448 -0
- package/src/shapefile/shapefile-loader-types.ts +68 -0
- package/src/shapefile/shapefile-loader.ts +76 -0
- package/src/shapefile/shp-format.ts +34 -0
- package/src/shapefile/shp-loader-types.ts +60 -0
- package/src/shapefile/shp-loader.ts +80 -0
- package/src/shapefile/unbundled.ts +12 -0
- package/src/shapefile.ts +6 -0
- package/src/shp.ts +5 -0
- package/src/tcx.ts +5 -0
- package/src/workers/dbf-worker.ts +8 -0
- package/src/workers/flatgeobuf-worker.ts +8 -0
- package/src/workers/geopackage-worker.ts +8 -0
- package/src/workers/shp-worker.ts +8 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
ArrowTable,
|
|
7
|
+
ArrowTableBatch,
|
|
8
|
+
Field,
|
|
9
|
+
GeoArrowEncodingPreference
|
|
10
|
+
} from '@loaders.gl/core/schema';
|
|
11
|
+
import {makeTableScanBatch} from '@loaders.gl/core/loader-utils';
|
|
12
|
+
import {type GeoParquetGeometryType} from '@loaders.gl/core/schema';
|
|
13
|
+
import {convertFeaturesToGeoArrowTable} from '@loaders.gl/arrow-geometry/feature-table';
|
|
14
|
+
import {convertWKBToGeometry} from '@loaders.gl/arrow-geometry/geometry-codecs';
|
|
15
|
+
import {
|
|
16
|
+
makeWKBGeometryField,
|
|
17
|
+
setWKBGeometryColumnMetadata
|
|
18
|
+
} from '@loaders.gl/arrow-geometry/geometry-field';
|
|
19
|
+
import {ArrowTableBuilder} from '@loaders.gl/core/schema-utils';
|
|
20
|
+
import {parseSHP, parseSHPInBatches} from './parse-shp';
|
|
21
|
+
import {parseSHPHeader, type SHPHeader} from './parse-shp-header';
|
|
22
|
+
import type {SHPLoaderOptions} from './types';
|
|
23
|
+
import {
|
|
24
|
+
type SHPWKBGeometry,
|
|
25
|
+
makeSHPWKBGeometryArrowTable,
|
|
26
|
+
makeWKBGeometryArrowTable
|
|
27
|
+
} from './build-wkb-geometry-arrow';
|
|
28
|
+
import {makeSHPGeoArrowGeometryTable} from './build-geoarrow-geometry-arrow';
|
|
29
|
+
|
|
30
|
+
const GEOMETRY_COLUMN_NAME = 'geometry';
|
|
31
|
+
const SHP_HEADER_SIZE = 100;
|
|
32
|
+
|
|
33
|
+
export function parseSHPToArrow(arrayBuffer: ArrayBuffer, options?: SHPLoaderOptions): ArrowTable {
|
|
34
|
+
if (
|
|
35
|
+
options?.geoarrow?.encodingPreference === 'geoarrow.geometry' ||
|
|
36
|
+
options?.shp?.geoarrow?.encodingPreference === 'geoarrow.geometry'
|
|
37
|
+
) {
|
|
38
|
+
const result = parseSHP(arrayBuffer, options);
|
|
39
|
+
return convertFeaturesToGeoArrowTable(
|
|
40
|
+
result.geometries.map(geometry => ({
|
|
41
|
+
type: 'Feature' as const,
|
|
42
|
+
geometry: geometry ? convertWKBToGeometry(geometry.buffer) : null,
|
|
43
|
+
properties: {}
|
|
44
|
+
})) as any,
|
|
45
|
+
{encodingPreference: 'geoarrow.geometry'}
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
if (
|
|
49
|
+
shouldUseTypedGeoArrow(
|
|
50
|
+
options?.shp?.geoarrowEncoding,
|
|
51
|
+
options?.geoarrow?.encodingPreference || options?.shp?.geoarrow?.encodingPreference
|
|
52
|
+
)
|
|
53
|
+
) {
|
|
54
|
+
return makeSHPGeoArrowGeometryTable(arrayBuffer, options);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const header = parseSHPHeader(new DataView(arrayBuffer, 0, SHP_HEADER_SIZE));
|
|
58
|
+
const schema = buildOutputSchema(header);
|
|
59
|
+
return makeSHPWKBGeometryArrowTable(arrayBuffer, schema, options);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export async function* parseSHPToArrowInBatches(
|
|
63
|
+
asyncIterator:
|
|
64
|
+
| AsyncIterable<ArrayBufferLike | ArrayBufferView>
|
|
65
|
+
| Iterable<ArrayBufferLike | ArrayBufferView>,
|
|
66
|
+
options?: SHPLoaderOptions
|
|
67
|
+
): AsyncIterable<ArrowTableBatch> {
|
|
68
|
+
const preference =
|
|
69
|
+
options?.geoarrow?.encodingPreference || options?.shp?.geoarrow?.encodingPreference;
|
|
70
|
+
if (preference && preference !== 'geoarrow.wkb') {
|
|
71
|
+
const geometries: (SHPWKBGeometry | null)[] = [];
|
|
72
|
+
for await (const batch of parseSHPInBatches(asyncIterator, getWKBOptions(options))) {
|
|
73
|
+
if (!isSHPHeader(batch)) {
|
|
74
|
+
geometries.push(...(batch as (SHPWKBGeometry | null)[]));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const geometryFeatures = geometries.map(geometry => ({
|
|
78
|
+
type: 'Feature' as const,
|
|
79
|
+
geometry: geometry ? convertWKBToGeometry(geometry.buffer) : null,
|
|
80
|
+
properties: {}
|
|
81
|
+
}));
|
|
82
|
+
yield makeTableScanBatch(
|
|
83
|
+
convertFeaturesToGeoArrowTable(geometryFeatures as any, {encodingPreference: preference})
|
|
84
|
+
);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (shouldUseTypedGeoArrow(options?.shp?.geoarrowEncoding, preference)) {
|
|
89
|
+
throw new Error('Typed GeoArrow SHP output is only supported for non-streaming parse.');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const shpIterator = parseSHPInBatches(asyncIterator, getWKBOptions(options));
|
|
93
|
+
let header: SHPHeader | undefined;
|
|
94
|
+
let yieldedDataBatch = false;
|
|
95
|
+
|
|
96
|
+
for await (const batch of shpIterator) {
|
|
97
|
+
if (isSHPHeader(batch)) {
|
|
98
|
+
header = batch;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const geometries = batch as (SHPWKBGeometry | null)[];
|
|
103
|
+
const schema = buildOutputSchema(header);
|
|
104
|
+
const arrowTable = makeWKBGeometryArrowTable(geometries, schema);
|
|
105
|
+
yieldedDataBatch = true;
|
|
106
|
+
yield makeTableScanBatch(arrowTable);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (!yieldedDataBatch) {
|
|
110
|
+
yield makeEmptyArrowBatch(buildOutputSchema(header));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function shouldUseTypedGeoArrow(
|
|
115
|
+
encoding: unknown,
|
|
116
|
+
preference?: GeoArrowEncodingPreference
|
|
117
|
+
): boolean {
|
|
118
|
+
return encoding === 'geoarrow' || preference === 'optimized';
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function buildOutputSchema(header?: SHPHeader) {
|
|
122
|
+
const geometryField: Field = makeWKBGeometryField(GEOMETRY_COLUMN_NAME);
|
|
123
|
+
const schema = {
|
|
124
|
+
fields: [geometryField],
|
|
125
|
+
metadata: {}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
setWKBGeometryColumnMetadata(schema.metadata, {
|
|
129
|
+
geometryColumnName: GEOMETRY_COLUMN_NAME,
|
|
130
|
+
geometryTypes: inferGeometryTypes(header)
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
return schema;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function isSHPHeader(batch: unknown): batch is SHPHeader {
|
|
137
|
+
return Boolean(batch && typeof batch === 'object' && 'type' in batch && 'length' in batch);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function inferGeometryTypes(header?: SHPHeader): GeoParquetGeometryType[] {
|
|
141
|
+
const fallbackType = getGeometryTypeFromHeader(header?.type);
|
|
142
|
+
return fallbackType ? [fallbackType] : [];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function getGeometryTypeFromHeader(type?: number): GeoParquetGeometryType | null {
|
|
146
|
+
switch (type) {
|
|
147
|
+
case 1:
|
|
148
|
+
case 11:
|
|
149
|
+
case 21:
|
|
150
|
+
return type === 11 ? 'Point Z' : 'Point';
|
|
151
|
+
case 3:
|
|
152
|
+
case 13:
|
|
153
|
+
case 23:
|
|
154
|
+
return type === 13 ? 'LineString Z' : 'LineString';
|
|
155
|
+
case 5:
|
|
156
|
+
case 15:
|
|
157
|
+
case 25:
|
|
158
|
+
return type === 15 ? 'Polygon Z' : 'Polygon';
|
|
159
|
+
case 8:
|
|
160
|
+
case 18:
|
|
161
|
+
case 28:
|
|
162
|
+
return type === 18 ? 'MultiPoint Z' : 'MultiPoint';
|
|
163
|
+
default:
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function getWKBOptions(options?: SHPLoaderOptions): SHPLoaderOptions {
|
|
169
|
+
return {
|
|
170
|
+
...options,
|
|
171
|
+
shp: {
|
|
172
|
+
...options?.shp,
|
|
173
|
+
shape: 'wkb'
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function makeEmptyArrowBatch(schema: ArrowTable['schema']): ArrowTableBatch {
|
|
179
|
+
if (!schema) {
|
|
180
|
+
throw new Error('SHP Arrow batch requires a schema');
|
|
181
|
+
}
|
|
182
|
+
const table = new ArrowTableBuilder(schema).finishTable();
|
|
183
|
+
return makeTableScanBatch({...table, schema});
|
|
184
|
+
}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {toArrayBufferIterator} from '@loaders.gl/core/loader-utils';
|
|
6
|
+
import {BinaryChunkReader} from '../streaming/binary-chunk-reader';
|
|
7
|
+
import {parseSHPHeader, SHPHeader} from './parse-shp-header';
|
|
8
|
+
import {parseRecordToWKB} from './parse-shp-geometry';
|
|
9
|
+
import {SHPLoaderOptions} from './types';
|
|
10
|
+
|
|
11
|
+
const LITTLE_ENDIAN = true;
|
|
12
|
+
const BIG_ENDIAN = false;
|
|
13
|
+
|
|
14
|
+
const SHP_HEADER_SIZE = 100;
|
|
15
|
+
// According to the spec, the record header is just 8 bytes, but here we set it
|
|
16
|
+
// to 12 so that we can also access the record's type
|
|
17
|
+
const SHP_RECORD_HEADER_SIZE = 12;
|
|
18
|
+
|
|
19
|
+
const STATE = {
|
|
20
|
+
EXPECTING_HEADER: 0,
|
|
21
|
+
EXPECTING_RECORD: 1,
|
|
22
|
+
END: 2,
|
|
23
|
+
ERROR: 3
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A complete or partial result from the SHP file parser.
|
|
28
|
+
*/
|
|
29
|
+
export type SHPResult = {
|
|
30
|
+
geometries: (Uint8Array | null)[];
|
|
31
|
+
header?: SHPHeader;
|
|
32
|
+
error?: string;
|
|
33
|
+
progress: {
|
|
34
|
+
bytesUsed: number;
|
|
35
|
+
bytesTotal: number;
|
|
36
|
+
rows: number;
|
|
37
|
+
};
|
|
38
|
+
currentIndex: number;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
class SHPParser {
|
|
42
|
+
options?: SHPLoaderOptions = {};
|
|
43
|
+
binaryReader = new BinaryChunkReader({maxRewindBytes: SHP_RECORD_HEADER_SIZE});
|
|
44
|
+
state = STATE.EXPECTING_HEADER;
|
|
45
|
+
result: SHPResult = {
|
|
46
|
+
geometries: [],
|
|
47
|
+
// Initialize with number values to make TS happy
|
|
48
|
+
// These are initialized for real in STATE.EXPECTING_HEADER
|
|
49
|
+
progress: {
|
|
50
|
+
bytesTotal: NaN,
|
|
51
|
+
bytesUsed: NaN,
|
|
52
|
+
rows: NaN
|
|
53
|
+
},
|
|
54
|
+
currentIndex: NaN
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
constructor(options?: SHPLoaderOptions) {
|
|
58
|
+
this.options = options;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
write(arrayBuffer: ArrayBuffer) {
|
|
62
|
+
this.binaryReader.write(arrayBuffer);
|
|
63
|
+
this.state = parseState(this.state, this.result, this.binaryReader, this.options);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
end() {
|
|
67
|
+
this.binaryReader.end();
|
|
68
|
+
this.state = parseState(this.state, this.result, this.binaryReader, this.options);
|
|
69
|
+
// this.result.progress.bytesUsed = this.binaryReader.bytesUsed();
|
|
70
|
+
if (this.state !== STATE.END) {
|
|
71
|
+
this.state = STATE.ERROR;
|
|
72
|
+
this.result.error = 'SHP incomplete file';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function parseSHP(arrayBuffer: ArrayBuffer, options?: SHPLoaderOptions): SHPResult {
|
|
78
|
+
const shpParser = new SHPParser({
|
|
79
|
+
...options,
|
|
80
|
+
shp: {
|
|
81
|
+
...options?.shp,
|
|
82
|
+
batchSize: undefined
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
shpParser.write(arrayBuffer);
|
|
86
|
+
shpParser.end();
|
|
87
|
+
|
|
88
|
+
return shpParser.result;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @param asyncIterator
|
|
93
|
+
* @param options
|
|
94
|
+
* @returns
|
|
95
|
+
*/
|
|
96
|
+
export async function* parseSHPInBatches(
|
|
97
|
+
asyncIterator:
|
|
98
|
+
| AsyncIterable<ArrayBufferLike | ArrayBufferView>
|
|
99
|
+
| Iterable<ArrayBufferLike | ArrayBufferView>,
|
|
100
|
+
options?: SHPLoaderOptions
|
|
101
|
+
): AsyncGenerator<(Uint8Array | null)[] | object> {
|
|
102
|
+
const parser = new SHPParser(options);
|
|
103
|
+
let headerReturned = false;
|
|
104
|
+
for await (const arrayBuffer of toArrayBufferIterator(asyncIterator)) {
|
|
105
|
+
parser.write(arrayBuffer);
|
|
106
|
+
if (!headerReturned && parser.result.header) {
|
|
107
|
+
headerReturned = true;
|
|
108
|
+
yield parser.result.header;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const batchSize = options?.shp?.batchSize || Number.POSITIVE_INFINITY;
|
|
112
|
+
while (
|
|
113
|
+
batchSize === Number.POSITIVE_INFINITY
|
|
114
|
+
? parser.result.geometries.length > 0
|
|
115
|
+
: parser.result.geometries.length >= batchSize
|
|
116
|
+
) {
|
|
117
|
+
yield parser.result.geometries;
|
|
118
|
+
parser.result.geometries = [];
|
|
119
|
+
parser.state = parseState(parser.state, parser.result, parser.binaryReader, parser.options);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
parser.binaryReader.end();
|
|
123
|
+
parser.state = parseState(parser.state, parser.result, parser.binaryReader, {
|
|
124
|
+
...parser.options,
|
|
125
|
+
shp: {
|
|
126
|
+
...parser.options?.shp,
|
|
127
|
+
batchSize: undefined
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
if (parser.result.geometries.length > 0) {
|
|
131
|
+
yield parser.result.geometries;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* State-machine parser for SHP data
|
|
139
|
+
*
|
|
140
|
+
* Note that whenever more data is needed, a `return`, not a `break`, is
|
|
141
|
+
* necessary, as the `break` keeps the context within `parseState`, while
|
|
142
|
+
* `return` releases context so that more data can be written into the
|
|
143
|
+
* BinaryChunkReader.
|
|
144
|
+
*
|
|
145
|
+
* @param state Current state
|
|
146
|
+
* @param result An object to hold result data
|
|
147
|
+
* @param binaryReader
|
|
148
|
+
* @return State at end of current parsing
|
|
149
|
+
*/
|
|
150
|
+
/* eslint-disable complexity, max-depth */
|
|
151
|
+
function parseState(
|
|
152
|
+
state: number,
|
|
153
|
+
result: SHPResult,
|
|
154
|
+
binaryReader: BinaryChunkReader,
|
|
155
|
+
options?: SHPLoaderOptions
|
|
156
|
+
): number {
|
|
157
|
+
// eslint-disable-next-line no-constant-condition
|
|
158
|
+
while (true) {
|
|
159
|
+
try {
|
|
160
|
+
switch (state) {
|
|
161
|
+
case STATE.ERROR:
|
|
162
|
+
case STATE.END:
|
|
163
|
+
return state;
|
|
164
|
+
|
|
165
|
+
case STATE.EXPECTING_HEADER:
|
|
166
|
+
// Parse initial file header
|
|
167
|
+
const dataView = binaryReader.getDataView(SHP_HEADER_SIZE);
|
|
168
|
+
if (!dataView) {
|
|
169
|
+
return state;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
result.header = parseSHPHeader(dataView);
|
|
173
|
+
result.progress = {
|
|
174
|
+
bytesUsed: 0,
|
|
175
|
+
bytesTotal: result.header.length,
|
|
176
|
+
rows: 0
|
|
177
|
+
};
|
|
178
|
+
// index numbering starts at 1
|
|
179
|
+
result.currentIndex = 1;
|
|
180
|
+
state = STATE.EXPECTING_RECORD;
|
|
181
|
+
break;
|
|
182
|
+
|
|
183
|
+
case STATE.EXPECTING_RECORD:
|
|
184
|
+
while (binaryReader.hasAvailableBytes(SHP_RECORD_HEADER_SIZE)) {
|
|
185
|
+
const batchSize = options?.shp?.batchSize || Number.POSITIVE_INFINITY;
|
|
186
|
+
if (result.geometries.length >= batchSize) {
|
|
187
|
+
return state;
|
|
188
|
+
}
|
|
189
|
+
const recordHeaderView = binaryReader.getDataView(SHP_RECORD_HEADER_SIZE) as DataView;
|
|
190
|
+
const recordHeader = {
|
|
191
|
+
recordNumber: recordHeaderView.getInt32(0, BIG_ENDIAN),
|
|
192
|
+
// 2 byte words; includes the four words of record header
|
|
193
|
+
byteLength: recordHeaderView.getInt32(4, BIG_ENDIAN) * 2,
|
|
194
|
+
// This is actually part of the record, not the header...
|
|
195
|
+
type: recordHeaderView.getInt32(8, LITTLE_ENDIAN)
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
if (!binaryReader.hasAvailableBytes(recordHeader.byteLength - 4)) {
|
|
199
|
+
binaryReader.rewind(SHP_RECORD_HEADER_SIZE);
|
|
200
|
+
return state;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const invalidRecord =
|
|
204
|
+
recordHeader.byteLength < 4 ||
|
|
205
|
+
(recordHeader.type !== result.header?.type && recordHeader.type !== 0) ||
|
|
206
|
+
recordHeader.recordNumber !== result.currentIndex;
|
|
207
|
+
|
|
208
|
+
// All records must have at least four bytes (for the record shape type)
|
|
209
|
+
if (invalidRecord) {
|
|
210
|
+
// Malformed record, try again, advancing just 4 bytes
|
|
211
|
+
// Note: this is a rewind because binaryReader.getDataView above
|
|
212
|
+
// moved the pointer forward 12 bytes, so rewinding 8 bytes still
|
|
213
|
+
// leaves us 4 bytes ahead
|
|
214
|
+
binaryReader.rewind(SHP_RECORD_HEADER_SIZE - 4);
|
|
215
|
+
} else {
|
|
216
|
+
// Note: type is actually part of the record, not the header, so
|
|
217
|
+
// rewind 4 bytes before reading record
|
|
218
|
+
binaryReader.rewind(4);
|
|
219
|
+
|
|
220
|
+
const recordView = binaryReader.getDataView(recordHeader.byteLength) as DataView;
|
|
221
|
+
result.geometries.push(parseRecordToWKB(recordView, options));
|
|
222
|
+
|
|
223
|
+
result.currentIndex++;
|
|
224
|
+
result.progress.rows = result.currentIndex - 1;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (binaryReader.ended) {
|
|
229
|
+
state = STATE.END;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return state;
|
|
233
|
+
|
|
234
|
+
default:
|
|
235
|
+
state = STATE.ERROR;
|
|
236
|
+
result.error = `illegal parser state ${state}`;
|
|
237
|
+
return state;
|
|
238
|
+
}
|
|
239
|
+
} catch (error) {
|
|
240
|
+
state = STATE.ERROR;
|
|
241
|
+
result.error = `SHP parsing failed: ${(error as Error)?.message}`;
|
|
242
|
+
return state;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {parseSHPHeader} from './parse-shp-header';
|
|
6
|
+
|
|
7
|
+
export interface SHXOutput {
|
|
8
|
+
offsets: Int32Array;
|
|
9
|
+
lengths: Int32Array;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const SHX_HEADER_SIZE = 100;
|
|
13
|
+
const BIG_ENDIAN = false;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param arrayBuffer
|
|
17
|
+
* @returns SHXOutput
|
|
18
|
+
*/
|
|
19
|
+
export function parseShx(arrayBuffer: ArrayBuffer): SHXOutput {
|
|
20
|
+
// SHX header is identical to SHP Header
|
|
21
|
+
const headerView = new DataView(arrayBuffer, 0, SHX_HEADER_SIZE);
|
|
22
|
+
const header = parseSHPHeader(headerView);
|
|
23
|
+
const contentLength = header.length - SHX_HEADER_SIZE;
|
|
24
|
+
|
|
25
|
+
const contentView = new DataView(arrayBuffer, SHX_HEADER_SIZE, contentLength);
|
|
26
|
+
|
|
27
|
+
const offsets = new Int32Array(contentLength);
|
|
28
|
+
const lengths = new Int32Array(contentLength);
|
|
29
|
+
|
|
30
|
+
for (let i = 0; i < contentLength / 8; i++) {
|
|
31
|
+
offsets[i] = contentView.getInt32(i * 8, BIG_ENDIAN);
|
|
32
|
+
lengths[i] = contentView.getInt32(i * 8 + 4, BIG_ENDIAN);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
offsets,
|
|
37
|
+
lengths
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {GeoArrowEncodingPreference, Schema, ObjectRowTable} from '@loaders.gl/core/schema';
|
|
6
|
+
import type {StrictLoaderOptions} from '@loaders.gl/core/loader-utils';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* GeoArrow geometry encoding mode for SHP Arrow output.
|
|
10
|
+
* `geoarrow` infers a geometry-specific encoding from the SHP header.
|
|
11
|
+
*/
|
|
12
|
+
export type SHPGeoArrowEncoding = 'geoarrow.wkb' | 'geoarrow';
|
|
13
|
+
|
|
14
|
+
export type SHPLoaderOptions = StrictLoaderOptions & {
|
|
15
|
+
/** Preferred encoding for Arrow geometry output. */
|
|
16
|
+
geoarrow?: {encodingPreference?: GeoArrowEncodingPreference};
|
|
17
|
+
shp?: {
|
|
18
|
+
_maxDimensions?: number;
|
|
19
|
+
shape?: 'arrow-table' | 'wkb';
|
|
20
|
+
geoarrowEncoding?: SHPGeoArrowEncoding;
|
|
21
|
+
/** Preferred encoding for Arrow geometry output. */
|
|
22
|
+
geoarrow?: {encodingPreference?: GeoArrowEncodingPreference};
|
|
23
|
+
batchSize?: number;
|
|
24
|
+
/** Override the URL to the worker bundle (by default loads from unpkg.com) */
|
|
25
|
+
workerUrl?: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type DBFLoaderOptions = StrictLoaderOptions & {
|
|
30
|
+
dbf?: {
|
|
31
|
+
encoding?: string;
|
|
32
|
+
shape?: 'rows' | 'table' | 'object-row-table' | 'arrow-table';
|
|
33
|
+
batchSize?: number;
|
|
34
|
+
/** Override the URL to the worker bundle (by default loads from unpkg.com) */
|
|
35
|
+
workerUrl?: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type ShapefileLoaderOptions = StrictLoaderOptions &
|
|
40
|
+
SHPLoaderOptions &
|
|
41
|
+
DBFLoaderOptions & {
|
|
42
|
+
shapefile?: {
|
|
43
|
+
shape?: 'geojson-table' | 'arrow-table' | 'v3';
|
|
44
|
+
geoarrowEncoding?: SHPGeoArrowEncoding;
|
|
45
|
+
/** Preferred encoding for Arrow geometry output. */
|
|
46
|
+
geoarrow?: {encodingPreference?: GeoArrowEncodingPreference};
|
|
47
|
+
batchSize?: number;
|
|
48
|
+
};
|
|
49
|
+
gis?: import('@loaders.gl/core/loader-utils').CRSReprojectionOptions;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type DBFRowsOutput = ObjectRowTable['data'];
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* DBF Table output. Deprecated in favor of ObjectRowTable
|
|
56
|
+
* @deprecated
|
|
57
|
+
*/
|
|
58
|
+
export interface DBFTableOutput {
|
|
59
|
+
schema?: Schema;
|
|
60
|
+
rows: DBFRowsOutput;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type DBFHeader = {
|
|
64
|
+
// Last updated date
|
|
65
|
+
year: number;
|
|
66
|
+
month: number;
|
|
67
|
+
day: number;
|
|
68
|
+
// Number of records in data file
|
|
69
|
+
nRecords: number;
|
|
70
|
+
// Length of header in bytes
|
|
71
|
+
headerLength: number;
|
|
72
|
+
// Length of each record
|
|
73
|
+
recordLength: number;
|
|
74
|
+
// Not sure if this is usually set
|
|
75
|
+
languageDriver: number;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export type DBFField = {
|
|
79
|
+
name: string;
|
|
80
|
+
dataType: string;
|
|
81
|
+
fieldLength: number;
|
|
82
|
+
decimal: number;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export type DBFResult = {
|
|
86
|
+
data: {[key: string]: any}[];
|
|
87
|
+
schema?: Schema;
|
|
88
|
+
error?: string;
|
|
89
|
+
dbfHeader?: DBFHeader;
|
|
90
|
+
dbfFields?: DBFField[];
|
|
91
|
+
progress?: {
|
|
92
|
+
bytesUsed: number;
|
|
93
|
+
rowsTotal: number;
|
|
94
|
+
rows: number;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
DehydratedArrowTable,
|
|
7
|
+
SplitArrowBuffersOptions
|
|
8
|
+
} from '@loaders.gl/core/schema-utils/arrow-transport';
|
|
9
|
+
import {
|
|
10
|
+
dehydrateArrowTable,
|
|
11
|
+
hydrateArrowTable
|
|
12
|
+
} from '@loaders.gl/core/schema-utils/arrow-transport';
|
|
13
|
+
import type {LoaderOptions} from '@loaders.gl/core/loader-utils';
|
|
14
|
+
import type {ArrowTable} from '@loaders.gl/core/schema';
|
|
15
|
+
|
|
16
|
+
type SerializedArrowTable = Omit<ArrowTable, 'data'> & {
|
|
17
|
+
data: DehydratedArrowTable;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** Serializes Shapefile-family worker results so Arrow tables survive structured clone. */
|
|
21
|
+
export function serializeShapefileWorkerResult(result: unknown, options?: LoaderOptions): unknown {
|
|
22
|
+
if (!isArrowTable(result)) {
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
const bufferCopyMode = getWorkerTransferBufferCopyMode(options);
|
|
26
|
+
return {
|
|
27
|
+
...result,
|
|
28
|
+
data: dehydrateArrowTable(result.data, bufferCopyMode ? {copy: bufferCopyMode} : undefined)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Deserializes a Shapefile-family worker result into a real Arrow table. */
|
|
33
|
+
export function deserializeShapefileWorkerResult<T>(result: unknown): T {
|
|
34
|
+
if (isSerializedArrowTable(result)) {
|
|
35
|
+
return {...result, data: hydrateArrowTable(result.data)} as T;
|
|
36
|
+
}
|
|
37
|
+
return result as T;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Serializes one Shapefile-family Arrow batch using the same transport as an atomic result. */
|
|
41
|
+
export const serializeShapefileWorkerBatch = serializeShapefileWorkerResult;
|
|
42
|
+
|
|
43
|
+
/** Deserializes one Shapefile-family Arrow batch. */
|
|
44
|
+
export const deserializeShapefileWorkerBatch = deserializeShapefileWorkerResult;
|
|
45
|
+
|
|
46
|
+
function isArrowTable(value: unknown): value is ArrowTable {
|
|
47
|
+
const table = value as ArrowTable;
|
|
48
|
+
return Boolean(
|
|
49
|
+
table &&
|
|
50
|
+
typeof table === 'object' &&
|
|
51
|
+
table.shape === 'arrow-table' &&
|
|
52
|
+
table.data &&
|
|
53
|
+
'batches' in table.data
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function isSerializedArrowTable(value: unknown): value is SerializedArrowTable {
|
|
58
|
+
const table = value as SerializedArrowTable;
|
|
59
|
+
return Boolean(
|
|
60
|
+
table &&
|
|
61
|
+
typeof table === 'object' &&
|
|
62
|
+
table.shape === 'arrow-table' &&
|
|
63
|
+
table.data &&
|
|
64
|
+
table.data.transport === 'arrow-js'
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function getWorkerTransferBufferCopyMode(
|
|
69
|
+
options?: LoaderOptions
|
|
70
|
+
): SplitArrowBuffersOptions['copy'] | undefined {
|
|
71
|
+
return options?.core?.workerTransferBufferCopy ?? options?.workerTransferBufferCopy;
|
|
72
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
export class BinaryReader {
|
|
6
|
+
offset: number;
|
|
7
|
+
arrayBuffer: ArrayBuffer;
|
|
8
|
+
|
|
9
|
+
constructor(arrayBuffer: ArrayBuffer) {
|
|
10
|
+
/** current global (stream) offset */
|
|
11
|
+
this.offset = 0;
|
|
12
|
+
/** current buffer from iterator */
|
|
13
|
+
this.arrayBuffer = arrayBuffer;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Checks if there are available bytes in data
|
|
17
|
+
*
|
|
18
|
+
* @param bytes
|
|
19
|
+
* @returns boolean
|
|
20
|
+
*/
|
|
21
|
+
hasAvailableBytes(bytes: number): boolean {
|
|
22
|
+
return this.arrayBuffer.byteLength - this.offset >= bytes;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Get the required number of bytes from the iterator
|
|
27
|
+
*
|
|
28
|
+
* @param bytes
|
|
29
|
+
* @returns Dataview
|
|
30
|
+
*/
|
|
31
|
+
getDataView(bytes: number): DataView {
|
|
32
|
+
if (bytes && !this.hasAvailableBytes(bytes)) {
|
|
33
|
+
throw new Error('binary data exhausted');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const dataView = bytes
|
|
37
|
+
? new DataView(this.arrayBuffer, this.offset, bytes)
|
|
38
|
+
: new DataView(this.arrayBuffer, this.offset);
|
|
39
|
+
this.offset += bytes;
|
|
40
|
+
return dataView;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Skipping
|
|
45
|
+
*
|
|
46
|
+
* @param bytes
|
|
47
|
+
*/
|
|
48
|
+
skip(bytes: number): void {
|
|
49
|
+
this.offset += bytes;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Rewinding
|
|
54
|
+
*
|
|
55
|
+
* @param bytes
|
|
56
|
+
*/
|
|
57
|
+
rewind(bytes: number): void {
|
|
58
|
+
this.offset -= bytes;
|
|
59
|
+
}
|
|
60
|
+
}
|