@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,679 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
/* eslint-disable camelcase */
|
|
6
|
+
import {CRSReprojectionError} from '@loaders.gl/core/loader-utils';
|
|
7
|
+
import type {
|
|
8
|
+
ArrowTable,
|
|
9
|
+
DataType,
|
|
10
|
+
Feature,
|
|
11
|
+
Field,
|
|
12
|
+
Geometry,
|
|
13
|
+
GeoJSONTable,
|
|
14
|
+
Schema
|
|
15
|
+
} from '@loaders.gl/core/schema';
|
|
16
|
+
import {ArrowTableBuilder} from '@loaders.gl/core/schema-utils';
|
|
17
|
+
import {type GeoParquetGeometryType} from '@loaders.gl/core/schema';
|
|
18
|
+
import {
|
|
19
|
+
makeWKBGeometryField,
|
|
20
|
+
setWKBGeometrySchemaMetadata
|
|
21
|
+
} from '@loaders.gl/arrow-geometry/geometry-field';
|
|
22
|
+
import {convertWKBToGeometry} from '@loaders.gl/arrow-geometry/geometry-codecs';
|
|
23
|
+
import {reprojectWKBInPlace} from '@loaders.gl/arrow-geometry/binary-geometry-to-wkb';
|
|
24
|
+
import {transformGeoJsonCoords} from '@loaders.gl/arrow-geometry/legacy-binary';
|
|
25
|
+
import {convertFeaturesToGeoArrowTable} from '@loaders.gl/arrow-geometry/feature-table';
|
|
26
|
+
import {projectionEngine} from '@math.gl/geospatial/projection';
|
|
27
|
+
import type {Projection} from '@math.gl/geospatial/projection';
|
|
28
|
+
import {
|
|
29
|
+
parseWKTCRS,
|
|
30
|
+
type ReadonlyCRSDefinition,
|
|
31
|
+
type WKTCRSDefinition
|
|
32
|
+
} from '@math.gl/geospatial/crs';
|
|
33
|
+
import initSqlJs, {Database, SqlJsStatic, Statement} from 'sql.js';
|
|
34
|
+
|
|
35
|
+
import type {GeoPackageLoaderOptions} from '../geopackage-loader-types';
|
|
36
|
+
import type {
|
|
37
|
+
DataColumnsMapping,
|
|
38
|
+
DataColumnsRow,
|
|
39
|
+
GeoPackageGeometryTypes,
|
|
40
|
+
GeoPackageVectorTableInfo,
|
|
41
|
+
GeometryBitFlags,
|
|
42
|
+
PragmaTableInfoRow,
|
|
43
|
+
ProjectionMapping,
|
|
44
|
+
SpatialRefSysRow,
|
|
45
|
+
SQLiteTypes
|
|
46
|
+
} from './types';
|
|
47
|
+
|
|
48
|
+
import {DEFAULT_SQLJS_CDN} from '../geopackage-loader-options';
|
|
49
|
+
export {DEFAULT_SQLJS_CDN} from '../geopackage-loader-options';
|
|
50
|
+
|
|
51
|
+
const GEOMETRY_OUTPUT_COLUMN_NAME = 'geometry';
|
|
52
|
+
|
|
53
|
+
// https://www.geopackage.org/spec121/#flags_layout
|
|
54
|
+
const ENVELOPE_BYTE_LENGTHS = {
|
|
55
|
+
0: 0,
|
|
56
|
+
1: 32,
|
|
57
|
+
2: 48,
|
|
58
|
+
3: 48,
|
|
59
|
+
4: 64,
|
|
60
|
+
5: 0,
|
|
61
|
+
6: 0,
|
|
62
|
+
7: 0
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// Documentation: https://www.geopackage.org/spec130/index.html#table_column_data_types
|
|
66
|
+
const SQL_TYPE_MAPPING: Record<SQLiteTypes | GeoPackageGeometryTypes, DataType> = {
|
|
67
|
+
BOOLEAN: 'bool',
|
|
68
|
+
TINYINT: 'int8',
|
|
69
|
+
SMALLINT: 'int16',
|
|
70
|
+
MEDIUMINT: 'int32',
|
|
71
|
+
INT: 'int32',
|
|
72
|
+
INTEGER: 'int32',
|
|
73
|
+
FLOAT: 'float32',
|
|
74
|
+
DOUBLE: 'float64',
|
|
75
|
+
REAL: 'float64',
|
|
76
|
+
TEXT: 'utf8',
|
|
77
|
+
BLOB: 'binary',
|
|
78
|
+
DATE: 'utf8',
|
|
79
|
+
DATETIME: 'utf8',
|
|
80
|
+
GEOMETRY: 'binary',
|
|
81
|
+
POINT: 'binary',
|
|
82
|
+
LINESTRING: 'binary',
|
|
83
|
+
POLYGON: 'binary',
|
|
84
|
+
MULTIPOINT: 'binary',
|
|
85
|
+
MULTILINESTRING: 'binary',
|
|
86
|
+
MULTIPOLYGON: 'binary',
|
|
87
|
+
GEOMETRYCOLLECTION: 'binary'
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const DEFAULT_TABLE_MARKERS = new Set(['default', 'default table', 'main', 'primary']);
|
|
91
|
+
|
|
92
|
+
/** Parses a GeoPackage into one selected vector table. */
|
|
93
|
+
export async function parseGeoPackage(
|
|
94
|
+
arrayBuffer: ArrayBuffer,
|
|
95
|
+
options?: GeoPackageLoaderOptions
|
|
96
|
+
): Promise<GeoJSONTable | ArrowTable> {
|
|
97
|
+
const shape = options?.geopackage?.shape || 'arrow-table';
|
|
98
|
+
if (shape === 'arrow-table') {
|
|
99
|
+
return parseGeoPackageToArrow(arrayBuffer, options);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const database = await loadGeoPackageDatabase(
|
|
103
|
+
arrayBuffer,
|
|
104
|
+
options?.geopackage?.sqlJsCDN ?? DEFAULT_SQLJS_CDN
|
|
105
|
+
);
|
|
106
|
+
const vectorTables = listGeoPackageVectorTables(database);
|
|
107
|
+
const projections = getProjections(database);
|
|
108
|
+
const {reproject = false, targetCrs = 'WGS84'} = options?.gis || {};
|
|
109
|
+
|
|
110
|
+
switch (shape) {
|
|
111
|
+
case 'geojson-table': {
|
|
112
|
+
const selectedTable = selectGeoPackageVectorTable(vectorTables, options?.geopackage?.table);
|
|
113
|
+
return getGeoPackageGeoJSONTable(database, selectedTable, projections, {
|
|
114
|
+
reproject,
|
|
115
|
+
targetCrs
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
default:
|
|
119
|
+
throw new Error(`Unsupported GeoPackage output shape: ${shape}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Parses one selected GeoPackage vector table into a WKB-backed Arrow table. */
|
|
124
|
+
export async function parseGeoPackageToArrow(
|
|
125
|
+
arrayBuffer: ArrayBuffer,
|
|
126
|
+
options?: GeoPackageLoaderOptions
|
|
127
|
+
): Promise<ArrowTable> {
|
|
128
|
+
const database = await loadGeoPackageDatabase(
|
|
129
|
+
arrayBuffer,
|
|
130
|
+
options?.geopackage?.sqlJsCDN ?? DEFAULT_SQLJS_CDN
|
|
131
|
+
);
|
|
132
|
+
const vectorTables = listGeoPackageVectorTables(database);
|
|
133
|
+
const selectedTable = selectGeoPackageVectorTable(vectorTables, options?.geopackage?.table);
|
|
134
|
+
const projections = getProjections(database);
|
|
135
|
+
const {reproject = false, targetCrs = 'WGS84'} = options?.gis || {};
|
|
136
|
+
|
|
137
|
+
const preference =
|
|
138
|
+
options?.geoarrow?.encodingPreference || options?.geopackage?.geoarrow?.encodingPreference;
|
|
139
|
+
if (preference && preference !== 'geoarrow.wkb') {
|
|
140
|
+
const geoJSONTable = getGeoPackageGeoJSONTable(database, selectedTable, projections, {
|
|
141
|
+
reproject,
|
|
142
|
+
targetCrs
|
|
143
|
+
});
|
|
144
|
+
return convertFeaturesToGeoArrowTable(geoJSONTable.features, {
|
|
145
|
+
encodingPreference: preference
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return getGeoPackageArrowTable(database, selectedTable, projections, {
|
|
150
|
+
reproject,
|
|
151
|
+
targetCrs
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** Initialize SQL.js and create a GeoPackage database handle. */
|
|
156
|
+
export async function loadGeoPackageDatabase(
|
|
157
|
+
arrayBuffer: ArrayBuffer,
|
|
158
|
+
sqlJsCDN: string | null
|
|
159
|
+
): Promise<Database> {
|
|
160
|
+
let sql: SqlJsStatic;
|
|
161
|
+
if (sqlJsCDN) {
|
|
162
|
+
sql = await initSqlJs({
|
|
163
|
+
locateFile: fileName => `${sqlJsCDN}${fileName}`
|
|
164
|
+
});
|
|
165
|
+
} else {
|
|
166
|
+
sql = await initSqlJs();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return new sql.Database(new Uint8Array(arrayBuffer));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** Reads vector table metadata by joining `gpkg_contents` and `gpkg_geometry_columns`. */
|
|
173
|
+
export function listGeoPackageVectorTables(database: Database): GeoPackageVectorTableInfo[] {
|
|
174
|
+
// Raster-only GeoPackages need not contain the optional feature schema.
|
|
175
|
+
if (
|
|
176
|
+
!database.exec(
|
|
177
|
+
"SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'gpkg_geometry_columns'"
|
|
178
|
+
).length
|
|
179
|
+
)
|
|
180
|
+
return [];
|
|
181
|
+
const statement = database.prepare(`
|
|
182
|
+
SELECT
|
|
183
|
+
gpkg_contents.table_name,
|
|
184
|
+
gpkg_contents.identifier,
|
|
185
|
+
gpkg_contents.description,
|
|
186
|
+
gpkg_contents.last_change,
|
|
187
|
+
gpkg_contents.min_x,
|
|
188
|
+
gpkg_contents.min_y,
|
|
189
|
+
gpkg_contents.max_x,
|
|
190
|
+
gpkg_contents.max_y,
|
|
191
|
+
gpkg_contents.srs_id,
|
|
192
|
+
gpkg_geometry_columns.column_name,
|
|
193
|
+
gpkg_geometry_columns.geometry_type_name,
|
|
194
|
+
gpkg_geometry_columns.z,
|
|
195
|
+
gpkg_geometry_columns.m
|
|
196
|
+
FROM gpkg_contents
|
|
197
|
+
INNER JOIN gpkg_geometry_columns
|
|
198
|
+
ON gpkg_contents.table_name = gpkg_geometry_columns.table_name
|
|
199
|
+
WHERE gpkg_contents.data_type='features';
|
|
200
|
+
`);
|
|
201
|
+
|
|
202
|
+
const vectorTables: GeoPackageVectorTableInfo[] = [];
|
|
203
|
+
while (statement.step()) {
|
|
204
|
+
const row = statement.getAsObject() as Record<string, unknown>;
|
|
205
|
+
const bounds = getGeoPackageBounds(row);
|
|
206
|
+
vectorTables.push({
|
|
207
|
+
name: String(row.table_name),
|
|
208
|
+
identifier: normalizeOptionalString(row.identifier),
|
|
209
|
+
description: normalizeOptionalString(row.description),
|
|
210
|
+
lastChange: String(row.last_change),
|
|
211
|
+
srsId: normalizeOptionalNumber(row.srs_id),
|
|
212
|
+
geometryColumnName: String(row.column_name),
|
|
213
|
+
geometryTypeName: String(row.geometry_type_name) as GeoPackageGeometryTypes,
|
|
214
|
+
z: Number(row.z) as 0 | 1 | 2,
|
|
215
|
+
m: Number(row.m) as 0 | 1 | 2,
|
|
216
|
+
bounds
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return vectorTables;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** Selects a vector table by explicit name, explicit preference marker, or first-table fallback. */
|
|
224
|
+
export function selectGeoPackageVectorTable(
|
|
225
|
+
vectorTables: GeoPackageVectorTableInfo[],
|
|
226
|
+
tableName?: string
|
|
227
|
+
): GeoPackageVectorTableInfo {
|
|
228
|
+
if (!vectorTables.length) {
|
|
229
|
+
throw new Error('GeoPackage contains no vector feature tables.');
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (tableName) {
|
|
233
|
+
const selectedTable = vectorTables.find(vectorTable => vectorTable.name === tableName);
|
|
234
|
+
if (!selectedTable) {
|
|
235
|
+
throw new Error(`GeoPackage table not found: ${tableName}`);
|
|
236
|
+
}
|
|
237
|
+
return selectedTable;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (vectorTables.length === 1) {
|
|
241
|
+
return vectorTables[0];
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const preferredTable = vectorTables.find(
|
|
245
|
+
vectorTable =>
|
|
246
|
+
isDefaultTableMarker(vectorTable.identifier) || isDefaultTableMarker(vectorTable.name)
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
return preferredTable || vectorTables[0];
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** Loads one vector table as a GeoJSON feature collection. */
|
|
253
|
+
export function getGeoPackageGeoJSONTable(
|
|
254
|
+
database: Database,
|
|
255
|
+
vectorTable: GeoPackageVectorTableInfo,
|
|
256
|
+
projections: ProjectionMapping,
|
|
257
|
+
options: {reproject: boolean; targetCrs: ReadonlyCRSDefinition}
|
|
258
|
+
): GeoJSONTable {
|
|
259
|
+
const dataColumns = getDataColumns(database, vectorTable.name);
|
|
260
|
+
const featureIdColumn = getFeatureIdName(database, vectorTable.name);
|
|
261
|
+
const queryResult = database.exec(`SELECT * FROM \`${vectorTable.name}\`;`)[0];
|
|
262
|
+
const columns = queryResult?.columns || [];
|
|
263
|
+
const values = queryResult?.values || [];
|
|
264
|
+
const projection = getProjection(vectorTable, projections, options);
|
|
265
|
+
|
|
266
|
+
const geojsonFeatures = values.map(row =>
|
|
267
|
+
constructGeoJsonFeature(columns, row, vectorTable, dataColumns, featureIdColumn, projection)
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
return {
|
|
271
|
+
shape: 'geojson-table',
|
|
272
|
+
schema: getSchema(database, vectorTable.name),
|
|
273
|
+
type: 'FeatureCollection',
|
|
274
|
+
// @ts-expect-error TODO - null geometries causing problems...
|
|
275
|
+
features: geojsonFeatures
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/** Loads one vector table as an Arrow table with a WKB geometry column. */
|
|
280
|
+
export function getGeoPackageArrowTable(
|
|
281
|
+
database: Database,
|
|
282
|
+
vectorTable: GeoPackageVectorTableInfo,
|
|
283
|
+
projections: ProjectionMapping,
|
|
284
|
+
options: {reproject: boolean; targetCrs: ReadonlyCRSDefinition}
|
|
285
|
+
): ArrowTable {
|
|
286
|
+
const queryResult = database.exec(`SELECT * FROM \`${vectorTable.name}\`;`)[0];
|
|
287
|
+
const columns = queryResult?.columns || [];
|
|
288
|
+
const values = queryResult?.values || [];
|
|
289
|
+
const projection = getProjection(vectorTable, projections, options);
|
|
290
|
+
const outputCrs = options.reproject
|
|
291
|
+
? (options.targetCrs as ReadonlyCRSDefinition)
|
|
292
|
+
: vectorTable.srsId === undefined
|
|
293
|
+
? undefined
|
|
294
|
+
: projections[vectorTable.srsId];
|
|
295
|
+
const schema = getGeoPackageArrowSchema(database, vectorTable, outputCrs);
|
|
296
|
+
const tableBuilder = new ArrowTableBuilder(schema);
|
|
297
|
+
|
|
298
|
+
for (const row of values) {
|
|
299
|
+
tableBuilder.addObjectRow(
|
|
300
|
+
constructArrowRow(columns, row, vectorTable.geometryColumnName, projection)
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return tableBuilder.finishTable();
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/** Find all projections defined in GeoPackage. */
|
|
308
|
+
export function getProjections(database: Database): ProjectionMapping {
|
|
309
|
+
const statement = database.prepare('SELECT * FROM gpkg_spatial_ref_sys;');
|
|
310
|
+
const projectionMapping: ProjectionMapping = {};
|
|
311
|
+
|
|
312
|
+
while (statement.step()) {
|
|
313
|
+
const projectionRow = statement.getAsObject() as unknown as SpatialRefSysRow;
|
|
314
|
+
const definition = getSpatialReferenceSystemDefinition(projectionRow);
|
|
315
|
+
if (definition) {
|
|
316
|
+
projectionMapping[projectionRow.srs_id] = definition;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
return projectionMapping;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/** Selects the preferred usable CRS definition from one GeoPackage SRS row. */
|
|
324
|
+
export function getSpatialReferenceSystemDefinition(
|
|
325
|
+
spatialReferenceSystem: SpatialRefSysRow
|
|
326
|
+
): WKTCRSDefinition | undefined {
|
|
327
|
+
const definition = spatialReferenceSystem.definition_12_063 || spatialReferenceSystem.definition;
|
|
328
|
+
return definition && definition.trim().toLowerCase() !== 'undefined' ? definition : undefined;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function constructGeoJsonFeature(
|
|
332
|
+
columns: string[],
|
|
333
|
+
row: unknown[],
|
|
334
|
+
vectorTable: GeoPackageVectorTableInfo,
|
|
335
|
+
dataColumns: DataColumnsMapping | null,
|
|
336
|
+
featureIdColumn: string | null,
|
|
337
|
+
projection: Projection | null
|
|
338
|
+
): Feature<Geometry | null> {
|
|
339
|
+
const featureIdIndex = featureIdColumn ? columns.indexOf(featureIdColumn) : -1;
|
|
340
|
+
const geometryColumnIndex = columns.indexOf(vectorTable.geometryColumnName);
|
|
341
|
+
const rawGeometry = parseGeometry(row[geometryColumnIndex]);
|
|
342
|
+
const geometry = projection ? reprojectGeometry(rawGeometry, projection) : rawGeometry;
|
|
343
|
+
|
|
344
|
+
const properties: Record<string, unknown> = {};
|
|
345
|
+
if (dataColumns) {
|
|
346
|
+
for (const [columnName, propertyName] of Object.entries(dataColumns)) {
|
|
347
|
+
const columnIndex = columns.indexOf(columnName);
|
|
348
|
+
const outputName = propertyName || columnName;
|
|
349
|
+
properties[outputName] = row[columnIndex];
|
|
350
|
+
}
|
|
351
|
+
} else {
|
|
352
|
+
for (let columnIndex = 0; columnIndex < columns.length; columnIndex++) {
|
|
353
|
+
if (columnIndex === featureIdIndex || columnIndex === geometryColumnIndex) {
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
properties[columns[columnIndex]] = row[columnIndex];
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
return {
|
|
361
|
+
id:
|
|
362
|
+
featureIdIndex >= 0 &&
|
|
363
|
+
(typeof row[featureIdIndex] === 'string' || typeof row[featureIdIndex] === 'number')
|
|
364
|
+
? row[featureIdIndex]
|
|
365
|
+
: undefined,
|
|
366
|
+
type: 'Feature',
|
|
367
|
+
geometry,
|
|
368
|
+
properties
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function constructArrowRow(
|
|
373
|
+
columns: string[],
|
|
374
|
+
row: unknown[],
|
|
375
|
+
geometryColumnName: string,
|
|
376
|
+
projection: Projection | null
|
|
377
|
+
): Record<string, unknown> {
|
|
378
|
+
const arrowRow: Record<string, unknown> = {};
|
|
379
|
+
|
|
380
|
+
for (let columnIndex = 0; columnIndex < columns.length; columnIndex++) {
|
|
381
|
+
const columnName = columns[columnIndex];
|
|
382
|
+
const value = row[columnIndex];
|
|
383
|
+
|
|
384
|
+
if (columnName === geometryColumnName) {
|
|
385
|
+
const wkb = parseGeometryWKB(value);
|
|
386
|
+
if (wkb && projection) {
|
|
387
|
+
reprojectWKBInPlace(wkb, coordinate => projection.projectSync(coordinate));
|
|
388
|
+
}
|
|
389
|
+
arrowRow[GEOMETRY_OUTPUT_COLUMN_NAME] = wkb;
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
arrowRow[columnName] = value;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
return arrowRow;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/** Creates the requested GeoPackage projection or rejects missing source CRS metadata. */
|
|
400
|
+
export function getProjection(
|
|
401
|
+
vectorTable: GeoPackageVectorTableInfo,
|
|
402
|
+
projections: ProjectionMapping,
|
|
403
|
+
options: {reproject: boolean; targetCrs: ReadonlyCRSDefinition}
|
|
404
|
+
): Projection | null {
|
|
405
|
+
if (!options.reproject) {
|
|
406
|
+
return null;
|
|
407
|
+
}
|
|
408
|
+
if (vectorTable.srsId === undefined) {
|
|
409
|
+
throw new CRSReprojectionError(
|
|
410
|
+
'missing-source-crs',
|
|
411
|
+
`GeoPackage reprojection requires a source CRS identifier for table "${vectorTable.name}"`,
|
|
412
|
+
{targetCrs: options.targetCrs}
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
const sourceProjection = projections[vectorTable.srsId];
|
|
417
|
+
if (!sourceProjection) {
|
|
418
|
+
throw new CRSReprojectionError(
|
|
419
|
+
'missing-source-crs',
|
|
420
|
+
`GeoPackage reprojection requires a defined source CRS for SRS ${vectorTable.srsId}`,
|
|
421
|
+
{targetCrs: options.targetCrs}
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
try {
|
|
426
|
+
return projectionEngine.createProjection({
|
|
427
|
+
from: getProjectionDefinition(sourceProjection),
|
|
428
|
+
to: options.targetCrs as ReadonlyCRSDefinition
|
|
429
|
+
});
|
|
430
|
+
} catch (error) {
|
|
431
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
432
|
+
throw new CRSReprojectionError(
|
|
433
|
+
'transformation-failed',
|
|
434
|
+
`GeoPackage reprojection failed: ${message}`,
|
|
435
|
+
{sourceCrs: sourceProjection, targetCrs: options.targetCrs, cause: error}
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/** Resolve legacy Web Mercator extensions without changing stored CRS metadata. */
|
|
441
|
+
function getProjectionDefinition(definition: WKTCRSDefinition): ReadonlyCRSDefinition {
|
|
442
|
+
if (/^\s*PROJCS\s*\[/i.test(definition) && /EXTENSION\s*\[\s*"PROJ4"/i.test(definition)) {
|
|
443
|
+
const {root} = parseWKTCRS(definition);
|
|
444
|
+
const authority = root.values.find(
|
|
445
|
+
value => value.type === 'node' && value.keyword.toUpperCase() === 'AUTHORITY'
|
|
446
|
+
);
|
|
447
|
+
if (
|
|
448
|
+
authority?.type === 'node' &&
|
|
449
|
+
authority.values[0]?.type === 'string' &&
|
|
450
|
+
authority.values[0].value.toUpperCase() === 'EPSG' &&
|
|
451
|
+
authority.values[1]?.type === 'string' &&
|
|
452
|
+
authority.values[1].value === '3857'
|
|
453
|
+
) {
|
|
454
|
+
return 'EPSG:3857';
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
return definition;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
function reprojectGeometry(geometry: Geometry | null, projection: Projection): Geometry | null {
|
|
461
|
+
if (!geometry) {
|
|
462
|
+
return null;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
const feature = {type: 'Feature', geometry, properties: {}} as Feature;
|
|
466
|
+
return transformGeoJsonCoords([feature], coordinate => projection.projectSync(coordinate))[0]
|
|
467
|
+
.geometry;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Parse geometry buffer.
|
|
472
|
+
* GeoPackage vector geometries are slightly extended past the WKB standard.
|
|
473
|
+
*/
|
|
474
|
+
function parseGeometry(geometryValue: unknown): Geometry | null {
|
|
475
|
+
const wkb = parseGeometryWKB(geometryValue);
|
|
476
|
+
return wkb
|
|
477
|
+
? convertWKBToGeometry(wkb.buffer.slice(wkb.byteOffset, wkb.byteOffset + wkb.byteLength))
|
|
478
|
+
: null;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
function parseGeometryWKB(geometryValue: unknown): Uint8Array | null {
|
|
482
|
+
if (!geometryValue) {
|
|
483
|
+
return null;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
const arrayBuffer = getArrayBufferFromValue(geometryValue);
|
|
487
|
+
const view = new DataView(arrayBuffer);
|
|
488
|
+
const {envelopeLength, emptyGeometry} = parseGeometryBitFlags(view.getUint8(3));
|
|
489
|
+
|
|
490
|
+
if (emptyGeometry) {
|
|
491
|
+
return null;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
const wkbOffset = 8 + envelopeLength;
|
|
495
|
+
return new Uint8Array(arrayBuffer, wkbOffset);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
function parseGeometryBitFlags(byte: number): GeometryBitFlags {
|
|
499
|
+
const envelopeValue = (byte & 0b00001110) / 2;
|
|
500
|
+
const envelopeLength = ENVELOPE_BYTE_LENGTHS[envelopeValue] as number;
|
|
501
|
+
|
|
502
|
+
return {
|
|
503
|
+
littleEndian: Boolean(byte & 0b00000001),
|
|
504
|
+
envelopeLength,
|
|
505
|
+
emptyGeometry: Boolean(byte & 0b00010000),
|
|
506
|
+
extendedGeometryType: Boolean(byte & 0b00100000)
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
function getFeatureIdName(database: Database, tableName: string): string | null {
|
|
511
|
+
const statement = database.prepare(`PRAGMA table_info(\`${tableName}\`)`);
|
|
512
|
+
|
|
513
|
+
while (statement.step()) {
|
|
514
|
+
const pragmaTableInfo = statement.getAsObject() as unknown as PragmaTableInfoRow;
|
|
515
|
+
if (pragmaTableInfo.pk) {
|
|
516
|
+
return pragmaTableInfo.name;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
return null;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
function getDataColumns(database: Database, tableName: string): DataColumnsMapping | null {
|
|
524
|
+
let statement: Statement;
|
|
525
|
+
try {
|
|
526
|
+
statement = database.prepare('SELECT * FROM gpkg_data_columns WHERE table_name=:tableName;');
|
|
527
|
+
} catch (error) {
|
|
528
|
+
if ((error as Error).message.includes('no such table')) {
|
|
529
|
+
return null;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
throw error;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
statement.bind({':tableName': tableName});
|
|
536
|
+
|
|
537
|
+
const dataColumns: DataColumnsMapping = {};
|
|
538
|
+
while (statement.step()) {
|
|
539
|
+
const column = statement.getAsObject() as unknown as DataColumnsRow;
|
|
540
|
+
dataColumns[column.column_name] = column.name || null;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
return dataColumns;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
function getSchema(database: Database, tableName: string): Schema {
|
|
547
|
+
const statement = database.prepare(`PRAGMA table_info(\`${tableName}\`)`);
|
|
548
|
+
const fields: Field[] = [];
|
|
549
|
+
|
|
550
|
+
while (statement.step()) {
|
|
551
|
+
const pragmaTableInfo = statement.getAsObject() as unknown as PragmaTableInfoRow;
|
|
552
|
+
fields.push({
|
|
553
|
+
name: pragmaTableInfo.name,
|
|
554
|
+
type: getSqliteFieldType(pragmaTableInfo.type),
|
|
555
|
+
nullable: !pragmaTableInfo.notnull
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
return {fields, metadata: {}};
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/** Reads a selected GeoPackage feature-table schema without materializing its rows. */
|
|
563
|
+
export function getGeoPackageArrowSchema(
|
|
564
|
+
database: Database,
|
|
565
|
+
vectorTable: GeoPackageVectorTableInfo,
|
|
566
|
+
crs?: ReadonlyCRSDefinition
|
|
567
|
+
): Schema {
|
|
568
|
+
const statement = database.prepare(`PRAGMA table_info(\`${vectorTable.name}\`)`);
|
|
569
|
+
const fields: Field[] = [];
|
|
570
|
+
|
|
571
|
+
while (statement.step()) {
|
|
572
|
+
const pragmaTableInfo = statement.getAsObject() as unknown as PragmaTableInfoRow;
|
|
573
|
+
if (pragmaTableInfo.name === vectorTable.geometryColumnName) {
|
|
574
|
+
continue;
|
|
575
|
+
}
|
|
576
|
+
fields.push({
|
|
577
|
+
name: pragmaTableInfo.name,
|
|
578
|
+
type: getSqliteFieldType(pragmaTableInfo.type),
|
|
579
|
+
nullable: !pragmaTableInfo.notnull
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
const geometryField = makeWKBGeometryField(GEOMETRY_OUTPUT_COLUMN_NAME);
|
|
584
|
+
if (crs) {
|
|
585
|
+
geometryField.metadata!['ARROW:extension:metadata'] = JSON.stringify(
|
|
586
|
+
getGeoArrowCrsMetadata(crs)
|
|
587
|
+
);
|
|
588
|
+
}
|
|
589
|
+
fields.push(geometryField);
|
|
590
|
+
|
|
591
|
+
const schema: Schema = {fields, metadata: {}};
|
|
592
|
+
setWKBGeometrySchemaMetadata(schema, {
|
|
593
|
+
geometryColumnName: GEOMETRY_OUTPUT_COLUMN_NAME,
|
|
594
|
+
geometryTypes: [getGeoMetadataGeometryType(vectorTable)]
|
|
595
|
+
});
|
|
596
|
+
return schema;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/** Preserves a GeoPackage output CRS using the matching GeoArrow metadata representation. */
|
|
600
|
+
function getGeoArrowCrsMetadata(crs: ReadonlyCRSDefinition): Record<string, unknown> {
|
|
601
|
+
if (typeof crs !== 'string') {
|
|
602
|
+
return {crs, crs_type: 'projjson'};
|
|
603
|
+
}
|
|
604
|
+
if (/^[A-Za-z][A-Za-z0-9_.-]*:[^\s]+$/.test(crs)) {
|
|
605
|
+
return {crs, crs_type: 'authority_code'};
|
|
606
|
+
}
|
|
607
|
+
return {crs};
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
function getGeoMetadataGeometryType(
|
|
611
|
+
vectorTable: GeoPackageVectorTableInfo
|
|
612
|
+
): GeoParquetGeometryType {
|
|
613
|
+
const geometryTypeNameMap: Record<GeoPackageGeometryTypes, GeoParquetGeometryType | 'Geometry'> =
|
|
614
|
+
{
|
|
615
|
+
GEOMETRY: 'Geometry',
|
|
616
|
+
POINT: 'Point',
|
|
617
|
+
LINESTRING: 'LineString',
|
|
618
|
+
POLYGON: 'Polygon',
|
|
619
|
+
MULTIPOINT: 'MultiPoint',
|
|
620
|
+
MULTILINESTRING: 'MultiLineString',
|
|
621
|
+
MULTIPOLYGON: 'MultiPolygon',
|
|
622
|
+
GEOMETRYCOLLECTION: 'GeometryCollection'
|
|
623
|
+
};
|
|
624
|
+
|
|
625
|
+
const geometryType = geometryTypeNameMap[vectorTable.geometryTypeName] || 'Geometry';
|
|
626
|
+
return (vectorTable.z > 0 ? `${geometryType} Z` : geometryType) as GeoParquetGeometryType;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
function getSqliteFieldType(sqliteType: string | undefined): DataType {
|
|
630
|
+
const normalizedType = (sqliteType || 'TEXT').toUpperCase() as
|
|
631
|
+
| SQLiteTypes
|
|
632
|
+
| GeoPackageGeometryTypes;
|
|
633
|
+
return SQL_TYPE_MAPPING[normalizedType] || 'utf8';
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
function getGeoPackageBounds(row: Record<string, unknown>) {
|
|
637
|
+
const minX = normalizeOptionalNumber(row.min_x);
|
|
638
|
+
const minY = normalizeOptionalNumber(row.min_y);
|
|
639
|
+
const maxX = normalizeOptionalNumber(row.max_x);
|
|
640
|
+
const maxY = normalizeOptionalNumber(row.max_y);
|
|
641
|
+
|
|
642
|
+
if (minX === undefined || minY === undefined || maxX === undefined || maxY === undefined) {
|
|
643
|
+
return undefined;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
return {minX, minY, maxX, maxY};
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
function isDefaultTableMarker(value?: string): boolean {
|
|
650
|
+
if (!value) {
|
|
651
|
+
return false;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
const normalizedValue = value
|
|
655
|
+
.toLowerCase()
|
|
656
|
+
.replace(/[^a-z0-9]+/g, ' ')
|
|
657
|
+
.trim();
|
|
658
|
+
return DEFAULT_TABLE_MARKERS.has(normalizedValue);
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
function getArrayBufferFromValue(value: unknown): ArrayBuffer {
|
|
662
|
+
if (value instanceof ArrayBuffer) {
|
|
663
|
+
return value;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
if (ArrayBuffer.isView(value)) {
|
|
667
|
+
return value.buffer.slice(value.byteOffset, value.byteOffset + value.byteLength) as ArrayBuffer;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
throw new Error('Expected GeoPackage geometry column to contain binary data.');
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
function normalizeOptionalString(value: unknown): string | undefined {
|
|
674
|
+
return typeof value === 'string' && value.length ? value : undefined;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
function normalizeOptionalNumber(value: unknown): number | undefined {
|
|
678
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
679
|
+
}
|