@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,78 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {ObjectRowTableBatch, ArrayRowTableBatch} from '@loaders.gl/core/schema';
|
|
6
|
+
|
|
7
|
+
type RowTableBatch = ObjectRowTableBatch | ArrayRowTableBatch;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Zip two iterators together
|
|
11
|
+
*
|
|
12
|
+
* @param iterator1
|
|
13
|
+
* @param iterator2
|
|
14
|
+
*/
|
|
15
|
+
export async function* zipBatchIterators(
|
|
16
|
+
iterator1: AsyncIterator<RowTableBatch> | Iterator<RowTableBatch>,
|
|
17
|
+
iterator2: AsyncIterator<RowTableBatch> | Iterator<RowTableBatch>,
|
|
18
|
+
shape: 'object-row-table' | 'array-row-table'
|
|
19
|
+
): AsyncGenerator<RowTableBatch, void, unknown> {
|
|
20
|
+
const batch1Data: unknown[] = [];
|
|
21
|
+
const batch2Data: unknown[] = [];
|
|
22
|
+
let iterator1Done: boolean = false;
|
|
23
|
+
let iterator2Done: boolean = false;
|
|
24
|
+
|
|
25
|
+
// TODO - one could let all iterators flow at full speed using `Promise.race`
|
|
26
|
+
// however we might end up with a big temporary buffer
|
|
27
|
+
while (!iterator1Done && !iterator2Done) {
|
|
28
|
+
if (batch1Data.length === 0 && !iterator1Done) {
|
|
29
|
+
const {value, done} = await iterator1.next();
|
|
30
|
+
if (done) {
|
|
31
|
+
iterator1Done = true;
|
|
32
|
+
} else {
|
|
33
|
+
// @ts-expect-error
|
|
34
|
+
batch1Data.push(...value);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (batch2Data.length === 0 && !iterator2Done) {
|
|
38
|
+
const {value, done} = await iterator2.next();
|
|
39
|
+
if (done) {
|
|
40
|
+
iterator2Done = true;
|
|
41
|
+
} else {
|
|
42
|
+
batch2Data.push(...value);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const batchData = extractBatchData(batch1Data, batch2Data);
|
|
47
|
+
if (batchData) {
|
|
48
|
+
yield {
|
|
49
|
+
batchType: 'data',
|
|
50
|
+
shape,
|
|
51
|
+
length: batchData.length,
|
|
52
|
+
data: batchData
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Extract batch of same length from two batches
|
|
60
|
+
*
|
|
61
|
+
* @param batch1
|
|
62
|
+
* @param batch2
|
|
63
|
+
* @return array | null
|
|
64
|
+
*/
|
|
65
|
+
function extractBatchData(batch1: any[], batch2: any[]): any[] | null {
|
|
66
|
+
const batchLength: number = Math.min(batch1.length, batch2.length);
|
|
67
|
+
if (batchLength === 0) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Non interleaved arrays
|
|
72
|
+
const batch: any[] = [batch1.slice(0, batchLength), batch2.slice(0, batchLength)];
|
|
73
|
+
|
|
74
|
+
// Modify the 2 batches
|
|
75
|
+
batch1.splice(0, batchLength);
|
|
76
|
+
batch2.splice(0, batchLength);
|
|
77
|
+
return batch;
|
|
78
|
+
}
|
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {CRSReprojectionError, type LoaderContext} from '@loaders.gl/core/loader-utils';
|
|
6
|
+
import {
|
|
7
|
+
makeTableScanBatch,
|
|
8
|
+
parseFromContext,
|
|
9
|
+
parseInBatchesFromContext,
|
|
10
|
+
toArrayBufferIterator
|
|
11
|
+
} from '@loaders.gl/core/loader-utils';
|
|
12
|
+
import * as arrow from 'apache-arrow';
|
|
13
|
+
import type {
|
|
14
|
+
ArrowTable,
|
|
15
|
+
ArrowTableBatch,
|
|
16
|
+
Field,
|
|
17
|
+
Schema as TableSchema
|
|
18
|
+
} from '@loaders.gl/core/schema';
|
|
19
|
+
import {ArrowTableBuilder, convertSchemaToArrow} from '@loaders.gl/core/schema-utils';
|
|
20
|
+
import {convertFeaturesToGeoArrowTable} from '@loaders.gl/arrow-geometry/feature-table';
|
|
21
|
+
import {convertWKBToGeometry} from '@loaders.gl/arrow-geometry/geometry-codecs';
|
|
22
|
+
import {type GeoParquetGeometryType} from '@loaders.gl/core/schema';
|
|
23
|
+
import {
|
|
24
|
+
makeWKBGeometryField,
|
|
25
|
+
setWKBGeometryColumnMetadata
|
|
26
|
+
} from '@loaders.gl/arrow-geometry/geometry-field';
|
|
27
|
+
import {projectionEngine} from '@math.gl/geospatial/projection';
|
|
28
|
+
import type {ReadonlyCRSDefinition, WKTCRSDefinition} from '@math.gl/geospatial/crs';
|
|
29
|
+
import {SHPLoaderWithParser} from './shp-loader';
|
|
30
|
+
import {DBFLoaderWithParser} from './dbf-loader';
|
|
31
|
+
import type {ShapefileLoaderOptions} from './shapefile-loader-types';
|
|
32
|
+
import type {SHPResult} from './lib/parsers/parse-shp';
|
|
33
|
+
import type {SHPHeader} from './lib/parsers/parse-shp-header';
|
|
34
|
+
import {loadShapefileSidecarFiles, replaceExtension} from './lib/parsers/parse-shapefile';
|
|
35
|
+
import {
|
|
36
|
+
type SHPWKBGeometry,
|
|
37
|
+
makeWKBGeometryArrowTable
|
|
38
|
+
} from './lib/parsers/build-wkb-geometry-arrow';
|
|
39
|
+
import {makeSHPGeoArrowGeometryTable} from './lib/parsers/build-geoarrow-geometry-arrow';
|
|
40
|
+
const GEOMETRY_COLUMN_NAME = 'geometry';
|
|
41
|
+
|
|
42
|
+
/** Parses a shapefile and returns an Arrow table with a WKB geometry column. */
|
|
43
|
+
export async function parseShapefileToArrow(
|
|
44
|
+
arrayBuffer: ArrayBuffer,
|
|
45
|
+
options?: ShapefileLoaderOptions,
|
|
46
|
+
context?: LoaderContext
|
|
47
|
+
): Promise<ArrowTable> {
|
|
48
|
+
const {cpg, prj} = await loadShapefileSidecarFiles(options, context);
|
|
49
|
+
const transform = getReprojectionTransform(prj, options);
|
|
50
|
+
const geoArrowEncoding = getTypedGeoArrowEncoding(options);
|
|
51
|
+
let header: SHPHeader | undefined;
|
|
52
|
+
let geometryTable: ArrowTable;
|
|
53
|
+
|
|
54
|
+
if (geoArrowEncoding) {
|
|
55
|
+
geometryTable = makeSHPGeoArrowGeometryTable(arrayBuffer, options, {transform});
|
|
56
|
+
} else {
|
|
57
|
+
const shpResult = (await parseFromContext(
|
|
58
|
+
arrayBuffer,
|
|
59
|
+
SHPLoaderWithParser,
|
|
60
|
+
{
|
|
61
|
+
...options,
|
|
62
|
+
shp: {
|
|
63
|
+
...options?.shp,
|
|
64
|
+
shape: 'wkb'
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
context!
|
|
68
|
+
)) as SHPResult;
|
|
69
|
+
header = shpResult.header;
|
|
70
|
+
geometryTable = makeGeometryArrowTable(
|
|
71
|
+
shpResult.geometries as (SHPWKBGeometry | null)[],
|
|
72
|
+
header,
|
|
73
|
+
transform
|
|
74
|
+
);
|
|
75
|
+
if (
|
|
76
|
+
options?.geoarrow?.encodingPreference === 'geoarrow.geometry' ||
|
|
77
|
+
options?.shapefile?.geoarrow?.encodingPreference === 'geoarrow.geometry'
|
|
78
|
+
) {
|
|
79
|
+
const geometryColumn = geometryTable.data.getChild(GEOMETRY_COLUMN_NAME);
|
|
80
|
+
const geometries = geometryColumn?.toArray() || [];
|
|
81
|
+
geometryTable = convertFeaturesToGeoArrowTable(
|
|
82
|
+
geometries.map(geometry => ({
|
|
83
|
+
type: 'Feature' as const,
|
|
84
|
+
geometry: geometry ? convertWKBToGeometry(geometry.slice().buffer) : null,
|
|
85
|
+
properties: {}
|
|
86
|
+
})),
|
|
87
|
+
{encodingPreference: 'geoarrow.geometry'}
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
let propertySchema: TableSchema | null = null;
|
|
93
|
+
let propertyTable: ArrowTable | null = null;
|
|
94
|
+
|
|
95
|
+
const dbfResponse = context?.url
|
|
96
|
+
? await context.fetch(replaceExtension(context.url, 'dbf')).catch(() => null)
|
|
97
|
+
: null;
|
|
98
|
+
if (dbfResponse?.ok) {
|
|
99
|
+
propertyTable = (await parseFromContext(
|
|
100
|
+
dbfResponse as any,
|
|
101
|
+
DBFLoaderWithParser,
|
|
102
|
+
{
|
|
103
|
+
...options,
|
|
104
|
+
dbf: {
|
|
105
|
+
...options?.dbf,
|
|
106
|
+
shape: 'arrow-table' as const,
|
|
107
|
+
encoding: cpg || 'latin1'
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
context!
|
|
111
|
+
)) as ArrowTable;
|
|
112
|
+
propertySchema = propertyTable.schema || null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const schema = buildOutputSchema(propertySchema, header, geometryTable.schema);
|
|
116
|
+
return propertyTable
|
|
117
|
+
? appendGeometryColumnToArrowTable(propertyTable, geometryTable, schema)
|
|
118
|
+
: geometryTable;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Parses a shapefile into Arrow batches while keeping DBF-derived schema stable. */
|
|
122
|
+
export async function* parseShapefileToArrowInBatches(
|
|
123
|
+
asyncIterator:
|
|
124
|
+
| AsyncIterable<ArrayBufferLike | ArrayBufferView>
|
|
125
|
+
| Iterable<ArrayBufferLike | ArrayBufferView>,
|
|
126
|
+
options?: ShapefileLoaderOptions,
|
|
127
|
+
context?: LoaderContext
|
|
128
|
+
): AsyncIterable<ArrowTableBatch> {
|
|
129
|
+
if (getTypedGeoArrowEncoding(options)) {
|
|
130
|
+
throw new Error('Typed GeoArrow shapefile output is only supported for non-streaming parse.');
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const {cpg, prj} = await loadShapefileSidecarFiles(options, context);
|
|
134
|
+
const batchSize =
|
|
135
|
+
options?.shapefile?.batchSize || options?.shp?.batchSize || options?.dbf?.batchSize || 10000;
|
|
136
|
+
|
|
137
|
+
const shapeIterable = await parseInBatchesFromContext(
|
|
138
|
+
toArrayBufferIterator(asyncIterator),
|
|
139
|
+
SHPLoaderWithParser,
|
|
140
|
+
{
|
|
141
|
+
...options,
|
|
142
|
+
shp: {
|
|
143
|
+
...options?.shp,
|
|
144
|
+
shape: 'wkb',
|
|
145
|
+
batchSize
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
context!
|
|
149
|
+
);
|
|
150
|
+
const shapeIterator = getAsyncIterator(shapeIterable);
|
|
151
|
+
|
|
152
|
+
const shapeHeader = await getNextNonMetadataValue(shapeIterator);
|
|
153
|
+
const header = shapeHeader as SHPHeader;
|
|
154
|
+
|
|
155
|
+
let propertyIterator: AsyncIterator<any> | null = null;
|
|
156
|
+
let propertySchema: TableSchema | null = null;
|
|
157
|
+
|
|
158
|
+
const dbfResponse = context?.url
|
|
159
|
+
? await context.fetch(replaceExtension(context.url, 'dbf')).catch(() => null)
|
|
160
|
+
: null;
|
|
161
|
+
if (dbfResponse?.ok) {
|
|
162
|
+
const dbfOptions = {
|
|
163
|
+
...options,
|
|
164
|
+
dbf: {
|
|
165
|
+
...options?.dbf,
|
|
166
|
+
shape: 'arrow-table' as const,
|
|
167
|
+
batchSize,
|
|
168
|
+
encoding: cpg || 'latin1'
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
const propertyIterable = await parseInBatchesFromContext(
|
|
172
|
+
dbfResponse,
|
|
173
|
+
DBFLoaderWithParser,
|
|
174
|
+
dbfOptions,
|
|
175
|
+
context!
|
|
176
|
+
);
|
|
177
|
+
propertyIterator = getAsyncIterator(propertyIterable);
|
|
178
|
+
|
|
179
|
+
const firstPropertyBatch = await getNextArrowBatch(propertyIterator);
|
|
180
|
+
propertySchema = firstPropertyBatch?.schema || null;
|
|
181
|
+
const outputSchema = buildOutputSchema(propertySchema, header);
|
|
182
|
+
const propertyQueue: arrow.Table[] = [];
|
|
183
|
+
const geometryQueue: arrow.Table[] = [];
|
|
184
|
+
let yieldedDataBatch = false;
|
|
185
|
+
|
|
186
|
+
if (firstPropertyBatch && firstPropertyBatch.length > 0) {
|
|
187
|
+
propertyQueue.push(firstPropertyBatch.data);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
let shapeDone = false;
|
|
191
|
+
let propertyDone = false;
|
|
192
|
+
while (
|
|
193
|
+
!shapeDone ||
|
|
194
|
+
!propertyDone ||
|
|
195
|
+
getQueuedRowCount(geometryQueue) > 0 ||
|
|
196
|
+
getQueuedRowCount(propertyQueue) > 0
|
|
197
|
+
) {
|
|
198
|
+
if (!shapeDone && getQueuedRowCount(geometryQueue) === 0) {
|
|
199
|
+
const shapeBatch = await shapeIterator.next();
|
|
200
|
+
if (shapeBatch.done) {
|
|
201
|
+
shapeDone = true;
|
|
202
|
+
} else if (shapeBatch.value?.batchType !== 'metadata') {
|
|
203
|
+
const transform = getReprojectionTransform(prj, options);
|
|
204
|
+
geometryQueue.push(
|
|
205
|
+
makeGeometryArrowTable(shapeBatch.value as (SHPWKBGeometry | null)[], header, transform)
|
|
206
|
+
.data
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (!propertyDone && getQueuedRowCount(propertyQueue) < getQueuedRowCount(geometryQueue)) {
|
|
212
|
+
const propertyBatch = await getNextArrowBatch(propertyIterator);
|
|
213
|
+
if (!propertyBatch) {
|
|
214
|
+
propertyDone = true;
|
|
215
|
+
} else if (propertyBatch.length > 0) {
|
|
216
|
+
propertyQueue.push(propertyBatch.data);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const rowCount = Math.min(getQueuedRowCount(geometryQueue), getQueuedRowCount(propertyQueue));
|
|
221
|
+
if (rowCount === 0) {
|
|
222
|
+
if (
|
|
223
|
+
(shapeDone && getQueuedRowCount(geometryQueue) === 0) ||
|
|
224
|
+
(propertyDone && getQueuedRowCount(propertyQueue) === 0)
|
|
225
|
+
) {
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const propertyTable = takeRowsFromQueue(propertyQueue, rowCount);
|
|
232
|
+
const geometryTable = takeRowsFromQueue(geometryQueue, rowCount);
|
|
233
|
+
const batch = appendGeometryColumnToArrowTable(
|
|
234
|
+
{shape: 'arrow-table', schema: propertySchema || undefined, data: propertyTable},
|
|
235
|
+
{shape: 'arrow-table', data: geometryTable},
|
|
236
|
+
outputSchema
|
|
237
|
+
);
|
|
238
|
+
yieldedDataBatch = true;
|
|
239
|
+
yield makeTableScanBatch(batch);
|
|
240
|
+
}
|
|
241
|
+
if (!yieldedDataBatch) {
|
|
242
|
+
yield makeEmptyArrowBatch(outputSchema);
|
|
243
|
+
}
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const outputSchema = buildOutputSchema(null, header);
|
|
248
|
+
let yieldedDataBatch = false;
|
|
249
|
+
|
|
250
|
+
while (true) {
|
|
251
|
+
const shapeBatch = await shapeIterator.next();
|
|
252
|
+
if (shapeBatch.done) {
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
if (shapeBatch.value?.batchType === 'metadata') {
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
const transform = getReprojectionTransform(prj, options);
|
|
259
|
+
const arrowTable = makeGeometryArrowTable(
|
|
260
|
+
shapeBatch.value as (SHPWKBGeometry | null)[],
|
|
261
|
+
header,
|
|
262
|
+
transform
|
|
263
|
+
);
|
|
264
|
+
yieldedDataBatch = true;
|
|
265
|
+
yield makeTableScanBatch({...arrowTable, schema: outputSchema});
|
|
266
|
+
}
|
|
267
|
+
if (!yieldedDataBatch) {
|
|
268
|
+
yield makeEmptyArrowBatch(outputSchema);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/** Creates the output Arrow schema by appending the WKB geometry column to DBF fields. */
|
|
273
|
+
function buildOutputSchema(
|
|
274
|
+
propertySchema: TableSchema | null,
|
|
275
|
+
header?: SHPHeader,
|
|
276
|
+
geometrySchema?: TableSchema
|
|
277
|
+
): TableSchema {
|
|
278
|
+
const geometryField: Field =
|
|
279
|
+
geometrySchema?.fields[0] || makeWKBGeometryField(GEOMETRY_COLUMN_NAME);
|
|
280
|
+
const schema: TableSchema = {
|
|
281
|
+
fields: [...(propertySchema?.fields || []), geometryField],
|
|
282
|
+
metadata: {
|
|
283
|
+
...(propertySchema?.metadata || {}),
|
|
284
|
+
...(geometrySchema?.metadata || {})
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
if (!geometrySchema) {
|
|
289
|
+
setWKBGeometryColumnMetadata(schema.metadata!, {
|
|
290
|
+
geometryColumnName: GEOMETRY_COLUMN_NAME,
|
|
291
|
+
geometryTypes: inferGeometryTypes(header)
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
return schema;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function makeGeometryArrowTable(
|
|
299
|
+
geometries: (SHPWKBGeometry | null | undefined)[],
|
|
300
|
+
header?: SHPHeader,
|
|
301
|
+
transform?: (coordinate: number[]) => number[]
|
|
302
|
+
) {
|
|
303
|
+
const geometrySchema = buildOutputSchema(null, header);
|
|
304
|
+
return makeWKBGeometryArrowTable(geometries, geometrySchema, transform);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function appendGeometryColumnToArrowTable(
|
|
308
|
+
propertyTable: ArrowTable,
|
|
309
|
+
geometryTable: ArrowTable,
|
|
310
|
+
schema: TableSchema
|
|
311
|
+
): ArrowTable {
|
|
312
|
+
const propertyBatch = propertyTable.data.batches[0];
|
|
313
|
+
const geometryBatch = geometryTable.data.batches[0];
|
|
314
|
+
const arrowSchema = convertSchemaToArrow(schema);
|
|
315
|
+
const structField = new arrow.Struct(arrowSchema.fields);
|
|
316
|
+
const children = [...propertyBatch.data.children, geometryBatch.data.children[0]];
|
|
317
|
+
const rowCount = Math.max(propertyTable.data.numRows, geometryTable.data.numRows);
|
|
318
|
+
const structData = new arrow.Data(structField, 0, rowCount, 0, undefined, children);
|
|
319
|
+
const recordBatch = new arrow.RecordBatch(arrowSchema, structData);
|
|
320
|
+
|
|
321
|
+
return {
|
|
322
|
+
shape: 'arrow-table',
|
|
323
|
+
schema,
|
|
324
|
+
data: new arrow.Table(arrowSchema, [recordBatch])
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function getReprojectionTransform(
|
|
329
|
+
sourceCrs: WKTCRSDefinition | undefined,
|
|
330
|
+
options?: ShapefileLoaderOptions
|
|
331
|
+
): ((coordinate: number[]) => number[]) | undefined {
|
|
332
|
+
const {reproject = false, targetCrs = 'WGS84'} = options?.gis || {};
|
|
333
|
+
if (!reproject) {
|
|
334
|
+
return undefined;
|
|
335
|
+
}
|
|
336
|
+
if (!sourceCrs) {
|
|
337
|
+
throw new CRSReprojectionError(
|
|
338
|
+
'missing-source-crs',
|
|
339
|
+
'Shapefile reprojection requires a source CRS from the .prj sidecar file',
|
|
340
|
+
{targetCrs}
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
try {
|
|
344
|
+
const projection = projectionEngine.createProjection({
|
|
345
|
+
from: sourceCrs,
|
|
346
|
+
to: (targetCrs || 'WGS84') as ReadonlyCRSDefinition
|
|
347
|
+
});
|
|
348
|
+
return coordinate => projection.projectSync(coordinate);
|
|
349
|
+
} catch (error) {
|
|
350
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
351
|
+
throw new CRSReprojectionError(
|
|
352
|
+
'transformation-failed',
|
|
353
|
+
`Shapefile reprojection failed: ${message}`,
|
|
354
|
+
{sourceCrs, targetCrs: targetCrs || 'WGS84', cause: error}
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function getTypedGeoArrowEncoding(options?: ShapefileLoaderOptions): boolean {
|
|
360
|
+
const encoding = options?.shapefile?.geoarrowEncoding || options?.shp?.geoarrowEncoding;
|
|
361
|
+
const preference =
|
|
362
|
+
options?.geoarrow?.encodingPreference ||
|
|
363
|
+
options?.shapefile?.geoarrow?.encodingPreference ||
|
|
364
|
+
options?.shp?.geoarrow?.encodingPreference;
|
|
365
|
+
return encoding === 'geoarrow' || preference === 'optimized';
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/** Infers GeoParquet geometry type metadata from parsed geometries or the SHP header. */
|
|
369
|
+
function inferGeometryTypes(header?: SHPHeader): GeoParquetGeometryType[] {
|
|
370
|
+
const fallbackType = getGeometryTypeFromHeader(header?.type);
|
|
371
|
+
return fallbackType ? [fallbackType] : [];
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/** Maps SHP header geometry type codes to GeoParquet geometry type strings. */
|
|
375
|
+
function getGeometryTypeFromHeader(type?: number): GeoParquetGeometryType | null {
|
|
376
|
+
switch (type) {
|
|
377
|
+
case 1:
|
|
378
|
+
case 11:
|
|
379
|
+
case 21:
|
|
380
|
+
return type === 11 ? 'Point Z' : 'Point';
|
|
381
|
+
case 3:
|
|
382
|
+
case 13:
|
|
383
|
+
case 23:
|
|
384
|
+
return type === 13 ? 'LineString Z' : 'LineString';
|
|
385
|
+
case 5:
|
|
386
|
+
case 15:
|
|
387
|
+
case 25:
|
|
388
|
+
return type === 15 ? 'Polygon Z' : 'Polygon';
|
|
389
|
+
case 8:
|
|
390
|
+
case 18:
|
|
391
|
+
case 28:
|
|
392
|
+
return type === 18 ? 'MultiPoint Z' : 'MultiPoint';
|
|
393
|
+
default:
|
|
394
|
+
return null;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/** Normalizes sync or async iterables to a single async iterator interface. */
|
|
399
|
+
function getAsyncIterator(iterable: AsyncIterable<any> | Iterable<any>): AsyncIterator<any> {
|
|
400
|
+
const iterator = iterable[Symbol.asyncIterator]?.() || iterable[Symbol.iterator]?.();
|
|
401
|
+
return iterator as AsyncIterator<any>;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/** Reads the next non-metadata value from a parser iterator. */
|
|
405
|
+
async function getNextNonMetadataValue(iterator: AsyncIterator<any>): Promise<any> {
|
|
406
|
+
while (true) {
|
|
407
|
+
const result = await iterator.next();
|
|
408
|
+
if (result.done) {
|
|
409
|
+
return null;
|
|
410
|
+
}
|
|
411
|
+
if (result.value?.batchType !== 'metadata') {
|
|
412
|
+
return result.value;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
async function getNextArrowBatch(iterator: AsyncIterator<any>): Promise<ArrowTableBatch | null> {
|
|
418
|
+
while (true) {
|
|
419
|
+
const result = await iterator.next();
|
|
420
|
+
if (result.done) {
|
|
421
|
+
return null;
|
|
422
|
+
}
|
|
423
|
+
if (result.value?.shape === 'arrow-table') {
|
|
424
|
+
return result.value;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function getQueuedRowCount(queue: arrow.Table[]): number {
|
|
430
|
+
return queue.reduce((rowCount, table) => rowCount + table.numRows, 0);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function takeRowsFromQueue(queue: arrow.Table[], rowCount: number): arrow.Table {
|
|
434
|
+
const table = queue[0];
|
|
435
|
+
if (rowCount === table.numRows) {
|
|
436
|
+
queue.shift();
|
|
437
|
+
return table;
|
|
438
|
+
}
|
|
439
|
+
const result = table.slice(0, rowCount);
|
|
440
|
+
queue[0] = table.slice(rowCount, table.numRows - rowCount);
|
|
441
|
+
return result;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/** Creates an explicit empty Arrow batch so zero-row shapefiles still expose schema in batch mode. */
|
|
445
|
+
function makeEmptyArrowBatch(schema: TableSchema): ArrowTableBatch {
|
|
446
|
+
const table = new ArrowTableBuilder(schema).finishTable();
|
|
447
|
+
return makeTableScanBatch({...table, schema});
|
|
448
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
CRSReprojectionOptions,
|
|
7
|
+
StrictLoaderOptions,
|
|
8
|
+
Loader
|
|
9
|
+
} from '@loaders.gl/core/loader-utils';
|
|
10
|
+
import type {
|
|
11
|
+
Batch,
|
|
12
|
+
GeoArrowEncodingPreference,
|
|
13
|
+
GeoJSONTable,
|
|
14
|
+
ArrowTable,
|
|
15
|
+
ArrowTableBatch
|
|
16
|
+
} from '@loaders.gl/core/schema';
|
|
17
|
+
import type {SHPLoaderOptions} from './shp-loader-types';
|
|
18
|
+
import type {ShapefileOutput} from './lib/parsers/parse-shapefile';
|
|
19
|
+
import type {DBFLoaderOptions} from './dbf-loader-types';
|
|
20
|
+
import type {SHPGeoArrowEncoding} from './lib/parsers/types';
|
|
21
|
+
import {ShapefileFormat} from './shp-format';
|
|
22
|
+
|
|
23
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
24
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
25
|
+
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
26
|
+
|
|
27
|
+
export type ShapefileLoaderOptions = StrictLoaderOptions &
|
|
28
|
+
SHPLoaderOptions &
|
|
29
|
+
DBFLoaderOptions & {
|
|
30
|
+
/** Preferred encoding for Arrow geometry output. */
|
|
31
|
+
geoarrow?: {encodingPreference?: GeoArrowEncodingPreference};
|
|
32
|
+
shapefile?: {
|
|
33
|
+
shape?: 'geojson-table' | 'arrow-table' | 'v3';
|
|
34
|
+
geoarrowEncoding?: SHPGeoArrowEncoding;
|
|
35
|
+
/** Preferred encoding for Arrow geometry output. */
|
|
36
|
+
geoarrow?: {encodingPreference?: GeoArrowEncodingPreference};
|
|
37
|
+
batchSize?: number;
|
|
38
|
+
};
|
|
39
|
+
/** Opt-in coordinate transformation for decoded feature coordinates. */
|
|
40
|
+
gis?: CRSReprojectionOptions;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** Preloads the parser-bearing Shapefile loader implementation. */
|
|
44
|
+
async function preloadShapefileLoader() {
|
|
45
|
+
const {ShapefileLoaderWithParser} = await import('@loaders.gl/geospatial/shapefile');
|
|
46
|
+
return ShapefileLoaderWithParser;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Metadata-only Shapefile loader. */
|
|
50
|
+
export const ShapefileLoader = {
|
|
51
|
+
dataType: null as unknown as ShapefileOutput | GeoJSONTable | ArrowTable,
|
|
52
|
+
batchType: null as unknown as ShapefileOutput | Batch | ArrowTableBatch,
|
|
53
|
+
...ShapefileFormat,
|
|
54
|
+
version: VERSION,
|
|
55
|
+
options: {
|
|
56
|
+
shapefile: {
|
|
57
|
+
shape: 'arrow-table'
|
|
58
|
+
},
|
|
59
|
+
shp: {
|
|
60
|
+
_maxDimensions: 4
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
preload: preloadShapefileLoader
|
|
64
|
+
} as const satisfies Loader<
|
|
65
|
+
ShapefileOutput | GeoJSONTable | ArrowTable,
|
|
66
|
+
ShapefileOutput | Batch | ArrowTableBatch,
|
|
67
|
+
ShapefileLoaderOptions
|
|
68
|
+
>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {StrictLoaderOptions, LoaderWithParser} from '@loaders.gl/core/loader-utils';
|
|
6
|
+
import type {
|
|
7
|
+
Batch,
|
|
8
|
+
GeoArrowEncodingPreference,
|
|
9
|
+
GeoJSONTable,
|
|
10
|
+
ArrowTable,
|
|
11
|
+
ArrowTableBatch
|
|
12
|
+
} from '@loaders.gl/core/schema';
|
|
13
|
+
import {SHPLoaderOptions} from './shp-loader-types';
|
|
14
|
+
import {
|
|
15
|
+
parseShapefile,
|
|
16
|
+
parseShapefileInBatches,
|
|
17
|
+
type ShapefileOutput
|
|
18
|
+
} from './lib/parsers/parse-shapefile';
|
|
19
|
+
import {DBFLoaderOptions} from './dbf-loader-types';
|
|
20
|
+
import type {SHPGeoArrowEncoding} from './lib/parsers/types';
|
|
21
|
+
import {parseShapefileToArrow, parseShapefileToArrowInBatches} from './shapefile-arrow-loader';
|
|
22
|
+
import {ShapefileLoader as ShapefileLoaderMetadata} from './shapefile-loader-types';
|
|
23
|
+
import {
|
|
24
|
+
deserializeShapefileWorkerBatch,
|
|
25
|
+
deserializeShapefileWorkerResult,
|
|
26
|
+
serializeShapefileWorkerBatch,
|
|
27
|
+
serializeShapefileWorkerResult
|
|
28
|
+
} from './lib/shapefile-worker-transport';
|
|
29
|
+
|
|
30
|
+
const {preload: _ShapefileLoaderPreload, ...ShapefileLoaderMetadataWithoutPreload} =
|
|
31
|
+
ShapefileLoaderMetadata;
|
|
32
|
+
|
|
33
|
+
export type ShapefileLoaderOptions = StrictLoaderOptions &
|
|
34
|
+
SHPLoaderOptions &
|
|
35
|
+
DBFLoaderOptions & {
|
|
36
|
+
/** Preferred encoding for Arrow geometry output. */
|
|
37
|
+
geoarrow?: {encodingPreference?: GeoArrowEncodingPreference};
|
|
38
|
+
shapefile?: {
|
|
39
|
+
shape?: 'geojson-table' | 'arrow-table' | 'v3';
|
|
40
|
+
geoarrowEncoding?: SHPGeoArrowEncoding;
|
|
41
|
+
/** Preferred encoding for Arrow geometry output. */
|
|
42
|
+
geoarrow?: {encodingPreference?: GeoArrowEncodingPreference};
|
|
43
|
+
batchSize?: number;
|
|
44
|
+
};
|
|
45
|
+
gis?: import('@loaders.gl/core/loader-utils').CRSReprojectionOptions;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Shapefile loader
|
|
50
|
+
* @note Shapefile is multifile format and requires providing additional files
|
|
51
|
+
*/
|
|
52
|
+
export const ShapefileLoaderWithParser = {
|
|
53
|
+
...ShapefileLoaderMetadataWithoutPreload,
|
|
54
|
+
parse: (arrayBuffer, options, context) =>
|
|
55
|
+
getShapefileShape(options) === 'arrow-table'
|
|
56
|
+
? parseShapefileToArrow(arrayBuffer, options, context)
|
|
57
|
+
: parseShapefile(arrayBuffer, options, context),
|
|
58
|
+
parseInBatches: (asyncIterator, options, context) =>
|
|
59
|
+
getShapefileShape(options) === 'arrow-table'
|
|
60
|
+
? parseShapefileToArrowInBatches(asyncIterator, options, context)
|
|
61
|
+
: parseShapefileInBatches(asyncIterator, options, context),
|
|
62
|
+
serializeWorkerResult: serializeShapefileWorkerResult,
|
|
63
|
+
deserializeWorkerResult: deserializeShapefileWorkerResult,
|
|
64
|
+
serializeWorkerBatch: serializeShapefileWorkerBatch,
|
|
65
|
+
deserializeWorkerBatch: deserializeShapefileWorkerBatch
|
|
66
|
+
} as const satisfies LoaderWithParser<
|
|
67
|
+
ShapefileOutput | GeoJSONTable | ArrowTable,
|
|
68
|
+
ShapefileOutput | Batch | ArrowTableBatch,
|
|
69
|
+
ShapefileLoaderOptions
|
|
70
|
+
>;
|
|
71
|
+
|
|
72
|
+
function getShapefileShape(
|
|
73
|
+
options?: ShapefileLoaderOptions
|
|
74
|
+
): NonNullable<ShapefileLoaderOptions['shapefile']>['shape'] {
|
|
75
|
+
return options?.shapefile?.shape || 'arrow-table';
|
|
76
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Format} from '@loaders.gl/core/loader-utils';
|
|
6
|
+
const SHP_MAGIC_NUMBER = [0x00, 0x00, 0x27, 0x0a];
|
|
7
|
+
|
|
8
|
+
/** SHP geometry file format. */
|
|
9
|
+
export const SHPFormat = {
|
|
10
|
+
name: 'SHP',
|
|
11
|
+
id: 'shp',
|
|
12
|
+
module: 'geospatial',
|
|
13
|
+
category: 'geometry',
|
|
14
|
+
encoding: 'binary',
|
|
15
|
+
format: 'shp',
|
|
16
|
+
extensions: ['shp'],
|
|
17
|
+
mimeTypes: ['application/octet-stream'],
|
|
18
|
+
binary: true,
|
|
19
|
+
tests: [new Uint8Array(SHP_MAGIC_NUMBER).buffer]
|
|
20
|
+
} as const satisfies Format;
|
|
21
|
+
|
|
22
|
+
/** ESRI Shapefile dataset format. */
|
|
23
|
+
export const ShapefileFormat = {
|
|
24
|
+
name: 'Shapefile',
|
|
25
|
+
id: 'shapefile',
|
|
26
|
+
module: 'geospatial',
|
|
27
|
+
category: 'geometry',
|
|
28
|
+
encoding: 'binary',
|
|
29
|
+
format: 'shapefile',
|
|
30
|
+
extensions: ['shp'],
|
|
31
|
+
mimeTypes: ['application/octet-stream'],
|
|
32
|
+
binary: true,
|
|
33
|
+
tests: [new Uint8Array(SHP_MAGIC_NUMBER).buffer]
|
|
34
|
+
} as const satisfies Format;
|