@loaders.gl/tiles 5.0.0-alpha.12 → 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/LICENSE +1 -1
- package/README.md +18 -72
- package/dist/dist.dev.js +6979 -42928
- package/dist/dist.min.js +3 -22
- package/dist/image-set.d.ts +1 -1
- package/dist/image-set.d.ts.map +1 -1
- package/dist/index.cjs +2847 -8781
- package/dist/index.cjs.map +3 -4
- package/dist/index.d.ts +4 -45
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -27
- package/dist/index.js.map +1 -1
- package/dist/mlt/bundled.d.ts +3 -0
- package/dist/mlt/bundled.d.ts.map +1 -0
- package/dist/mlt/bundled.js +5 -0
- package/dist/mlt/bundled.js.map +1 -0
- package/dist/mlt/index.cjs +3701 -0
- package/dist/mlt/index.cjs.map +6 -0
- package/dist/mlt/index.d.ts +10 -0
- package/dist/mlt/index.d.ts.map +1 -0
- package/dist/mlt/index.js +12 -0
- package/dist/mlt/index.js.map +1 -0
- package/dist/mlt/lib/encode-mlt-geometry.d.ts +6 -0
- package/dist/mlt/lib/encode-mlt-geometry.d.ts.map +1 -0
- package/dist/mlt/lib/encode-mlt-geometry.js +150 -0
- package/dist/mlt/lib/encode-mlt-geometry.js.map +1 -0
- package/dist/mlt/lib/encode-mlt-streams.d.ts +13 -0
- package/dist/mlt/lib/encode-mlt-streams.d.ts.map +1 -0
- package/dist/mlt/lib/encode-mlt-streams.js +57 -0
- package/dist/mlt/lib/encode-mlt-streams.js.map +1 -0
- package/dist/mlt/lib/encode-mlt.d.ts +6 -0
- package/dist/mlt/lib/encode-mlt.d.ts.map +1 -0
- package/dist/mlt/lib/encode-mlt.js +174 -0
- package/dist/mlt/lib/encode-mlt.js.map +1 -0
- package/dist/mlt/lib/parse-mlt.d.ts +11 -0
- package/dist/mlt/lib/parse-mlt.d.ts.map +1 -0
- package/dist/mlt/lib/parse-mlt.js +675 -0
- package/dist/mlt/lib/parse-mlt.js.map +1 -0
- package/dist/mlt/mlt-format.d.ts +14 -0
- package/dist/mlt/mlt-format.d.ts.map +1 -0
- package/dist/mlt/mlt-format.js +17 -0
- package/dist/mlt/mlt-format.js.map +1 -0
- package/dist/mlt/mlt-loader-with-parser.d.ts +91 -0
- package/dist/mlt/mlt-loader-with-parser.d.ts.map +1 -0
- package/dist/mlt/mlt-loader-with-parser.js +29 -0
- package/dist/mlt/mlt-loader-with-parser.js.map +1 -0
- package/dist/mlt/mlt-loader.d.ts +115 -0
- package/dist/mlt/mlt-loader.d.ts.map +1 -0
- package/dist/mlt/mlt-loader.js +38 -0
- package/dist/mlt/mlt-loader.js.map +1 -0
- package/dist/mlt/mlt-source-loader.d.ts +82 -0
- package/dist/mlt/mlt-source-loader.d.ts.map +1 -0
- package/dist/mlt/mlt-source-loader.js +179 -0
- package/dist/mlt/mlt-source-loader.js.map +1 -0
- package/dist/mlt/mlt-writer.d.ts +45 -0
- package/dist/mlt/mlt-writer.d.ts.map +1 -0
- package/dist/mlt/mlt-writer.js +21 -0
- package/dist/mlt/mlt-writer.js.map +1 -0
- package/dist/mlt/unbundled.d.ts +3 -0
- package/dist/mlt/unbundled.d.ts.map +1 -0
- package/dist/mlt/unbundled.js +5 -0
- package/dist/mlt/unbundled.js.map +1 -0
- package/dist/mvt/arrow-table-tile-source-loader-types.d.ts +36 -0
- package/dist/mvt/arrow-table-tile-source-loader-types.d.ts.map +1 -0
- package/dist/mvt/arrow-table-tile-source-loader-types.js +36 -0
- package/dist/mvt/arrow-table-tile-source-loader-types.js.map +1 -0
- package/dist/mvt/arrow-table-tile-source-loader.cjs +6343 -0
- package/dist/mvt/arrow-table-tile-source-loader.cjs.map +6 -0
- package/dist/mvt/arrow-table-tile-source-loader.d.ts +69 -0
- package/dist/mvt/arrow-table-tile-source-loader.d.ts.map +1 -0
- package/dist/mvt/arrow-table-tile-source-loader.js +216 -0
- package/dist/mvt/arrow-table-tile-source-loader.js.map +1 -0
- package/dist/mvt/arrow-table-tile-source-types.d.ts +21 -0
- package/dist/mvt/arrow-table-tile-source-types.d.ts.map +1 -0
- package/dist/mvt/arrow-table-tile-source-types.js +6 -0
- package/dist/mvt/arrow-table-tile-source-types.js.map +1 -0
- package/dist/mvt/bundled.d.ts +6 -0
- package/dist/mvt/bundled.d.ts.map +1 -0
- package/dist/mvt/bundled.js +7 -0
- package/dist/mvt/bundled.js.map +1 -0
- package/dist/mvt/dist.dev.js +46689 -0
- package/dist/mvt/dist.min.js +94 -0
- package/dist/mvt/index.cjs +10095 -0
- package/dist/mvt/index.cjs.map +6 -0
- package/dist/mvt/index.d.ts +28 -0
- package/dist/mvt/index.d.ts.map +1 -0
- package/dist/mvt/index.js +27 -0
- package/dist/mvt/index.js.map +1 -0
- package/dist/mvt/lib/encode-mvt-arrow.d.ts +6 -0
- package/dist/mvt/lib/encode-mvt-arrow.d.ts.map +1 -0
- package/dist/mvt/lib/encode-mvt-arrow.js +225 -0
- package/dist/mvt/lib/encode-mvt-arrow.js.map +1 -0
- package/dist/mvt/lib/encode-mvt.d.ts +30 -0
- package/dist/mvt/lib/encode-mvt.d.ts.map +1 -0
- package/dist/mvt/lib/encode-mvt.js +20 -0
- package/dist/mvt/lib/encode-mvt.js.map +1 -0
- package/dist/mvt/lib/get-schemas-from-tilejson.d.ts +4 -0
- package/dist/mvt/lib/get-schemas-from-tilejson.d.ts.map +1 -0
- package/dist/mvt/lib/get-schemas-from-tilejson.js +56 -0
- package/dist/mvt/lib/get-schemas-from-tilejson.js.map +1 -0
- package/dist/mvt/lib/is-longitude-latitude-crs.d.ts +3 -0
- package/dist/mvt/lib/is-longitude-latitude-crs.d.ts.map +1 -0
- package/dist/mvt/lib/is-longitude-latitude-crs.js +13 -0
- package/dist/mvt/lib/is-longitude-latitude-crs.js.map +1 -0
- package/dist/mvt/lib/mapbox-vt-pbf/geojson-wrapper.d.ts +25 -0
- package/dist/mvt/lib/mapbox-vt-pbf/geojson-wrapper.d.ts.map +1 -0
- package/dist/mvt/lib/mapbox-vt-pbf/geojson-wrapper.js +73 -0
- package/dist/mvt/lib/mapbox-vt-pbf/geojson-wrapper.js.map +1 -0
- package/dist/mvt/lib/mapbox-vt-pbf/to-vector-tile.d.ts +52 -0
- package/dist/mvt/lib/mapbox-vt-pbf/to-vector-tile.d.ts.map +1 -0
- package/dist/mvt/lib/mapbox-vt-pbf/to-vector-tile.js +165 -0
- package/dist/mvt/lib/mapbox-vt-pbf/to-vector-tile.js.map +1 -0
- package/dist/mvt/lib/mvt-pbf/mvt-constants.d.ts +116 -0
- package/dist/mvt/lib/mvt-pbf/mvt-constants.d.ts.map +1 -0
- package/dist/mvt/lib/mvt-pbf/mvt-constants.js +127 -0
- package/dist/mvt/lib/mvt-pbf/mvt-constants.js.map +1 -0
- package/dist/mvt/lib/mvt-pbf/mvt-types.d.ts +17 -0
- package/dist/mvt/lib/mvt-pbf/mvt-types.d.ts.map +1 -0
- package/dist/mvt/lib/mvt-pbf/mvt-types.js +5 -0
- package/dist/mvt/lib/mvt-pbf/mvt-types.js.map +1 -0
- package/dist/mvt/lib/mvt-pbf/parse-geometry-from-pbf.d.ts +77 -0
- package/dist/mvt/lib/mvt-pbf/parse-geometry-from-pbf.d.ts.map +1 -0
- package/dist/mvt/lib/mvt-pbf/parse-geometry-from-pbf.js +235 -0
- package/dist/mvt/lib/mvt-pbf/parse-geometry-from-pbf.js.map +1 -0
- package/dist/mvt/lib/mvt-pbf/parse-mvt-from-pbf.d.ts +25 -0
- package/dist/mvt/lib/mvt-pbf/parse-mvt-from-pbf.d.ts.map +1 -0
- package/dist/mvt/lib/mvt-pbf/parse-mvt-from-pbf.js +263 -0
- package/dist/mvt/lib/mvt-pbf/parse-mvt-from-pbf.js.map +1 -0
- package/dist/mvt/lib/mvt-pbf/write-mvt-to-pbf.d.ts +4 -0
- package/dist/mvt/lib/mvt-pbf/write-mvt-to-pbf.d.ts.map +1 -0
- package/dist/mvt/lib/mvt-pbf/write-mvt-to-pbf.js +134 -0
- package/dist/mvt/lib/mvt-pbf/write-mvt-to-pbf.js.map +1 -0
- package/dist/mvt/lib/mvt-worker-transport.d.ts +15 -0
- package/dist/mvt/lib/mvt-worker-transport.d.ts.map +1 -0
- package/dist/mvt/lib/mvt-worker-transport.js +54 -0
- package/dist/mvt/lib/mvt-worker-transport.js.map +1 -0
- package/dist/mvt/lib/parse-mvt-geojson.d.ts +6 -0
- package/dist/mvt/lib/parse-mvt-geojson.d.ts.map +1 -0
- package/dist/mvt/lib/parse-mvt-geojson.js +48 -0
- package/dist/mvt/lib/parse-mvt-geojson.js.map +1 -0
- package/dist/mvt/lib/parse-mvt.d.ts +14 -0
- package/dist/mvt/lib/parse-mvt.d.ts.map +1 -0
- package/dist/mvt/lib/parse-mvt.js +105 -0
- package/dist/mvt/lib/parse-mvt.js.map +1 -0
- package/dist/mvt/lib/parse-tilejson.d.ts +74 -0
- package/dist/mvt/lib/parse-tilejson.d.ts.map +1 -0
- package/dist/mvt/lib/parse-tilejson.js +267 -0
- package/dist/mvt/lib/parse-tilejson.js.map +1 -0
- package/dist/mvt/lib/resolve-table-tile-parameters.d.ts +4 -0
- package/dist/mvt/lib/resolve-table-tile-parameters.d.ts.map +1 -0
- package/dist/mvt/lib/resolve-table-tile-parameters.js +16 -0
- package/dist/mvt/lib/resolve-table-tile-parameters.js.map +1 -0
- package/dist/mvt/lib/types.d.ts +88 -0
- package/dist/mvt/lib/types.d.ts.map +1 -0
- package/dist/mvt/lib/types.js.map +1 -0
- package/dist/mvt/lib/utils/geometry-utils.d.ts +83 -0
- package/dist/mvt/lib/utils/geometry-utils.d.ts.map +1 -0
- package/dist/mvt/lib/utils/geometry-utils.js +211 -0
- package/dist/mvt/lib/utils/geometry-utils.js.map +1 -0
- package/dist/mvt/lib/vector-tile/vector-tile-feature.d.ts +72 -0
- package/dist/mvt/lib/vector-tile/vector-tile-feature.d.ts.map +1 -0
- package/dist/mvt/lib/vector-tile/vector-tile-feature.js +350 -0
- package/dist/mvt/lib/vector-tile/vector-tile-feature.js.map +1 -0
- package/dist/mvt/lib/vector-tile/vector-tile-layer.d.ts +29 -0
- package/dist/mvt/lib/vector-tile/vector-tile-layer.d.ts.map +1 -0
- package/dist/mvt/lib/vector-tile/vector-tile-layer.js +108 -0
- package/dist/mvt/lib/vector-tile/vector-tile-layer.js.map +1 -0
- package/dist/mvt/lib/vector-tile/vector-tile.d.ts +9 -0
- package/dist/mvt/lib/vector-tile/vector-tile.d.ts.map +1 -0
- package/dist/mvt/lib/vector-tile/vector-tile.js +28 -0
- package/dist/mvt/lib/vector-tile/vector-tile.js.map +1 -0
- package/dist/mvt/lib/vector-tiler/arrow-tile.d.ts +6 -0
- package/dist/mvt/lib/vector-tiler/arrow-tile.d.ts.map +1 -0
- package/dist/mvt/lib/vector-tiler/arrow-tile.js +84 -0
- package/dist/mvt/lib/vector-tiler/arrow-tile.js.map +1 -0
- package/dist/mvt/lib/vector-tiler/features/clip-features.d.ts +16 -0
- package/dist/mvt/lib/vector-tiler/features/clip-features.d.ts.map +1 -0
- package/dist/mvt/lib/vector-tiler/features/clip-features.js +211 -0
- package/dist/mvt/lib/vector-tiler/features/clip-features.js.map +1 -0
- package/dist/mvt/lib/vector-tiler/features/convert-feature.d.ts +18 -0
- package/dist/mvt/lib/vector-tiler/features/convert-feature.d.ts.map +1 -0
- package/dist/mvt/lib/vector-tiler/features/convert-feature.js +161 -0
- package/dist/mvt/lib/vector-tiler/features/convert-feature.js.map +1 -0
- package/dist/mvt/lib/vector-tiler/features/proto-feature.d.ts +30 -0
- package/dist/mvt/lib/vector-tiler/features/proto-feature.d.ts.map +1 -0
- package/dist/mvt/lib/vector-tiler/features/proto-feature.js +53 -0
- package/dist/mvt/lib/vector-tiler/features/proto-feature.js.map +1 -0
- package/dist/mvt/lib/vector-tiler/features/simplify-path.d.ts +10 -0
- package/dist/mvt/lib/vector-tiler/features/simplify-path.d.ts.map +1 -0
- package/dist/mvt/lib/vector-tiler/features/simplify-path.js +67 -0
- package/dist/mvt/lib/vector-tiler/features/simplify-path.js.map +1 -0
- package/dist/mvt/lib/vector-tiler/features/wrap-features.d.ts +17 -0
- package/dist/mvt/lib/vector-tiler/features/wrap-features.d.ts.map +1 -0
- package/dist/mvt/lib/vector-tiler/features/wrap-features.js +95 -0
- package/dist/mvt/lib/vector-tiler/features/wrap-features.js.map +1 -0
- package/dist/mvt/lib/vector-tiler/proto-tile.d.ts +40 -0
- package/dist/mvt/lib/vector-tiler/proto-tile.d.ts.map +1 -0
- package/dist/mvt/lib/vector-tiler/proto-tile.js +139 -0
- package/dist/mvt/lib/vector-tiler/proto-tile.js.map +1 -0
- package/dist/mvt/lib/vector-tiler/tile-to-geojson.d.ts +12 -0
- package/dist/mvt/lib/vector-tiler/tile-to-geojson.d.ts.map +1 -0
- package/dist/mvt/lib/vector-tiler/tile-to-geojson.js +81 -0
- package/dist/mvt/lib/vector-tiler/tile-to-geojson.js.map +1 -0
- package/dist/mvt/lib/vector-tiler/transform-tile.d.ts +7 -0
- package/dist/mvt/lib/vector-tiler/transform-tile.d.ts.map +1 -0
- package/dist/mvt/lib/vector-tiler/transform-tile.js +42 -0
- package/dist/mvt/lib/vector-tiler/transform-tile.js.map +1 -0
- package/dist/mvt/map-style-format.d.ts +13 -0
- package/dist/mvt/map-style-format.d.ts.map +1 -0
- package/dist/mvt/map-style-format.js +16 -0
- package/dist/mvt/map-style-format.js.map +1 -0
- package/dist/mvt/map-style-loader-with-parser.d.ts +26 -0
- package/dist/mvt/map-style-loader-with-parser.d.ts.map +1 -0
- package/dist/mvt/map-style-loader-with-parser.js +38 -0
- package/dist/mvt/map-style-loader-with-parser.js.map +1 -0
- package/dist/mvt/map-style-loader.d.ts +44 -0
- package/dist/mvt/map-style-loader.d.ts.map +1 -0
- package/dist/mvt/map-style-loader.js +25 -0
- package/dist/mvt/map-style-loader.js.map +1 -0
- package/dist/mvt/map-style-schema.d.ts +58 -0
- package/dist/mvt/map-style-schema.d.ts.map +1 -0
- package/dist/mvt/map-style-schema.js +47 -0
- package/dist/mvt/map-style-schema.js.map +1 -0
- package/dist/mvt/map-style.d.ts +110 -0
- package/dist/mvt/map-style.d.ts.map +1 -0
- package/dist/mvt/map-style.js +90 -0
- package/dist/mvt/map-style.js.map +1 -0
- package/dist/mvt/mvt-format.d.ts +14 -0
- package/dist/mvt/mvt-format.d.ts.map +1 -0
- package/dist/mvt/mvt-format.js +23 -0
- package/dist/mvt/mvt-format.js.map +1 -0
- package/dist/mvt/mvt-geojson-loader-types.d.ts +82 -0
- package/dist/mvt/mvt-geojson-loader-types.d.ts.map +1 -0
- package/dist/mvt/mvt-geojson-loader-types.js +34 -0
- package/dist/mvt/mvt-geojson-loader-types.js.map +1 -0
- package/dist/mvt/mvt-geojson-loader.cjs +1366 -0
- package/dist/mvt/mvt-geojson-loader.cjs.map +6 -0
- package/dist/mvt/mvt-geojson-loader.d.ts +32 -0
- package/dist/mvt/mvt-geojson-loader.d.ts.map +1 -0
- package/dist/mvt/mvt-geojson-loader.js +13 -0
- package/dist/mvt/mvt-geojson-loader.js.map +1 -0
- package/dist/mvt/mvt-loader-with-parser.d.ts +105 -0
- package/dist/mvt/mvt-loader-with-parser.d.ts.map +1 -0
- package/dist/mvt/mvt-loader-with-parser.js +21 -0
- package/dist/mvt/mvt-loader-with-parser.js.map +1 -0
- package/dist/mvt/mvt-loader.d.ts +129 -0
- package/dist/mvt/mvt-loader.d.ts.map +1 -0
- package/dist/mvt/mvt-loader.js +40 -0
- package/dist/mvt/mvt-loader.js.map +1 -0
- package/dist/mvt/mvt-source-loader.d.ts +102 -0
- package/dist/mvt/mvt-source-loader.d.ts.map +1 -0
- package/dist/mvt/mvt-source-loader.js +275 -0
- package/dist/mvt/mvt-source-loader.js.map +1 -0
- package/dist/mvt/mvt-writer.d.ts +28 -0
- package/dist/mvt/mvt-writer.d.ts.map +1 -0
- package/dist/mvt/mvt-writer.js +32 -0
- package/dist/mvt/mvt-writer.js.map +1 -0
- package/dist/mvt/table-tile-source-loader.d.ts +169 -0
- package/dist/mvt/table-tile-source-loader.d.ts.map +1 -0
- package/dist/mvt/table-tile-source-loader.js +478 -0
- package/dist/mvt/table-tile-source-loader.js.map +1 -0
- package/dist/mvt/tilejson-format.d.ts +13 -0
- package/dist/mvt/tilejson-format.d.ts.map +1 -0
- package/dist/mvt/tilejson-format.js +16 -0
- package/dist/mvt/tilejson-format.js.map +1 -0
- package/dist/mvt/tilejson-loader-with-parser.d.ts +13 -0
- package/dist/mvt/tilejson-loader-with-parser.d.ts.map +1 -0
- package/dist/mvt/tilejson-loader-with-parser.js +25 -0
- package/dist/mvt/tilejson-loader-with-parser.js.map +1 -0
- package/dist/mvt/tilejson-loader.d.ts +56 -0
- package/dist/mvt/tilejson-loader.d.ts.map +1 -0
- package/dist/mvt/tilejson-loader.js +28 -0
- package/dist/mvt/tilejson-loader.js.map +1 -0
- package/dist/mvt/tilejson-zod-schema.cjs +79 -0
- package/dist/mvt/tilejson-zod-schema.cjs.map +6 -0
- package/dist/mvt/tilejson-zod-schema.d.ts +218 -0
- package/dist/mvt/tilejson-zod-schema.d.ts.map +1 -0
- package/dist/mvt/tilejson-zod-schema.js +68 -0
- package/dist/mvt/tilejson-zod-schema.js.map +1 -0
- package/dist/mvt/tilejson.schema.json +197 -0
- package/dist/mvt/unbundled.d.ts +8 -0
- package/dist/mvt/unbundled.d.ts.map +1 -0
- package/dist/mvt/unbundled.js +8 -0
- package/dist/mvt/unbundled.js.map +1 -0
- package/dist/mvt/workers/mvt-worker-node.d.ts +2 -0
- package/dist/mvt/workers/mvt-worker-node.d.ts.map +1 -0
- package/dist/mvt/workers/mvt-worker-node.js +8 -0
- package/dist/mvt/workers/mvt-worker-node.js.map +1 -0
- package/dist/mvt/workers/mvt-worker.d.ts +2 -0
- package/dist/mvt/workers/mvt-worker.d.ts.map +1 -0
- package/dist/mvt/workers/mvt-worker.js +7 -0
- package/dist/mvt/workers/mvt-worker.js.map +1 -0
- package/dist/mvt-worker-node.js +72460 -0
- package/dist/mvt-worker-node.js.map +7 -0
- package/dist/mvt-worker.js +21239 -0
- package/dist/pmtiles/bundled.d.ts +3 -0
- package/dist/pmtiles/bundled.d.ts.map +1 -0
- package/dist/pmtiles/bundled.js +5 -0
- package/dist/pmtiles/bundled.js.map +1 -0
- package/dist/pmtiles/dist.dev.js +50530 -0
- package/dist/pmtiles/dist.min.js +94 -0
- package/dist/pmtiles/geoarrow.cjs +6718 -0
- package/dist/pmtiles/geoarrow.cjs.map +6 -0
- package/dist/pmtiles/geoarrow.d.ts +30 -0
- package/dist/pmtiles/geoarrow.d.ts.map +1 -0
- package/dist/pmtiles/geoarrow.js +143 -0
- package/dist/pmtiles/geoarrow.js.map +1 -0
- package/dist/pmtiles/index.cjs +8011 -0
- package/dist/pmtiles/index.cjs.map +6 -0
- package/dist/pmtiles/index.d.ts +14 -0
- package/dist/pmtiles/index.d.ts.map +1 -0
- package/dist/pmtiles/index.js +10 -0
- package/dist/pmtiles/index.js.map +1 -0
- package/dist/pmtiles/lib/blob-source.d.ts +14 -0
- package/dist/pmtiles/lib/blob-source.d.ts.map +1 -0
- package/dist/pmtiles/lib/blob-source.js +32 -0
- package/dist/pmtiles/lib/blob-source.js.map +1 -0
- package/dist/pmtiles/lib/encode-pmtiles.d.ts +8 -0
- package/dist/pmtiles/lib/encode-pmtiles.d.ts.map +1 -0
- package/dist/pmtiles/lib/encode-pmtiles.js +268 -0
- package/dist/pmtiles/lib/encode-pmtiles.js.map +1 -0
- package/dist/pmtiles/lib/parse-pmtiles.d.ts +52 -0
- package/dist/pmtiles/lib/parse-pmtiles.d.ts.map +1 -0
- package/dist/pmtiles/lib/parse-pmtiles.js +95 -0
- package/dist/pmtiles/lib/parse-pmtiles.js.map +1 -0
- package/dist/pmtiles/lib/range-request-source.d.ts +24 -0
- package/dist/pmtiles/lib/range-request-source.d.ts.map +1 -0
- package/dist/pmtiles/lib/range-request-source.js +45 -0
- package/dist/pmtiles/lib/range-request-source.js.map +1 -0
- package/dist/pmtiles/lib/version.d.ts +2 -0
- package/dist/pmtiles/lib/version.d.ts.map +1 -0
- package/dist/pmtiles/lib/version.js +8 -0
- package/dist/pmtiles/lib/version.js.map +1 -0
- package/dist/pmtiles/pmtiles-format.d.ts +14 -0
- package/dist/pmtiles/pmtiles-format.d.ts.map +1 -0
- package/dist/pmtiles/pmtiles-format.js +17 -0
- package/dist/pmtiles/pmtiles-format.js.map +1 -0
- package/dist/pmtiles/pmtiles-loader-with-parser.d.ts +30 -0
- package/dist/pmtiles/pmtiles-loader-with-parser.d.ts.map +1 -0
- package/dist/pmtiles/pmtiles-loader-with-parser.js +41 -0
- package/dist/pmtiles/pmtiles-loader-with-parser.js.map +1 -0
- package/dist/pmtiles/pmtiles-loader.d.ts +41 -0
- package/dist/pmtiles/pmtiles-loader.d.ts.map +1 -0
- package/dist/pmtiles/pmtiles-loader.js +20 -0
- package/dist/pmtiles/pmtiles-loader.js.map +1 -0
- package/dist/pmtiles/pmtiles-source-loader.d.ts +85 -0
- package/dist/pmtiles/pmtiles-source-loader.d.ts.map +1 -0
- package/dist/pmtiles/pmtiles-source-loader.js +239 -0
- package/dist/pmtiles/pmtiles-source-loader.js.map +1 -0
- package/dist/pmtiles/pmtiles-writer-types.d.ts +39 -0
- package/dist/pmtiles/pmtiles-writer-types.d.ts.map +1 -0
- package/dist/{point-cloud-tile-source-types.js → pmtiles/pmtiles-writer-types.js} +1 -1
- package/dist/pmtiles/pmtiles-writer-types.js.map +1 -0
- package/dist/pmtiles/pmtiles-writer.d.ts +22 -0
- package/dist/pmtiles/pmtiles-writer.d.ts.map +1 -0
- package/dist/pmtiles/pmtiles-writer.js +15 -0
- package/dist/pmtiles/pmtiles-writer.js.map +1 -0
- package/dist/pmtiles/raster.cjs +1183 -0
- package/dist/pmtiles/raster.cjs.map +6 -0
- package/dist/pmtiles/raster.d.ts +30 -0
- package/dist/pmtiles/raster.d.ts.map +1 -0
- package/dist/pmtiles/raster.js +212 -0
- package/dist/pmtiles/raster.js.map +1 -0
- package/dist/pmtiles/source-info.d.ts +25 -0
- package/dist/pmtiles/source-info.d.ts.map +1 -0
- package/dist/{types.js → pmtiles/source-info.js} +1 -1
- package/dist/pmtiles/source-info.js.map +1 -0
- package/dist/pmtiles/unbundled.d.ts +3 -0
- package/dist/pmtiles/unbundled.d.ts.map +1 -0
- package/dist/pmtiles/unbundled.js +5 -0
- package/dist/pmtiles/unbundled.js.map +1 -0
- package/dist/raster-set.d.ts +1 -1
- package/dist/raster-set.d.ts.map +1 -1
- package/dist/raster-set.js +1 -1
- package/dist/raster-set.js.map +1 -1
- package/dist/tile-matrix.cjs +81 -0
- package/dist/tile-matrix.cjs.map +6 -0
- package/dist/tile-matrix.d.ts +52 -0
- package/dist/tile-matrix.d.ts.map +1 -0
- package/dist/tile-matrix.js +75 -0
- package/dist/tile-matrix.js.map +1 -0
- package/dist/tileset-2d/tile-2d-header.d.ts +2 -2
- package/dist/tileset-2d/tile-2d-header.d.ts.map +1 -1
- package/dist/tileset-2d/tile-2d-header.js +11 -11
- package/dist/tileset-2d/tile-2d-header.js.map +1 -1
- package/dist/tileset-2d/tileset-2d.d.ts +19 -10
- package/dist/tileset-2d/tileset-2d.d.ts.map +1 -1
- package/dist/tileset-2d/tileset-2d.js +69 -15
- package/dist/tileset-2d/tileset-2d.js.map +1 -1
- package/package.json +101 -25
- package/src/image-set.ts +1 -1
- package/src/index.ts +8 -128
- package/src/mlt/bundled.ts +9 -0
- package/src/mlt/index.ts +18 -0
- package/src/mlt/lib/encode-mlt-geometry.ts +162 -0
- package/src/mlt/lib/encode-mlt-streams.ts +66 -0
- package/src/mlt/lib/encode-mlt.ts +215 -0
- package/src/mlt/lib/parse-mlt.ts +906 -0
- package/src/mlt/libs/mlt-decoder.cjs +4552 -0
- package/src/mlt/mlt-format.ts +19 -0
- package/src/mlt/mlt-loader-with-parser.ts +57 -0
- package/src/mlt/mlt-loader.ts +64 -0
- package/src/mlt/mlt-source-loader.ts +266 -0
- package/src/mlt/mlt-writer.ts +47 -0
- package/src/mlt/unbundled.ts +6 -0
- package/src/mvt/arrow-table-tile-source-loader-types.ts +55 -0
- package/src/mvt/arrow-table-tile-source-loader.ts +307 -0
- package/src/mvt/arrow-table-tile-source-types.ts +32 -0
- package/src/mvt/bundled.ts +14 -0
- package/src/mvt/index.ts +67 -0
- package/src/mvt/lib/encode-mvt-arrow.ts +273 -0
- package/src/mvt/lib/encode-mvt.ts +46 -0
- package/src/mvt/lib/get-schemas-from-tilejson.ts +64 -0
- package/src/mvt/lib/is-longitude-latitude-crs.ts +15 -0
- package/src/mvt/lib/mapbox-vt-pbf/geojson-to-vt.ts.disabled +76 -0
- package/src/mvt/lib/mapbox-vt-pbf/geojson-wrapper.ts +89 -0
- package/src/mvt/lib/mapbox-vt-pbf/to-vector-tile.ts +230 -0
- package/src/mvt/lib/mvt-pbf/mvt-constants.ts +135 -0
- package/src/mvt/lib/mvt-pbf/mvt-types.ts +22 -0
- package/src/mvt/lib/mvt-pbf/parse-geometry-from-pbf.ts +285 -0
- package/src/mvt/lib/mvt-pbf/parse-mvt-from-pbf.ts +310 -0
- package/src/mvt/lib/mvt-pbf/write-mvt-to-pbf.ts +162 -0
- package/src/mvt/lib/mvt-worker-transport.ts +74 -0
- package/src/mvt/lib/parse-mvt-geojson.ts +65 -0
- package/src/mvt/lib/parse-mvt.ts +145 -0
- package/src/mvt/lib/parse-tilejson.ts +397 -0
- package/src/mvt/lib/resolve-table-tile-parameters.ts +23 -0
- package/src/mvt/lib/types.ts +90 -0
- package/src/mvt/lib/utils/geometry-utils.ts +238 -0
- package/src/mvt/lib/vector-tile/LICENSE.txt +31 -0
- package/src/mvt/lib/vector-tile/vector-tile-feature.ts +430 -0
- package/src/mvt/lib/vector-tile/vector-tile-layer.ts +130 -0
- package/src/mvt/lib/vector-tile/vector-tile.ts +32 -0
- package/src/mvt/lib/vector-tiler/LICENSE +19 -0
- package/src/mvt/lib/vector-tiler/arrow-tile.ts +93 -0
- package/src/mvt/lib/vector-tiler/features/clip-features.ts +250 -0
- package/src/mvt/lib/vector-tiler/features/convert-feature.ts +213 -0
- package/src/mvt/lib/vector-tiler/features/proto-feature.ts +104 -0
- package/src/mvt/lib/vector-tiler/features/simplify-path.ts +84 -0
- package/src/mvt/lib/vector-tiler/features/wrap-features.ts +125 -0
- package/src/mvt/lib/vector-tiler/proto-tile.ts +217 -0
- package/src/mvt/lib/vector-tiler/tile-to-geojson.ts +104 -0
- package/src/mvt/lib/vector-tiler/transform-tile.ts +57 -0
- package/src/mvt/map-style-format.ts +18 -0
- package/src/mvt/map-style-loader-with-parser.ts +62 -0
- package/src/mvt/map-style-loader.ts +31 -0
- package/src/mvt/map-style-schema.ts +53 -0
- package/src/mvt/map-style.ts +218 -0
- package/src/mvt/mvt-format.ts +25 -0
- package/src/mvt/mvt-geojson-loader-types.ts +60 -0
- package/src/mvt/mvt-geojson-loader.ts +20 -0
- package/src/mvt/mvt-loader-with-parser.ts +53 -0
- package/src/mvt/mvt-loader.ts +73 -0
- package/src/mvt/mvt-source-loader.ts +410 -0
- package/src/mvt/mvt-writer.ts +35 -0
- package/src/mvt/table-tile-source-loader.ts +672 -0
- package/src/mvt/tilejson-format.ts +18 -0
- package/src/mvt/tilejson-loader-with-parser.ts +38 -0
- package/src/mvt/tilejson-loader.ts +42 -0
- package/src/mvt/tilejson-zod-schema.ts +199 -0
- package/src/mvt/unbundled.ts +13 -0
- package/src/mvt/workers/mvt-worker-node.ts +9 -0
- package/src/mvt/workers/mvt-worker.ts +8 -0
- package/src/pmtiles/bundled.ts +6 -0
- package/src/pmtiles/geoarrow.ts +188 -0
- package/src/pmtiles/index.ts +27 -0
- package/src/pmtiles/lib/blob-source.ts +41 -0
- package/src/pmtiles/lib/encode-pmtiles.ts +322 -0
- package/src/pmtiles/lib/parse-pmtiles.ts +180 -0
- package/src/pmtiles/lib/range-request-source.ts +60 -0
- package/src/pmtiles/lib/version.ts +8 -0
- package/src/pmtiles/pmtiles-format.ts +19 -0
- package/src/pmtiles/pmtiles-loader-with-parser.ts +60 -0
- package/src/pmtiles/pmtiles-loader.ts +30 -0
- package/src/pmtiles/pmtiles-source-loader.ts +346 -0
- package/src/pmtiles/pmtiles-writer-types.ts +45 -0
- package/src/pmtiles/pmtiles-writer.ts +26 -0
- package/src/pmtiles/raster.ts +289 -0
- package/src/pmtiles/source-info.ts +25 -0
- package/src/pmtiles/unbundled.ts +6 -0
- package/src/raster-set.ts +2 -2
- package/src/tile-matrix.ts +138 -0
- package/src/tileset-2d/tile-2d-header.ts +14 -13
- package/src/tileset-2d/tileset-2d.ts +81 -19
- package/dist/constants.d.ts +0 -38
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -39
- package/dist/constants.js.map +0 -1
- package/dist/point-cloud/point-cloud-tile.d.ts +0 -47
- package/dist/point-cloud/point-cloud-tile.d.ts.map +0 -1
- package/dist/point-cloud/point-cloud-tile.js +0 -70
- package/dist/point-cloud/point-cloud-tile.js.map +0 -1
- package/dist/point-cloud/point-cloud-tileset.d.ts +0 -135
- package/dist/point-cloud/point-cloud-tileset.d.ts.map +0 -1
- package/dist/point-cloud/point-cloud-tileset.js +0 -549
- package/dist/point-cloud/point-cloud-tileset.js.map +0 -1
- package/dist/point-cloud/types.d.ts +0 -81
- package/dist/point-cloud/types.d.ts.map +0 -1
- package/dist/point-cloud/types.js.map +0 -1
- package/dist/point-cloud-tile-source-loader-types.d.ts +0 -31
- package/dist/point-cloud-tile-source-loader-types.d.ts.map +0 -1
- package/dist/point-cloud-tile-source-loader-types.js +0 -34
- package/dist/point-cloud-tile-source-loader-types.js.map +0 -1
- package/dist/point-cloud-tile-source-loader.cjs +0 -81
- package/dist/point-cloud-tile-source-loader.cjs.map +0 -7
- package/dist/point-cloud-tile-source-loader.d.ts +0 -27
- package/dist/point-cloud-tile-source-loader.d.ts.map +0 -1
- package/dist/point-cloud-tile-source-loader.js +0 -17
- package/dist/point-cloud-tile-source-loader.js.map +0 -1
- package/dist/point-cloud-tile-source-types.d.ts +0 -15
- package/dist/point-cloud-tile-source-types.d.ts.map +0 -1
- package/dist/point-cloud-tile-source-types.js.map +0 -1
- package/dist/point-cloud-tile-source.cjs +0 -105
- package/dist/point-cloud-tile-source.cjs.map +0 -7
- package/dist/point-cloud-tile-source.d.ts +0 -36
- package/dist/point-cloud-tile-source.d.ts.map +0 -1
- package/dist/point-cloud-tile-source.js +0 -84
- package/dist/point-cloud-tile-source.js.map +0 -1
- package/dist/spatial/format-spatial-reference.d.ts +0 -68
- package/dist/spatial/format-spatial-reference.d.ts.map +0 -1
- package/dist/spatial/format-spatial-reference.js +0 -291
- package/dist/spatial/format-spatial-reference.js.map +0 -1
- package/dist/spatial/get-spatial-coordinate-frame.d.ts +0 -20
- package/dist/spatial/get-spatial-coordinate-frame.d.ts.map +0 -1
- package/dist/spatial/get-spatial-coordinate-frame.js +0 -139
- package/dist/spatial/get-spatial-coordinate-frame.js.map +0 -1
- package/dist/spatial/i3s-elevation.d.ts +0 -20
- package/dist/spatial/i3s-elevation.d.ts.map +0 -1
- package/dist/spatial/i3s-elevation.js +0 -90
- package/dist/spatial/i3s-elevation.js.map +0 -1
- package/dist/spatial/i3s-spatial-transformer.d.ts +0 -205
- package/dist/spatial/i3s-spatial-transformer.d.ts.map +0 -1
- package/dist/spatial/i3s-spatial-transformer.js +0 -731
- package/dist/spatial/i3s-spatial-transformer.js.map +0 -1
- package/dist/spatial/normalize-crs-identifier.d.ts +0 -15
- package/dist/spatial/normalize-crs-identifier.d.ts.map +0 -1
- package/dist/spatial/normalize-crs-identifier.js +0 -22
- package/dist/spatial/normalize-crs-identifier.js.map +0 -1
- package/dist/spatial/spatial-coordinate-transformer.d.ts +0 -54
- package/dist/spatial/spatial-coordinate-transformer.d.ts.map +0 -1
- package/dist/spatial/spatial-coordinate-transformer.js +0 -311
- package/dist/spatial/spatial-coordinate-transformer.js.map +0 -1
- package/dist/spatial/spatial-resource-registry.d.ts +0 -47
- package/dist/spatial/spatial-resource-registry.d.ts.map +0 -1
- package/dist/spatial/spatial-resource-registry.js +0 -76
- package/dist/spatial/spatial-resource-registry.js.map +0 -1
- package/dist/spatial/spatial-types.d.ts +0 -190
- package/dist/spatial/spatial-types.d.ts.map +0 -1
- package/dist/spatial/spatial-types.js +0 -192
- package/dist/spatial/spatial-types.js.map +0 -1
- package/dist/spatial/tiles-3d-spatial-transformer.d.ts +0 -32
- package/dist/spatial/tiles-3d-spatial-transformer.d.ts.map +0 -1
- package/dist/spatial/tiles-3d-spatial-transformer.js +0 -163
- package/dist/spatial/tiles-3d-spatial-transformer.js.map +0 -1
- package/dist/tileset-3d/common/indexed-archive-tileset-source.d.ts +0 -60
- package/dist/tileset-3d/common/indexed-archive-tileset-source.d.ts.map +0 -1
- package/dist/tileset-3d/common/indexed-archive-tileset-source.js +0 -130
- package/dist/tileset-3d/common/indexed-archive-tileset-source.js.map +0 -1
- package/dist/tileset-3d/common/tile-3d-contracts.d.ts +0 -63
- package/dist/tileset-3d/common/tile-3d-contracts.d.ts.map +0 -1
- package/dist/tileset-3d/common/tile-3d-contracts.js +0 -51
- package/dist/tileset-3d/common/tile-3d-contracts.js.map +0 -1
- package/dist/tileset-3d/common/tile-3d.d.ts +0 -410
- package/dist/tileset-3d/common/tile-3d.d.ts.map +0 -1
- package/dist/tileset-3d/common/tile-3d.js +0 -1056
- package/dist/tileset-3d/common/tile-3d.js.map +0 -1
- package/dist/tileset-3d/common/tileset-3d.d.ts +0 -369
- package/dist/tileset-3d/common/tileset-3d.d.ts.map +0 -1
- package/dist/tileset-3d/common/tileset-3d.js +0 -879
- package/dist/tileset-3d/common/tileset-3d.js.map +0 -1
- package/dist/tileset-3d/common/tileset-cache.d.ts +0 -29
- package/dist/tileset-3d/common/tileset-cache.d.ts.map +0 -1
- package/dist/tileset-3d/common/tileset-cache.js +0 -82
- package/dist/tileset-3d/common/tileset-cache.js.map +0 -1
- package/dist/tileset-3d/common/tileset-content-traversal.d.ts +0 -37
- package/dist/tileset-3d/common/tileset-content-traversal.d.ts.map +0 -1
- package/dist/tileset-3d/common/tileset-content-traversal.js +0 -80
- package/dist/tileset-3d/common/tileset-content-traversal.js.map +0 -1
- package/dist/tileset-3d/common/tileset-observability.d.ts +0 -60
- package/dist/tileset-3d/common/tileset-observability.d.ts.map +0 -1
- package/dist/tileset-3d/common/tileset-observability.js +0 -39
- package/dist/tileset-3d/common/tileset-observability.js.map +0 -1
- package/dist/tileset-3d/common/tileset-source.d.ts +0 -228
- package/dist/tileset-3d/common/tileset-source.d.ts.map +0 -1
- package/dist/tileset-3d/common/tileset-source.js +0 -17
- package/dist/tileset-3d/common/tileset-source.js.map +0 -1
- package/dist/tileset-3d/common/tileset-traverser.d.ts +0 -88
- package/dist/tileset-3d/common/tileset-traverser.d.ts.map +0 -1
- package/dist/tileset-3d/common/tileset-traverser.js +0 -341
- package/dist/tileset-3d/common/tileset-traverser.js.map +0 -1
- package/dist/tileset-3d/format-3d-tiles/implicit-tiling.d.ts +0 -182
- package/dist/tileset-3d/format-3d-tiles/implicit-tiling.d.ts.map +0 -1
- package/dist/tileset-3d/format-3d-tiles/implicit-tiling.js +0 -678
- package/dist/tileset-3d/format-3d-tiles/implicit-tiling.js.map +0 -1
- package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.d.ts +0 -221
- package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.d.ts.map +0 -1
- package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.js +0 -770
- package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.js.map +0 -1
- package/dist/tileset-3d/format-3d-tiles/tileset-3d-traverser.d.ts +0 -111
- package/dist/tileset-3d/format-3d-tiles/tileset-3d-traverser.d.ts.map +0 -1
- package/dist/tileset-3d/format-3d-tiles/tileset-3d-traverser.js +0 -339
- package/dist/tileset-3d/format-3d-tiles/tileset-3d-traverser.js.map +0 -1
- package/dist/tileset-3d/format-i3s/i3s-pending-tiles-register.d.ts +0 -27
- package/dist/tileset-3d/format-i3s/i3s-pending-tiles-register.d.ts.map +0 -1
- package/dist/tileset-3d/format-i3s/i3s-pending-tiles-register.js +0 -45
- package/dist/tileset-3d/format-i3s/i3s-pending-tiles-register.js.map +0 -1
- package/dist/tileset-3d/format-i3s/i3s-source.d.ts +0 -116
- package/dist/tileset-3d/format-i3s/i3s-source.d.ts.map +0 -1
- package/dist/tileset-3d/format-i3s/i3s-source.js +0 -450
- package/dist/tileset-3d/format-i3s/i3s-source.js.map +0 -1
- package/dist/tileset-3d/format-i3s/i3s-tile-manager.d.ts +0 -34
- package/dist/tileset-3d/format-i3s/i3s-tile-manager.d.ts.map +0 -1
- package/dist/tileset-3d/format-i3s/i3s-tile-manager.js +0 -81
- package/dist/tileset-3d/format-i3s/i3s-tile-manager.js.map +0 -1
- package/dist/tileset-3d/format-i3s/i3s-tileset-traverser.d.ts +0 -25
- package/dist/tileset-3d/format-i3s/i3s-tileset-traverser.d.ts.map +0 -1
- package/dist/tileset-3d/format-i3s/i3s-tileset-traverser.js +0 -84
- package/dist/tileset-3d/format-i3s/i3s-tileset-traverser.js.map +0 -1
- package/dist/tileset-3d/helpers/3d-tiles-options.d.ts +0 -5
- package/dist/tileset-3d/helpers/3d-tiles-options.d.ts.map +0 -1
- package/dist/tileset-3d/helpers/3d-tiles-options.js +0 -9
- package/dist/tileset-3d/helpers/3d-tiles-options.js.map +0 -1
- package/dist/tileset-3d/helpers/bounding-volume.d.ts +0 -23
- package/dist/tileset-3d/helpers/bounding-volume.d.ts.map +0 -1
- package/dist/tileset-3d/helpers/bounding-volume.js +0 -236
- package/dist/tileset-3d/helpers/bounding-volume.js.map +0 -1
- package/dist/tileset-3d/helpers/frame-state.d.ts +0 -93
- package/dist/tileset-3d/helpers/frame-state.d.ts.map +0 -1
- package/dist/tileset-3d/helpers/frame-state.js +0 -211
- package/dist/tileset-3d/helpers/frame-state.js.map +0 -1
- package/dist/tileset-3d/helpers/i3s-lod.d.ts +0 -20
- package/dist/tileset-3d/helpers/i3s-lod.d.ts.map +0 -1
- package/dist/tileset-3d/helpers/i3s-lod.js +0 -95
- package/dist/tileset-3d/helpers/i3s-lod.js.map +0 -1
- package/dist/tileset-3d/helpers/s2-bounding-volume.d.ts +0 -17
- package/dist/tileset-3d/helpers/s2-bounding-volume.d.ts.map +0 -1
- package/dist/tileset-3d/helpers/s2-bounding-volume.js +0 -17
- package/dist/tileset-3d/helpers/s2-bounding-volume.js.map +0 -1
- package/dist/tileset-3d/helpers/tiles-3d-lod.d.ts +0 -72
- package/dist/tileset-3d/helpers/tiles-3d-lod.d.ts.map +0 -1
- package/dist/tileset-3d/helpers/tiles-3d-lod.js +0 -257
- package/dist/tileset-3d/helpers/tiles-3d-lod.js.map +0 -1
- package/dist/tileset-3d/helpers/tiles-3d-request-priority.d.ts +0 -134
- package/dist/tileset-3d/helpers/tiles-3d-request-priority.d.ts.map +0 -1
- package/dist/tileset-3d/helpers/tiles-3d-request-priority.js +0 -179
- package/dist/tileset-3d/helpers/tiles-3d-request-priority.js.map +0 -1
- package/dist/tileset-3d/helpers/transform-utils.d.ts +0 -3
- package/dist/tileset-3d/helpers/transform-utils.d.ts.map +0 -1
- package/dist/tileset-3d/helpers/transform-utils.js +0 -86
- package/dist/tileset-3d/helpers/transform-utils.js.map +0 -1
- package/dist/tileset-3d/helpers/zoom.d.ts +0 -46
- package/dist/tileset-3d/helpers/zoom.d.ts.map +0 -1
- package/dist/tileset-3d/helpers/zoom.js +0 -86
- package/dist/tileset-3d/helpers/zoom.js.map +0 -1
- package/dist/types.d.ts +0 -48
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/doubly-linked-list-node.d.ts +0 -11
- package/dist/utils/doubly-linked-list-node.d.ts.map +0 -1
- package/dist/utils/doubly-linked-list-node.js +0 -20
- package/dist/utils/doubly-linked-list-node.js.map +0 -1
- package/dist/utils/doubly-linked-list.d.ts +0 -30
- package/dist/utils/doubly-linked-list.d.ts.map +0 -1
- package/dist/utils/doubly-linked-list.js +0 -93
- package/dist/utils/doubly-linked-list.js.map +0 -1
- package/dist/utils/managed-array.d.ts +0 -85
- package/dist/utils/managed-array.d.ts.map +0 -1
- package/dist/utils/managed-array.js +0 -152
- package/dist/utils/managed-array.js.map +0 -1
- package/src/constants.ts +0 -59
- package/src/point-cloud/point-cloud-tile.ts +0 -80
- package/src/point-cloud/point-cloud-tileset.ts +0 -767
- package/src/point-cloud/types.ts +0 -99
- package/src/point-cloud-tile-source-loader-types.ts +0 -53
- package/src/point-cloud-tile-source-loader.ts +0 -32
- package/src/point-cloud-tile-source-types.ts +0 -20
- package/src/point-cloud-tile-source.ts +0 -112
- package/src/spatial/format-spatial-reference.ts +0 -385
- package/src/spatial/get-spatial-coordinate-frame.ts +0 -169
- package/src/spatial/i3s-elevation.ts +0 -96
- package/src/spatial/i3s-spatial-transformer.ts +0 -1021
- package/src/spatial/normalize-crs-identifier.ts +0 -26
- package/src/spatial/spatial-coordinate-transformer.ts +0 -397
- package/src/spatial/spatial-resource-registry.ts +0 -90
- package/src/spatial/spatial-types.ts +0 -422
- package/src/spatial/tiles-3d-spatial-transformer.ts +0 -194
- package/src/tileset-3d/common/indexed-archive-tileset-source.ts +0 -205
- package/src/tileset-3d/common/tile-3d-contracts.ts +0 -115
- package/src/tileset-3d/common/tile-3d.ts +0 -1310
- package/src/tileset-3d/common/tileset-3d.ts +0 -1210
- package/src/tileset-3d/common/tileset-cache.ts +0 -111
- package/src/tileset-3d/common/tileset-content-traversal.ts +0 -114
- package/src/tileset-3d/common/tileset-observability.ts +0 -100
- package/src/tileset-3d/common/tileset-source.ts +0 -284
- package/src/tileset-3d/common/tileset-traverser.ts +0 -416
- package/src/tileset-3d/format-3d-tiles/implicit-tiling.ts +0 -1056
- package/src/tileset-3d/format-3d-tiles/tiles-3d-source.ts +0 -1025
- package/src/tileset-3d/format-3d-tiles/tileset-3d-traverser.ts +0 -391
- package/src/tileset-3d/format-i3s/i3s-pending-tiles-register.ts +0 -48
- package/src/tileset-3d/format-i3s/i3s-source.ts +0 -557
- package/src/tileset-3d/format-i3s/i3s-tile-manager.ts +0 -105
- package/src/tileset-3d/format-i3s/i3s-tileset-traverser.ts +0 -102
- package/src/tileset-3d/helpers/3d-tiles-options.ts +0 -11
- package/src/tileset-3d/helpers/bounding-volume.ts +0 -281
- package/src/tileset-3d/helpers/frame-state.ts +0 -322
- package/src/tileset-3d/helpers/i3s-lod.ts +0 -109
- package/src/tileset-3d/helpers/s2-bounding-volume.ts +0 -32
- package/src/tileset-3d/helpers/tiles-3d-lod.ts +0 -370
- package/src/tileset-3d/helpers/tiles-3d-request-priority.ts +0 -301
- package/src/tileset-3d/helpers/transform-utils.ts +0 -109
- package/src/tileset-3d/helpers/zoom.ts +0 -120
- package/src/types.ts +0 -54
- package/src/utils/doubly-linked-list-node.ts +0 -22
- package/src/utils/doubly-linked-list.ts +0 -105
- package/src/utils/managed-array.ts +0 -174
- /package/dist/{point-cloud → mvt/lib}/types.js +0 -0
|
@@ -0,0 +1,3701 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn, res, err) => function __init() {
|
|
9
|
+
if (err) throw err[0];
|
|
10
|
+
try {
|
|
11
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
12
|
+
} catch (e) {
|
|
13
|
+
throw err = [e], e;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
+
|
|
38
|
+
// dist/mlt/mlt-format.js
|
|
39
|
+
var MLTFormat;
|
|
40
|
+
var init_mlt_format = __esm({
|
|
41
|
+
"dist/mlt/mlt-format.js"() {
|
|
42
|
+
"use strict";
|
|
43
|
+
MLTFormat = {
|
|
44
|
+
name: "MapLibre Tile",
|
|
45
|
+
id: "mlt",
|
|
46
|
+
module: "tiles",
|
|
47
|
+
encoding: "binary",
|
|
48
|
+
format: "mlt",
|
|
49
|
+
extensions: ["mlt"],
|
|
50
|
+
mimeTypes: ["application/vnd.maplibre-tile"],
|
|
51
|
+
category: "geometry"
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// ../arrow-geometry/src/legacy-binary/geometry-info.ts
|
|
57
|
+
function getGeometryInfo(features) {
|
|
58
|
+
let pointPositionsCount = 0;
|
|
59
|
+
let pointFeaturesCount = 0;
|
|
60
|
+
let linePositionsCount = 0;
|
|
61
|
+
let linePathsCount = 0;
|
|
62
|
+
let lineFeaturesCount = 0;
|
|
63
|
+
let polygonPositionsCount = 0;
|
|
64
|
+
let polygonObjectsCount = 0;
|
|
65
|
+
let polygonRingsCount = 0;
|
|
66
|
+
let polygonFeaturesCount = 0;
|
|
67
|
+
const coordLengths = /* @__PURE__ */ new Set();
|
|
68
|
+
for (const feature of features) {
|
|
69
|
+
const geometry = feature.geometry;
|
|
70
|
+
switch (geometry.type) {
|
|
71
|
+
case "Point":
|
|
72
|
+
pointFeaturesCount++;
|
|
73
|
+
pointPositionsCount++;
|
|
74
|
+
coordLengths.add(geometry.coordinates.length);
|
|
75
|
+
break;
|
|
76
|
+
case "MultiPoint":
|
|
77
|
+
pointFeaturesCount++;
|
|
78
|
+
pointPositionsCount += geometry.coordinates.length;
|
|
79
|
+
for (const point of geometry.coordinates) {
|
|
80
|
+
coordLengths.add(point.length);
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
83
|
+
case "LineString":
|
|
84
|
+
lineFeaturesCount++;
|
|
85
|
+
linePositionsCount += geometry.coordinates.length;
|
|
86
|
+
linePathsCount++;
|
|
87
|
+
for (const coord of geometry.coordinates) {
|
|
88
|
+
coordLengths.add(coord.length);
|
|
89
|
+
}
|
|
90
|
+
break;
|
|
91
|
+
case "MultiLineString":
|
|
92
|
+
lineFeaturesCount++;
|
|
93
|
+
for (const line of geometry.coordinates) {
|
|
94
|
+
linePositionsCount += line.length;
|
|
95
|
+
linePathsCount++;
|
|
96
|
+
for (const coord of line) {
|
|
97
|
+
coordLengths.add(coord.length);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
break;
|
|
101
|
+
case "Polygon":
|
|
102
|
+
polygonFeaturesCount++;
|
|
103
|
+
polygonObjectsCount++;
|
|
104
|
+
polygonRingsCount += geometry.coordinates.length;
|
|
105
|
+
const flattened = geometry.coordinates.flat();
|
|
106
|
+
polygonPositionsCount += flattened.length;
|
|
107
|
+
for (const coord of flattened) {
|
|
108
|
+
coordLengths.add(coord.length);
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
case "MultiPolygon":
|
|
112
|
+
polygonFeaturesCount++;
|
|
113
|
+
for (const polygon of geometry.coordinates) {
|
|
114
|
+
polygonObjectsCount++;
|
|
115
|
+
polygonRingsCount += polygon.length;
|
|
116
|
+
const flattened2 = polygon.flat();
|
|
117
|
+
polygonPositionsCount += flattened2.length;
|
|
118
|
+
for (const coord of flattened2) {
|
|
119
|
+
coordLengths.add(coord.length);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
break;
|
|
123
|
+
default:
|
|
124
|
+
throw new Error(`Unsupported geometry type: ${geometry.type}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
coordLength: coordLengths.size > 0 ? Math.max(...coordLengths) : 2,
|
|
129
|
+
pointPositionsCount,
|
|
130
|
+
pointFeaturesCount,
|
|
131
|
+
linePositionsCount,
|
|
132
|
+
linePathsCount,
|
|
133
|
+
lineFeaturesCount,
|
|
134
|
+
polygonPositionsCount,
|
|
135
|
+
polygonObjectsCount,
|
|
136
|
+
polygonRingsCount,
|
|
137
|
+
polygonFeaturesCount
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
var init_geometry_info = __esm({
|
|
141
|
+
"../arrow-geometry/src/legacy-binary/geometry-info.ts"() {
|
|
142
|
+
"use strict";
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// ../arrow-geometry/src/legacy-binary/convert-geojson-to-flat-geojson.ts
|
|
147
|
+
function convertGeojsonToFlatGeojson(features, options = { coordLength: 2, fixRingWinding: true }) {
|
|
148
|
+
return features.map((feature) => flattenFeature(feature, options));
|
|
149
|
+
}
|
|
150
|
+
function flattenPoint(coordinates, data, indices, options) {
|
|
151
|
+
indices.push(data.length);
|
|
152
|
+
data.push(...coordinates);
|
|
153
|
+
for (let i = coordinates.length; i < options.coordLength; i++) {
|
|
154
|
+
data.push(0);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function flattenLineString(coordinates, data, indices, options) {
|
|
158
|
+
indices.push(data.length);
|
|
159
|
+
for (const c of coordinates) {
|
|
160
|
+
data.push(...c);
|
|
161
|
+
for (let i = c.length; i < options.coordLength; i++) {
|
|
162
|
+
data.push(0);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function flattenPolygon(coordinates, data, indices, areas, options) {
|
|
167
|
+
let count = 0;
|
|
168
|
+
const ringAreas = [];
|
|
169
|
+
const polygons = [];
|
|
170
|
+
for (const lineString of coordinates) {
|
|
171
|
+
const lineString2d = lineString.map((p) => p.slice(0, 2));
|
|
172
|
+
let area = (0, import_polygon.getPolygonSignedArea)(lineString2d.flat());
|
|
173
|
+
const ccw = area < 0;
|
|
174
|
+
if (options.fixRingWinding && (count === 0 && !ccw || count > 0 && ccw)) {
|
|
175
|
+
lineString.reverse();
|
|
176
|
+
area = -area;
|
|
177
|
+
}
|
|
178
|
+
ringAreas.push(area);
|
|
179
|
+
flattenLineString(lineString, data, polygons, options);
|
|
180
|
+
count++;
|
|
181
|
+
}
|
|
182
|
+
if (count > 0) {
|
|
183
|
+
areas.push(ringAreas);
|
|
184
|
+
indices.push(polygons);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
function flattenFeature(feature, options) {
|
|
188
|
+
const { geometry } = feature;
|
|
189
|
+
if (geometry.type === "GeometryCollection") {
|
|
190
|
+
throw new Error("GeometryCollection type not supported");
|
|
191
|
+
}
|
|
192
|
+
const data = [];
|
|
193
|
+
const indices = [];
|
|
194
|
+
let areas;
|
|
195
|
+
let type;
|
|
196
|
+
switch (geometry.type) {
|
|
197
|
+
case "Point":
|
|
198
|
+
type = "Point";
|
|
199
|
+
flattenPoint(geometry.coordinates, data, indices, options);
|
|
200
|
+
break;
|
|
201
|
+
case "MultiPoint":
|
|
202
|
+
type = "Point";
|
|
203
|
+
geometry.coordinates.map((c) => flattenPoint(c, data, indices, options));
|
|
204
|
+
break;
|
|
205
|
+
case "LineString":
|
|
206
|
+
type = "LineString";
|
|
207
|
+
flattenLineString(geometry.coordinates, data, indices, options);
|
|
208
|
+
break;
|
|
209
|
+
case "MultiLineString":
|
|
210
|
+
type = "LineString";
|
|
211
|
+
geometry.coordinates.map((c) => flattenLineString(c, data, indices, options));
|
|
212
|
+
break;
|
|
213
|
+
case "Polygon":
|
|
214
|
+
type = "Polygon";
|
|
215
|
+
areas = [];
|
|
216
|
+
flattenPolygon(geometry.coordinates, data, indices, areas, options);
|
|
217
|
+
break;
|
|
218
|
+
case "MultiPolygon":
|
|
219
|
+
type = "Polygon";
|
|
220
|
+
areas = [];
|
|
221
|
+
geometry.coordinates.map((c) => flattenPolygon(c, data, indices, areas, options));
|
|
222
|
+
break;
|
|
223
|
+
default:
|
|
224
|
+
throw new Error(`Unknown type: ${type}`);
|
|
225
|
+
}
|
|
226
|
+
return { ...feature, geometry: { type, indices, data, areas } };
|
|
227
|
+
}
|
|
228
|
+
var import_polygon;
|
|
229
|
+
var init_convert_geojson_to_flat_geojson = __esm({
|
|
230
|
+
"../arrow-geometry/src/legacy-binary/convert-geojson-to-flat-geojson.ts"() {
|
|
231
|
+
"use strict";
|
|
232
|
+
import_polygon = require("@math.gl/geometry/polygon");
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
// ../arrow-geometry/src/legacy-binary/convert-flat-geojson-to-binary-features.ts
|
|
237
|
+
function convertFlatGeojsonToBinaryFeatureCollection(features, geometryInfo, options) {
|
|
238
|
+
const propArrayTypes = extractNumericPropTypes(features);
|
|
239
|
+
const numericPropKeys = Object.keys(propArrayTypes).filter((k) => propArrayTypes[k] !== Array);
|
|
240
|
+
return fillArrays(
|
|
241
|
+
features,
|
|
242
|
+
{
|
|
243
|
+
propArrayTypes,
|
|
244
|
+
...geometryInfo
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
numericPropKeys: options && options.numericPropKeys || numericPropKeys,
|
|
248
|
+
PositionDataType: options ? options.PositionDataType : Float32Array,
|
|
249
|
+
triangulate: options ? options.triangulate : true
|
|
250
|
+
}
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
function extractNumericPropTypes(features) {
|
|
254
|
+
const propArrayTypes = {};
|
|
255
|
+
for (const feature of features) {
|
|
256
|
+
if (feature.properties) {
|
|
257
|
+
for (const key in feature.properties) {
|
|
258
|
+
const val = feature.properties[key];
|
|
259
|
+
propArrayTypes[key] = deduceArrayType(val, propArrayTypes[key]);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return propArrayTypes;
|
|
264
|
+
}
|
|
265
|
+
function fillArrays(features, geometryInfo, options) {
|
|
266
|
+
const {
|
|
267
|
+
pointPositionsCount,
|
|
268
|
+
pointFeaturesCount,
|
|
269
|
+
linePositionsCount,
|
|
270
|
+
linePathsCount,
|
|
271
|
+
lineFeaturesCount,
|
|
272
|
+
polygonPositionsCount,
|
|
273
|
+
polygonObjectsCount,
|
|
274
|
+
polygonRingsCount,
|
|
275
|
+
polygonFeaturesCount,
|
|
276
|
+
propArrayTypes,
|
|
277
|
+
coordLength
|
|
278
|
+
} = geometryInfo;
|
|
279
|
+
const { numericPropKeys = [], PositionDataType = Float32Array, triangulate = true } = options;
|
|
280
|
+
const hasGlobalId = features[0] && "id" in features[0];
|
|
281
|
+
const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;
|
|
282
|
+
const points = {
|
|
283
|
+
type: "Point",
|
|
284
|
+
positions: new PositionDataType(pointPositionsCount * coordLength),
|
|
285
|
+
globalFeatureIds: new GlobalFeatureIdsDataType(pointPositionsCount),
|
|
286
|
+
featureIds: pointFeaturesCount > 65535 ? new Uint32Array(pointPositionsCount) : new Uint16Array(pointPositionsCount),
|
|
287
|
+
numericProps: {},
|
|
288
|
+
properties: [],
|
|
289
|
+
fields: []
|
|
290
|
+
};
|
|
291
|
+
const lines = {
|
|
292
|
+
type: "LineString",
|
|
293
|
+
pathIndices: linePositionsCount > 65535 ? new Uint32Array(linePathsCount + 1) : new Uint16Array(linePathsCount + 1),
|
|
294
|
+
positions: new PositionDataType(linePositionsCount * coordLength),
|
|
295
|
+
globalFeatureIds: new GlobalFeatureIdsDataType(linePositionsCount),
|
|
296
|
+
featureIds: lineFeaturesCount > 65535 ? new Uint32Array(linePositionsCount) : new Uint16Array(linePositionsCount),
|
|
297
|
+
numericProps: {},
|
|
298
|
+
properties: [],
|
|
299
|
+
fields: []
|
|
300
|
+
};
|
|
301
|
+
const polygons = {
|
|
302
|
+
type: "Polygon",
|
|
303
|
+
polygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonObjectsCount + 1) : new Uint16Array(polygonObjectsCount + 1),
|
|
304
|
+
primitivePolygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonRingsCount + 1) : new Uint16Array(polygonRingsCount + 1),
|
|
305
|
+
positions: new PositionDataType(polygonPositionsCount * coordLength),
|
|
306
|
+
globalFeatureIds: new GlobalFeatureIdsDataType(polygonPositionsCount),
|
|
307
|
+
featureIds: polygonFeaturesCount > 65535 ? new Uint32Array(polygonPositionsCount) : new Uint16Array(polygonPositionsCount),
|
|
308
|
+
numericProps: {},
|
|
309
|
+
properties: [],
|
|
310
|
+
fields: []
|
|
311
|
+
};
|
|
312
|
+
if (triangulate) {
|
|
313
|
+
polygons.triangles = [];
|
|
314
|
+
}
|
|
315
|
+
for (const object of [points, lines, polygons]) {
|
|
316
|
+
for (const propName of numericPropKeys) {
|
|
317
|
+
const T = propArrayTypes[propName];
|
|
318
|
+
object.numericProps[propName] = new T(object.positions.length / coordLength);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
lines.pathIndices[linePathsCount] = linePositionsCount;
|
|
322
|
+
polygons.polygonIndices[polygonObjectsCount] = polygonPositionsCount;
|
|
323
|
+
polygons.primitivePolygonIndices[polygonRingsCount] = polygonPositionsCount;
|
|
324
|
+
const indexMap = {
|
|
325
|
+
pointPosition: 0,
|
|
326
|
+
pointFeature: 0,
|
|
327
|
+
linePosition: 0,
|
|
328
|
+
linePath: 0,
|
|
329
|
+
lineFeature: 0,
|
|
330
|
+
polygonPosition: 0,
|
|
331
|
+
polygonObject: 0,
|
|
332
|
+
polygonRing: 0,
|
|
333
|
+
polygonFeature: 0,
|
|
334
|
+
feature: 0
|
|
335
|
+
};
|
|
336
|
+
for (const feature of features) {
|
|
337
|
+
const geometry = feature.geometry;
|
|
338
|
+
const properties = feature.properties || {};
|
|
339
|
+
switch (geometry.type) {
|
|
340
|
+
case "Point":
|
|
341
|
+
handlePoint(geometry, points, indexMap, coordLength, properties);
|
|
342
|
+
points.properties.push(keepStringProperties(properties, numericPropKeys));
|
|
343
|
+
if (hasGlobalId) {
|
|
344
|
+
points.fields.push({ id: feature.id });
|
|
345
|
+
}
|
|
346
|
+
indexMap.pointFeature++;
|
|
347
|
+
break;
|
|
348
|
+
case "LineString":
|
|
349
|
+
handleLineString(geometry, lines, indexMap, coordLength, properties);
|
|
350
|
+
lines.properties.push(keepStringProperties(properties, numericPropKeys));
|
|
351
|
+
if (hasGlobalId) {
|
|
352
|
+
lines.fields.push({ id: feature.id });
|
|
353
|
+
}
|
|
354
|
+
indexMap.lineFeature++;
|
|
355
|
+
break;
|
|
356
|
+
case "Polygon":
|
|
357
|
+
handlePolygon(geometry, polygons, indexMap, coordLength, properties);
|
|
358
|
+
polygons.properties.push(keepStringProperties(properties, numericPropKeys));
|
|
359
|
+
if (hasGlobalId) {
|
|
360
|
+
polygons.fields.push({ id: feature.id });
|
|
361
|
+
}
|
|
362
|
+
indexMap.polygonFeature++;
|
|
363
|
+
break;
|
|
364
|
+
default:
|
|
365
|
+
throw new Error("Invalid geometry type");
|
|
366
|
+
}
|
|
367
|
+
indexMap.feature++;
|
|
368
|
+
}
|
|
369
|
+
return makeAccessorObjects(points, lines, polygons, coordLength);
|
|
370
|
+
}
|
|
371
|
+
function handlePoint(geometry, points, indexMap, coordLength, properties) {
|
|
372
|
+
points.positions.set(geometry.data, indexMap.pointPosition * coordLength);
|
|
373
|
+
const nPositions = geometry.data.length / coordLength;
|
|
374
|
+
fillNumericProperties(points, properties, indexMap.pointPosition, nPositions);
|
|
375
|
+
points.globalFeatureIds.fill(
|
|
376
|
+
indexMap.feature,
|
|
377
|
+
indexMap.pointPosition,
|
|
378
|
+
indexMap.pointPosition + nPositions
|
|
379
|
+
);
|
|
380
|
+
points.featureIds.fill(
|
|
381
|
+
indexMap.pointFeature,
|
|
382
|
+
indexMap.pointPosition,
|
|
383
|
+
indexMap.pointPosition + nPositions
|
|
384
|
+
);
|
|
385
|
+
indexMap.pointPosition += nPositions;
|
|
386
|
+
}
|
|
387
|
+
function handleLineString(geometry, lines, indexMap, coordLength, properties) {
|
|
388
|
+
lines.positions.set(geometry.data, indexMap.linePosition * coordLength);
|
|
389
|
+
const nPositions = geometry.data.length / coordLength;
|
|
390
|
+
fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);
|
|
391
|
+
lines.globalFeatureIds.fill(
|
|
392
|
+
indexMap.feature,
|
|
393
|
+
indexMap.linePosition,
|
|
394
|
+
indexMap.linePosition + nPositions
|
|
395
|
+
);
|
|
396
|
+
lines.featureIds.fill(
|
|
397
|
+
indexMap.lineFeature,
|
|
398
|
+
indexMap.linePosition,
|
|
399
|
+
indexMap.linePosition + nPositions
|
|
400
|
+
);
|
|
401
|
+
for (let i = 0, il = geometry.indices.length; i < il; ++i) {
|
|
402
|
+
const start = geometry.indices[i];
|
|
403
|
+
const end = i === il - 1 ? geometry.data.length : geometry.indices[i + 1];
|
|
404
|
+
lines.pathIndices[indexMap.linePath++] = indexMap.linePosition;
|
|
405
|
+
indexMap.linePosition += (end - start) / coordLength;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
function handlePolygon(geometry, polygons, indexMap, coordLength, properties) {
|
|
409
|
+
polygons.positions.set(geometry.data, indexMap.polygonPosition * coordLength);
|
|
410
|
+
const nPositions = geometry.data.length / coordLength;
|
|
411
|
+
fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);
|
|
412
|
+
polygons.globalFeatureIds.fill(
|
|
413
|
+
indexMap.feature,
|
|
414
|
+
indexMap.polygonPosition,
|
|
415
|
+
indexMap.polygonPosition + nPositions
|
|
416
|
+
);
|
|
417
|
+
polygons.featureIds.fill(
|
|
418
|
+
indexMap.polygonFeature,
|
|
419
|
+
indexMap.polygonPosition,
|
|
420
|
+
indexMap.polygonPosition + nPositions
|
|
421
|
+
);
|
|
422
|
+
for (let l = 0, ll = geometry.indices.length; l < ll; ++l) {
|
|
423
|
+
const startPosition = indexMap.polygonPosition;
|
|
424
|
+
polygons.polygonIndices[indexMap.polygonObject++] = startPosition;
|
|
425
|
+
const areas = geometry.areas[l];
|
|
426
|
+
const indices = geometry.indices[l];
|
|
427
|
+
const nextIndices = geometry.indices[l + 1];
|
|
428
|
+
for (let i = 0, il = indices.length; i < il; ++i) {
|
|
429
|
+
const start = indices[i];
|
|
430
|
+
const end = i === il - 1 ? (
|
|
431
|
+
// last line, so either read to:
|
|
432
|
+
nextIndices === void 0 ? geometry.data.length : nextIndices[0]
|
|
433
|
+
) : indices[i + 1];
|
|
434
|
+
polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;
|
|
435
|
+
indexMap.polygonPosition += (end - start) / coordLength;
|
|
436
|
+
}
|
|
437
|
+
const endPosition = indexMap.polygonPosition;
|
|
438
|
+
triangulatePolygon(polygons, areas, indices, { startPosition, endPosition, coordLength });
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
function triangulatePolygon(polygons, areas, indices, {
|
|
442
|
+
startPosition,
|
|
443
|
+
endPosition,
|
|
444
|
+
coordLength
|
|
445
|
+
}) {
|
|
446
|
+
if (!polygons.triangles) {
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
const start = startPosition * coordLength;
|
|
450
|
+
const end = endPosition * coordLength;
|
|
451
|
+
const polygonPositions = polygons.positions.subarray(start, end);
|
|
452
|
+
const offset = indices[0];
|
|
453
|
+
const holes = indices.slice(1).map((n) => (n - offset) / coordLength);
|
|
454
|
+
const triangles = (0, import_polygon2.earcut)(polygonPositions, holes, coordLength, areas);
|
|
455
|
+
for (let t = 0, tl = triangles.length; t < tl; ++t) {
|
|
456
|
+
polygons.triangles.push(startPosition + triangles[t]);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
function wrapProps(obj, size) {
|
|
460
|
+
const returnObj = {};
|
|
461
|
+
for (const key in obj) {
|
|
462
|
+
returnObj[key] = { value: obj[key], size };
|
|
463
|
+
}
|
|
464
|
+
return returnObj;
|
|
465
|
+
}
|
|
466
|
+
function makeAccessorObjects(points, lines, polygons, coordLength) {
|
|
467
|
+
const binaryFeatures = {
|
|
468
|
+
shape: "binary-feature-collection",
|
|
469
|
+
points: {
|
|
470
|
+
...points,
|
|
471
|
+
positions: { value: points.positions, size: coordLength },
|
|
472
|
+
globalFeatureIds: { value: points.globalFeatureIds, size: 1 },
|
|
473
|
+
featureIds: { value: points.featureIds, size: 1 },
|
|
474
|
+
numericProps: wrapProps(points.numericProps, 1)
|
|
475
|
+
},
|
|
476
|
+
lines: {
|
|
477
|
+
...lines,
|
|
478
|
+
positions: { value: lines.positions, size: coordLength },
|
|
479
|
+
pathIndices: { value: lines.pathIndices, size: 1 },
|
|
480
|
+
globalFeatureIds: { value: lines.globalFeatureIds, size: 1 },
|
|
481
|
+
featureIds: { value: lines.featureIds, size: 1 },
|
|
482
|
+
numericProps: wrapProps(lines.numericProps, 1)
|
|
483
|
+
},
|
|
484
|
+
polygons: {
|
|
485
|
+
...polygons,
|
|
486
|
+
positions: { value: polygons.positions, size: coordLength },
|
|
487
|
+
polygonIndices: { value: polygons.polygonIndices, size: 1 },
|
|
488
|
+
primitivePolygonIndices: { value: polygons.primitivePolygonIndices, size: 1 },
|
|
489
|
+
globalFeatureIds: { value: polygons.globalFeatureIds, size: 1 },
|
|
490
|
+
featureIds: { value: polygons.featureIds, size: 1 },
|
|
491
|
+
numericProps: wrapProps(polygons.numericProps, 1)
|
|
492
|
+
}
|
|
493
|
+
// triangles not expected
|
|
494
|
+
};
|
|
495
|
+
if (binaryFeatures.polygons && polygons.triangles) {
|
|
496
|
+
binaryFeatures.polygons.triangles = { value: new Uint32Array(polygons.triangles), size: 1 };
|
|
497
|
+
}
|
|
498
|
+
return binaryFeatures;
|
|
499
|
+
}
|
|
500
|
+
function fillNumericProperties(object, properties, index, length) {
|
|
501
|
+
for (const numericPropName in object.numericProps) {
|
|
502
|
+
if (numericPropName in properties) {
|
|
503
|
+
const value = properties[numericPropName];
|
|
504
|
+
object.numericProps[numericPropName].fill(value, index, index + length);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
function keepStringProperties(properties, numericKeys) {
|
|
509
|
+
const props = {};
|
|
510
|
+
for (const key in properties) {
|
|
511
|
+
if (!numericKeys.includes(key)) {
|
|
512
|
+
props[key] = properties[key];
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
return props;
|
|
516
|
+
}
|
|
517
|
+
function deduceArrayType(x, constructor) {
|
|
518
|
+
if (constructor === Array || !Number.isFinite(x)) {
|
|
519
|
+
return Array;
|
|
520
|
+
}
|
|
521
|
+
return constructor === Float64Array || Math.fround(x) !== x ? Float64Array : Float32Array;
|
|
522
|
+
}
|
|
523
|
+
var import_polygon2;
|
|
524
|
+
var init_convert_flat_geojson_to_binary_features = __esm({
|
|
525
|
+
"../arrow-geometry/src/legacy-binary/convert-flat-geojson-to-binary-features.ts"() {
|
|
526
|
+
"use strict";
|
|
527
|
+
import_polygon2 = require("@math.gl/geometry/polygon");
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
// ../arrow-geometry/src/legacy-binary/convert-geojson-to-binary-features.ts
|
|
532
|
+
function convertGeojsonToBinaryFeatureCollection(features, options = { fixRingWinding: true, triangulate: true }) {
|
|
533
|
+
const geometryInfo = getGeometryInfo(features);
|
|
534
|
+
const coordLength = geometryInfo.coordLength;
|
|
535
|
+
const { fixRingWinding } = options;
|
|
536
|
+
const flatFeatures = convertGeojsonToFlatGeojson(features, { coordLength, fixRingWinding });
|
|
537
|
+
return convertFlatGeojsonToBinaryFeatureCollection(flatFeatures, geometryInfo, {
|
|
538
|
+
numericPropKeys: options.numericPropKeys,
|
|
539
|
+
PositionDataType: options.PositionDataType || Float32Array,
|
|
540
|
+
triangulate: options.triangulate
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
var init_convert_geojson_to_binary_features = __esm({
|
|
544
|
+
"../arrow-geometry/src/legacy-binary/convert-geojson-to-binary-features.ts"() {
|
|
545
|
+
"use strict";
|
|
546
|
+
init_geometry_info();
|
|
547
|
+
init_convert_geojson_to_flat_geojson();
|
|
548
|
+
init_convert_flat_geojson_to_binary_features();
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
// ../arrow-geometry/src/legacy-binary.ts
|
|
553
|
+
var init_legacy_binary = __esm({
|
|
554
|
+
"../arrow-geometry/src/legacy-binary.ts"() {
|
|
555
|
+
"use strict";
|
|
556
|
+
init_convert_geojson_to_binary_features();
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
// ../arrow-geometry/src/geometry-utils.ts
|
|
561
|
+
function normalizeEmptyPoints(geometry) {
|
|
562
|
+
if (geometry.type === "Point") {
|
|
563
|
+
return geometry.coordinates.length > 0 && geometry.coordinates.every(Number.isNaN) ? { ...geometry, coordinates: [] } : geometry;
|
|
564
|
+
}
|
|
565
|
+
if (geometry.type === "MultiPoint") {
|
|
566
|
+
const coordinates = geometry.coordinates.map(
|
|
567
|
+
(coordinate) => coordinate.length > 0 && coordinate.every(Number.isNaN) ? [] : coordinate
|
|
568
|
+
);
|
|
569
|
+
return coordinates.some((coordinate, index) => coordinate !== geometry.coordinates[index]) ? { ...geometry, coordinates } : geometry;
|
|
570
|
+
}
|
|
571
|
+
if (geometry.type === "GeometryCollection") {
|
|
572
|
+
const geometries = geometry.geometries.map(normalizeEmptyPoints);
|
|
573
|
+
return geometries.some((child, index) => child !== geometry.geometries[index]) ? { ...geometry, geometries } : geometry;
|
|
574
|
+
}
|
|
575
|
+
return geometry;
|
|
576
|
+
}
|
|
577
|
+
var init_geometry_utils = __esm({
|
|
578
|
+
"../arrow-geometry/src/geometry-utils.ts"() {
|
|
579
|
+
"use strict";
|
|
580
|
+
}
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
// ../arrow-geometry/src/geometry-codecs.ts
|
|
584
|
+
function convertWKBToGeometry(input) {
|
|
585
|
+
const bytes = ArrayBuffer.isView(input) ? new Uint8Array(input.buffer, input.byteOffset, input.byteLength) : new Uint8Array(input);
|
|
586
|
+
return normalizeEmptyPoints((0, import_wkb.parseWKB)(bytes).geometry);
|
|
587
|
+
}
|
|
588
|
+
var import_wkb;
|
|
589
|
+
var init_geometry_codecs = __esm({
|
|
590
|
+
"../arrow-geometry/src/geometry-codecs.ts"() {
|
|
591
|
+
"use strict";
|
|
592
|
+
import_wkb = require("@math.gl/geospatial/wkb");
|
|
593
|
+
init_geometry_utils();
|
|
594
|
+
}
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
// ../core/src/schema/metadata.ts
|
|
598
|
+
function getMetadataValue(metadata, key) {
|
|
599
|
+
return metadata instanceof Map ? metadata.get(key) || null : metadata[key] || null;
|
|
600
|
+
}
|
|
601
|
+
function setMetadataValue(metadata, key, value) {
|
|
602
|
+
if (metadata instanceof Map) {
|
|
603
|
+
metadata.set(key, value);
|
|
604
|
+
} else {
|
|
605
|
+
metadata[key] = value;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
function getGeoMetadata(metadata) {
|
|
609
|
+
if (!metadata) {
|
|
610
|
+
return null;
|
|
611
|
+
}
|
|
612
|
+
const stringifiedGeoMetadata = getMetadataValue(metadata, "geo");
|
|
613
|
+
const geoMetadata = stringifiedGeoMetadata && parseJSONStringMetadata(stringifiedGeoMetadata);
|
|
614
|
+
if (!geoMetadata) {
|
|
615
|
+
return null;
|
|
616
|
+
}
|
|
617
|
+
for (const column of Object.values(geoMetadata.columns || {})) {
|
|
618
|
+
if (column && typeof column === "object" && typeof column.encoding === "string") {
|
|
619
|
+
column.encoding = column.encoding.toLowerCase();
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
return geoMetadata;
|
|
623
|
+
}
|
|
624
|
+
function setGeoMetadata(metadata, geoMetadata) {
|
|
625
|
+
setMetadataValue(metadata, "geo", JSON.stringify(geoMetadata));
|
|
626
|
+
}
|
|
627
|
+
function parseJSONStringMetadata(stringifiedMetadata) {
|
|
628
|
+
if (!stringifiedMetadata) {
|
|
629
|
+
return null;
|
|
630
|
+
}
|
|
631
|
+
try {
|
|
632
|
+
const metadata = JSON.parse(stringifiedMetadata);
|
|
633
|
+
return metadata && typeof metadata === "object" ? metadata : null;
|
|
634
|
+
} catch {
|
|
635
|
+
return null;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
var init_metadata = __esm({
|
|
639
|
+
"../core/src/schema/metadata.ts"() {
|
|
640
|
+
"use strict";
|
|
641
|
+
}
|
|
642
|
+
});
|
|
643
|
+
|
|
644
|
+
// ../core/src/schema/index.ts
|
|
645
|
+
var init_schema = __esm({
|
|
646
|
+
"../core/src/schema/index.ts"() {
|
|
647
|
+
"use strict";
|
|
648
|
+
init_metadata();
|
|
649
|
+
}
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
// ../arrow-geometry/src/geometry-field.ts
|
|
653
|
+
function makeWKBGeometryField(geometryColumnName = "geometry", nullable = true) {
|
|
654
|
+
return {
|
|
655
|
+
name: geometryColumnName,
|
|
656
|
+
type: "binary",
|
|
657
|
+
nullable,
|
|
658
|
+
metadata: {
|
|
659
|
+
"ARROW:extension:name": "geoarrow.wkb"
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
function setWKBGeometryColumnMetadata(metadata, options = {}) {
|
|
664
|
+
const geometryColumnName = options.geometryColumnName || "geometry";
|
|
665
|
+
const primaryColumnName = options.primaryColumnName || geometryColumnName;
|
|
666
|
+
const geometryTypes = options.geometryTypes || [];
|
|
667
|
+
const nextGeoMetadata = getGeoMetadata(metadata) || { columns: {} };
|
|
668
|
+
nextGeoMetadata.version = options.version || nextGeoMetadata.version || DEFAULT_GEO_METADATA_VERSION;
|
|
669
|
+
nextGeoMetadata.primary_column = primaryColumnName;
|
|
670
|
+
nextGeoMetadata.columns ||= {};
|
|
671
|
+
nextGeoMetadata.columns[geometryColumnName] = {
|
|
672
|
+
...nextGeoMetadata.columns[geometryColumnName],
|
|
673
|
+
...options.columnMetadata,
|
|
674
|
+
encoding: "wkb",
|
|
675
|
+
geometry_types: geometryTypes
|
|
676
|
+
};
|
|
677
|
+
setGeoMetadata(metadata, nextGeoMetadata);
|
|
678
|
+
}
|
|
679
|
+
function setWKBGeometrySchemaMetadata(schema, options = {}) {
|
|
680
|
+
schema.metadata ||= {};
|
|
681
|
+
setWKBGeometryColumnMetadata(schema.metadata, options);
|
|
682
|
+
return schema;
|
|
683
|
+
}
|
|
684
|
+
var DEFAULT_GEO_METADATA_VERSION;
|
|
685
|
+
var init_geometry_field = __esm({
|
|
686
|
+
"../arrow-geometry/src/geometry-field.ts"() {
|
|
687
|
+
"use strict";
|
|
688
|
+
init_schema();
|
|
689
|
+
DEFAULT_GEO_METADATA_VERSION = "1.1.0";
|
|
690
|
+
}
|
|
691
|
+
});
|
|
692
|
+
|
|
693
|
+
// ../core/src/schema-utils/lib/schema/data-type.ts
|
|
694
|
+
function getDataTypeFromValue(value, defaultNumberType = "float32") {
|
|
695
|
+
if (value instanceof Date) {
|
|
696
|
+
return "date-millisecond";
|
|
697
|
+
}
|
|
698
|
+
if (typeof value === "number") {
|
|
699
|
+
return defaultNumberType;
|
|
700
|
+
}
|
|
701
|
+
if (typeof value === "boolean") {
|
|
702
|
+
return "bool";
|
|
703
|
+
}
|
|
704
|
+
if (typeof value === "string") {
|
|
705
|
+
return "utf8";
|
|
706
|
+
}
|
|
707
|
+
if (value === null || value === "undefined") {
|
|
708
|
+
return "null";
|
|
709
|
+
}
|
|
710
|
+
return "null";
|
|
711
|
+
}
|
|
712
|
+
function getDataTypeFromArray(array) {
|
|
713
|
+
let type = getDataTypeFromTypedArray(array);
|
|
714
|
+
if (type !== "null") {
|
|
715
|
+
return { type, nullable: false };
|
|
716
|
+
}
|
|
717
|
+
if (array.length > 0) {
|
|
718
|
+
type = getDataTypeFromValue(array[0]);
|
|
719
|
+
return { type, nullable: true };
|
|
720
|
+
}
|
|
721
|
+
return { type: "null", nullable: true };
|
|
722
|
+
}
|
|
723
|
+
function getDataTypeFromTypedArray(array) {
|
|
724
|
+
if (typeof Float16Array !== "undefined" && array instanceof Float16Array) {
|
|
725
|
+
return "float16";
|
|
726
|
+
}
|
|
727
|
+
switch (array.constructor) {
|
|
728
|
+
case Int8Array:
|
|
729
|
+
return "int8";
|
|
730
|
+
case Uint8Array:
|
|
731
|
+
case Uint8ClampedArray:
|
|
732
|
+
return "uint8";
|
|
733
|
+
case Int16Array:
|
|
734
|
+
return "int16";
|
|
735
|
+
case Uint16Array:
|
|
736
|
+
return "uint16";
|
|
737
|
+
case Int32Array:
|
|
738
|
+
return "int32";
|
|
739
|
+
case Uint32Array:
|
|
740
|
+
return "uint32";
|
|
741
|
+
case BigInt64Array:
|
|
742
|
+
return "int64";
|
|
743
|
+
case BigUint64Array:
|
|
744
|
+
return "uint64";
|
|
745
|
+
case Float32Array:
|
|
746
|
+
return "float32";
|
|
747
|
+
case Float64Array:
|
|
748
|
+
return "float64";
|
|
749
|
+
default:
|
|
750
|
+
return "null";
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
var import_types;
|
|
754
|
+
var init_data_type = __esm({
|
|
755
|
+
"../core/src/schema-utils/lib/schema/data-type.ts"() {
|
|
756
|
+
"use strict";
|
|
757
|
+
import_types = require("@math.gl/core/types");
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
|
|
761
|
+
// ../core/src/schema-utils/lib/schema/convert-arrow-schema.ts
|
|
762
|
+
function convertArrowToSchema(arrowSchema) {
|
|
763
|
+
return serializeArrowSchema(arrowSchema);
|
|
764
|
+
}
|
|
765
|
+
function convertSchemaToArrow(schema, options) {
|
|
766
|
+
return deserializeArrowSchema(schema, options);
|
|
767
|
+
}
|
|
768
|
+
function serializeArrowSchema(arrowSchema) {
|
|
769
|
+
return {
|
|
770
|
+
fields: arrowSchema.fields.map((arrowField) => serializeArrowField(arrowField)),
|
|
771
|
+
metadata: serializeArrowMetadata(arrowSchema.metadata)
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
function deserializeArrowSchema(schema, options) {
|
|
775
|
+
return new arrow.Schema(
|
|
776
|
+
schema.fields.map((field) => deserializeArrowField(field, options)),
|
|
777
|
+
deserializeArrowMetadata(schema.metadata)
|
|
778
|
+
);
|
|
779
|
+
}
|
|
780
|
+
function serializeArrowMetadata(arrowMetadata) {
|
|
781
|
+
return Object.fromEntries(arrowMetadata);
|
|
782
|
+
}
|
|
783
|
+
function deserializeArrowMetadata(metadata) {
|
|
784
|
+
return metadata ? new Map(Object.entries(metadata)) : /* @__PURE__ */ new Map();
|
|
785
|
+
}
|
|
786
|
+
function serializeArrowField(field) {
|
|
787
|
+
return {
|
|
788
|
+
name: field.name,
|
|
789
|
+
type: serializeArrowType(field.type),
|
|
790
|
+
nullable: field.nullable,
|
|
791
|
+
metadata: serializeArrowMetadata(field.metadata)
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
function deserializeArrowField(field, options) {
|
|
795
|
+
return new arrow.Field(
|
|
796
|
+
field.name,
|
|
797
|
+
deserializeArrowType(field.type, options),
|
|
798
|
+
field.nullable,
|
|
799
|
+
deserializeArrowMetadata(field.metadata)
|
|
800
|
+
);
|
|
801
|
+
}
|
|
802
|
+
function serializeArrowType(arrowType) {
|
|
803
|
+
if (isArrowViewType(arrowType, "BinaryView")) {
|
|
804
|
+
return "binary-view";
|
|
805
|
+
}
|
|
806
|
+
if (isArrowViewType(arrowType, "Utf8View")) {
|
|
807
|
+
return "utf8-view";
|
|
808
|
+
}
|
|
809
|
+
if (isOptionalArrowType(arrowType, "LargeList")) {
|
|
810
|
+
const largeListType = arrowType;
|
|
811
|
+
return {
|
|
812
|
+
type: "large-list",
|
|
813
|
+
children: [serializeArrowField(largeListType.valueField)]
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
switch (arrowType.constructor) {
|
|
817
|
+
case arrow.Null:
|
|
818
|
+
return "null";
|
|
819
|
+
case arrow.Binary:
|
|
820
|
+
return "binary";
|
|
821
|
+
case arrow.FixedSizeBinary:
|
|
822
|
+
return {
|
|
823
|
+
type: "fixed-size-binary",
|
|
824
|
+
byteWidth: arrowType.byteWidth
|
|
825
|
+
};
|
|
826
|
+
case arrow.Bool:
|
|
827
|
+
return "bool";
|
|
828
|
+
case arrow.Int:
|
|
829
|
+
const intType = arrowType;
|
|
830
|
+
return `${intType.isSigned ? "" : "u"}int${intType.bitWidth}`;
|
|
831
|
+
case arrow.Int8:
|
|
832
|
+
return "int8";
|
|
833
|
+
case arrow.Int16:
|
|
834
|
+
return "int16";
|
|
835
|
+
case arrow.Int32:
|
|
836
|
+
return "int32";
|
|
837
|
+
case arrow.Int64:
|
|
838
|
+
return "int64";
|
|
839
|
+
case arrow.Uint8:
|
|
840
|
+
return "uint8";
|
|
841
|
+
case arrow.Uint16:
|
|
842
|
+
return "uint16";
|
|
843
|
+
case arrow.Uint32:
|
|
844
|
+
return "uint32";
|
|
845
|
+
case arrow.Uint64:
|
|
846
|
+
return "uint64";
|
|
847
|
+
case arrow.Float:
|
|
848
|
+
const precision = arrowType.precision;
|
|
849
|
+
switch (precision) {
|
|
850
|
+
case arrow.Precision.HALF:
|
|
851
|
+
return "float16";
|
|
852
|
+
case arrow.Precision.SINGLE:
|
|
853
|
+
return "float32";
|
|
854
|
+
case arrow.Precision.DOUBLE:
|
|
855
|
+
return "float64";
|
|
856
|
+
default:
|
|
857
|
+
return "float16";
|
|
858
|
+
}
|
|
859
|
+
case arrow.Float16:
|
|
860
|
+
return "float16";
|
|
861
|
+
case arrow.Float32:
|
|
862
|
+
return "float32";
|
|
863
|
+
case arrow.Float64:
|
|
864
|
+
return "float64";
|
|
865
|
+
case arrow.Utf8:
|
|
866
|
+
return "utf8";
|
|
867
|
+
case arrow.Decimal:
|
|
868
|
+
const decimal = arrowType;
|
|
869
|
+
return {
|
|
870
|
+
type: "decimal",
|
|
871
|
+
bitWidth: decimal.bitWidth,
|
|
872
|
+
precision: decimal.precision,
|
|
873
|
+
scale: decimal.scale
|
|
874
|
+
};
|
|
875
|
+
case arrow.Date_:
|
|
876
|
+
const dateUnit = arrowType.unit;
|
|
877
|
+
return dateUnit === arrow.DateUnit.DAY ? "date-day" : "date-millisecond";
|
|
878
|
+
case arrow.DateDay:
|
|
879
|
+
return "date-day";
|
|
880
|
+
case arrow.DateMillisecond:
|
|
881
|
+
return "date-millisecond";
|
|
882
|
+
case arrow.Time:
|
|
883
|
+
const timeUnit = arrowType.unit;
|
|
884
|
+
switch (timeUnit) {
|
|
885
|
+
case arrow.TimeUnit.SECOND:
|
|
886
|
+
return "time-second";
|
|
887
|
+
case arrow.TimeUnit.MILLISECOND:
|
|
888
|
+
return "time-millisecond";
|
|
889
|
+
case arrow.TimeUnit.MICROSECOND:
|
|
890
|
+
return "time-microsecond";
|
|
891
|
+
case arrow.TimeUnit.NANOSECOND:
|
|
892
|
+
return "time-nanosecond";
|
|
893
|
+
default:
|
|
894
|
+
return "time-second";
|
|
895
|
+
}
|
|
896
|
+
case arrow.TimeMillisecond:
|
|
897
|
+
return "time-millisecond";
|
|
898
|
+
case arrow.TimeSecond:
|
|
899
|
+
return "time-second";
|
|
900
|
+
case arrow.TimeMicrosecond:
|
|
901
|
+
return "time-microsecond";
|
|
902
|
+
case arrow.TimeNanosecond:
|
|
903
|
+
return "time-nanosecond";
|
|
904
|
+
case arrow.Timestamp:
|
|
905
|
+
const timeStampUnit = arrowType.unit;
|
|
906
|
+
switch (timeStampUnit) {
|
|
907
|
+
case arrow.TimeUnit.SECOND:
|
|
908
|
+
return "timestamp-second";
|
|
909
|
+
case arrow.TimeUnit.MILLISECOND:
|
|
910
|
+
return "timestamp-millisecond";
|
|
911
|
+
case arrow.TimeUnit.MICROSECOND:
|
|
912
|
+
return "timestamp-microsecond";
|
|
913
|
+
case arrow.TimeUnit.NANOSECOND:
|
|
914
|
+
return "timestamp-nanosecond";
|
|
915
|
+
default:
|
|
916
|
+
return "timestamp-second";
|
|
917
|
+
}
|
|
918
|
+
case arrow.TimestampSecond:
|
|
919
|
+
return "timestamp-second";
|
|
920
|
+
case arrow.TimestampMillisecond:
|
|
921
|
+
return "timestamp-millisecond";
|
|
922
|
+
case arrow.TimestampMicrosecond:
|
|
923
|
+
return "timestamp-microsecond";
|
|
924
|
+
case arrow.TimestampNanosecond:
|
|
925
|
+
return "timestamp-nanosecond";
|
|
926
|
+
case arrow.Interval:
|
|
927
|
+
const intervalUnit = arrowType.unit;
|
|
928
|
+
switch (intervalUnit) {
|
|
929
|
+
case arrow.IntervalUnit.DAY_TIME:
|
|
930
|
+
return "interval-daytime";
|
|
931
|
+
case arrow.IntervalUnit.YEAR_MONTH:
|
|
932
|
+
return "interval-yearmonth";
|
|
933
|
+
default:
|
|
934
|
+
return "interval-daytime";
|
|
935
|
+
}
|
|
936
|
+
case arrow.IntervalDayTime:
|
|
937
|
+
return "interval-daytime";
|
|
938
|
+
case arrow.IntervalYearMonth:
|
|
939
|
+
return "interval-yearmonth";
|
|
940
|
+
case arrow.Map_:
|
|
941
|
+
const mapType = arrowType;
|
|
942
|
+
return {
|
|
943
|
+
type: "map",
|
|
944
|
+
keysSorted: mapType.keysSorted,
|
|
945
|
+
children: mapType.children.map((arrowField) => serializeArrowField(arrowField))
|
|
946
|
+
};
|
|
947
|
+
case arrow.List:
|
|
948
|
+
const listType = arrowType;
|
|
949
|
+
const listField = listType.valueField;
|
|
950
|
+
return {
|
|
951
|
+
type: "list",
|
|
952
|
+
children: [serializeArrowField(listField)]
|
|
953
|
+
};
|
|
954
|
+
case arrow.FixedSizeList:
|
|
955
|
+
const fixedSizeList = arrowType;
|
|
956
|
+
return {
|
|
957
|
+
type: "fixed-size-list",
|
|
958
|
+
listSize: fixedSizeList.listSize,
|
|
959
|
+
children: [serializeArrowField(fixedSizeList.children[0])]
|
|
960
|
+
};
|
|
961
|
+
case arrow.Struct:
|
|
962
|
+
const structType = arrowType;
|
|
963
|
+
return {
|
|
964
|
+
type: "struct",
|
|
965
|
+
children: structType.children.map((arrowField) => serializeArrowField(arrowField))
|
|
966
|
+
};
|
|
967
|
+
case arrow.SparseUnion:
|
|
968
|
+
case arrow.DenseUnion:
|
|
969
|
+
const unionType = arrowType;
|
|
970
|
+
return {
|
|
971
|
+
type: unionType instanceof arrow.DenseUnion ? "dense-union" : "sparse-union",
|
|
972
|
+
typeIds: unionType.typeIds,
|
|
973
|
+
children: unionType.children.map((arrowField) => serializeArrowField(arrowField)),
|
|
974
|
+
typeIdToChildIndex: { ...unionType.typeIdToChildIndex }
|
|
975
|
+
};
|
|
976
|
+
case arrow.Dictionary:
|
|
977
|
+
const dictionaryType = arrowType;
|
|
978
|
+
return {
|
|
979
|
+
type: "dictionary",
|
|
980
|
+
id: dictionaryType.id,
|
|
981
|
+
indices: serializeArrowDictionaryKeyType(dictionaryType.indices),
|
|
982
|
+
dictionary: serializeArrowType(dictionaryType.dictionary),
|
|
983
|
+
isOrdered: dictionaryType.isOrdered
|
|
984
|
+
};
|
|
985
|
+
default:
|
|
986
|
+
throw new Error(`arrow type not supported: ${arrowType.constructor.name}`);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
function deserializeArrowType(dataType, options) {
|
|
990
|
+
if (typeof dataType === "object") {
|
|
991
|
+
switch (dataType.type) {
|
|
992
|
+
case "decimal":
|
|
993
|
+
return new arrow.Decimal(dataType.scale, dataType.precision, dataType.bitWidth);
|
|
994
|
+
case "map": {
|
|
995
|
+
const children = dataType.children.map(
|
|
996
|
+
(arrowField) => deserializeArrowField(arrowField, options)
|
|
997
|
+
);
|
|
998
|
+
return new arrow.Map_(children[0], dataType.keysSorted);
|
|
999
|
+
}
|
|
1000
|
+
case "list": {
|
|
1001
|
+
const field = deserializeArrowField(dataType.children[0], options);
|
|
1002
|
+
return new arrow.List(field);
|
|
1003
|
+
}
|
|
1004
|
+
case "large-list": {
|
|
1005
|
+
const field = deserializeArrowField(dataType.children[0], options);
|
|
1006
|
+
const LargeList = getOptionalArrowConstructor("LargeList");
|
|
1007
|
+
if (!LargeList) {
|
|
1008
|
+
throw new Error(
|
|
1009
|
+
"LargeList requires an Apache Arrow runtime that exports the LargeList constructor"
|
|
1010
|
+
);
|
|
1011
|
+
}
|
|
1012
|
+
return new LargeList(field);
|
|
1013
|
+
}
|
|
1014
|
+
case "fixed-size-list": {
|
|
1015
|
+
const child = deserializeArrowField(dataType.children[0], options);
|
|
1016
|
+
return new arrow.FixedSizeList(dataType.listSize, child);
|
|
1017
|
+
}
|
|
1018
|
+
case "fixed-size-binary":
|
|
1019
|
+
return new arrow.FixedSizeBinary(dataType.byteWidth);
|
|
1020
|
+
case "struct": {
|
|
1021
|
+
const children = dataType.children.map(
|
|
1022
|
+
(arrowField) => deserializeArrowField(arrowField, options)
|
|
1023
|
+
);
|
|
1024
|
+
return new arrow.Struct(children);
|
|
1025
|
+
}
|
|
1026
|
+
case "sparse-union":
|
|
1027
|
+
case "dense-union": {
|
|
1028
|
+
const children = dataType.children.map(
|
|
1029
|
+
(arrowField) => deserializeArrowField(arrowField, options)
|
|
1030
|
+
);
|
|
1031
|
+
return dataType.type === "dense-union" ? new arrow.DenseUnion(dataType.typeIds, children) : new arrow.SparseUnion(dataType.typeIds, children);
|
|
1032
|
+
}
|
|
1033
|
+
case "dictionary": {
|
|
1034
|
+
return new arrow.Dictionary(
|
|
1035
|
+
deserializeArrowType(dataType.dictionary, options),
|
|
1036
|
+
deserializeArrowDictionaryKeyType(dataType.indices),
|
|
1037
|
+
dataType.id,
|
|
1038
|
+
dataType.isOrdered
|
|
1039
|
+
);
|
|
1040
|
+
}
|
|
1041
|
+
default:
|
|
1042
|
+
throw new Error("array type not supported");
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
switch (dataType) {
|
|
1046
|
+
case "null":
|
|
1047
|
+
return new arrow.Null();
|
|
1048
|
+
case "binary":
|
|
1049
|
+
return makeVariableWidthArrowType("BinaryView", new arrow.Binary(), options);
|
|
1050
|
+
case "binary-view":
|
|
1051
|
+
return makeRequiredArrowViewType("BinaryView");
|
|
1052
|
+
case "bool":
|
|
1053
|
+
return new arrow.Bool();
|
|
1054
|
+
case "int8":
|
|
1055
|
+
return new arrow.Int8();
|
|
1056
|
+
case "int16":
|
|
1057
|
+
return new arrow.Int16();
|
|
1058
|
+
case "int32":
|
|
1059
|
+
return new arrow.Int32();
|
|
1060
|
+
case "int64":
|
|
1061
|
+
return new arrow.Int64();
|
|
1062
|
+
case "uint8":
|
|
1063
|
+
return new arrow.Uint8();
|
|
1064
|
+
case "uint16":
|
|
1065
|
+
return new arrow.Uint16();
|
|
1066
|
+
case "uint32":
|
|
1067
|
+
return new arrow.Uint32();
|
|
1068
|
+
case "uint64":
|
|
1069
|
+
return new arrow.Uint64();
|
|
1070
|
+
case "float16":
|
|
1071
|
+
return new arrow.Float16();
|
|
1072
|
+
case "float32":
|
|
1073
|
+
return new arrow.Float32();
|
|
1074
|
+
case "float64":
|
|
1075
|
+
return new arrow.Float64();
|
|
1076
|
+
case "utf8":
|
|
1077
|
+
return makeVariableWidthArrowType("Utf8View", new arrow.Utf8(), options);
|
|
1078
|
+
case "utf8-view":
|
|
1079
|
+
return makeRequiredArrowViewType("Utf8View");
|
|
1080
|
+
case "date-day":
|
|
1081
|
+
return new arrow.DateDay();
|
|
1082
|
+
case "date-millisecond":
|
|
1083
|
+
return new arrow.DateMillisecond();
|
|
1084
|
+
case "time-second":
|
|
1085
|
+
return new arrow.TimeSecond();
|
|
1086
|
+
case "time-millisecond":
|
|
1087
|
+
return new arrow.TimeMillisecond();
|
|
1088
|
+
case "time-microsecond":
|
|
1089
|
+
return new arrow.TimeMicrosecond();
|
|
1090
|
+
case "time-nanosecond":
|
|
1091
|
+
return new arrow.TimeNanosecond();
|
|
1092
|
+
case "timestamp-second":
|
|
1093
|
+
return new arrow.TimestampSecond();
|
|
1094
|
+
case "timestamp-millisecond":
|
|
1095
|
+
return new arrow.TimestampMillisecond();
|
|
1096
|
+
case "timestamp-microsecond":
|
|
1097
|
+
return new arrow.TimestampMicrosecond();
|
|
1098
|
+
case "timestamp-nanosecond":
|
|
1099
|
+
return new arrow.TimestampNanosecond();
|
|
1100
|
+
case "interval-daytime":
|
|
1101
|
+
return new arrow.IntervalDayTime();
|
|
1102
|
+
case "interval-yearmonth":
|
|
1103
|
+
return new arrow.IntervalYearMonth();
|
|
1104
|
+
default:
|
|
1105
|
+
throw new Error("array type not supported");
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
function getOptionalArrowConstructor(typeName) {
|
|
1109
|
+
return arrow[typeName];
|
|
1110
|
+
}
|
|
1111
|
+
function isArrowViewType(arrowType, viewTypeName) {
|
|
1112
|
+
const constructor = getOptionalArrowConstructor(viewTypeName);
|
|
1113
|
+
if (constructor && arrowType instanceof constructor) {
|
|
1114
|
+
return true;
|
|
1115
|
+
}
|
|
1116
|
+
const guards = arrow.DataType;
|
|
1117
|
+
const guard = viewTypeName === "BinaryView" ? guards.isBinaryView : guards.isUtf8View;
|
|
1118
|
+
return Boolean(guard == null ? void 0 : guard(arrowType));
|
|
1119
|
+
}
|
|
1120
|
+
function isOptionalArrowType(arrowType, typeName) {
|
|
1121
|
+
const constructor = getOptionalArrowConstructor(typeName);
|
|
1122
|
+
return Boolean(constructor && arrowType instanceof constructor);
|
|
1123
|
+
}
|
|
1124
|
+
function makeVariableWidthArrowType(viewTypeName, fallbackType, options) {
|
|
1125
|
+
const viewTypeMode = (options == null ? void 0 : options.viewTypes) || "never";
|
|
1126
|
+
if (viewTypeMode === "never") {
|
|
1127
|
+
return fallbackType;
|
|
1128
|
+
}
|
|
1129
|
+
const constructor = getOptionalArrowConstructor(viewTypeName);
|
|
1130
|
+
if (constructor) {
|
|
1131
|
+
return new constructor();
|
|
1132
|
+
}
|
|
1133
|
+
if (viewTypeMode === "require") {
|
|
1134
|
+
throw new Error(
|
|
1135
|
+
`${viewTypeName} requires apache-arrow 21.2.0 or later; the installed runtime does not support it`
|
|
1136
|
+
);
|
|
1137
|
+
}
|
|
1138
|
+
return fallbackType;
|
|
1139
|
+
}
|
|
1140
|
+
function makeRequiredArrowViewType(viewTypeName) {
|
|
1141
|
+
const constructor = getOptionalArrowConstructor(viewTypeName);
|
|
1142
|
+
if (!constructor) {
|
|
1143
|
+
throw new Error(
|
|
1144
|
+
`${viewTypeName} requires apache-arrow 21.2.0 or later; the installed runtime does not support it`
|
|
1145
|
+
);
|
|
1146
|
+
}
|
|
1147
|
+
return new constructor();
|
|
1148
|
+
}
|
|
1149
|
+
function serializeArrowDictionaryKeyType(arrowType) {
|
|
1150
|
+
if (arrowType instanceof arrow.Int) {
|
|
1151
|
+
const prefix = arrowType.isSigned ? "int" : "uint";
|
|
1152
|
+
const keyType = `${prefix}${arrowType.bitWidth}`;
|
|
1153
|
+
if (isSchemaDictionaryKeyType(keyType)) {
|
|
1154
|
+
return keyType;
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
switch (arrowType.constructor) {
|
|
1158
|
+
case arrow.Int8:
|
|
1159
|
+
return "int8";
|
|
1160
|
+
case arrow.Int16:
|
|
1161
|
+
return "int16";
|
|
1162
|
+
case arrow.Int32:
|
|
1163
|
+
return "int32";
|
|
1164
|
+
case arrow.Uint8:
|
|
1165
|
+
return "uint8";
|
|
1166
|
+
case arrow.Uint16:
|
|
1167
|
+
return "uint16";
|
|
1168
|
+
case arrow.Uint32:
|
|
1169
|
+
return "uint32";
|
|
1170
|
+
default:
|
|
1171
|
+
throw new Error(`arrow dictionary index type not supported: ${arrowType.constructor.name}`);
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
function isSchemaDictionaryKeyType(keyType) {
|
|
1175
|
+
return ["int8", "int16", "int32", "uint8", "uint16", "uint32"].includes(keyType);
|
|
1176
|
+
}
|
|
1177
|
+
function deserializeArrowDictionaryKeyType(keyType) {
|
|
1178
|
+
switch (keyType) {
|
|
1179
|
+
case "int8":
|
|
1180
|
+
return new arrow.Int8();
|
|
1181
|
+
case "int16":
|
|
1182
|
+
return new arrow.Int16();
|
|
1183
|
+
case "int32":
|
|
1184
|
+
return new arrow.Int32();
|
|
1185
|
+
case "uint8":
|
|
1186
|
+
return new arrow.Uint8();
|
|
1187
|
+
case "uint16":
|
|
1188
|
+
return new arrow.Uint16();
|
|
1189
|
+
case "uint32":
|
|
1190
|
+
return new arrow.Uint32();
|
|
1191
|
+
default:
|
|
1192
|
+
throw new Error(`schema dictionary index type not supported: ${keyType}`);
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
var arrow;
|
|
1196
|
+
var init_convert_arrow_schema = __esm({
|
|
1197
|
+
"../core/src/schema-utils/lib/schema/convert-arrow-schema.ts"() {
|
|
1198
|
+
"use strict";
|
|
1199
|
+
arrow = __toESM(require("apache-arrow"), 1);
|
|
1200
|
+
}
|
|
1201
|
+
});
|
|
1202
|
+
|
|
1203
|
+
// ../core/src/schema-utils/lib/table/batch-builder/arrow-table-builder.ts
|
|
1204
|
+
var arrow2, ArrowTableBuilder;
|
|
1205
|
+
var init_arrow_table_builder = __esm({
|
|
1206
|
+
"../core/src/schema-utils/lib/table/batch-builder/arrow-table-builder.ts"() {
|
|
1207
|
+
"use strict";
|
|
1208
|
+
arrow2 = __toESM(require("apache-arrow"), 1);
|
|
1209
|
+
init_convert_arrow_schema();
|
|
1210
|
+
ArrowTableBuilder = class {
|
|
1211
|
+
schema;
|
|
1212
|
+
arrowSchema;
|
|
1213
|
+
arrowBuilders;
|
|
1214
|
+
length;
|
|
1215
|
+
constructor(schema, options) {
|
|
1216
|
+
this.arrowSchema = convertSchemaToArrow(schema, options);
|
|
1217
|
+
this.schema = (options == null ? void 0 : options.viewTypes) && options.viewTypes !== "never" ? convertArrowToSchema(this.arrowSchema) : schema;
|
|
1218
|
+
this.arrowBuilders = this.arrowSchema.fields.map(
|
|
1219
|
+
(field) => arrow2.makeBuilder({ type: field.type, nullValues: [null] })
|
|
1220
|
+
);
|
|
1221
|
+
this.length = 0;
|
|
1222
|
+
}
|
|
1223
|
+
addObjectRow(row) {
|
|
1224
|
+
for (let i = 0; i < this.arrowBuilders.length; i++) {
|
|
1225
|
+
const columnName = this.schema.fields[i].name;
|
|
1226
|
+
const value = row[columnName];
|
|
1227
|
+
this.arrowBuilders[i].append(value);
|
|
1228
|
+
}
|
|
1229
|
+
this.length++;
|
|
1230
|
+
}
|
|
1231
|
+
addArrayRow(row) {
|
|
1232
|
+
for (let i = 0; i < this.arrowBuilders.length; i++) {
|
|
1233
|
+
this.arrowBuilders[i].append(row[i]);
|
|
1234
|
+
}
|
|
1235
|
+
this.length++;
|
|
1236
|
+
}
|
|
1237
|
+
/** Makes sure that a first batch with schema is sent even if no rows */
|
|
1238
|
+
firstBatch() {
|
|
1239
|
+
const arrowRecordBatch = this._getArrowRecordBatch();
|
|
1240
|
+
if (arrowRecordBatch.numCols !== 0) {
|
|
1241
|
+
return null;
|
|
1242
|
+
}
|
|
1243
|
+
return {
|
|
1244
|
+
shape: "arrow-table",
|
|
1245
|
+
batchType: "data",
|
|
1246
|
+
length: arrowRecordBatch.numRows,
|
|
1247
|
+
schema: this.schema,
|
|
1248
|
+
data: new arrow2.Table(arrowRecordBatch)
|
|
1249
|
+
};
|
|
1250
|
+
}
|
|
1251
|
+
/** Flush the current batch if conditions are right */
|
|
1252
|
+
flushBatch() {
|
|
1253
|
+
const arrowRecordBatch = this._getArrowRecordBatch();
|
|
1254
|
+
if (arrowRecordBatch.numCols === 0) {
|
|
1255
|
+
return null;
|
|
1256
|
+
}
|
|
1257
|
+
return {
|
|
1258
|
+
shape: "arrow-table",
|
|
1259
|
+
batchType: "data",
|
|
1260
|
+
length: arrowRecordBatch.numRows,
|
|
1261
|
+
schema: this.schema,
|
|
1262
|
+
data: new arrow2.Table(arrowRecordBatch)
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1265
|
+
/** Get a last batch if any data is left */
|
|
1266
|
+
finishBatch() {
|
|
1267
|
+
const arrowRecordBatch = this._getArrowRecordBatch();
|
|
1268
|
+
this.arrowBuilders.forEach((builder) => builder.finish());
|
|
1269
|
+
if (arrowRecordBatch.numCols === 0 && arrowRecordBatch.numRows === 0) {
|
|
1270
|
+
return null;
|
|
1271
|
+
}
|
|
1272
|
+
return {
|
|
1273
|
+
shape: "arrow-table",
|
|
1274
|
+
batchType: "data",
|
|
1275
|
+
length: arrowRecordBatch.numRows,
|
|
1276
|
+
schema: this.schema,
|
|
1277
|
+
data: new arrow2.Table(arrowRecordBatch)
|
|
1278
|
+
};
|
|
1279
|
+
}
|
|
1280
|
+
/** Return a table with all the accumulated data */
|
|
1281
|
+
finishTable() {
|
|
1282
|
+
const arrowRecordBatch = this._getArrowRecordBatch();
|
|
1283
|
+
this.arrowBuilders.forEach((builder) => builder.finish());
|
|
1284
|
+
return {
|
|
1285
|
+
shape: "arrow-table",
|
|
1286
|
+
schema: this.schema,
|
|
1287
|
+
data: new arrow2.Table(arrowRecordBatch)
|
|
1288
|
+
};
|
|
1289
|
+
}
|
|
1290
|
+
/** Extract a record batch flushing the currently accumulated data in the builders */
|
|
1291
|
+
_getArrowRecordBatch() {
|
|
1292
|
+
var _a;
|
|
1293
|
+
const { arrowBuilders, arrowSchema } = this;
|
|
1294
|
+
const arrowDatas = arrowBuilders.map((builder) => builder.flush());
|
|
1295
|
+
const length = ((_a = arrowDatas[0]) == null ? void 0 : _a.length) || this.length;
|
|
1296
|
+
this.length = 0;
|
|
1297
|
+
const structField = new arrow2.Struct(arrowSchema.fields);
|
|
1298
|
+
const arrowStructData = new arrow2.Data(structField, 0, length, 0, void 0, arrowDatas);
|
|
1299
|
+
const arrowRecordBatch = new arrow2.RecordBatch(arrowSchema, arrowStructData);
|
|
1300
|
+
return arrowRecordBatch;
|
|
1301
|
+
}
|
|
1302
|
+
};
|
|
1303
|
+
}
|
|
1304
|
+
});
|
|
1305
|
+
|
|
1306
|
+
// ../core/src/schema-utils/index.ts
|
|
1307
|
+
var init_schema_utils = __esm({
|
|
1308
|
+
"../core/src/schema-utils/index.ts"() {
|
|
1309
|
+
"use strict";
|
|
1310
|
+
init_convert_arrow_schema();
|
|
1311
|
+
init_data_type();
|
|
1312
|
+
init_arrow_table_builder();
|
|
1313
|
+
}
|
|
1314
|
+
});
|
|
1315
|
+
|
|
1316
|
+
// ../arrow-geometry/src/wkb-types.ts
|
|
1317
|
+
var WKBGeometryType;
|
|
1318
|
+
var init_wkb_types = __esm({
|
|
1319
|
+
"../arrow-geometry/src/wkb-types.ts"() {
|
|
1320
|
+
"use strict";
|
|
1321
|
+
WKBGeometryType = /* @__PURE__ */ ((WKBGeometryType2) => {
|
|
1322
|
+
WKBGeometryType2[WKBGeometryType2["Point"] = 1] = "Point";
|
|
1323
|
+
WKBGeometryType2[WKBGeometryType2["LineString"] = 2] = "LineString";
|
|
1324
|
+
WKBGeometryType2[WKBGeometryType2["Polygon"] = 3] = "Polygon";
|
|
1325
|
+
WKBGeometryType2[WKBGeometryType2["MultiPoint"] = 4] = "MultiPoint";
|
|
1326
|
+
WKBGeometryType2[WKBGeometryType2["MultiLineString"] = 5] = "MultiLineString";
|
|
1327
|
+
WKBGeometryType2[WKBGeometryType2["MultiPolygon"] = 6] = "MultiPolygon";
|
|
1328
|
+
WKBGeometryType2[WKBGeometryType2["GeometryCollection"] = 7] = "GeometryCollection";
|
|
1329
|
+
return WKBGeometryType2;
|
|
1330
|
+
})(WKBGeometryType || {});
|
|
1331
|
+
}
|
|
1332
|
+
});
|
|
1333
|
+
|
|
1334
|
+
// ../arrow-geometry/src/wkb-builder.ts
|
|
1335
|
+
function getDimension(hasZ, hasM) {
|
|
1336
|
+
return hasZ && hasM ? "xyzm" : hasZ ? "xyz" : hasM ? "xym" : "xy";
|
|
1337
|
+
}
|
|
1338
|
+
function getGeometryTypeName(type) {
|
|
1339
|
+
return typeof type === "number" ? WKBGeometryType[type] : type;
|
|
1340
|
+
}
|
|
1341
|
+
var import_wkb2, WKBBuilder2;
|
|
1342
|
+
var init_wkb_builder = __esm({
|
|
1343
|
+
"../arrow-geometry/src/wkb-builder.ts"() {
|
|
1344
|
+
"use strict";
|
|
1345
|
+
import_wkb2 = require("@math.gl/geospatial/wkb");
|
|
1346
|
+
init_wkb_types();
|
|
1347
|
+
WKBBuilder2 = class _WKBBuilder {
|
|
1348
|
+
mode;
|
|
1349
|
+
hasZ;
|
|
1350
|
+
hasM;
|
|
1351
|
+
transform;
|
|
1352
|
+
builder;
|
|
1353
|
+
constructor(options) {
|
|
1354
|
+
this.mode = options.mode;
|
|
1355
|
+
this.hasZ = Boolean(options.hasZ);
|
|
1356
|
+
this.hasM = Boolean(options.hasM);
|
|
1357
|
+
this.transform = options.transform;
|
|
1358
|
+
const dimension = getDimension(this.hasZ, this.hasM);
|
|
1359
|
+
const transform = options.transform ? (coordinate) => {
|
|
1360
|
+
const transformed = options.transform([coordinate[0], coordinate[1]]);
|
|
1361
|
+
return [transformed[0], transformed[1], ...coordinate.slice(2)];
|
|
1362
|
+
} : void 0;
|
|
1363
|
+
this.builder = options.mode === "write" ? new import_wkb2.WKBBuilder({
|
|
1364
|
+
mode: "write",
|
|
1365
|
+
target: options.target,
|
|
1366
|
+
byteOffset: options.byteOffset,
|
|
1367
|
+
dimension,
|
|
1368
|
+
transform
|
|
1369
|
+
}) : new import_wkb2.WKBBuilder({ mode: "measure", dimension, transform });
|
|
1370
|
+
}
|
|
1371
|
+
/** Begins a geometry by type, optionally writing its count field. */
|
|
1372
|
+
beginGeometry(type, count) {
|
|
1373
|
+
const geometryTypeName = getGeometryTypeName(type);
|
|
1374
|
+
if (!geometryTypeName) {
|
|
1375
|
+
throw new Error("Unsupported WKB geometry type");
|
|
1376
|
+
}
|
|
1377
|
+
this.callBuilder(() => this.builder.beginGeometry(geometryTypeName, count));
|
|
1378
|
+
}
|
|
1379
|
+
/** Begins one point geometry. */
|
|
1380
|
+
beginPoint() {
|
|
1381
|
+
this.callBuilder(() => this.builder.beginPoint());
|
|
1382
|
+
}
|
|
1383
|
+
/** Begins one linestring geometry. */
|
|
1384
|
+
beginLineString(pointCount) {
|
|
1385
|
+
this.callBuilder(() => this.builder.beginLineString(pointCount));
|
|
1386
|
+
}
|
|
1387
|
+
/** Begins one polygon geometry. */
|
|
1388
|
+
beginPolygon(ringCount) {
|
|
1389
|
+
this.callBuilder(() => this.builder.beginPolygon(ringCount));
|
|
1390
|
+
}
|
|
1391
|
+
/** Begins one linear ring inside a polygon. */
|
|
1392
|
+
beginLinearRing(pointCount) {
|
|
1393
|
+
this.callBuilder(() => this.builder.beginLinearRing(pointCount));
|
|
1394
|
+
}
|
|
1395
|
+
/** Begins one multipoint geometry. */
|
|
1396
|
+
beginMultiPoint(pointCount) {
|
|
1397
|
+
this.callBuilder(() => this.builder.beginMultiPoint(pointCount));
|
|
1398
|
+
}
|
|
1399
|
+
/** Begins one multilinestring geometry. */
|
|
1400
|
+
beginMultiLineString(lineCount) {
|
|
1401
|
+
this.callBuilder(() => this.builder.beginMultiLineString(lineCount));
|
|
1402
|
+
}
|
|
1403
|
+
/** Begins one multipolygon geometry. */
|
|
1404
|
+
beginMultiPolygon(polygonCount) {
|
|
1405
|
+
this.callBuilder(() => this.builder.beginMultiPolygon(polygonCount));
|
|
1406
|
+
}
|
|
1407
|
+
/** Writes one coordinate using the builder's dimensional options. */
|
|
1408
|
+
writeCoordinate(x, y, z, m) {
|
|
1409
|
+
this.callBuilder(() => this.builder.writeCoordinate(x, y, z, m));
|
|
1410
|
+
}
|
|
1411
|
+
/** Finishes the current geometry and returns its byte length. */
|
|
1412
|
+
finishGeometry() {
|
|
1413
|
+
return this.callBuilder(() => this.builder.finishGeometry());
|
|
1414
|
+
}
|
|
1415
|
+
/** Returns the number of bytes measured or written by this builder. */
|
|
1416
|
+
getByteLength() {
|
|
1417
|
+
return this.callBuilder(() => this.builder.finishGeometry());
|
|
1418
|
+
}
|
|
1419
|
+
/** Runs a math.gl builder operation while preserving the legacy facade error text. */
|
|
1420
|
+
callBuilder(callback) {
|
|
1421
|
+
try {
|
|
1422
|
+
return callback();
|
|
1423
|
+
} catch (error) {
|
|
1424
|
+
if (error instanceof Error && error.message.includes("target buffer overflow")) {
|
|
1425
|
+
throw new Error("WKBBuilder overflow");
|
|
1426
|
+
}
|
|
1427
|
+
throw error;
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
/** Measures geometry writer callbacks and returns Arrow Binary offsets. */
|
|
1431
|
+
static measureGeometryArray(geometryWriters, options = {}) {
|
|
1432
|
+
const valueOffsets = new Int32Array(geometryWriters.length + 1);
|
|
1433
|
+
for (let index = 0; index < geometryWriters.length; index++) {
|
|
1434
|
+
const writer = geometryWriters[index];
|
|
1435
|
+
if (writer) {
|
|
1436
|
+
const builder = new _WKBBuilder({ mode: "measure", ...options });
|
|
1437
|
+
writer(builder);
|
|
1438
|
+
valueOffsets[index + 1] = valueOffsets[index] + builder.finishGeometry();
|
|
1439
|
+
} else {
|
|
1440
|
+
valueOffsets[index + 1] = valueOffsets[index];
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
return valueOffsets;
|
|
1444
|
+
}
|
|
1445
|
+
/** Writes geometry writer callbacks into an existing contiguous values buffer. */
|
|
1446
|
+
static writeGeometryArray(geometryWriters, valueOffsets, values, options = {}) {
|
|
1447
|
+
for (let index = 0; index < geometryWriters.length; index++) {
|
|
1448
|
+
const writer = geometryWriters[index];
|
|
1449
|
+
if (writer) {
|
|
1450
|
+
const builder = new _WKBBuilder({
|
|
1451
|
+
mode: "write",
|
|
1452
|
+
target: values,
|
|
1453
|
+
byteOffset: valueOffsets[index],
|
|
1454
|
+
...options
|
|
1455
|
+
});
|
|
1456
|
+
writer(builder);
|
|
1457
|
+
builder.finishGeometry();
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
return values;
|
|
1461
|
+
}
|
|
1462
|
+
/** Builds Arrow-style offsets, values, and validity buffers in two passes. */
|
|
1463
|
+
static buildGeometryArray(geometryWriters, options = {}) {
|
|
1464
|
+
const valueOffsets = _WKBBuilder.measureGeometryArray(geometryWriters, options);
|
|
1465
|
+
const values = new Uint8Array(valueOffsets[valueOffsets.length - 1]);
|
|
1466
|
+
_WKBBuilder.writeGeometryArray(geometryWriters, valueOffsets, values, options);
|
|
1467
|
+
const nullBitmap = new Uint8Array(Math.ceil(geometryWriters.length / 8));
|
|
1468
|
+
let nullCount = 0;
|
|
1469
|
+
for (let index = 0; index < geometryWriters.length; index++) {
|
|
1470
|
+
if (geometryWriters[index]) nullBitmap[index >> 3] |= 1 << (index & 7);
|
|
1471
|
+
else nullCount++;
|
|
1472
|
+
}
|
|
1473
|
+
return { valueOffsets, values, nullBitmap: nullCount ? nullBitmap : void 0, nullCount };
|
|
1474
|
+
}
|
|
1475
|
+
};
|
|
1476
|
+
}
|
|
1477
|
+
});
|
|
1478
|
+
|
|
1479
|
+
// ../arrow-geometry/src/wkb-arrow-utils.ts
|
|
1480
|
+
function makeWKBGeometryDataFromWriters(geometryWriters, options = {}) {
|
|
1481
|
+
return makeWKBGeometryDataFromArray(
|
|
1482
|
+
WKBBuilder2.buildGeometryArray(normalizeGeometryWriters(geometryWriters), options)
|
|
1483
|
+
);
|
|
1484
|
+
}
|
|
1485
|
+
function makeWKBGeometryDataFromArray(geometryArray) {
|
|
1486
|
+
return new arrow3.Data(
|
|
1487
|
+
new arrow3.Binary(),
|
|
1488
|
+
0,
|
|
1489
|
+
geometryArray.valueOffsets.length - 1,
|
|
1490
|
+
geometryArray.nullCount,
|
|
1491
|
+
[
|
|
1492
|
+
geometryArray.valueOffsets,
|
|
1493
|
+
geometryArray.values,
|
|
1494
|
+
geometryArray.nullCount > 0 ? geometryArray.nullBitmap : void 0
|
|
1495
|
+
]
|
|
1496
|
+
);
|
|
1497
|
+
}
|
|
1498
|
+
function normalizeGeometryWriters(geometryWriters) {
|
|
1499
|
+
return geometryWriters.map((geometryWriter) => geometryWriter || null);
|
|
1500
|
+
}
|
|
1501
|
+
var arrow3;
|
|
1502
|
+
var init_wkb_arrow_utils = __esm({
|
|
1503
|
+
"../arrow-geometry/src/wkb-arrow-utils.ts"() {
|
|
1504
|
+
"use strict";
|
|
1505
|
+
arrow3 = __toESM(require("apache-arrow"), 1);
|
|
1506
|
+
init_wkb_builder();
|
|
1507
|
+
}
|
|
1508
|
+
});
|
|
1509
|
+
|
|
1510
|
+
// ../arrow-geometry/src/geoarrow-builder.ts
|
|
1511
|
+
function makePrimitiveData(values) {
|
|
1512
|
+
return arrow4.makeData({ type: new arrow4.Float64(), data: values });
|
|
1513
|
+
}
|
|
1514
|
+
function getBoxFieldNames(dimension) {
|
|
1515
|
+
const minimumNames = dimension === "xy" ? ["xmin", "ymin"] : dimension === "xyz" ? ["xmin", "ymin", "zmin"] : dimension === "xym" ? ["xmin", "ymin", "mmin"] : ["xmin", "ymin", "zmin", "mmin"];
|
|
1516
|
+
const maximumNames = dimension === "xy" ? ["xmax", "ymax"] : dimension === "xyz" ? ["xmax", "ymax", "zmax"] : dimension === "xym" ? ["xmax", "ymax", "mmax"] : ["xmax", "ymax", "zmax", "mmax"];
|
|
1517
|
+
return [...minimumNames, ...maximumNames];
|
|
1518
|
+
}
|
|
1519
|
+
function getCoordinateSize(dimension) {
|
|
1520
|
+
return dimension === "xy" ? 2 : dimension === "xyzm" ? 4 : 3;
|
|
1521
|
+
}
|
|
1522
|
+
function makeCoordinateData(values, dimension, coordinateLayout) {
|
|
1523
|
+
if (coordinateLayout === "separated") {
|
|
1524
|
+
const coordinateBuffers = values;
|
|
1525
|
+
const coordinateNames = getCoordinateNames(dimension);
|
|
1526
|
+
return arrow4.makeData({
|
|
1527
|
+
type: new arrow4.Struct(
|
|
1528
|
+
coordinateNames.map((name) => new arrow4.Field(name, new arrow4.Float64(), false))
|
|
1529
|
+
),
|
|
1530
|
+
children: coordinateNames.map((name) => makePrimitiveData(coordinateBuffers[name]))
|
|
1531
|
+
});
|
|
1532
|
+
}
|
|
1533
|
+
return arrow4.makeData({
|
|
1534
|
+
type: new arrow4.FixedSizeList(
|
|
1535
|
+
getCoordinateSize(dimension),
|
|
1536
|
+
new arrow4.Field(dimension, new arrow4.Float64(), false)
|
|
1537
|
+
),
|
|
1538
|
+
child: makePrimitiveData(values)
|
|
1539
|
+
});
|
|
1540
|
+
}
|
|
1541
|
+
function makeBoxData(values, dimension) {
|
|
1542
|
+
const names = getBoxFieldNames(dimension);
|
|
1543
|
+
const children = names.map((name, index) => {
|
|
1544
|
+
if (values instanceof Float64Array) {
|
|
1545
|
+
const boxSize = names.length;
|
|
1546
|
+
return makePrimitiveData(
|
|
1547
|
+
Float64Array.from(
|
|
1548
|
+
{ length: values.length / boxSize },
|
|
1549
|
+
(_, rowIndex) => values[rowIndex * boxSize + index]
|
|
1550
|
+
)
|
|
1551
|
+
);
|
|
1552
|
+
}
|
|
1553
|
+
return makePrimitiveData(values[name]);
|
|
1554
|
+
});
|
|
1555
|
+
return arrow4.makeData({
|
|
1556
|
+
type: new arrow4.Struct(names.map((name) => new arrow4.Field(name, new arrow4.Float64(), false))),
|
|
1557
|
+
children
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1560
|
+
function makeListData(child, offsets, fieldName, offsetType) {
|
|
1561
|
+
return arrow4.makeData({
|
|
1562
|
+
type: offsetType === "int64" ? makeLargeListType(new arrow4.Field(fieldName, child.type, false)) : new arrow4.List(new arrow4.Field(fieldName, child.type, false)),
|
|
1563
|
+
valueOffsets: offsets,
|
|
1564
|
+
child
|
|
1565
|
+
});
|
|
1566
|
+
}
|
|
1567
|
+
function makeLargeListType(field) {
|
|
1568
|
+
const LargeList = getOptionalArrowConstructor2("LargeList");
|
|
1569
|
+
if (!LargeList) {
|
|
1570
|
+
throw new Error(
|
|
1571
|
+
"64-bit GeoArrow offsets require an Apache Arrow runtime that exports LargeList"
|
|
1572
|
+
);
|
|
1573
|
+
}
|
|
1574
|
+
return new LargeList(field);
|
|
1575
|
+
}
|
|
1576
|
+
function getOptionalArrowConstructor2(typeName) {
|
|
1577
|
+
return arrow4[typeName];
|
|
1578
|
+
}
|
|
1579
|
+
function makeCoordinateBuffers(coordinateCount, dimension, coordinateLayout) {
|
|
1580
|
+
if (coordinateLayout === "interleaved") {
|
|
1581
|
+
return new Float64Array(coordinateCount * getCoordinateSize(dimension));
|
|
1582
|
+
}
|
|
1583
|
+
const coordinateNames = getCoordinateNames(dimension);
|
|
1584
|
+
const buffers = {
|
|
1585
|
+
x: new Float64Array(coordinateCount),
|
|
1586
|
+
y: new Float64Array(coordinateCount)
|
|
1587
|
+
};
|
|
1588
|
+
for (const name of coordinateNames.slice(2)) buffers[name] = new Float64Array(coordinateCount);
|
|
1589
|
+
return buffers;
|
|
1590
|
+
}
|
|
1591
|
+
function makeBoxBuffers(boxCount, dimension, coordinateLayout) {
|
|
1592
|
+
const names = getBoxFieldNames(dimension);
|
|
1593
|
+
if (coordinateLayout === "interleaved") {
|
|
1594
|
+
return new Float64Array(boxCount * names.length);
|
|
1595
|
+
}
|
|
1596
|
+
const buffers = {};
|
|
1597
|
+
for (const name of names) {
|
|
1598
|
+
buffers[name] = new Float64Array(boxCount);
|
|
1599
|
+
}
|
|
1600
|
+
return buffers;
|
|
1601
|
+
}
|
|
1602
|
+
function getBoxValues(dimension, xmin, ymin, xmax, ymax, zmin, zmax, mmin, mmax) {
|
|
1603
|
+
switch (dimension) {
|
|
1604
|
+
case "xy":
|
|
1605
|
+
return [xmin, ymin, xmax, ymax];
|
|
1606
|
+
case "xyz":
|
|
1607
|
+
return [xmin, ymin, zmin ?? Number.NaN, xmax, ymax, zmax ?? Number.NaN];
|
|
1608
|
+
case "xym":
|
|
1609
|
+
return [xmin, ymin, mmin ?? Number.NaN, xmax, ymax, mmax ?? Number.NaN];
|
|
1610
|
+
case "xyzm":
|
|
1611
|
+
return [
|
|
1612
|
+
xmin,
|
|
1613
|
+
ymin,
|
|
1614
|
+
zmin ?? Number.NaN,
|
|
1615
|
+
mmin ?? Number.NaN,
|
|
1616
|
+
xmax,
|
|
1617
|
+
ymax,
|
|
1618
|
+
zmax ?? Number.NaN,
|
|
1619
|
+
mmax ?? Number.NaN
|
|
1620
|
+
];
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
function getCoordinateNames(dimension) {
|
|
1624
|
+
switch (dimension) {
|
|
1625
|
+
case "xy":
|
|
1626
|
+
return ["x", "y"];
|
|
1627
|
+
case "xyz":
|
|
1628
|
+
return ["x", "y", "z"];
|
|
1629
|
+
case "xym":
|
|
1630
|
+
return ["x", "y", "m"];
|
|
1631
|
+
case "xyzm":
|
|
1632
|
+
return ["x", "y", "z", "m"];
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
function withNulls(data, geometryArray) {
|
|
1636
|
+
return new arrow4.Data(
|
|
1637
|
+
data.type,
|
|
1638
|
+
0,
|
|
1639
|
+
geometryArray.length,
|
|
1640
|
+
geometryArray.nullCount,
|
|
1641
|
+
[
|
|
1642
|
+
data.valueOffsets,
|
|
1643
|
+
data.values,
|
|
1644
|
+
geometryArray.nullCount > 0 ? geometryArray.nullBitmap : void 0
|
|
1645
|
+
],
|
|
1646
|
+
data.children
|
|
1647
|
+
);
|
|
1648
|
+
}
|
|
1649
|
+
var arrow4, GeoArrowBuilder;
|
|
1650
|
+
var init_geoarrow_builder = __esm({
|
|
1651
|
+
"../arrow-geometry/src/geoarrow-builder.ts"() {
|
|
1652
|
+
"use strict";
|
|
1653
|
+
arrow4 = __toESM(require("apache-arrow"), 1);
|
|
1654
|
+
GeoArrowBuilder = class _GeoArrowBuilder {
|
|
1655
|
+
/** GeoArrow extension encoding emitted by this builder. */
|
|
1656
|
+
encoding;
|
|
1657
|
+
/** Whether coordinate tuples include Z. */
|
|
1658
|
+
hasZ;
|
|
1659
|
+
/** Whether coordinate tuples include M. */
|
|
1660
|
+
hasM;
|
|
1661
|
+
/** Exact coordinate dimension emitted by this builder. */
|
|
1662
|
+
dimension;
|
|
1663
|
+
state;
|
|
1664
|
+
/** Creates a GeoArrow builder in measure or write mode. */
|
|
1665
|
+
constructor(options) {
|
|
1666
|
+
this.encoding = options.encoding;
|
|
1667
|
+
this.dimension = options.dimension || (options.hasZ && options.hasM ? "xyzm" : options.hasZ ? "xyz" : options.hasM ? "xym" : "xy");
|
|
1668
|
+
this.hasZ = this.dimension === "xyz" || this.dimension === "xyzm";
|
|
1669
|
+
this.hasM = this.dimension === "xym" || this.dimension === "xyzm";
|
|
1670
|
+
const coordinateLayout = options.coordinateLayout || "interleaved";
|
|
1671
|
+
const offsetType = options.offsetType || "int32";
|
|
1672
|
+
this.state = {
|
|
1673
|
+
mode: options.mode,
|
|
1674
|
+
encoding: options.encoding,
|
|
1675
|
+
coordinateSize: getCoordinateSize(this.dimension),
|
|
1676
|
+
coordinateLayout,
|
|
1677
|
+
offsetType,
|
|
1678
|
+
transform: options.transform,
|
|
1679
|
+
length: 0,
|
|
1680
|
+
nullCount: 0,
|
|
1681
|
+
coordinateCount: 0,
|
|
1682
|
+
geometryChildCount: 0,
|
|
1683
|
+
partChildCount: 0,
|
|
1684
|
+
geometryOffsetCount: 1,
|
|
1685
|
+
partOffsetCount: 1,
|
|
1686
|
+
ringOffsetCount: 1,
|
|
1687
|
+
target: options.mode === "write" ? options.target : void 0
|
|
1688
|
+
};
|
|
1689
|
+
this.initializeOffsets();
|
|
1690
|
+
}
|
|
1691
|
+
/** Emits one null geometry row. */
|
|
1692
|
+
writeNullGeometry() {
|
|
1693
|
+
this.state.length++;
|
|
1694
|
+
this.state.nullCount++;
|
|
1695
|
+
if (this.encoding !== "geoarrow.point" && this.encoding !== "geoarrow.box") {
|
|
1696
|
+
this.writeGeometryOffset();
|
|
1697
|
+
}
|
|
1698
|
+
if (this.encoding === "geoarrow.point") this.state.coordinateCount++;
|
|
1699
|
+
}
|
|
1700
|
+
/** Begins one top-level geometry. */
|
|
1701
|
+
beginGeometry(_type, _count) {
|
|
1702
|
+
this.setValid(this.state.length);
|
|
1703
|
+
this.state.length++;
|
|
1704
|
+
}
|
|
1705
|
+
/** Begins one point geometry or nested point. */
|
|
1706
|
+
beginPoint() {
|
|
1707
|
+
if (this.encoding === "geoarrow.point") this.beginGeometry();
|
|
1708
|
+
}
|
|
1709
|
+
/** Begins one axis-aligned GeoArrow box row. */
|
|
1710
|
+
beginBox() {
|
|
1711
|
+
if (this.encoding !== "geoarrow.box") {
|
|
1712
|
+
throw new Error(`Cannot write Box into ${this.encoding}`);
|
|
1713
|
+
}
|
|
1714
|
+
this.beginGeometry();
|
|
1715
|
+
}
|
|
1716
|
+
/** Writes one axis-aligned box in canonical minimum-then-maximum ordinate order. */
|
|
1717
|
+
writeBox(xmin, ymin, xmax, ymax, zmin, zmax, mmin, mmax) {
|
|
1718
|
+
if (this.encoding !== "geoarrow.box") {
|
|
1719
|
+
throw new Error(`Cannot write Box into ${this.encoding}`);
|
|
1720
|
+
}
|
|
1721
|
+
const coordinateIndex = this.state.coordinateCount;
|
|
1722
|
+
const values = getBoxValues(this.dimension, xmin, ymin, xmax, ymax, zmin, zmax, mmin, mmax);
|
|
1723
|
+
if (this.state.mode === "write") {
|
|
1724
|
+
this.writeBoxValues(this.getTarget().coordinates, coordinateIndex, values);
|
|
1725
|
+
}
|
|
1726
|
+
this.state.coordinateCount++;
|
|
1727
|
+
}
|
|
1728
|
+
/** Begins one line string geometry or nested line string. */
|
|
1729
|
+
beginLineString(pointCount) {
|
|
1730
|
+
if (this.encoding === "geoarrow.linestring") {
|
|
1731
|
+
this.beginGeometry();
|
|
1732
|
+
this.writeGeometryOffset(pointCount);
|
|
1733
|
+
return;
|
|
1734
|
+
}
|
|
1735
|
+
if (this.encoding === "geoarrow.multilinestring") {
|
|
1736
|
+
this.writePartOffset(pointCount);
|
|
1737
|
+
return;
|
|
1738
|
+
}
|
|
1739
|
+
throw new Error(`Cannot write LineString into ${this.encoding}`);
|
|
1740
|
+
}
|
|
1741
|
+
/** Begins one polygon geometry or nested polygon. */
|
|
1742
|
+
beginPolygon(ringCount) {
|
|
1743
|
+
if (this.encoding === "geoarrow.polygon") {
|
|
1744
|
+
this.beginGeometry();
|
|
1745
|
+
this.writeGeometryOffset(ringCount);
|
|
1746
|
+
return;
|
|
1747
|
+
}
|
|
1748
|
+
if (this.encoding === "geoarrow.multipolygon") {
|
|
1749
|
+
this.writePartOffset(ringCount);
|
|
1750
|
+
return;
|
|
1751
|
+
}
|
|
1752
|
+
throw new Error(`Cannot write Polygon into ${this.encoding}`);
|
|
1753
|
+
}
|
|
1754
|
+
/** Begins one polygon linear ring. */
|
|
1755
|
+
beginLinearRing(pointCount) {
|
|
1756
|
+
if (this.encoding === "geoarrow.polygon") {
|
|
1757
|
+
this.writePartOffset(pointCount);
|
|
1758
|
+
return;
|
|
1759
|
+
}
|
|
1760
|
+
if (this.encoding === "geoarrow.multipolygon") {
|
|
1761
|
+
this.writeRingOffset(pointCount);
|
|
1762
|
+
return;
|
|
1763
|
+
}
|
|
1764
|
+
throw new Error(`Cannot write LinearRing into ${this.encoding}`);
|
|
1765
|
+
}
|
|
1766
|
+
/** Begins one multipoint geometry. */
|
|
1767
|
+
beginMultiPoint(pointCount) {
|
|
1768
|
+
if (this.encoding !== "geoarrow.multipoint") {
|
|
1769
|
+
throw new Error(`Cannot write MultiPoint into ${this.encoding}`);
|
|
1770
|
+
}
|
|
1771
|
+
this.beginGeometry();
|
|
1772
|
+
this.writeGeometryOffset(pointCount);
|
|
1773
|
+
}
|
|
1774
|
+
/** Begins one multilinestring geometry. */
|
|
1775
|
+
beginMultiLineString(lineCount) {
|
|
1776
|
+
if (this.encoding !== "geoarrow.multilinestring") {
|
|
1777
|
+
throw new Error(`Cannot write MultiLineString into ${this.encoding}`);
|
|
1778
|
+
}
|
|
1779
|
+
this.beginGeometry();
|
|
1780
|
+
this.writeGeometryOffset(lineCount);
|
|
1781
|
+
}
|
|
1782
|
+
/** Begins one multipolygon geometry. */
|
|
1783
|
+
beginMultiPolygon(polygonCount) {
|
|
1784
|
+
if (this.encoding !== "geoarrow.multipolygon") {
|
|
1785
|
+
throw new Error(`Cannot write MultiPolygon into ${this.encoding}`);
|
|
1786
|
+
}
|
|
1787
|
+
this.beginGeometry();
|
|
1788
|
+
this.writeGeometryOffset(polygonCount);
|
|
1789
|
+
}
|
|
1790
|
+
/** Writes one coordinate tuple. The third ordinate is M for an XYM builder. */
|
|
1791
|
+
writeCoordinate(x, y, z, m) {
|
|
1792
|
+
const coordinateIndex = this.state.coordinateCount;
|
|
1793
|
+
if (this.state.mode === "write") {
|
|
1794
|
+
const target = this.getTarget();
|
|
1795
|
+
const coordinate = this.getCoordinateValuesForWrite(x, y, z, m);
|
|
1796
|
+
const transformedCoordinate = this.state.transform ? this.state.transform(coordinate) : coordinate;
|
|
1797
|
+
this.writeCoordinateValues(
|
|
1798
|
+
target.coordinates,
|
|
1799
|
+
coordinateIndex,
|
|
1800
|
+
transformedCoordinate,
|
|
1801
|
+
coordinate
|
|
1802
|
+
);
|
|
1803
|
+
}
|
|
1804
|
+
this.state.coordinateCount++;
|
|
1805
|
+
}
|
|
1806
|
+
/** Completes the current geometry array and returns its row count. */
|
|
1807
|
+
finishGeometry() {
|
|
1808
|
+
return this.state.length;
|
|
1809
|
+
}
|
|
1810
|
+
/** Returns current measured or written array metadata. */
|
|
1811
|
+
getGeometryArray() {
|
|
1812
|
+
return {
|
|
1813
|
+
encoding: this.encoding,
|
|
1814
|
+
coordinateSize: this.state.coordinateSize,
|
|
1815
|
+
dimension: this.dimension,
|
|
1816
|
+
coordinateLayout: this.state.coordinateLayout,
|
|
1817
|
+
offsetType: this.state.offsetType,
|
|
1818
|
+
length: this.state.length,
|
|
1819
|
+
nullCount: this.state.nullCount,
|
|
1820
|
+
nullBitmap: this.getNullBitmap(),
|
|
1821
|
+
coordinates: this.getCoordinateValues(),
|
|
1822
|
+
geometryOffsets: this.getGeometryOffsets(),
|
|
1823
|
+
partOffsets: this.getPartOffsets(),
|
|
1824
|
+
ringOffsets: this.getRingOffsets()
|
|
1825
|
+
};
|
|
1826
|
+
}
|
|
1827
|
+
/** Measures geometry callbacks and returns allocated offsets. */
|
|
1828
|
+
static measureGeometryArray(writers, options) {
|
|
1829
|
+
const builder = new _GeoArrowBuilder({ mode: "measure", ...options });
|
|
1830
|
+
for (const writer of writers) writer ? writer(builder) : builder.writeNullGeometry();
|
|
1831
|
+
builder.finishGeometry();
|
|
1832
|
+
return builder.getGeometryArray();
|
|
1833
|
+
}
|
|
1834
|
+
/** Writes geometry callbacks into a measured target. */
|
|
1835
|
+
static writeGeometryArray(writers, measured, options) {
|
|
1836
|
+
const builder = new _GeoArrowBuilder({ mode: "write", target: measured, ...options });
|
|
1837
|
+
for (const writer of writers) writer ? writer(builder) : builder.writeNullGeometry();
|
|
1838
|
+
builder.finishGeometry();
|
|
1839
|
+
return builder.getGeometryArray();
|
|
1840
|
+
}
|
|
1841
|
+
/** Builds GeoArrow buffers from callbacks in two passes. */
|
|
1842
|
+
static buildGeometryArray(writers, options) {
|
|
1843
|
+
const measured = _GeoArrowBuilder.measureGeometryArray(writers, options);
|
|
1844
|
+
return _GeoArrowBuilder.writeGeometryArray(writers, measured, options);
|
|
1845
|
+
}
|
|
1846
|
+
/** Wraps GeoArrow buffers in an Apache Arrow Data instance. */
|
|
1847
|
+
static makeGeometryData(geometryArray) {
|
|
1848
|
+
if (geometryArray.encoding === "geoarrow.box") {
|
|
1849
|
+
return withNulls(
|
|
1850
|
+
makeBoxData(geometryArray.coordinates, geometryArray.dimension),
|
|
1851
|
+
geometryArray
|
|
1852
|
+
);
|
|
1853
|
+
}
|
|
1854
|
+
const coordinateData = makeCoordinateData(
|
|
1855
|
+
geometryArray.coordinates,
|
|
1856
|
+
geometryArray.dimension,
|
|
1857
|
+
geometryArray.coordinateLayout
|
|
1858
|
+
);
|
|
1859
|
+
let data = coordinateData;
|
|
1860
|
+
switch (geometryArray.encoding) {
|
|
1861
|
+
case "geoarrow.point":
|
|
1862
|
+
return withNulls(data, geometryArray);
|
|
1863
|
+
case "geoarrow.linestring":
|
|
1864
|
+
case "geoarrow.multipoint":
|
|
1865
|
+
data = makeListData(
|
|
1866
|
+
coordinateData,
|
|
1867
|
+
geometryArray.geometryOffsets,
|
|
1868
|
+
"vertices",
|
|
1869
|
+
geometryArray.offsetType
|
|
1870
|
+
);
|
|
1871
|
+
return withNulls(data, geometryArray);
|
|
1872
|
+
case "geoarrow.polygon":
|
|
1873
|
+
case "geoarrow.multilinestring":
|
|
1874
|
+
data = makeListData(
|
|
1875
|
+
coordinateData,
|
|
1876
|
+
geometryArray.partOffsets,
|
|
1877
|
+
"vertices",
|
|
1878
|
+
geometryArray.offsetType
|
|
1879
|
+
);
|
|
1880
|
+
data = makeListData(
|
|
1881
|
+
data,
|
|
1882
|
+
geometryArray.geometryOffsets,
|
|
1883
|
+
"rings",
|
|
1884
|
+
geometryArray.offsetType
|
|
1885
|
+
);
|
|
1886
|
+
return withNulls(data, geometryArray);
|
|
1887
|
+
case "geoarrow.multipolygon":
|
|
1888
|
+
data = makeListData(
|
|
1889
|
+
coordinateData,
|
|
1890
|
+
geometryArray.ringOffsets,
|
|
1891
|
+
"vertices",
|
|
1892
|
+
geometryArray.offsetType
|
|
1893
|
+
);
|
|
1894
|
+
data = makeListData(data, geometryArray.partOffsets, "rings", geometryArray.offsetType);
|
|
1895
|
+
data = makeListData(
|
|
1896
|
+
data,
|
|
1897
|
+
geometryArray.geometryOffsets,
|
|
1898
|
+
"polygons",
|
|
1899
|
+
geometryArray.offsetType
|
|
1900
|
+
);
|
|
1901
|
+
return withNulls(data, geometryArray);
|
|
1902
|
+
default:
|
|
1903
|
+
throw new Error(`Unsupported GeoArrow encoding ${geometryArray.encoding}`);
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
initializeOffsets() {
|
|
1907
|
+
if (this.state.mode !== "measure") return;
|
|
1908
|
+
const target = {
|
|
1909
|
+
nullBitmap: new Uint8Array(0),
|
|
1910
|
+
coordinates: makeCoordinateBuffers(0, this.dimension, this.state.coordinateLayout)
|
|
1911
|
+
};
|
|
1912
|
+
if (this.encoding !== "geoarrow.point" && this.encoding !== "geoarrow.box") {
|
|
1913
|
+
target.geometryOffsets = this.makeOffsets(1);
|
|
1914
|
+
}
|
|
1915
|
+
if (this.encoding === "geoarrow.polygon" || this.encoding === "geoarrow.multilinestring" || this.encoding === "geoarrow.multipolygon") {
|
|
1916
|
+
target.partOffsets = this.makeOffsets(1);
|
|
1917
|
+
}
|
|
1918
|
+
if (this.encoding === "geoarrow.multipolygon") target.ringOffsets = this.makeOffsets(1);
|
|
1919
|
+
this.state.target = target;
|
|
1920
|
+
}
|
|
1921
|
+
getCoordinateValuesForWrite(x, y, z, m) {
|
|
1922
|
+
if (this.dimension === "xy") return [x, y];
|
|
1923
|
+
if (this.dimension === "xyz") return [x, y, z ?? Number.NaN];
|
|
1924
|
+
if (this.dimension === "xym") return [x, y, m ?? z ?? Number.NaN];
|
|
1925
|
+
return [x, y, z ?? Number.NaN, m ?? Number.NaN];
|
|
1926
|
+
}
|
|
1927
|
+
writeGeometryOffset(childCount = 0) {
|
|
1928
|
+
if (this.encoding === "geoarrow.point") return;
|
|
1929
|
+
this.state.geometryChildCount += childCount;
|
|
1930
|
+
this.appendOffset("geometryOffsets", this.state.geometryChildCount);
|
|
1931
|
+
}
|
|
1932
|
+
writePartOffset(childCount = 0) {
|
|
1933
|
+
this.state.partChildCount += childCount;
|
|
1934
|
+
this.appendOffset("partOffsets", this.state.partChildCount);
|
|
1935
|
+
}
|
|
1936
|
+
writeRingOffset(childCount = 0) {
|
|
1937
|
+
this.appendOffset("ringOffsets", this.state.coordinateCount + childCount);
|
|
1938
|
+
}
|
|
1939
|
+
appendOffset(name, value) {
|
|
1940
|
+
const target = this.getTarget();
|
|
1941
|
+
const offsets = target[name];
|
|
1942
|
+
if (!offsets) return;
|
|
1943
|
+
if (this.state.mode === "measure") {
|
|
1944
|
+
this.incrementOffsetCount(name);
|
|
1945
|
+
return;
|
|
1946
|
+
}
|
|
1947
|
+
const index = this.getOffsetCount(name);
|
|
1948
|
+
if (index >= offsets.length) throw new Error(`GeoArrowBuilder target ${name} overflow`);
|
|
1949
|
+
offsets[index] = offsets instanceof BigInt64Array ? BigInt(value) : value;
|
|
1950
|
+
this.incrementOffsetCount(name);
|
|
1951
|
+
}
|
|
1952
|
+
getOffsetCount(name) {
|
|
1953
|
+
switch (name) {
|
|
1954
|
+
case "geometryOffsets":
|
|
1955
|
+
return this.state.geometryOffsetCount;
|
|
1956
|
+
case "partOffsets":
|
|
1957
|
+
return this.state.partOffsetCount;
|
|
1958
|
+
case "ringOffsets":
|
|
1959
|
+
return this.state.ringOffsetCount;
|
|
1960
|
+
default:
|
|
1961
|
+
throw new Error(`Unexpected offset buffer ${name}`);
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
incrementOffsetCount(name) {
|
|
1965
|
+
switch (name) {
|
|
1966
|
+
case "geometryOffsets":
|
|
1967
|
+
this.state.geometryOffsetCount++;
|
|
1968
|
+
return;
|
|
1969
|
+
case "partOffsets":
|
|
1970
|
+
this.state.partOffsetCount++;
|
|
1971
|
+
return;
|
|
1972
|
+
case "ringOffsets":
|
|
1973
|
+
this.state.ringOffsetCount++;
|
|
1974
|
+
return;
|
|
1975
|
+
default:
|
|
1976
|
+
throw new Error(`Unexpected offset buffer ${name}`);
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
setValid(rowIndex) {
|
|
1980
|
+
if (this.state.mode !== "write") return;
|
|
1981
|
+
const bitmap = this.getTarget().nullBitmap;
|
|
1982
|
+
bitmap[rowIndex >> 3] |= 1 << (rowIndex & 7);
|
|
1983
|
+
}
|
|
1984
|
+
getTarget() {
|
|
1985
|
+
if (!this.state.target) throw new Error("GeoArrowBuilder target is not initialized");
|
|
1986
|
+
return this.state.target;
|
|
1987
|
+
}
|
|
1988
|
+
getNullBitmap() {
|
|
1989
|
+
return this.state.mode === "measure" ? new Uint8Array(Math.ceil(this.state.length / 8)) : this.getTarget().nullBitmap;
|
|
1990
|
+
}
|
|
1991
|
+
getCoordinateValues() {
|
|
1992
|
+
return this.state.mode === "measure" ? this.encoding === "geoarrow.box" ? makeBoxBuffers(this.state.coordinateCount, this.dimension, this.state.coordinateLayout) : makeCoordinateBuffers(
|
|
1993
|
+
this.state.coordinateCount,
|
|
1994
|
+
this.dimension,
|
|
1995
|
+
this.state.coordinateLayout
|
|
1996
|
+
) : this.getTarget().coordinates;
|
|
1997
|
+
}
|
|
1998
|
+
getGeometryOffsets() {
|
|
1999
|
+
return this.state.mode === "measure" && this.encoding !== "geoarrow.point" && this.encoding !== "geoarrow.box" ? this.makeOffsets(this.state.geometryOffsetCount) : this.getTarget().geometryOffsets;
|
|
2000
|
+
}
|
|
2001
|
+
getPartOffsets() {
|
|
2002
|
+
return this.state.mode === "measure" && (this.encoding === "geoarrow.polygon" || this.encoding === "geoarrow.multilinestring" || this.encoding === "geoarrow.multipolygon") ? this.makeOffsets(this.state.partOffsetCount) : this.getTarget().partOffsets;
|
|
2003
|
+
}
|
|
2004
|
+
getRingOffsets() {
|
|
2005
|
+
return this.state.mode === "measure" && this.encoding === "geoarrow.multipolygon" ? this.makeOffsets(this.state.ringOffsetCount) : this.getTarget().ringOffsets;
|
|
2006
|
+
}
|
|
2007
|
+
makeOffsets(length) {
|
|
2008
|
+
return this.state.offsetType === "int64" ? new BigInt64Array(length) : new Int32Array(length);
|
|
2009
|
+
}
|
|
2010
|
+
writeCoordinateValues(coordinates, coordinateIndex, transformedCoordinate, originalCoordinate) {
|
|
2011
|
+
if (coordinates instanceof Float64Array) {
|
|
2012
|
+
if (coordinateIndex >= coordinates.length / this.state.coordinateSize) {
|
|
2013
|
+
throw new Error("GeoArrowBuilder target coordinate buffer overflow");
|
|
2014
|
+
}
|
|
2015
|
+
const valueOffset = coordinateIndex * this.state.coordinateSize;
|
|
2016
|
+
for (let dimensionIndex = 0; dimensionIndex < this.state.coordinateSize; dimensionIndex++) {
|
|
2017
|
+
coordinates[valueOffset + dimensionIndex] = transformedCoordinate[dimensionIndex] ?? originalCoordinate[dimensionIndex] ?? Number.NaN;
|
|
2018
|
+
}
|
|
2019
|
+
return;
|
|
2020
|
+
}
|
|
2021
|
+
const coordinateNames = getCoordinateNames(this.dimension);
|
|
2022
|
+
for (let dimensionIndex = 0; dimensionIndex < coordinateNames.length; dimensionIndex++) {
|
|
2023
|
+
const coordinateValues = coordinates[coordinateNames[dimensionIndex]];
|
|
2024
|
+
if (!coordinateValues || coordinateIndex >= coordinateValues.length) {
|
|
2025
|
+
throw new Error("GeoArrowBuilder target coordinate buffer overflow");
|
|
2026
|
+
}
|
|
2027
|
+
coordinateValues[coordinateIndex] = transformedCoordinate[dimensionIndex] ?? originalCoordinate[dimensionIndex] ?? Number.NaN;
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
writeBoxValues(coordinates, coordinateIndex, values) {
|
|
2031
|
+
if (coordinates instanceof Float64Array) {
|
|
2032
|
+
const valueOffset = coordinateIndex * values.length;
|
|
2033
|
+
if (valueOffset + values.length > coordinates.length) {
|
|
2034
|
+
throw new Error("GeoArrowBuilder target box buffer overflow");
|
|
2035
|
+
}
|
|
2036
|
+
coordinates.set(values, valueOffset);
|
|
2037
|
+
return;
|
|
2038
|
+
}
|
|
2039
|
+
const boxCoordinates = coordinates;
|
|
2040
|
+
const names = getBoxFieldNames(this.dimension);
|
|
2041
|
+
for (let index = 0; index < names.length; index++) {
|
|
2042
|
+
const valuesBuffer = boxCoordinates[names[index]];
|
|
2043
|
+
if (!(valuesBuffer instanceof Float64Array) || coordinateIndex >= valuesBuffer.length) {
|
|
2044
|
+
throw new Error("GeoArrowBuilder target box buffer overflow");
|
|
2045
|
+
}
|
|
2046
|
+
valuesBuffer[coordinateIndex] = values[index];
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
2049
|
+
};
|
|
2050
|
+
}
|
|
2051
|
+
});
|
|
2052
|
+
|
|
2053
|
+
// ../arrow-geometry/src/index.ts
|
|
2054
|
+
var init_src = __esm({
|
|
2055
|
+
"../arrow-geometry/src/index.ts"() {
|
|
2056
|
+
"use strict";
|
|
2057
|
+
init_geoarrow_builder();
|
|
2058
|
+
}
|
|
2059
|
+
});
|
|
2060
|
+
|
|
2061
|
+
// dist/mlt/lib/parse-mlt.js
|
|
2062
|
+
function parseMLT(arrayBuffer, options) {
|
|
2063
|
+
const mltOptions = checkOptions(options);
|
|
2064
|
+
const shape = mltOptions.shape;
|
|
2065
|
+
switch (shape) {
|
|
2066
|
+
case "geojson-table": {
|
|
2067
|
+
const table = {
|
|
2068
|
+
shape: "geojson-table",
|
|
2069
|
+
type: "FeatureCollection",
|
|
2070
|
+
features: parseToGeojsonFeatures(arrayBuffer, mltOptions)
|
|
2071
|
+
};
|
|
2072
|
+
return table;
|
|
2073
|
+
}
|
|
2074
|
+
case "binary-geometry": {
|
|
2075
|
+
const geojsonFeatures = parseToGeojsonFeatures(arrayBuffer, mltOptions);
|
|
2076
|
+
const binaryData = convertGeojsonToBinaryFeatureCollection(geojsonFeatures);
|
|
2077
|
+
binaryData.byteLength = arrayBuffer.byteLength;
|
|
2078
|
+
return binaryData;
|
|
2079
|
+
}
|
|
2080
|
+
case "arrow-table":
|
|
2081
|
+
return parseToArrowTable(arrayBuffer, mltOptions);
|
|
2082
|
+
default:
|
|
2083
|
+
throw new Error(shape || "undefined shape");
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
function parseToArrowTable(arrayBuffer, options) {
|
|
2087
|
+
var _a;
|
|
2088
|
+
if (arrayBuffer.byteLength <= 0) {
|
|
2089
|
+
return makeWKBArrowTable([], [], []);
|
|
2090
|
+
}
|
|
2091
|
+
const tile = new Uint8Array(arrayBuffer);
|
|
2092
|
+
const featureTables = getFeatureTables(decodeTile(tile));
|
|
2093
|
+
const selectedLayers = options.layers && options.layers.length > 0 ? options.layers : featureTables.map((ft) => ft.name).filter(Boolean);
|
|
2094
|
+
const propertyRows = [];
|
|
2095
|
+
const geometryWriters = [];
|
|
2096
|
+
const geometries = [];
|
|
2097
|
+
for (const featureTable of featureTables) {
|
|
2098
|
+
const layerName = featureTable.name;
|
|
2099
|
+
if (!layerName || !selectedLayers.includes(layerName)) {
|
|
2100
|
+
continue;
|
|
2101
|
+
}
|
|
2102
|
+
const geometryVector = featureTable.geometryVector;
|
|
2103
|
+
if (!geometryVector) {
|
|
2104
|
+
continue;
|
|
2105
|
+
}
|
|
2106
|
+
const tableGeometries = geometryVector.getGeometries();
|
|
2107
|
+
const featureCount = Math.min(geometryVector.numGeometries, tableGeometries.length);
|
|
2108
|
+
const propertyVectors = featureTable.propertyVectors || [];
|
|
2109
|
+
const extent = featureTable.extent ?? 4096;
|
|
2110
|
+
for (let featureIndex = 0; featureIndex < featureCount; featureIndex++) {
|
|
2111
|
+
const geometry = {
|
|
2112
|
+
type: geometryVector.geometryType(featureIndex),
|
|
2113
|
+
coordinates: tableGeometries[featureIndex],
|
|
2114
|
+
extent
|
|
2115
|
+
};
|
|
2116
|
+
const properties = {};
|
|
2117
|
+
for (const propertyVector of propertyVectors) {
|
|
2118
|
+
properties[propertyVector.name] = normalizePropertyValue(propertyVector.getValue(featureIndex));
|
|
2119
|
+
}
|
|
2120
|
+
if (options.layerProperty) {
|
|
2121
|
+
properties[options.layerProperty] = layerName;
|
|
2122
|
+
}
|
|
2123
|
+
propertyRows.push(properties);
|
|
2124
|
+
geometries.push(geometry);
|
|
2125
|
+
geometryWriters.push(createWKBGeometryWriter(geometry, options, extent));
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
const encodingPreference = (_a = options.geoarrow) == null ? void 0 : _a.encodingPreference;
|
|
2129
|
+
if (encodingPreference && encodingPreference !== "geoarrow.wkb") {
|
|
2130
|
+
return makeNativeArrowTable(propertyRows, geometries, options, encodingPreference);
|
|
2131
|
+
}
|
|
2132
|
+
return makeWKBArrowTable(propertyRows, geometryWriters, geometries);
|
|
2133
|
+
}
|
|
2134
|
+
function makeWKBArrowTable(propertyRows, geometryWriters, geometries) {
|
|
2135
|
+
const propertySchema = getPropertySchema(propertyRows);
|
|
2136
|
+
const schema = {
|
|
2137
|
+
fields: [...propertySchema.fields, makeWKBGeometryField("geometry")],
|
|
2138
|
+
metadata: { ...propertySchema.metadata || {} }
|
|
2139
|
+
};
|
|
2140
|
+
setWKBGeometrySchemaMetadata(schema, {
|
|
2141
|
+
geometryColumnName: "geometry",
|
|
2142
|
+
geometryTypes: [
|
|
2143
|
+
...new Set(geometries.map((geometry) => geometryTypeToGeoJSONType(geometry.type)))
|
|
2144
|
+
].filter(Boolean).map((type) => type)
|
|
2145
|
+
});
|
|
2146
|
+
const propertyBuilder = new ArrowTableBuilder(propertySchema);
|
|
2147
|
+
for (const propertyRow of propertyRows) {
|
|
2148
|
+
propertyBuilder.addObjectRow(propertyRow);
|
|
2149
|
+
}
|
|
2150
|
+
const propertyData = propertyBuilder.finishTable().data;
|
|
2151
|
+
const propertyBatch = propertyData.batches[0];
|
|
2152
|
+
const geometryData = makeWKBGeometryDataFromWriters(geometryWriters);
|
|
2153
|
+
const arrowSchema = convertSchemaToArrow(schema);
|
|
2154
|
+
const children = [...(propertyBatch == null ? void 0 : propertyBatch.data.children) || [], geometryData];
|
|
2155
|
+
const structData = arrow5.makeData({
|
|
2156
|
+
type: new arrow5.Struct(arrowSchema.fields),
|
|
2157
|
+
length: propertyRows.length,
|
|
2158
|
+
nullCount: 0,
|
|
2159
|
+
children
|
|
2160
|
+
});
|
|
2161
|
+
return {
|
|
2162
|
+
shape: "arrow-table",
|
|
2163
|
+
schema,
|
|
2164
|
+
data: new arrow5.Table(new arrow5.RecordBatch(arrowSchema, structData))
|
|
2165
|
+
};
|
|
2166
|
+
}
|
|
2167
|
+
function makeNativeArrowTable(propertyRows, geometries, options, encodingPreference) {
|
|
2168
|
+
const dimension = "xy";
|
|
2169
|
+
const encoding = selectGeoArrowEncoding(geometries, encodingPreference);
|
|
2170
|
+
const geometryVector = encoding === "geoarrow.geometry" ? makeGeoArrowUnionVector(geometries, options, dimension) : makeGeoArrowVector(geometries, encoding, options, dimension);
|
|
2171
|
+
const propertySchema = getPropertySchema(propertyRows);
|
|
2172
|
+
const propertyTableBuilder = new ArrowTableBuilder(propertySchema);
|
|
2173
|
+
for (const propertyRow of propertyRows) {
|
|
2174
|
+
propertyTableBuilder.addObjectRow(propertyRow);
|
|
2175
|
+
}
|
|
2176
|
+
const propertyBatch = propertyTableBuilder.finishTable().data.batches[0];
|
|
2177
|
+
const propertyArrowSchema = convertSchemaToArrow(propertySchema);
|
|
2178
|
+
const geometryTypes = [
|
|
2179
|
+
...new Set(geometries.map((geometry) => geometryTypeToGeoJSONType(geometry.type)))
|
|
2180
|
+
].filter(Boolean).map((type) => type);
|
|
2181
|
+
const geometryField = new arrow5.Field("geometry", geometryVector.type, true, /* @__PURE__ */ new Map([
|
|
2182
|
+
["ARROW:extension:name", encoding],
|
|
2183
|
+
["ARROW:extension:metadata", JSON.stringify({ encoding, geometry_types: geometryTypes })]
|
|
2184
|
+
]));
|
|
2185
|
+
const fields = [...propertyArrowSchema.fields, geometryField];
|
|
2186
|
+
const metadata = new Map(propertyArrowSchema.metadata || []);
|
|
2187
|
+
metadata.set("geo", JSON.stringify({
|
|
2188
|
+
version: "1.1.0",
|
|
2189
|
+
primary_column: "geometry",
|
|
2190
|
+
columns: { geometry: { encoding, geometry_types: geometryTypes } }
|
|
2191
|
+
}));
|
|
2192
|
+
const arrowSchema = new arrow5.Schema(fields, metadata);
|
|
2193
|
+
const children = [...(propertyBatch == null ? void 0 : propertyBatch.data.children) || [], geometryVector.data[0]];
|
|
2194
|
+
const structData = arrow5.makeData({
|
|
2195
|
+
type: new arrow5.Struct(fields),
|
|
2196
|
+
length: propertyRows.length,
|
|
2197
|
+
nullCount: 0,
|
|
2198
|
+
children
|
|
2199
|
+
});
|
|
2200
|
+
return {
|
|
2201
|
+
shape: "arrow-table",
|
|
2202
|
+
schema: convertArrowToSchema(arrowSchema),
|
|
2203
|
+
data: new arrow5.Table(new arrow5.RecordBatch(arrowSchema, structData))
|
|
2204
|
+
};
|
|
2205
|
+
}
|
|
2206
|
+
function selectGeoArrowEncoding(geometries, preference) {
|
|
2207
|
+
const geometryTypes = new Set(geometries.map((geometry) => geometryTypeToGeoJSONType(geometry.type)));
|
|
2208
|
+
if (preference === "geoarrow.geometry" || geometryTypes.size === 0) {
|
|
2209
|
+
return "geoarrow.geometry";
|
|
2210
|
+
}
|
|
2211
|
+
if (geometryTypes.size === 1) {
|
|
2212
|
+
return getNativeGeoArrowEncoding([...geometryTypes][0]);
|
|
2213
|
+
}
|
|
2214
|
+
if (geometryTypes.size === 2) {
|
|
2215
|
+
if (geometryTypes.has("Point") && geometryTypes.has("MultiPoint")) {
|
|
2216
|
+
return "geoarrow.multipoint";
|
|
2217
|
+
}
|
|
2218
|
+
if (geometryTypes.has("LineString") && geometryTypes.has("MultiLineString")) {
|
|
2219
|
+
return "geoarrow.multilinestring";
|
|
2220
|
+
}
|
|
2221
|
+
if (geometryTypes.has("Polygon") && geometryTypes.has("MultiPolygon")) {
|
|
2222
|
+
return "geoarrow.multipolygon";
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
return "geoarrow.geometry";
|
|
2226
|
+
}
|
|
2227
|
+
function makeGeoArrowVector(geometries, encoding, options, dimension) {
|
|
2228
|
+
const writers = geometries.map((geometry) => createGeoArrowGeometryWriter(geometry, encoding, options));
|
|
2229
|
+
const geometryArray = GeoArrowBuilder.buildGeometryArray(writers, { encoding, dimension });
|
|
2230
|
+
return arrow5.makeVector(GeoArrowBuilder.makeGeometryData(geometryArray));
|
|
2231
|
+
}
|
|
2232
|
+
function makeGeoArrowUnionVector(geometries, options, dimension) {
|
|
2233
|
+
const geometryGroups = /* @__PURE__ */ new Map();
|
|
2234
|
+
const supportedGeometryTypes = [
|
|
2235
|
+
"Point",
|
|
2236
|
+
"LineString",
|
|
2237
|
+
"Polygon",
|
|
2238
|
+
"MultiPoint",
|
|
2239
|
+
"MultiLineString",
|
|
2240
|
+
"MultiPolygon"
|
|
2241
|
+
];
|
|
2242
|
+
for (const geometryType of supportedGeometryTypes) {
|
|
2243
|
+
geometryGroups.set(geometryType, []);
|
|
2244
|
+
}
|
|
2245
|
+
const typeIds = [];
|
|
2246
|
+
const valueOffsets = [];
|
|
2247
|
+
for (const geometry of geometries) {
|
|
2248
|
+
const geometryType = geometryTypeToGeoJSONType(geometry.type) || "Point";
|
|
2249
|
+
const group = geometryGroups.get(geometryType) || [];
|
|
2250
|
+
valueOffsets.push(group.length);
|
|
2251
|
+
typeIds.push(getUnionTypeId(geometryType, dimension));
|
|
2252
|
+
group.push(geometry);
|
|
2253
|
+
geometryGroups.set(geometryType, group);
|
|
2254
|
+
}
|
|
2255
|
+
const orderedGeometryTypes = [...geometryGroups.keys()].sort((left, right) => getUnionTypeId(left, dimension) - getUnionTypeId(right, dimension));
|
|
2256
|
+
const childVectors = orderedGeometryTypes.map((geometryType) => {
|
|
2257
|
+
const encoding = getNativeGeoArrowEncoding(geometryType);
|
|
2258
|
+
return makeGeoArrowVector(geometryGroups.get(geometryType), encoding, options, dimension);
|
|
2259
|
+
});
|
|
2260
|
+
const fields = orderedGeometryTypes.map((geometryType) => new arrow5.Field(getUnionFieldName(geometryType, dimension), childVectors[orderedGeometryTypes.indexOf(geometryType)].type, true));
|
|
2261
|
+
const unionType = new arrow5.DenseUnion(orderedGeometryTypes.map((geometryType) => getUnionTypeId(geometryType, dimension)), fields);
|
|
2262
|
+
return arrow5.makeVector(arrow5.makeData({
|
|
2263
|
+
type: unionType,
|
|
2264
|
+
length: geometries.length,
|
|
2265
|
+
nullCount: 0,
|
|
2266
|
+
typeIds: Int8Array.from(typeIds),
|
|
2267
|
+
valueOffsets: Int32Array.from(valueOffsets),
|
|
2268
|
+
children: childVectors.map((vector) => vector.data[0])
|
|
2269
|
+
}));
|
|
2270
|
+
}
|
|
2271
|
+
function createGeoArrowGeometryWriter(geometry, encoding, options) {
|
|
2272
|
+
return (builder) => {
|
|
2273
|
+
var _a;
|
|
2274
|
+
const coordinates = geometry.coordinates;
|
|
2275
|
+
switch (geometryTypeToGeoJSONType(geometry.type)) {
|
|
2276
|
+
case "Point":
|
|
2277
|
+
if (encoding === "geoarrow.multipoint")
|
|
2278
|
+
builder.beginMultiPoint(1);
|
|
2279
|
+
builder.beginPoint();
|
|
2280
|
+
writeGeoArrowPoint(builder, (_a = coordinates[0]) == null ? void 0 : _a[0], options, geometry.extent);
|
|
2281
|
+
return;
|
|
2282
|
+
case "MultiPoint":
|
|
2283
|
+
builder.beginMultiPoint(coordinates.length);
|
|
2284
|
+
for (const [point] of coordinates) {
|
|
2285
|
+
builder.beginPoint();
|
|
2286
|
+
writeGeoArrowPoint(builder, point, options, geometry.extent);
|
|
2287
|
+
}
|
|
2288
|
+
return;
|
|
2289
|
+
case "LineString":
|
|
2290
|
+
if (encoding === "geoarrow.multilinestring")
|
|
2291
|
+
builder.beginMultiLineString(1);
|
|
2292
|
+
writeGeoArrowLineString(builder, coordinates[0] || [], options, geometry.extent);
|
|
2293
|
+
return;
|
|
2294
|
+
case "MultiLineString":
|
|
2295
|
+
builder.beginMultiLineString(coordinates.length);
|
|
2296
|
+
for (const line of coordinates)
|
|
2297
|
+
writeGeoArrowLineString(builder, line, options, geometry.extent);
|
|
2298
|
+
return;
|
|
2299
|
+
case "Polygon":
|
|
2300
|
+
if (encoding === "geoarrow.multipolygon")
|
|
2301
|
+
builder.beginMultiPolygon(1);
|
|
2302
|
+
writeGeoArrowPolygon(builder, coordinates, options, geometry.extent);
|
|
2303
|
+
return;
|
|
2304
|
+
case "MultiPolygon":
|
|
2305
|
+
builder.beginMultiPolygon(coordinates.length);
|
|
2306
|
+
for (const ring of coordinates) {
|
|
2307
|
+
builder.beginPolygon(1);
|
|
2308
|
+
builder.beginLinearRing(ring.length);
|
|
2309
|
+
for (const point of ring)
|
|
2310
|
+
writeGeoArrowPoint(builder, point, options, geometry.extent);
|
|
2311
|
+
}
|
|
2312
|
+
return;
|
|
2313
|
+
default:
|
|
2314
|
+
return;
|
|
2315
|
+
}
|
|
2316
|
+
};
|
|
2317
|
+
}
|
|
2318
|
+
function writeGeoArrowPoint(builder, point, options, extent) {
|
|
2319
|
+
const [x, y] = projectPoint((point == null ? void 0 : point.x) ?? Number.NaN, (point == null ? void 0 : point.y) ?? Number.NaN, options, extent);
|
|
2320
|
+
builder.writeCoordinate(x, y);
|
|
2321
|
+
}
|
|
2322
|
+
function writeGeoArrowLineString(builder, line, options, extent) {
|
|
2323
|
+
builder.beginLineString(line.length);
|
|
2324
|
+
for (const point of line)
|
|
2325
|
+
writeGeoArrowPoint(builder, point, options, extent);
|
|
2326
|
+
}
|
|
2327
|
+
function writeGeoArrowPolygon(builder, rings, options, extent) {
|
|
2328
|
+
builder.beginPolygon(rings.length);
|
|
2329
|
+
for (const ring of rings) {
|
|
2330
|
+
builder.beginLinearRing(ring.length);
|
|
2331
|
+
for (const point of ring)
|
|
2332
|
+
writeGeoArrowPoint(builder, point, options, extent);
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
function getNativeGeoArrowEncoding(geometryType) {
|
|
2336
|
+
switch (geometryType) {
|
|
2337
|
+
case "Point":
|
|
2338
|
+
return "geoarrow.point";
|
|
2339
|
+
case "LineString":
|
|
2340
|
+
return "geoarrow.linestring";
|
|
2341
|
+
case "Polygon":
|
|
2342
|
+
return "geoarrow.polygon";
|
|
2343
|
+
case "MultiPoint":
|
|
2344
|
+
return "geoarrow.multipoint";
|
|
2345
|
+
case "MultiLineString":
|
|
2346
|
+
return "geoarrow.multilinestring";
|
|
2347
|
+
case "MultiPolygon":
|
|
2348
|
+
return "geoarrow.multipolygon";
|
|
2349
|
+
default:
|
|
2350
|
+
throw new Error(`MLT Loader: unsupported GeoArrow geometry type ${geometryType}`);
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
function getUnionTypeId(geometryType, dimension) {
|
|
2354
|
+
const baseTypeIds = {
|
|
2355
|
+
Point: 1,
|
|
2356
|
+
LineString: 2,
|
|
2357
|
+
Polygon: 3,
|
|
2358
|
+
MultiPoint: 4,
|
|
2359
|
+
MultiLineString: 5,
|
|
2360
|
+
MultiPolygon: 6
|
|
2361
|
+
};
|
|
2362
|
+
const dimensionOffset = dimension === "xyz" ? 10 : dimension === "xym" ? 20 : dimension === "xyzm" ? 30 : 0;
|
|
2363
|
+
return (baseTypeIds[geometryType] || baseTypeIds.Point) + dimensionOffset;
|
|
2364
|
+
}
|
|
2365
|
+
function getUnionFieldName(geometryType, dimension) {
|
|
2366
|
+
return dimension === "xy" ? geometryType : `${geometryType} ${dimension.slice(1).toUpperCase()}`;
|
|
2367
|
+
}
|
|
2368
|
+
function getPropertySchema(propertyRows) {
|
|
2369
|
+
const fieldNames = /* @__PURE__ */ new Set();
|
|
2370
|
+
for (const propertyRow of propertyRows) {
|
|
2371
|
+
for (const fieldName of Object.keys(propertyRow)) {
|
|
2372
|
+
fieldNames.add(fieldName);
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
return {
|
|
2376
|
+
metadata: {},
|
|
2377
|
+
fields: [...fieldNames].map((fieldName) => {
|
|
2378
|
+
const inferredType = getDataTypeFromArray(propertyRows.map((propertyRow) => propertyRow[fieldName]));
|
|
2379
|
+
return {
|
|
2380
|
+
name: fieldName,
|
|
2381
|
+
type: inferredType.type === "float32" ? "float64" : inferredType.type,
|
|
2382
|
+
nullable: inferredType.nullable
|
|
2383
|
+
};
|
|
2384
|
+
})
|
|
2385
|
+
};
|
|
2386
|
+
}
|
|
2387
|
+
function normalizePropertyValue(propertyValue) {
|
|
2388
|
+
if (propertyValue === null || propertyValue === void 0 || typeof propertyValue === "string" || typeof propertyValue === "number" || typeof propertyValue === "boolean") {
|
|
2389
|
+
return propertyValue ?? null;
|
|
2390
|
+
}
|
|
2391
|
+
return JSON.stringify(propertyValue);
|
|
2392
|
+
}
|
|
2393
|
+
function createWKBGeometryWriter(geometry, options, extent) {
|
|
2394
|
+
const geometryType = geometryTypeToGeoJSONType(geometry.type);
|
|
2395
|
+
if (!geometryType || !geometry.coordinates) {
|
|
2396
|
+
return null;
|
|
2397
|
+
}
|
|
2398
|
+
const transform = (coordinate) => projectPoint(coordinate[0], coordinate[1], options, extent);
|
|
2399
|
+
return (builder) => {
|
|
2400
|
+
var _a, _b;
|
|
2401
|
+
const coordinates = geometry.coordinates;
|
|
2402
|
+
switch (geometryType) {
|
|
2403
|
+
case "Point":
|
|
2404
|
+
if (!((_a = coordinates[0]) == null ? void 0 : _a[0]))
|
|
2405
|
+
return;
|
|
2406
|
+
builder.beginPoint();
|
|
2407
|
+
writePoint(builder, coordinates[0][0], transform);
|
|
2408
|
+
return;
|
|
2409
|
+
case "MultiPoint":
|
|
2410
|
+
builder.beginMultiPoint(coordinates.length);
|
|
2411
|
+
for (const [point] of coordinates)
|
|
2412
|
+
writePoint(builder, point, transform);
|
|
2413
|
+
return;
|
|
2414
|
+
case "LineString":
|
|
2415
|
+
builder.beginLineString(((_b = coordinates[0]) == null ? void 0 : _b.length) || 0);
|
|
2416
|
+
for (const point of coordinates[0] || [])
|
|
2417
|
+
writePoint(builder, point, transform);
|
|
2418
|
+
return;
|
|
2419
|
+
case "MultiLineString":
|
|
2420
|
+
builder.beginMultiLineString(coordinates.length);
|
|
2421
|
+
for (const line of coordinates) {
|
|
2422
|
+
builder.beginLineString(line.length);
|
|
2423
|
+
for (const point of line)
|
|
2424
|
+
writePoint(builder, point, transform);
|
|
2425
|
+
}
|
|
2426
|
+
return;
|
|
2427
|
+
case "Polygon":
|
|
2428
|
+
builder.beginPolygon(coordinates.length);
|
|
2429
|
+
for (const ring of coordinates) {
|
|
2430
|
+
builder.beginLinearRing(ring.length);
|
|
2431
|
+
for (const point of ring)
|
|
2432
|
+
writePoint(builder, point, transform);
|
|
2433
|
+
}
|
|
2434
|
+
return;
|
|
2435
|
+
case "MultiPolygon":
|
|
2436
|
+
builder.beginMultiPolygon(coordinates.length);
|
|
2437
|
+
for (const ring of coordinates) {
|
|
2438
|
+
builder.beginPolygon(1);
|
|
2439
|
+
builder.beginLinearRing(ring.length);
|
|
2440
|
+
for (const point of ring)
|
|
2441
|
+
writePoint(builder, point, transform);
|
|
2442
|
+
}
|
|
2443
|
+
return;
|
|
2444
|
+
default:
|
|
2445
|
+
return;
|
|
2446
|
+
}
|
|
2447
|
+
};
|
|
2448
|
+
}
|
|
2449
|
+
function writePoint(builder, point, transform) {
|
|
2450
|
+
if (!point) {
|
|
2451
|
+
builder.writeCoordinate(Number.NaN, Number.NaN);
|
|
2452
|
+
return;
|
|
2453
|
+
}
|
|
2454
|
+
const [x, y] = transform([point.x, point.y]);
|
|
2455
|
+
builder.writeCoordinate(x, y);
|
|
2456
|
+
}
|
|
2457
|
+
function geometryTypeToGeoJSONType(type) {
|
|
2458
|
+
for (const [name, value] of Object.entries(GEOMETRY_TYPE)) {
|
|
2459
|
+
if (value === type) {
|
|
2460
|
+
const normalizedName = name.toLowerCase();
|
|
2461
|
+
return normalizedName === "point" ? "Point" : normalizedName === "linestring" ? "LineString" : normalizedName === "polygon" ? "Polygon" : normalizedName === "multipoint" ? "MultiPoint" : normalizedName === "multilinestring" ? "MultiLineString" : normalizedName === "multipolygon" ? "MultiPolygon" : null;
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
return null;
|
|
2465
|
+
}
|
|
2466
|
+
function parseToGeojsonFeatures(arrayBuffer, options) {
|
|
2467
|
+
if (arrayBuffer.byteLength <= 0) {
|
|
2468
|
+
return [];
|
|
2469
|
+
}
|
|
2470
|
+
const tile = new Uint8Array(arrayBuffer);
|
|
2471
|
+
const featureTables = getFeatureTables(decodeTile(tile));
|
|
2472
|
+
const features = [];
|
|
2473
|
+
const selectedLayers = options.layers && options.layers.length > 0 ? options.layers : featureTables.map((ft) => ft.name).filter(Boolean);
|
|
2474
|
+
for (const featureTable of featureTables) {
|
|
2475
|
+
const layerName = featureTable.name;
|
|
2476
|
+
if (!layerName || !selectedLayers.includes(layerName)) {
|
|
2477
|
+
continue;
|
|
2478
|
+
}
|
|
2479
|
+
const extent = featureTable.extent ?? 4096;
|
|
2480
|
+
for (const mltFeature of getTableFeatures(featureTable)) {
|
|
2481
|
+
const geoJSONFeature = convertFeatureToGeoJSON(mltFeature, options, layerName, extent);
|
|
2482
|
+
if (geoJSONFeature) {
|
|
2483
|
+
features.push(geoJSONFeature);
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
2487
|
+
return features;
|
|
2488
|
+
}
|
|
2489
|
+
function getFeatureTables(decodedTile) {
|
|
2490
|
+
if (Array.isArray(decodedTile)) {
|
|
2491
|
+
return decodedTile.filter((candidate) => isFeatureTable(candidate));
|
|
2492
|
+
}
|
|
2493
|
+
if (!decodedTile || typeof decodedTile !== "object") {
|
|
2494
|
+
return [];
|
|
2495
|
+
}
|
|
2496
|
+
return Object.values(decodedTile).filter((candidate) => isFeatureTable(candidate));
|
|
2497
|
+
}
|
|
2498
|
+
function isFeatureTable(candidate) {
|
|
2499
|
+
if (!candidate || typeof candidate !== "object") {
|
|
2500
|
+
return false;
|
|
2501
|
+
}
|
|
2502
|
+
return typeof candidate.name === "string" && (typeof candidate.getFeatures === "function" || Array.isArray(candidate.features) || typeof candidate[Symbol.iterator] === "function");
|
|
2503
|
+
}
|
|
2504
|
+
function getTableFeatures(featureTable) {
|
|
2505
|
+
var _a;
|
|
2506
|
+
if (typeof featureTable.getFeatures === "function") {
|
|
2507
|
+
const features = featureTable.getFeatures();
|
|
2508
|
+
if (Array.isArray(features)) {
|
|
2509
|
+
return features;
|
|
2510
|
+
}
|
|
2511
|
+
}
|
|
2512
|
+
if (Array.isArray(featureTable.features)) {
|
|
2513
|
+
return featureTable.features;
|
|
2514
|
+
}
|
|
2515
|
+
if (typeof featureTable[Symbol.iterator] === "function") {
|
|
2516
|
+
const iterableFeatures = (_a = featureTable[Symbol.iterator]) == null ? void 0 : _a.call(featureTable);
|
|
2517
|
+
if (!iterableFeatures) {
|
|
2518
|
+
return [];
|
|
2519
|
+
}
|
|
2520
|
+
return Array.isArray(iterableFeatures) ? iterableFeatures : Array.from(iterableFeatures);
|
|
2521
|
+
}
|
|
2522
|
+
return [];
|
|
2523
|
+
}
|
|
2524
|
+
function convertFeatureToGeoJSON(feature, options, layerName, extent) {
|
|
2525
|
+
const { geometry, properties, id } = feature;
|
|
2526
|
+
if (!geometry) {
|
|
2527
|
+
return null;
|
|
2528
|
+
}
|
|
2529
|
+
const geojsonGeometry = convertGeometryToGeoJSON(geometry, options, extent);
|
|
2530
|
+
if (!geojsonGeometry) {
|
|
2531
|
+
return null;
|
|
2532
|
+
}
|
|
2533
|
+
const featureProperties = { ...properties };
|
|
2534
|
+
if (options.layerProperty) {
|
|
2535
|
+
featureProperties[options.layerProperty] = layerName;
|
|
2536
|
+
}
|
|
2537
|
+
const geojsonFeature = {
|
|
2538
|
+
type: "Feature",
|
|
2539
|
+
geometry: geojsonGeometry,
|
|
2540
|
+
properties: featureProperties
|
|
2541
|
+
};
|
|
2542
|
+
if (id !== void 0 && id !== null) {
|
|
2543
|
+
geojsonFeature.id = typeof id === "bigint" && id >= 0n && id <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(id) : id;
|
|
2544
|
+
}
|
|
2545
|
+
return geojsonFeature;
|
|
2546
|
+
}
|
|
2547
|
+
function convertGeometryToGeoJSON(geometry, options, extent) {
|
|
2548
|
+
if (!geometry) {
|
|
2549
|
+
return null;
|
|
2550
|
+
}
|
|
2551
|
+
const { type, coordinates } = geometry;
|
|
2552
|
+
switch (type) {
|
|
2553
|
+
case GEOMETRY_TYPE.POINT: {
|
|
2554
|
+
const ring = coordinates == null ? void 0 : coordinates[0];
|
|
2555
|
+
const point = ring == null ? void 0 : ring[0];
|
|
2556
|
+
if (!point || typeof point.x !== "number" || typeof point.y !== "number") {
|
|
2557
|
+
return null;
|
|
2558
|
+
}
|
|
2559
|
+
return {
|
|
2560
|
+
type: "Point",
|
|
2561
|
+
coordinates: projectPoint(point.x, point.y, options, extent)
|
|
2562
|
+
};
|
|
2563
|
+
}
|
|
2564
|
+
case GEOMETRY_TYPE.MULTIPOINT: {
|
|
2565
|
+
return {
|
|
2566
|
+
type: "MultiPoint",
|
|
2567
|
+
coordinates: coordinates.map(([p]) => projectPoint(p.x, p.y, options, extent))
|
|
2568
|
+
};
|
|
2569
|
+
}
|
|
2570
|
+
case GEOMETRY_TYPE.LINESTRING: {
|
|
2571
|
+
return {
|
|
2572
|
+
type: "LineString",
|
|
2573
|
+
coordinates: coordinates[0].map((p) => projectPoint(p.x, p.y, options, extent))
|
|
2574
|
+
};
|
|
2575
|
+
}
|
|
2576
|
+
case GEOMETRY_TYPE.MULTILINESTRING: {
|
|
2577
|
+
return {
|
|
2578
|
+
type: "MultiLineString",
|
|
2579
|
+
coordinates: coordinates.map((ring) => ring.map((p) => projectPoint(p.x, p.y, options, extent)))
|
|
2580
|
+
};
|
|
2581
|
+
}
|
|
2582
|
+
case GEOMETRY_TYPE.POLYGON: {
|
|
2583
|
+
return {
|
|
2584
|
+
type: "Polygon",
|
|
2585
|
+
coordinates: coordinates.map((ring) => ring.map((p) => projectPoint(p.x, p.y, options, extent)))
|
|
2586
|
+
};
|
|
2587
|
+
}
|
|
2588
|
+
case GEOMETRY_TYPE.MULTIPOLYGON: {
|
|
2589
|
+
return {
|
|
2590
|
+
type: "MultiPolygon",
|
|
2591
|
+
coordinates: coordinates.map((ring) => [
|
|
2592
|
+
ring.map((p) => projectPoint(p.x, p.y, options, extent))
|
|
2593
|
+
])
|
|
2594
|
+
};
|
|
2595
|
+
}
|
|
2596
|
+
default:
|
|
2597
|
+
return null;
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
function projectPoint(x, y, options, extent) {
|
|
2601
|
+
if (options.coordinates === "wgs84" && options.tileIndex) {
|
|
2602
|
+
const { x: tx, y: ty, z } = options.tileIndex;
|
|
2603
|
+
const size = extent * Math.pow(2, z);
|
|
2604
|
+
const x0 = extent * tx;
|
|
2605
|
+
const y0 = extent * ty;
|
|
2606
|
+
const lng = (x + x0) * 360 / size - 180;
|
|
2607
|
+
const y2 = 180 - (y + y0) * 360 / size;
|
|
2608
|
+
const lat = 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
|
|
2609
|
+
return [lng, lat];
|
|
2610
|
+
}
|
|
2611
|
+
return [x / extent, y / extent];
|
|
2612
|
+
}
|
|
2613
|
+
function checkOptions(options) {
|
|
2614
|
+
var _a;
|
|
2615
|
+
const mltOptions = {
|
|
2616
|
+
...MLT_DEFAULT_OPTIONS,
|
|
2617
|
+
...(options == null ? void 0 : options.mlt) ?? {},
|
|
2618
|
+
geoarrow: ((_a = options == null ? void 0 : options.mlt) == null ? void 0 : _a.geoarrow) ?? (options == null ? void 0 : options.geoarrow)
|
|
2619
|
+
};
|
|
2620
|
+
if (mltOptions.coordinates === "wgs84" && !mltOptions.tileIndex) {
|
|
2621
|
+
throw new Error("MLT Loader: WGS84 coordinates require a tileIndex option");
|
|
2622
|
+
}
|
|
2623
|
+
return mltOptions;
|
|
2624
|
+
}
|
|
2625
|
+
var arrow5, maplibreMLT, decodeTile, GEOMETRY_TYPE;
|
|
2626
|
+
var init_parse_mlt = __esm({
|
|
2627
|
+
"dist/mlt/lib/parse-mlt.js"() {
|
|
2628
|
+
"use strict";
|
|
2629
|
+
arrow5 = __toESM(require("apache-arrow"), 1);
|
|
2630
|
+
init_legacy_binary();
|
|
2631
|
+
init_geometry_field();
|
|
2632
|
+
init_wkb_arrow_utils();
|
|
2633
|
+
init_src();
|
|
2634
|
+
init_schema_utils();
|
|
2635
|
+
maplibreMLT = __toESM(require("@maplibre/mlt"), 1);
|
|
2636
|
+
init_mlt_loader();
|
|
2637
|
+
decodeTile = (() => {
|
|
2638
|
+
var _a;
|
|
2639
|
+
const mltModule = maplibreMLT;
|
|
2640
|
+
const decodedTile = mltModule.decodeTile ?? ((_a = mltModule.default) == null ? void 0 : _a.decodeTile);
|
|
2641
|
+
if (!decodedTile) {
|
|
2642
|
+
throw new Error("MLT Loader: decodeTile export missing from @maplibre/mlt");
|
|
2643
|
+
}
|
|
2644
|
+
return (tile) => decodedTile(tile, void 0, false);
|
|
2645
|
+
})();
|
|
2646
|
+
GEOMETRY_TYPE = (() => {
|
|
2647
|
+
var _a;
|
|
2648
|
+
const mltModule = maplibreMLT;
|
|
2649
|
+
return mltModule.GEOMETRY_TYPE || ((_a = mltModule.default) == null ? void 0 : _a.GEOMETRY_TYPE) || {
|
|
2650
|
+
POINT: 0,
|
|
2651
|
+
LINESTRING: 1,
|
|
2652
|
+
POLYGON: 2,
|
|
2653
|
+
MULTIPOINT: 3,
|
|
2654
|
+
MULTILINESTRING: 4,
|
|
2655
|
+
MULTIPOLYGON: 5
|
|
2656
|
+
};
|
|
2657
|
+
})();
|
|
2658
|
+
}
|
|
2659
|
+
});
|
|
2660
|
+
|
|
2661
|
+
// dist/mlt/mlt-loader-with-parser.js
|
|
2662
|
+
var mlt_loader_with_parser_exports = {};
|
|
2663
|
+
__export(mlt_loader_with_parser_exports, {
|
|
2664
|
+
MLTLoaderWithParser: () => MLTLoaderWithParser,
|
|
2665
|
+
MLTWorkerLoaderWithParser: () => MLTWorkerLoaderWithParser,
|
|
2666
|
+
MLT_DEFAULT_OPTIONS: () => MLT_DEFAULT_OPTIONS2
|
|
2667
|
+
});
|
|
2668
|
+
var _MLTWorkerLoaderPreload, MLTWorkerLoaderMetadataWithoutPreload, _MLTLoaderPreload, MLTLoaderMetadataWithoutPreload, MLT_DEFAULT_OPTIONS2, MLTWorkerLoaderWithParser, MLTLoaderWithParser;
|
|
2669
|
+
var init_mlt_loader_with_parser = __esm({
|
|
2670
|
+
"dist/mlt/mlt-loader-with-parser.js"() {
|
|
2671
|
+
"use strict";
|
|
2672
|
+
init_parse_mlt();
|
|
2673
|
+
init_mlt_loader();
|
|
2674
|
+
init_mlt_loader();
|
|
2675
|
+
({ preload: _MLTWorkerLoaderPreload, ...MLTWorkerLoaderMetadataWithoutPreload } = MLTWorkerLoader);
|
|
2676
|
+
({ preload: _MLTLoaderPreload, ...MLTLoaderMetadataWithoutPreload } = MLTLoader);
|
|
2677
|
+
MLT_DEFAULT_OPTIONS2 = {
|
|
2678
|
+
shape: "arrow-table",
|
|
2679
|
+
coordinates: "local",
|
|
2680
|
+
layerProperty: "layerName"
|
|
2681
|
+
};
|
|
2682
|
+
MLTWorkerLoaderWithParser = {
|
|
2683
|
+
...MLTWorkerLoaderMetadataWithoutPreload
|
|
2684
|
+
};
|
|
2685
|
+
MLTLoaderWithParser = {
|
|
2686
|
+
...MLTLoaderMetadataWithoutPreload,
|
|
2687
|
+
parse: async (arrayBuffer, options) => parseMLT(arrayBuffer, options),
|
|
2688
|
+
parseSync: (arrayBuffer, options) => parseMLT(arrayBuffer, options)
|
|
2689
|
+
};
|
|
2690
|
+
}
|
|
2691
|
+
});
|
|
2692
|
+
|
|
2693
|
+
// dist/mlt/mlt-loader.js
|
|
2694
|
+
async function preload() {
|
|
2695
|
+
const { MLTLoaderWithParser: MLTLoaderWithParser2 } = await Promise.resolve().then(() => (init_mlt_loader_with_parser(), mlt_loader_with_parser_exports));
|
|
2696
|
+
return MLTLoaderWithParser2;
|
|
2697
|
+
}
|
|
2698
|
+
var VERSION, MLT_DEFAULT_OPTIONS, MLTLoader, MLTWorkerLoader;
|
|
2699
|
+
var init_mlt_loader = __esm({
|
|
2700
|
+
"dist/mlt/mlt-loader.js"() {
|
|
2701
|
+
"use strict";
|
|
2702
|
+
init_mlt_format();
|
|
2703
|
+
VERSION = true ? "5.0.0-alpha.13" : "latest";
|
|
2704
|
+
MLT_DEFAULT_OPTIONS = {
|
|
2705
|
+
shape: "arrow-table",
|
|
2706
|
+
coordinates: "local",
|
|
2707
|
+
layerProperty: "layerName"
|
|
2708
|
+
};
|
|
2709
|
+
MLTLoader = {
|
|
2710
|
+
...MLTFormat,
|
|
2711
|
+
dataType: null,
|
|
2712
|
+
batchType: null,
|
|
2713
|
+
version: VERSION,
|
|
2714
|
+
worker: false,
|
|
2715
|
+
binary: true,
|
|
2716
|
+
options: {
|
|
2717
|
+
mlt: {
|
|
2718
|
+
...MLT_DEFAULT_OPTIONS,
|
|
2719
|
+
layers: void 0,
|
|
2720
|
+
tileIndex: void 0
|
|
2721
|
+
}
|
|
2722
|
+
},
|
|
2723
|
+
preload
|
|
2724
|
+
};
|
|
2725
|
+
MLTWorkerLoader = MLTLoader;
|
|
2726
|
+
}
|
|
2727
|
+
});
|
|
2728
|
+
|
|
2729
|
+
// dist/mlt/index.js
|
|
2730
|
+
var index_exports = {};
|
|
2731
|
+
__export(index_exports, {
|
|
2732
|
+
MLTFormat: () => MLTFormat,
|
|
2733
|
+
MLTLoader: () => MLTLoader,
|
|
2734
|
+
MLTSourceLoader: () => MLTSourceLoader,
|
|
2735
|
+
MLTWorkerLoader: () => MLTWorkerLoader,
|
|
2736
|
+
MLTWriter: () => MLTWriter
|
|
2737
|
+
});
|
|
2738
|
+
module.exports = __toCommonJS(index_exports);
|
|
2739
|
+
init_mlt_format();
|
|
2740
|
+
init_mlt_loader();
|
|
2741
|
+
|
|
2742
|
+
// ../core/src/loader-utils/lib/log-utils/log.ts
|
|
2743
|
+
var import_log = require("probe.gl/log");
|
|
2744
|
+
var VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
2745
|
+
var version = VERSION2[0] >= "0" && VERSION2[0] <= "9" ? `v${VERSION2}` : "";
|
|
2746
|
+
function createLog() {
|
|
2747
|
+
const log2 = new import_log.Log({ id: "loaders.gl" });
|
|
2748
|
+
globalThis.loaders ||= {};
|
|
2749
|
+
globalThis.loaders.log = log2;
|
|
2750
|
+
globalThis.loaders.version = version;
|
|
2751
|
+
globalThis.probe ||= {};
|
|
2752
|
+
globalThis.probe.loaders = log2;
|
|
2753
|
+
return log2;
|
|
2754
|
+
}
|
|
2755
|
+
var log = createLog();
|
|
2756
|
+
|
|
2757
|
+
// ../core/src/loader-utils/lib/javascript-utils/is-type.ts
|
|
2758
|
+
var isObject = (value) => value !== null && typeof value === "object";
|
|
2759
|
+
var isPureObject = (value) => isObject(value) && value.constructor === {}.constructor;
|
|
2760
|
+
|
|
2761
|
+
// ../core/src/loader-utils/lib/option-utils/merge-options.ts
|
|
2762
|
+
function mergeOptions(baseOptions, newOptions) {
|
|
2763
|
+
return mergeOptionsRecursively(baseOptions || {}, newOptions);
|
|
2764
|
+
}
|
|
2765
|
+
function mergeOptionsRecursively(baseOptions, newOptions, level = 0) {
|
|
2766
|
+
if (level > 3) {
|
|
2767
|
+
return newOptions;
|
|
2768
|
+
}
|
|
2769
|
+
const options = { ...baseOptions };
|
|
2770
|
+
for (const [key, newValue] of Object.entries(newOptions)) {
|
|
2771
|
+
if (isPureObject(newValue)) {
|
|
2772
|
+
options[key] = mergeOptionsRecursively(
|
|
2773
|
+
options[key] || {},
|
|
2774
|
+
newOptions[key],
|
|
2775
|
+
level + 1
|
|
2776
|
+
);
|
|
2777
|
+
} else {
|
|
2778
|
+
options[key] = newOptions[key];
|
|
2779
|
+
}
|
|
2780
|
+
}
|
|
2781
|
+
return options;
|
|
2782
|
+
}
|
|
2783
|
+
|
|
2784
|
+
// ../core/src/loader-utils/lib/request-utils/authentication.ts
|
|
2785
|
+
function resolveCredentials(credentials, authentications = []) {
|
|
2786
|
+
if (credentials.every(isAuthentication)) return credentials;
|
|
2787
|
+
return credentials.map((credential, index) => {
|
|
2788
|
+
if (isAuthentication(credential)) return credential;
|
|
2789
|
+
const AuthenticationClass = authentications.find(
|
|
2790
|
+
(authentication2) => authentication2.type === (credential == null ? void 0 : credential.type)
|
|
2791
|
+
);
|
|
2792
|
+
if (!AuthenticationClass) {
|
|
2793
|
+
throw new Error(`No authentication class registered for credential at index ${index}.`);
|
|
2794
|
+
}
|
|
2795
|
+
let authentication;
|
|
2796
|
+
try {
|
|
2797
|
+
authentication = new AuthenticationClass(credential);
|
|
2798
|
+
} catch {
|
|
2799
|
+
throw new Error(`Invalid authentication configuration at index ${index}.`);
|
|
2800
|
+
}
|
|
2801
|
+
if (!isAuthentication(authentication)) {
|
|
2802
|
+
throw new Error(`Authentication class returned an invalid credential at index ${index}.`);
|
|
2803
|
+
}
|
|
2804
|
+
return authentication;
|
|
2805
|
+
});
|
|
2806
|
+
}
|
|
2807
|
+
function resolveAuthenticationOptions(options) {
|
|
2808
|
+
var _a, _b;
|
|
2809
|
+
if (!((_b = (_a = options.core) == null ? void 0 : _a.credentials) == null ? void 0 : _b.length)) return options;
|
|
2810
|
+
const credentials = resolveCredentials(options.core.credentials, options.core.authentications);
|
|
2811
|
+
if (credentials === options.core.credentials) return options;
|
|
2812
|
+
return { ...options, core: { ...options.core, credentials } };
|
|
2813
|
+
}
|
|
2814
|
+
function isAuthentication(credential) {
|
|
2815
|
+
if (!credential || typeof credential !== "object") return false;
|
|
2816
|
+
if (typeof credential.id !== "string" || !Array.isArray(credential.origins)) return false;
|
|
2817
|
+
if (credential.type === "request") return typeof credential.authenticate === "function";
|
|
2818
|
+
return (credential.type === "header" || credential.type === "query-parameter") && typeof credential.name === "string" && (typeof credential.token === "string" || typeof credential.token === "function") && Array.isArray(credential.refreshStatusCodes);
|
|
2819
|
+
}
|
|
2820
|
+
|
|
2821
|
+
// ../core/src/loader-utils/lib/request-utils/request-credentials.ts
|
|
2822
|
+
var AUTHENTICATED_FETCH = /* @__PURE__ */ Symbol("loaders.gl.authenticated-fetch");
|
|
2823
|
+
var refreshPromises = /* @__PURE__ */ new WeakMap();
|
|
2824
|
+
function createAuthenticatedFetch(options) {
|
|
2825
|
+
const suppliedFetch = options.fetch || ((url, requestOptions) => fetch(url, requestOptions));
|
|
2826
|
+
const existingMetadata = suppliedFetch[AUTHENTICATED_FETCH];
|
|
2827
|
+
const credentialResolutions = new Map(existingMetadata == null ? void 0 : existingMetadata.credentialResolutions);
|
|
2828
|
+
const resolvedCredentials = resolveCredentials(
|
|
2829
|
+
options.credentials.map((credential) => credentialResolutions.get(credential) || credential),
|
|
2830
|
+
options.authentications
|
|
2831
|
+
);
|
|
2832
|
+
options.credentials.forEach((credential, index) => {
|
|
2833
|
+
credentialResolutions.set(credential, resolvedCredentials[index]);
|
|
2834
|
+
});
|
|
2835
|
+
if (!options.fetchOptions && (!resolvedCredentials.length || (existingMetadata == null ? void 0 : existingMetadata.credentials.length) === resolvedCredentials.length && resolvedCredentials.every(
|
|
2836
|
+
(credential, index) => credential === existingMetadata.credentials[index]
|
|
2837
|
+
)))
|
|
2838
|
+
return suppliedFetch;
|
|
2839
|
+
const baseFetch = (existingMetadata == null ? void 0 : existingMetadata.fetch) || suppliedFetch;
|
|
2840
|
+
const credentials = existingMetadata ? [.../* @__PURE__ */ new Set([...resolvedCredentials, ...existingMetadata.credentials])] : resolvedCredentials;
|
|
2841
|
+
const fetchOptions = mergeFetchOptions(
|
|
2842
|
+
(existingMetadata == null ? void 0 : existingMetadata.fetchOptions) || {},
|
|
2843
|
+
options.fetchOptions
|
|
2844
|
+
);
|
|
2845
|
+
const tokenCredentials = credentials.filter(
|
|
2846
|
+
(credential) => credential.type !== "request"
|
|
2847
|
+
);
|
|
2848
|
+
const requestCredentials = credentials.filter(
|
|
2849
|
+
(credential) => credential.type === "request"
|
|
2850
|
+
);
|
|
2851
|
+
for (const credential of requestCredentials) normalizeRequestOrigins(credential.origins);
|
|
2852
|
+
const authenticatedFetch = async (url, requestOptions = {}) => {
|
|
2853
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
2854
|
+
requestOptions = mergeFetchOptions(fetchOptions, requestOptions);
|
|
2855
|
+
if ((_a = requestOptions.signal) == null ? void 0 : _a.aborted) throw createAbortError();
|
|
2856
|
+
if (!credentials.length) return baseFetch(url, requestOptions);
|
|
2857
|
+
const resolvedURL = parseHTTPURL(url);
|
|
2858
|
+
const authorization = resolvedURL ? await authorizeRequest(resolvedURL, requestOptions, tokenCredentials) : { url, options: requestOptions, credentials: [] };
|
|
2859
|
+
const signedRequest = await authenticateRequest(authorization, requestCredentials, "request");
|
|
2860
|
+
const response = await baseFetch(signedRequest.url, signedRequest.options);
|
|
2861
|
+
const refreshableCredentials = [];
|
|
2862
|
+
for (const resolvedCredential of authorization.credentials) {
|
|
2863
|
+
const { credential } = resolvedCredential;
|
|
2864
|
+
if (typeof credential.token === "function" && (isReplayableRequest(requestOptions) || ((_b = credential.canReplayRequest) == null ? void 0 : _b.call(credential, url, requestOptions))) && (isReplayableRequest(signedRequest.options) || ((_c = credential.canReplayRequest) == null ? void 0 : _c.call(credential, signedRequest.url, signedRequest.options))) && (credential.refreshStatusCodes.includes(response.status) || await ((_d = credential.shouldRefresh) == null ? void 0 : _d.call(credential, response))))
|
|
2865
|
+
refreshableCredentials.push(resolvedCredential);
|
|
2866
|
+
}
|
|
2867
|
+
const shouldRetrySignature = isReplayableRequest(requestOptions) && isReplayableRequest(signedRequest.options) && signedRequest.credentials.some(
|
|
2868
|
+
(credential) => {
|
|
2869
|
+
var _a2;
|
|
2870
|
+
return (_a2 = credential.refreshStatusCodes) == null ? void 0 : _a2.includes(response.status);
|
|
2871
|
+
}
|
|
2872
|
+
);
|
|
2873
|
+
if (!refreshableCredentials.length && !shouldRetrySignature) return response;
|
|
2874
|
+
if ((_e = requestOptions.signal) == null ? void 0 : _e.aborted) throw createAbortError();
|
|
2875
|
+
const refreshedTokens = /* @__PURE__ */ new Map();
|
|
2876
|
+
await Promise.all(
|
|
2877
|
+
refreshableCredentials.map(async ({ credential }) => {
|
|
2878
|
+
const token = await refreshCredential(credential, url, response);
|
|
2879
|
+
if (token) refreshedTokens.set(credential, token);
|
|
2880
|
+
})
|
|
2881
|
+
);
|
|
2882
|
+
if (!refreshedTokens.size && !shouldRetrySignature) return response;
|
|
2883
|
+
await ((_f = response.body) == null ? void 0 : _f.cancel().catch(() => {
|
|
2884
|
+
}));
|
|
2885
|
+
if ((_g = requestOptions.signal) == null ? void 0 : _g.aborted) throw createAbortError();
|
|
2886
|
+
const replayAuthorization = resolvedURL ? await authorizeRequest(
|
|
2887
|
+
resolvedURL,
|
|
2888
|
+
requestOptions,
|
|
2889
|
+
tokenCredentials,
|
|
2890
|
+
refreshedTokens,
|
|
2891
|
+
authorization.credentials
|
|
2892
|
+
) : { url, options: requestOptions };
|
|
2893
|
+
const replayRequest = await authenticateRequest(
|
|
2894
|
+
replayAuthorization,
|
|
2895
|
+
requestCredentials,
|
|
2896
|
+
"retry",
|
|
2897
|
+
response
|
|
2898
|
+
);
|
|
2899
|
+
return baseFetch(replayRequest.url, replayRequest.options);
|
|
2900
|
+
};
|
|
2901
|
+
Object.defineProperty(authenticatedFetch, AUTHENTICATED_FETCH, {
|
|
2902
|
+
value: {
|
|
2903
|
+
fetch: baseFetch,
|
|
2904
|
+
credentials,
|
|
2905
|
+
credentialResolutions,
|
|
2906
|
+
fetchOptions
|
|
2907
|
+
}
|
|
2908
|
+
});
|
|
2909
|
+
return authenticatedFetch;
|
|
2910
|
+
}
|
|
2911
|
+
function getAuthenticatedFetch(options = {}) {
|
|
2912
|
+
var _a, _b, _c;
|
|
2913
|
+
const fetchOption = options.fetch ?? ((_a = options.core) == null ? void 0 : _a.fetch);
|
|
2914
|
+
let fetchFunction;
|
|
2915
|
+
if (typeof fetchOption === "function") {
|
|
2916
|
+
fetchFunction = fetchOption;
|
|
2917
|
+
} else {
|
|
2918
|
+
fetchFunction = (url, requestOptions) => fetch(url, requestOptions);
|
|
2919
|
+
}
|
|
2920
|
+
return createAuthenticatedFetch({
|
|
2921
|
+
fetch: fetchFunction,
|
|
2922
|
+
fetchOptions: typeof fetchOption === "object" && fetchOption ? fetchOption : void 0,
|
|
2923
|
+
credentials: ((_b = options.core) == null ? void 0 : _b.credentials) || [],
|
|
2924
|
+
authentications: (_c = options.core) == null ? void 0 : _c.authentications
|
|
2925
|
+
});
|
|
2926
|
+
}
|
|
2927
|
+
function mergeFetchOptions(defaultOptions, requestOptions) {
|
|
2928
|
+
const mergedOptions = { ...defaultOptions, ...requestOptions };
|
|
2929
|
+
if (defaultOptions.headers || (requestOptions == null ? void 0 : requestOptions.headers)) {
|
|
2930
|
+
const headers = new Headers(defaultOptions.headers);
|
|
2931
|
+
new Headers(requestOptions == null ? void 0 : requestOptions.headers).forEach((value, key) => headers.set(key, value));
|
|
2932
|
+
mergedOptions.headers = headers;
|
|
2933
|
+
}
|
|
2934
|
+
return mergedOptions;
|
|
2935
|
+
}
|
|
2936
|
+
async function authenticateRequest(request, credentials, reason, response) {
|
|
2937
|
+
const appliedCredentials = [];
|
|
2938
|
+
const signal = request.options.signal;
|
|
2939
|
+
for (const credential of credentials) {
|
|
2940
|
+
const origin = getRequestOrigin(request.url);
|
|
2941
|
+
if (!origin || !normalizeRequestOrigins(credential.origins).includes(origin)) continue;
|
|
2942
|
+
if (signal == null ? void 0 : signal.aborted) throw createAbortError();
|
|
2943
|
+
const authenticatedRequest = await credential.authenticate({
|
|
2944
|
+
url: request.url,
|
|
2945
|
+
options: { ...request.options, headers: new Headers(request.options.headers) },
|
|
2946
|
+
reason,
|
|
2947
|
+
response: response ? { status: response.status, headers: new Headers(response.headers) } : void 0
|
|
2948
|
+
});
|
|
2949
|
+
if (!authenticatedRequest || typeof authenticatedRequest.url !== "string" || !authenticatedRequest.options || typeof authenticatedRequest.options !== "object") {
|
|
2950
|
+
throw new Error("Authentication callback returned an invalid request.");
|
|
2951
|
+
}
|
|
2952
|
+
request = {
|
|
2953
|
+
url: authenticatedRequest.url,
|
|
2954
|
+
options: { ...authenticatedRequest.options, ...signal ? { signal } : {} }
|
|
2955
|
+
};
|
|
2956
|
+
appliedCredentials.push(credential);
|
|
2957
|
+
}
|
|
2958
|
+
if (signal == null ? void 0 : signal.aborted) throw createAbortError();
|
|
2959
|
+
return { ...request, credentials: appliedCredentials };
|
|
2960
|
+
}
|
|
2961
|
+
function getRequestOrigin(url) {
|
|
2962
|
+
try {
|
|
2963
|
+
const parsedURL = new URL(url);
|
|
2964
|
+
if (!parsedURL.host || parsedURL.username || parsedURL.password) return null;
|
|
2965
|
+
return parsedURL.origin !== "null" ? parsedURL.origin : `${parsedURL.protocol}//${parsedURL.host}`;
|
|
2966
|
+
} catch {
|
|
2967
|
+
return null;
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2970
|
+
function normalizeRequestOrigins(origins) {
|
|
2971
|
+
if (!origins.length)
|
|
2972
|
+
throw new Error("Request authentication requires at least one exact origin.");
|
|
2973
|
+
return origins.map((origin) => {
|
|
2974
|
+
const resolvedOrigin = getRequestOrigin(origin);
|
|
2975
|
+
let url;
|
|
2976
|
+
try {
|
|
2977
|
+
url = new URL(origin);
|
|
2978
|
+
} catch {
|
|
2979
|
+
throw new Error("Invalid request authentication origin.");
|
|
2980
|
+
}
|
|
2981
|
+
if (!resolvedOrigin || url.pathname && url.pathname !== "/" || url.search || url.hash) {
|
|
2982
|
+
throw new Error("Invalid request authentication origin.");
|
|
2983
|
+
}
|
|
2984
|
+
return resolvedOrigin;
|
|
2985
|
+
});
|
|
2986
|
+
}
|
|
2987
|
+
async function authorizeRequest(sourceURL, requestOptions, credentials, tokenOverrides = /* @__PURE__ */ new Map(), previousCredentials = []) {
|
|
2988
|
+
const url = new URL(sourceURL);
|
|
2989
|
+
const headers = new Headers(requestOptions.headers);
|
|
2990
|
+
const resolvedCredentials = [];
|
|
2991
|
+
const previousTokens = new Map(
|
|
2992
|
+
previousCredentials.map(({ credential, token }) => [credential, token])
|
|
2993
|
+
);
|
|
2994
|
+
for (const credential of credentials) {
|
|
2995
|
+
if (!credential.origins.includes(url.origin)) continue;
|
|
2996
|
+
const overrideToken = tokenOverrides.get(credential);
|
|
2997
|
+
const previousToken = previousTokens.get(credential);
|
|
2998
|
+
const ownsQueryParameter = credential.type === "query-parameter" && previousToken !== void 0;
|
|
2999
|
+
const ownsHeader = credential.type === "header" && previousToken !== void 0;
|
|
3000
|
+
if (credential.type === "query-parameter" && url.searchParams.has(credential.name) && !ownsQueryParameter || credential.type === "header" && headers.has(credential.name) && !ownsHeader) {
|
|
3001
|
+
continue;
|
|
3002
|
+
}
|
|
3003
|
+
const token = overrideToken ?? previousToken ?? await resolveToken(credential.token, { url: sourceURL.toString(), reason: "request" });
|
|
3004
|
+
if (!token) continue;
|
|
3005
|
+
if (credential.type === "query-parameter") {
|
|
3006
|
+
url.searchParams.set(credential.name, token);
|
|
3007
|
+
} else {
|
|
3008
|
+
headers.set(credential.name, `${credential.prefix || ""}${token}`);
|
|
3009
|
+
}
|
|
3010
|
+
resolvedCredentials.push({ credential, token });
|
|
3011
|
+
}
|
|
3012
|
+
return {
|
|
3013
|
+
url: url.toString(),
|
|
3014
|
+
options: { ...requestOptions, headers },
|
|
3015
|
+
credentials: resolvedCredentials
|
|
3016
|
+
};
|
|
3017
|
+
}
|
|
3018
|
+
async function refreshCredential(credential, url, response) {
|
|
3019
|
+
const existingPromise = refreshPromises.get(credential);
|
|
3020
|
+
if (existingPromise) return existingPromise;
|
|
3021
|
+
const tokenProvider = credential.token;
|
|
3022
|
+
const promise = Promise.resolve(
|
|
3023
|
+
tokenProvider({
|
|
3024
|
+
url,
|
|
3025
|
+
reason: "refresh",
|
|
3026
|
+
response: { status: response.status, headers: response.headers }
|
|
3027
|
+
})
|
|
3028
|
+
).finally(() => refreshPromises.delete(credential));
|
|
3029
|
+
refreshPromises.set(credential, promise);
|
|
3030
|
+
return promise;
|
|
3031
|
+
}
|
|
3032
|
+
async function resolveToken(token, context) {
|
|
3033
|
+
return typeof token === "function" ? token(context) : token;
|
|
3034
|
+
}
|
|
3035
|
+
function parseHTTPURL(url) {
|
|
3036
|
+
try {
|
|
3037
|
+
const parsedURL = new URL(url);
|
|
3038
|
+
return ["http:", "https:"].includes(parsedURL.protocol) ? parsedURL : null;
|
|
3039
|
+
} catch {
|
|
3040
|
+
return null;
|
|
3041
|
+
}
|
|
3042
|
+
}
|
|
3043
|
+
function isReplayableRequest(options) {
|
|
3044
|
+
const method = (options.method || "GET").toUpperCase();
|
|
3045
|
+
if (!["GET", "HEAD", "OPTIONS", "PUT", "DELETE"].includes(method)) return false;
|
|
3046
|
+
return !(options.body && typeof ReadableStream !== "undefined" && options.body instanceof ReadableStream);
|
|
3047
|
+
}
|
|
3048
|
+
function createAbortError() {
|
|
3049
|
+
return new DOMException("The operation was aborted.", "AbortError");
|
|
3050
|
+
}
|
|
3051
|
+
|
|
3052
|
+
// ../core/src/loader-utils/lib/path-utils/file-aliases.ts
|
|
3053
|
+
var pathPrefix = "";
|
|
3054
|
+
var fileAliases = {};
|
|
3055
|
+
function resolvePath(filename) {
|
|
3056
|
+
for (const alias in fileAliases) {
|
|
3057
|
+
if (filename.startsWith(alias)) {
|
|
3058
|
+
const replacement = fileAliases[alias];
|
|
3059
|
+
filename = filename.replace(alias, replacement);
|
|
3060
|
+
}
|
|
3061
|
+
}
|
|
3062
|
+
if (!filename.startsWith("http://") && !filename.startsWith("https://")) {
|
|
3063
|
+
filename = `${pathPrefix}${filename}`;
|
|
3064
|
+
}
|
|
3065
|
+
return filename;
|
|
3066
|
+
}
|
|
3067
|
+
|
|
3068
|
+
// ../core/src/loader-utils/lib/sources/data-source.ts
|
|
3069
|
+
var UNAVAILABLE_CORE_API = {
|
|
3070
|
+
fetchFile: unavailableCoreApiMethod("fetchFile"),
|
|
3071
|
+
parse: unavailableCoreApiMethod("parse"),
|
|
3072
|
+
parseFile: unavailableCoreApiMethod("parseFile"),
|
|
3073
|
+
parseSync: unavailableCoreApiMethod("parseSync"),
|
|
3074
|
+
parseInBatches: unavailableCoreApiMethod("parseInBatches"),
|
|
3075
|
+
load: unavailableCoreApiMethod("load"),
|
|
3076
|
+
loadInBatches: unavailableCoreApiMethod("loadInBatches")
|
|
3077
|
+
};
|
|
3078
|
+
var DataSource = class _DataSource {
|
|
3079
|
+
static defaultOptions = {
|
|
3080
|
+
core: {
|
|
3081
|
+
type: "auto",
|
|
3082
|
+
attributions: [],
|
|
3083
|
+
loaders: [],
|
|
3084
|
+
onError: void 0
|
|
3085
|
+
}
|
|
3086
|
+
};
|
|
3087
|
+
optionsType;
|
|
3088
|
+
options;
|
|
3089
|
+
data;
|
|
3090
|
+
url;
|
|
3091
|
+
/** Shared parser options derived from the source options, excluding source-only core controls. */
|
|
3092
|
+
loadOptions;
|
|
3093
|
+
/** A resolved fetch function extracted from the shared core options. */
|
|
3094
|
+
fetch;
|
|
3095
|
+
/** Shared source-level runtime hooks, when supplied by the source factory. */
|
|
3096
|
+
coreApi;
|
|
3097
|
+
/** Whether a real CoreAPI instance was injected by the integration layer. */
|
|
3098
|
+
hasCoreApi;
|
|
3099
|
+
_needsRefresh = true;
|
|
3100
|
+
constructor(data, options, defaultOptions, coreApi) {
|
|
3101
|
+
this.options = mergeOptions(
|
|
3102
|
+
mergeOptions(_DataSource.defaultOptions, defaultOptions || {}),
|
|
3103
|
+
options
|
|
3104
|
+
);
|
|
3105
|
+
this.data = data;
|
|
3106
|
+
this.url = typeof data === "string" ? resolvePath(data) : "";
|
|
3107
|
+
const loadOptions = resolveAuthenticationOptions(getSourceLoaderOptions(this.options));
|
|
3108
|
+
this.loadOptions = loadOptions;
|
|
3109
|
+
const fetch2 = getFetchFunction(loadOptions);
|
|
3110
|
+
this.coreApi = coreApi || UNAVAILABLE_CORE_API;
|
|
3111
|
+
this.hasCoreApi = Boolean(coreApi);
|
|
3112
|
+
this.fetch = fetch2;
|
|
3113
|
+
}
|
|
3114
|
+
setProps(options) {
|
|
3115
|
+
const mergedOptions = mergeOptions(this.options, options);
|
|
3116
|
+
const loadOptions = resolveAuthenticationOptions(getSourceLoaderOptions(mergedOptions));
|
|
3117
|
+
this.options = mergedOptions;
|
|
3118
|
+
this.loadOptions = loadOptions;
|
|
3119
|
+
this.fetch = getFetchFunction(loadOptions);
|
|
3120
|
+
this.setNeedsRefresh();
|
|
3121
|
+
}
|
|
3122
|
+
/** Mark this data source as needing a refresh (redraw) */
|
|
3123
|
+
setNeedsRefresh() {
|
|
3124
|
+
this._needsRefresh = true;
|
|
3125
|
+
}
|
|
3126
|
+
/**
|
|
3127
|
+
* Does this data source need refreshing?
|
|
3128
|
+
* @note The specifics of the refresh mechanism depends on type of data source
|
|
3129
|
+
*/
|
|
3130
|
+
getNeedsRefresh(clear = true) {
|
|
3131
|
+
const needsRefresh = this._needsRefresh;
|
|
3132
|
+
if (clear) {
|
|
3133
|
+
this._needsRefresh = false;
|
|
3134
|
+
}
|
|
3135
|
+
return needsRefresh;
|
|
3136
|
+
}
|
|
3137
|
+
/** Reports a source-level failure through the configured callback or the shared logger. */
|
|
3138
|
+
reportError(error, message) {
|
|
3139
|
+
var _a;
|
|
3140
|
+
const normalizedError = normalizeError(error, message);
|
|
3141
|
+
const callback = (_a = this.options.core) == null ? void 0 : _a.onError;
|
|
3142
|
+
if (callback) {
|
|
3143
|
+
callback(normalizedError, this);
|
|
3144
|
+
} else {
|
|
3145
|
+
log.warn(`${this.constructor.name}: ${normalizedError.message}`)();
|
|
3146
|
+
}
|
|
3147
|
+
return normalizedError;
|
|
3148
|
+
}
|
|
3149
|
+
};
|
|
3150
|
+
function getFetchFunction(options) {
|
|
3151
|
+
return getAuthenticatedFetch(options);
|
|
3152
|
+
}
|
|
3153
|
+
function getSourceLoaderOptions(options) {
|
|
3154
|
+
var _a;
|
|
3155
|
+
if (options.loadOptions !== void 0 || ((_a = options.core) == null ? void 0 : _a.loadOptions) !== void 0) {
|
|
3156
|
+
throw new Error(
|
|
3157
|
+
"Source loadOptions and core.loadOptions were removed. Use core and root loader namespaces directly."
|
|
3158
|
+
);
|
|
3159
|
+
}
|
|
3160
|
+
const loadOptions = { ...options };
|
|
3161
|
+
if (options == null ? void 0 : options.core) {
|
|
3162
|
+
loadOptions.core = { ...options.core };
|
|
3163
|
+
const parserCore = loadOptions.core;
|
|
3164
|
+
for (const key of ["type", "attributions", "loaders", "onError", "loadOptions"]) {
|
|
3165
|
+
delete parserCore[key];
|
|
3166
|
+
}
|
|
3167
|
+
if (Object.keys(parserCore).length === 0) {
|
|
3168
|
+
delete loadOptions.core;
|
|
3169
|
+
}
|
|
3170
|
+
}
|
|
3171
|
+
const topLevelBaseUri = typeof loadOptions.baseUri === "string" ? loadOptions.baseUri : void 0;
|
|
3172
|
+
const topLevelBaseUrl = typeof loadOptions.baseUrl === "string" ? loadOptions.baseUrl : void 0;
|
|
3173
|
+
if (topLevelBaseUri !== void 0 || topLevelBaseUrl !== void 0) {
|
|
3174
|
+
loadOptions.core ||= {};
|
|
3175
|
+
if (loadOptions.core.baseUrl === void 0) {
|
|
3176
|
+
loadOptions.core.baseUrl = topLevelBaseUrl ?? topLevelBaseUri;
|
|
3177
|
+
}
|
|
3178
|
+
delete loadOptions.baseUri;
|
|
3179
|
+
delete loadOptions.baseUrl;
|
|
3180
|
+
}
|
|
3181
|
+
return loadOptions;
|
|
3182
|
+
}
|
|
3183
|
+
function normalizeError(error, message) {
|
|
3184
|
+
if (error instanceof Error) {
|
|
3185
|
+
return error;
|
|
3186
|
+
}
|
|
3187
|
+
if (typeof error === "string") {
|
|
3188
|
+
return new Error(error);
|
|
3189
|
+
}
|
|
3190
|
+
return new Error(message);
|
|
3191
|
+
}
|
|
3192
|
+
function unavailableCoreApiMethod(methodName) {
|
|
3193
|
+
return () => {
|
|
3194
|
+
throw new Error(
|
|
3195
|
+
`CoreAPI.${methodName} is unavailable. Use @loaders.gl/core.createDataSource().`
|
|
3196
|
+
);
|
|
3197
|
+
};
|
|
3198
|
+
}
|
|
3199
|
+
|
|
3200
|
+
// dist/mlt/mlt-source-loader.js
|
|
3201
|
+
init_mlt_format();
|
|
3202
|
+
var MLTSourceLoader = {
|
|
3203
|
+
dataType: null,
|
|
3204
|
+
batchType: null,
|
|
3205
|
+
...MLTFormat,
|
|
3206
|
+
name: "MLTTileSource",
|
|
3207
|
+
version: "0.0.0",
|
|
3208
|
+
type: "mlt",
|
|
3209
|
+
fromUrl: true,
|
|
3210
|
+
fromBlob: false,
|
|
3211
|
+
options: {
|
|
3212
|
+
mlt: {
|
|
3213
|
+
extension: ".mlt",
|
|
3214
|
+
metadataUrl: null,
|
|
3215
|
+
coordinates: "wgs84",
|
|
3216
|
+
shape: "arrow-table",
|
|
3217
|
+
layers: void 0
|
|
3218
|
+
}
|
|
3219
|
+
},
|
|
3220
|
+
defaultOptions: {
|
|
3221
|
+
mlt: {
|
|
3222
|
+
extension: ".mlt",
|
|
3223
|
+
metadataUrl: null,
|
|
3224
|
+
coordinates: "wgs84",
|
|
3225
|
+
shape: "arrow-table",
|
|
3226
|
+
layers: void 0
|
|
3227
|
+
}
|
|
3228
|
+
},
|
|
3229
|
+
testURL: (url) => url.endsWith(".mlt") || url.endsWith("/plain") || isURLTemplate(url),
|
|
3230
|
+
createDataSource: (url, options, coreApi) => new MLTTileSource(url, options, coreApi)
|
|
3231
|
+
};
|
|
3232
|
+
var MLTTileSource = class extends DataSource {
|
|
3233
|
+
metadataUrl;
|
|
3234
|
+
schema = "tms";
|
|
3235
|
+
metadata;
|
|
3236
|
+
extension;
|
|
3237
|
+
mimeType = "application/vnd.maplibre-tile";
|
|
3238
|
+
constructor(url, options, coreApi) {
|
|
3239
|
+
var _a, _b;
|
|
3240
|
+
super(url, options, MLTSourceLoader.defaultOptions, coreApi);
|
|
3241
|
+
this.metadataUrl = ((_a = this.options.mlt) == null ? void 0 : _a.metadataUrl) || null;
|
|
3242
|
+
this.extension = ((_b = this.options.mlt) == null ? void 0 : _b.extension) || ".mlt";
|
|
3243
|
+
this.getTileData = this.getTileData.bind(this);
|
|
3244
|
+
this.metadata = this.getMetadata();
|
|
3245
|
+
if (isURLTemplate(this.url)) {
|
|
3246
|
+
this.schema = "template";
|
|
3247
|
+
}
|
|
3248
|
+
}
|
|
3249
|
+
async getSchema() {
|
|
3250
|
+
return { fields: [], metadata: {} };
|
|
3251
|
+
}
|
|
3252
|
+
async getMetadata() {
|
|
3253
|
+
var _a;
|
|
3254
|
+
const attributions = ((_a = this.options.core) == null ? void 0 : _a.attributions) || [];
|
|
3255
|
+
if (!this.metadataUrl) {
|
|
3256
|
+
return { minZoom: 0, maxZoom: 30, attributions };
|
|
3257
|
+
}
|
|
3258
|
+
try {
|
|
3259
|
+
const response = await this.fetch(this.metadataUrl);
|
|
3260
|
+
if (!response.ok) {
|
|
3261
|
+
this.reportError(new Error(`${response.status} ${response.statusText}`), `Failed to fetch metadata from ${this.metadataUrl}`);
|
|
3262
|
+
return { minZoom: 0, maxZoom: 30, attributions };
|
|
3263
|
+
}
|
|
3264
|
+
const metadataText = await response.text();
|
|
3265
|
+
const metadataJson = JSON.parse(metadataText);
|
|
3266
|
+
const minZoom = Number.isFinite(metadataJson == null ? void 0 : metadataJson.minZoom) ? metadataJson.minZoom : Number.isFinite(metadataJson == null ? void 0 : metadataJson.minzoom) ? metadataJson.minzoom : 0;
|
|
3267
|
+
const maxZoom = Number.isFinite(metadataJson == null ? void 0 : metadataJson.maxZoom) ? metadataJson.maxZoom : Number.isFinite(metadataJson == null ? void 0 : metadataJson.maxzoom) ? metadataJson.maxzoom : 30;
|
|
3268
|
+
return {
|
|
3269
|
+
...metadataJson,
|
|
3270
|
+
minZoom,
|
|
3271
|
+
maxZoom,
|
|
3272
|
+
attributions: [...attributions, ...(metadataJson == null ? void 0 : metadataJson.attributions) || []]
|
|
3273
|
+
};
|
|
3274
|
+
} catch (error) {
|
|
3275
|
+
this.reportError(error, `Failed to fetch metadata from ${this.metadataUrl}`);
|
|
3276
|
+
return { minZoom: 0, maxZoom: 30, attributions };
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3279
|
+
async getTile(parameters) {
|
|
3280
|
+
const tileUrl = this.getTileURL(parameters.x, parameters.y, parameters.z);
|
|
3281
|
+
const response = await this.fetch(tileUrl);
|
|
3282
|
+
if (!response.ok) {
|
|
3283
|
+
this.reportError(new Error(`${response.status} ${response.statusText}`), `Failed to fetch tile ${tileUrl} ${JSON.stringify(parameters)}`);
|
|
3284
|
+
return null;
|
|
3285
|
+
}
|
|
3286
|
+
return response.arrayBuffer();
|
|
3287
|
+
}
|
|
3288
|
+
async getTileData(parameters) {
|
|
3289
|
+
const { index } = parameters;
|
|
3290
|
+
return this.getVectorTile({ x: index.x, y: index.y, z: index.z, layers: [] });
|
|
3291
|
+
}
|
|
3292
|
+
async getVectorTile(tileParameters) {
|
|
3293
|
+
const tileData = await this.getTile(tileParameters);
|
|
3294
|
+
return tileData ? this._parseTile(tileData, tileParameters) : null;
|
|
3295
|
+
}
|
|
3296
|
+
async _parseTile(arrayBuffer, tileParameters) {
|
|
3297
|
+
var _a, _b, _c;
|
|
3298
|
+
const options = this.options;
|
|
3299
|
+
const coordinates = ((_a = options.mlt) == null ? void 0 : _a.coordinates) || "wgs84";
|
|
3300
|
+
const shape = ((_b = options.mlt) == null ? void 0 : _b.shape) || "arrow-table";
|
|
3301
|
+
const tileIndex = coordinates === "wgs84" ? { x: tileParameters.x, y: tileParameters.y, z: tileParameters.z } : void 0;
|
|
3302
|
+
const loadOptions = {
|
|
3303
|
+
...this.loadOptions,
|
|
3304
|
+
mlt: {
|
|
3305
|
+
...this.loadOptions.mlt,
|
|
3306
|
+
shape,
|
|
3307
|
+
coordinates,
|
|
3308
|
+
layers: (_c = options.mlt) == null ? void 0 : _c.layers,
|
|
3309
|
+
tileIndex
|
|
3310
|
+
},
|
|
3311
|
+
geoarrow: options.geoarrow ?? this.loadOptions.geoarrow
|
|
3312
|
+
};
|
|
3313
|
+
const { MLTLoaderWithParser: MLTLoaderWithParser2 } = await Promise.resolve().then(() => (init_mlt_loader_with_parser(), mlt_loader_with_parser_exports));
|
|
3314
|
+
const parsed = await MLTLoaderWithParser2.parse(arrayBuffer, loadOptions);
|
|
3315
|
+
if (shape === "geojson-table") {
|
|
3316
|
+
return parsed.features || null;
|
|
3317
|
+
}
|
|
3318
|
+
if (shape === "binary-geometry" || shape === "arrow-table") {
|
|
3319
|
+
return parsed;
|
|
3320
|
+
}
|
|
3321
|
+
return parsed.features || null;
|
|
3322
|
+
}
|
|
3323
|
+
getTileURL(x, y, z) {
|
|
3324
|
+
switch (this.schema) {
|
|
3325
|
+
case "xyz":
|
|
3326
|
+
return `${this.url}/${x}/${y}/${z}${this.extension}`;
|
|
3327
|
+
case "tms":
|
|
3328
|
+
return `${this.url}/${z}/${x}/${y}${this.extension}`;
|
|
3329
|
+
case "template":
|
|
3330
|
+
return getURLFromTemplate(this.url, x, y, z, this.extension);
|
|
3331
|
+
default:
|
|
3332
|
+
throw new Error(`Unknown tile schema: ${this.schema}`);
|
|
3333
|
+
}
|
|
3334
|
+
}
|
|
3335
|
+
};
|
|
3336
|
+
function isURLTemplate(s) {
|
|
3337
|
+
return /(?=.*\{z\})(?=.*\{x\})(?=.*(\{y\}|\{\-y\}))|(?=.*\{x\})(?=.*(\{y\}|\{\-y\})(?=.*\{z\}))/i.test(s);
|
|
3338
|
+
}
|
|
3339
|
+
function getURLFromTemplate(template, x, y, z, extension = "") {
|
|
3340
|
+
const id = `${x}-${y}-${z}`;
|
|
3341
|
+
const url = template.replace(/\{x\}/g, x.toString()).replace(/\{-y\}/g, String((1 << z) - 1 - y)).replace(/\{y\}/g, y.toString()).replace(/\{z\}/g, z.toString()).replace(/\{id\}/g, id);
|
|
3342
|
+
if (!extension || url.endsWith(extension)) {
|
|
3343
|
+
return url;
|
|
3344
|
+
}
|
|
3345
|
+
const separatorIndex = url.search(/[?#]/);
|
|
3346
|
+
const path = separatorIndex < 0 ? url : url.slice(0, separatorIndex);
|
|
3347
|
+
const suffix = separatorIndex < 0 ? "" : url.slice(separatorIndex);
|
|
3348
|
+
const file = path.split("/").pop() || "";
|
|
3349
|
+
if (/\.[a-z0-9]+$/i.test(file)) {
|
|
3350
|
+
return url;
|
|
3351
|
+
}
|
|
3352
|
+
return `${path}${extension}${suffix}`;
|
|
3353
|
+
}
|
|
3354
|
+
|
|
3355
|
+
// dist/mlt/index.js
|
|
3356
|
+
init_mlt_loader();
|
|
3357
|
+
|
|
3358
|
+
// dist/mlt/lib/encode-mlt.js
|
|
3359
|
+
var arrow6 = __toESM(require("apache-arrow"), 1);
|
|
3360
|
+
init_schema();
|
|
3361
|
+
init_geometry_codecs();
|
|
3362
|
+
|
|
3363
|
+
// dist/mlt/lib/encode-mlt-streams.js
|
|
3364
|
+
function concatenateBytes(chunks) {
|
|
3365
|
+
const result = new Uint8Array(chunks.reduce((length, chunk) => length + chunk.length, 0));
|
|
3366
|
+
let offset = 0;
|
|
3367
|
+
for (const chunk of chunks) {
|
|
3368
|
+
result.set(chunk, offset);
|
|
3369
|
+
offset += chunk.length;
|
|
3370
|
+
}
|
|
3371
|
+
return result;
|
|
3372
|
+
}
|
|
3373
|
+
function encodeVarints(values) {
|
|
3374
|
+
const bytes = [];
|
|
3375
|
+
for (let value of values) {
|
|
3376
|
+
do {
|
|
3377
|
+
const remainder = value % 128;
|
|
3378
|
+
value = Math.floor(value / 128);
|
|
3379
|
+
bytes.push(remainder + (value ? 128 : 0));
|
|
3380
|
+
} while (value);
|
|
3381
|
+
}
|
|
3382
|
+
return Uint8Array.from(bytes);
|
|
3383
|
+
}
|
|
3384
|
+
function encodeString(value) {
|
|
3385
|
+
const bytes = new TextEncoder().encode(value);
|
|
3386
|
+
return concatenateBytes([encodeVarints([bytes.length]), bytes]);
|
|
3387
|
+
}
|
|
3388
|
+
function encodeStream(type, encoding, count, bytes) {
|
|
3389
|
+
return concatenateBytes([
|
|
3390
|
+
Uint8Array.of(type, encoding),
|
|
3391
|
+
encodeVarints([count, bytes.length]),
|
|
3392
|
+
bytes
|
|
3393
|
+
]);
|
|
3394
|
+
}
|
|
3395
|
+
function encodeIntegerStream(type, values) {
|
|
3396
|
+
return encodeStream(type, 2, values.length, encodeVarints(values));
|
|
3397
|
+
}
|
|
3398
|
+
function encodeBooleanStream(type, values) {
|
|
3399
|
+
const packed = new Uint8Array(Math.ceil(values.length / 8));
|
|
3400
|
+
for (let index = 0; index < values.length; index++)
|
|
3401
|
+
if (values[index])
|
|
3402
|
+
packed[index >> 3] |= 1 << index % 8;
|
|
3403
|
+
const chunks = [];
|
|
3404
|
+
for (let offset = 0; offset < packed.length; offset += 128) {
|
|
3405
|
+
const chunk = packed.subarray(offset, offset + 128);
|
|
3406
|
+
chunks.push(Uint8Array.of(256 - chunk.length), chunk);
|
|
3407
|
+
}
|
|
3408
|
+
return encodeStream(type, 96, values.length, concatenateBytes(chunks));
|
|
3409
|
+
}
|
|
3410
|
+
|
|
3411
|
+
// dist/mlt/lib/encode-mlt-geometry.js
|
|
3412
|
+
function quantizeGeometry(geometry, scale) {
|
|
3413
|
+
function projectPoint2(point) {
|
|
3414
|
+
if (point.length !== 2 || !point.every(Number.isFinite))
|
|
3415
|
+
throw new Error("MLT requires finite XY coordinates");
|
|
3416
|
+
const result = point.map((value) => Math.round(value * scale));
|
|
3417
|
+
if (result.some((value) => Math.abs(value) > 1073741823))
|
|
3418
|
+
throw new Error("MLT quantized coordinate limit exceeded");
|
|
3419
|
+
return result;
|
|
3420
|
+
}
|
|
3421
|
+
function projectLine(line) {
|
|
3422
|
+
return line.map(projectPoint2).filter((point, index, points) => !index || point[0] !== points[index - 1][0] || point[1] !== points[index - 1][1]);
|
|
3423
|
+
}
|
|
3424
|
+
function projectPolygon(polygon) {
|
|
3425
|
+
const rings = [];
|
|
3426
|
+
for (let index = 0; index < polygon.length; index++) {
|
|
3427
|
+
const ring = projectLine(polygon[index]);
|
|
3428
|
+
if (ring.length && ring[0][0] === ring[ring.length - 1][0] && ring[0][1] === ring[ring.length - 1][1])
|
|
3429
|
+
ring.pop();
|
|
3430
|
+
let area = 0;
|
|
3431
|
+
for (let vertex = 1; vertex + 1 < ring.length; vertex++)
|
|
3432
|
+
area += (ring[vertex][0] - ring[0][0]) * (ring[vertex + 1][1] - ring[0][1]) - (ring[vertex + 1][0] - ring[0][0]) * (ring[vertex][1] - ring[0][1]);
|
|
3433
|
+
if (ring.length < 3 || !area) {
|
|
3434
|
+
if (!index)
|
|
3435
|
+
return [];
|
|
3436
|
+
continue;
|
|
3437
|
+
}
|
|
3438
|
+
rings.push(ring);
|
|
3439
|
+
}
|
|
3440
|
+
return rings;
|
|
3441
|
+
}
|
|
3442
|
+
switch (geometry.type) {
|
|
3443
|
+
case "Point":
|
|
3444
|
+
return geometry.coordinates.length ? { type: "Point", coordinates: projectPoint2(geometry.coordinates) } : null;
|
|
3445
|
+
case "MultiPoint":
|
|
3446
|
+
return geometry.coordinates.length ? { type: "MultiPoint", coordinates: geometry.coordinates.map(projectPoint2) } : null;
|
|
3447
|
+
case "LineString": {
|
|
3448
|
+
const coordinates = projectLine(geometry.coordinates);
|
|
3449
|
+
return coordinates.length > 1 ? { type: "LineString", coordinates } : null;
|
|
3450
|
+
}
|
|
3451
|
+
case "MultiLineString": {
|
|
3452
|
+
const coordinates = geometry.coordinates.map(projectLine).filter((line) => line.length > 1);
|
|
3453
|
+
return coordinates.length ? { type: "MultiLineString", coordinates } : null;
|
|
3454
|
+
}
|
|
3455
|
+
case "Polygon": {
|
|
3456
|
+
const coordinates = projectPolygon(geometry.coordinates);
|
|
3457
|
+
return coordinates.length ? { type: "Polygon", coordinates } : null;
|
|
3458
|
+
}
|
|
3459
|
+
case "MultiPolygon": {
|
|
3460
|
+
const coordinates = geometry.coordinates.map(projectPolygon).filter((polygon) => polygon.length);
|
|
3461
|
+
return coordinates.length ? { type: "MultiPolygon", coordinates } : null;
|
|
3462
|
+
}
|
|
3463
|
+
default:
|
|
3464
|
+
throw new Error(`Unsupported MLT geometry: ${geometry.type}`);
|
|
3465
|
+
}
|
|
3466
|
+
}
|
|
3467
|
+
function encodeGeometryColumn(geometries) {
|
|
3468
|
+
const types = [];
|
|
3469
|
+
const geometryLengths = [];
|
|
3470
|
+
const partLengths = [];
|
|
3471
|
+
const ringLengths = [];
|
|
3472
|
+
const vertices = [];
|
|
3473
|
+
const hasPolygons = geometries.some((geometry) => geometry.type.includes("Polygon"));
|
|
3474
|
+
let previousX = 0;
|
|
3475
|
+
let previousY = 0;
|
|
3476
|
+
function writePoints(points) {
|
|
3477
|
+
for (const [x, y] of points) {
|
|
3478
|
+
const deltaX = x - previousX;
|
|
3479
|
+
const deltaY = y - previousY;
|
|
3480
|
+
vertices.push(deltaX < 0 ? -2 * deltaX - 1 : 2 * deltaX, deltaY < 0 ? -2 * deltaY - 1 : 2 * deltaY);
|
|
3481
|
+
previousX = x;
|
|
3482
|
+
previousY = y;
|
|
3483
|
+
}
|
|
3484
|
+
}
|
|
3485
|
+
function writeLine(line) {
|
|
3486
|
+
(hasPolygons ? ringLengths : partLengths).push(line.length);
|
|
3487
|
+
writePoints(line);
|
|
3488
|
+
}
|
|
3489
|
+
function writePolygon(polygon) {
|
|
3490
|
+
partLengths.push(polygon.length);
|
|
3491
|
+
for (const ring of polygon) {
|
|
3492
|
+
ringLengths.push(ring.length);
|
|
3493
|
+
writePoints(ring);
|
|
3494
|
+
}
|
|
3495
|
+
}
|
|
3496
|
+
for (const geometry of geometries) {
|
|
3497
|
+
switch (geometry.type) {
|
|
3498
|
+
case "Point":
|
|
3499
|
+
types.push(0);
|
|
3500
|
+
writePoints([geometry.coordinates]);
|
|
3501
|
+
break;
|
|
3502
|
+
case "LineString":
|
|
3503
|
+
types.push(1);
|
|
3504
|
+
writeLine(geometry.coordinates);
|
|
3505
|
+
break;
|
|
3506
|
+
case "Polygon":
|
|
3507
|
+
types.push(2);
|
|
3508
|
+
writePolygon(geometry.coordinates);
|
|
3509
|
+
break;
|
|
3510
|
+
case "MultiPoint":
|
|
3511
|
+
types.push(3);
|
|
3512
|
+
geometryLengths.push(geometry.coordinates.length);
|
|
3513
|
+
writePoints(geometry.coordinates);
|
|
3514
|
+
break;
|
|
3515
|
+
case "MultiLineString":
|
|
3516
|
+
types.push(4);
|
|
3517
|
+
geometryLengths.push(geometry.coordinates.length);
|
|
3518
|
+
geometry.coordinates.forEach(writeLine);
|
|
3519
|
+
break;
|
|
3520
|
+
case "MultiPolygon":
|
|
3521
|
+
types.push(5);
|
|
3522
|
+
geometryLengths.push(geometry.coordinates.length);
|
|
3523
|
+
geometry.coordinates.forEach(writePolygon);
|
|
3524
|
+
break;
|
|
3525
|
+
}
|
|
3526
|
+
}
|
|
3527
|
+
const streams = [encodeIntegerStream(16, types)];
|
|
3528
|
+
if (geometryLengths.length)
|
|
3529
|
+
streams.push(encodeIntegerStream(49, geometryLengths));
|
|
3530
|
+
if (partLengths.length)
|
|
3531
|
+
streams.push(encodeIntegerStream(50, partLengths));
|
|
3532
|
+
if (ringLengths.length)
|
|
3533
|
+
streams.push(encodeIntegerStream(51, ringLengths));
|
|
3534
|
+
streams.push(encodeStream(19, 66, vertices.length, encodeVarints(vertices)));
|
|
3535
|
+
return concatenateBytes([encodeVarints([streams.length]), ...streams]);
|
|
3536
|
+
}
|
|
3537
|
+
|
|
3538
|
+
// dist/mlt/lib/encode-mlt.js
|
|
3539
|
+
function encodeMLT(input, options = {}) {
|
|
3540
|
+
const table = input instanceof arrow6.Table ? input : input.data;
|
|
3541
|
+
const configuration = options.mlt ?? {};
|
|
3542
|
+
const extent = configuration.extent ?? 4096;
|
|
3543
|
+
const coordinates = configuration.coordinates ?? "local";
|
|
3544
|
+
const layerName = configuration.layerName ?? "features";
|
|
3545
|
+
const maximum = configuration.maxFeatures ?? 1e5;
|
|
3546
|
+
if (!Number.isInteger(extent) || extent < 1 || extent > 65536)
|
|
3547
|
+
throw new Error("Invalid MLT extent");
|
|
3548
|
+
if (!["local", "tile"].includes(coordinates))
|
|
3549
|
+
throw new Error("Invalid MLT coordinates");
|
|
3550
|
+
if (!layerName)
|
|
3551
|
+
throw new Error("MLT layerName must be nonempty");
|
|
3552
|
+
if (!Number.isSafeInteger(maximum) || maximum < 1 || table.numRows > maximum)
|
|
3553
|
+
throw new Error("MLT feature limit exceeded or invalid");
|
|
3554
|
+
const geoMetadata = getGeoMetadata(table.schema.metadata);
|
|
3555
|
+
const geometryName = configuration.geometryColumn ?? (geoMetadata == null ? void 0 : geoMetadata.primary_column);
|
|
3556
|
+
const candidates = table.schema.fields.filter((field) => geometryName ? field.name === geometryName : field.metadata.get("ARROW:extension:name") === "geoarrow.wkb");
|
|
3557
|
+
if (candidates.length !== 1)
|
|
3558
|
+
throw new Error("Select one GeoArrow WKB column with mlt.geometryColumn");
|
|
3559
|
+
const geometryField = candidates[0];
|
|
3560
|
+
const columnMetadata = geoMetadata == null ? void 0 : geoMetadata.columns[geometryField.name];
|
|
3561
|
+
if (geometryField.metadata.get("ARROW:extension:name") !== "geoarrow.wkb" && (columnMetadata == null ? void 0 : columnMetadata.encoding) !== "wkb")
|
|
3562
|
+
throw new Error("MLT requires GeoArrow WKB; tile native input with the Arrow tiler first");
|
|
3563
|
+
const extensionMetadata = JSON.parse(geometryField.metadata.get("ARROW:extension:metadata") || "{}");
|
|
3564
|
+
const coordinateSystem = extensionMetadata.crs ?? (columnMetadata == null ? void 0 : columnMetadata.crs) ?? (columnMetadata && !Object.hasOwn(columnMetadata, "crs") ? "OGC:CRS84" : null);
|
|
3565
|
+
if (coordinateSystem != null)
|
|
3566
|
+
throw new Error("MLT requires tile-local geometry; use the Arrow tiler for geographic input");
|
|
3567
|
+
const geometryColumn = table.getChild(geometryField.name);
|
|
3568
|
+
const propertyNames = configuration.propertyColumns ?? table.schema.fields.filter((field) => {
|
|
3569
|
+
var _a;
|
|
3570
|
+
return field.name !== geometryField.name && !((_a = field.metadata.get("ARROW:extension:name")) == null ? void 0 : _a.startsWith("geoarrow.")) && !(geoMetadata == null ? void 0 : geoMetadata.columns[field.name]);
|
|
3571
|
+
}).map((field) => field.name);
|
|
3572
|
+
if (new Set(propertyNames).size !== propertyNames.length)
|
|
3573
|
+
throw new Error("Duplicate MLT property column");
|
|
3574
|
+
const properties = propertyNames.map((name) => {
|
|
3575
|
+
const column = table.getChild(name);
|
|
3576
|
+
if (!column || name === geometryField.name)
|
|
3577
|
+
throw new Error(`Unknown MLT property column: ${name}`);
|
|
3578
|
+
return { name, column, type: getColumnType(column.type) };
|
|
3579
|
+
});
|
|
3580
|
+
const identifier = configuration.idColumn ? table.getChild(configuration.idColumn) : null;
|
|
3581
|
+
if (configuration.idColumn && !identifier)
|
|
3582
|
+
throw new Error("Unknown MLT idColumn");
|
|
3583
|
+
const rows = [];
|
|
3584
|
+
const geometries = [];
|
|
3585
|
+
const identifiers = [];
|
|
3586
|
+
for (let row = 0; row < table.numRows; row++) {
|
|
3587
|
+
if (!geometryColumn.isValid(row))
|
|
3588
|
+
continue;
|
|
3589
|
+
const geometry = quantizeGeometry(convertWKBToGeometry(geometryColumn.get(row)), coordinates === "local" ? extent : 1);
|
|
3590
|
+
if (!geometry)
|
|
3591
|
+
continue;
|
|
3592
|
+
const value = identifier == null ? void 0 : identifier.get(row);
|
|
3593
|
+
const numericId = value == null ? null : getScalar(value);
|
|
3594
|
+
if (numericId !== null && (typeof numericId !== "number" || !Number.isSafeInteger(numericId) || numericId < 0))
|
|
3595
|
+
throw new Error("MLT feature IDs must be nonnegative safe integers");
|
|
3596
|
+
rows.push(row);
|
|
3597
|
+
geometries.push(geometry);
|
|
3598
|
+
identifiers.push(numericId);
|
|
3599
|
+
}
|
|
3600
|
+
if (!rows.length)
|
|
3601
|
+
return new ArrayBuffer(0);
|
|
3602
|
+
const metadata = [];
|
|
3603
|
+
const columns = [];
|
|
3604
|
+
if (identifier) {
|
|
3605
|
+
const nullable = identifiers.some((value) => value === null);
|
|
3606
|
+
const longId = identifiers.some((value) => value !== null && value > 4294967295);
|
|
3607
|
+
metadata.push(Uint8Array.of((longId ? 2 : 0) + Number(nullable)));
|
|
3608
|
+
columns.push(concatenateBytes([
|
|
3609
|
+
...nullable ? [
|
|
3610
|
+
encodeBooleanStream(0, identifiers.map((value) => value !== null))
|
|
3611
|
+
] : [],
|
|
3612
|
+
encodeIntegerStream(16, identifiers.filter((value) => value !== null))
|
|
3613
|
+
]));
|
|
3614
|
+
}
|
|
3615
|
+
metadata.push(Uint8Array.of(4));
|
|
3616
|
+
columns.push(encodeGeometryColumn(geometries));
|
|
3617
|
+
for (const { name, column, type } of properties) {
|
|
3618
|
+
const values = rows.map((row) => column.get(row)).map((value) => value == null ? null : getScalar(value));
|
|
3619
|
+
const nullable = values.some((value) => value === null);
|
|
3620
|
+
const present = values.filter((value) => value !== null);
|
|
3621
|
+
const streams = nullable ? [
|
|
3622
|
+
encodeBooleanStream(0, values.map((value) => value !== null))
|
|
3623
|
+
] : [];
|
|
3624
|
+
metadata.push(concatenateBytes([Uint8Array.of(type + Number(nullable)), encodeString(name)]));
|
|
3625
|
+
switch (type) {
|
|
3626
|
+
case 10:
|
|
3627
|
+
streams.push(encodeBooleanStream(16, present));
|
|
3628
|
+
break;
|
|
3629
|
+
case 28: {
|
|
3630
|
+
const strings = present.map((value) => new TextEncoder().encode(value));
|
|
3631
|
+
streams.push(encodeIntegerStream(48, strings.map((value) => value.length)));
|
|
3632
|
+
const bytes = concatenateBytes(strings);
|
|
3633
|
+
streams.push(encodeStream(16, 0, bytes.length, bytes));
|
|
3634
|
+
break;
|
|
3635
|
+
}
|
|
3636
|
+
default: {
|
|
3637
|
+
const bytes = new Uint8Array(present.length * 8);
|
|
3638
|
+
const view = new DataView(bytes.buffer);
|
|
3639
|
+
for (let index = 0; index < present.length; index++)
|
|
3640
|
+
view.setFloat64(index * 8, present[index], true);
|
|
3641
|
+
streams.push(encodeStream(16, 0, present.length, bytes));
|
|
3642
|
+
}
|
|
3643
|
+
}
|
|
3644
|
+
columns.push(concatenateBytes([...type === 28 ? [encodeVarints([streams.length])] : [], ...streams]));
|
|
3645
|
+
}
|
|
3646
|
+
const body = concatenateBytes([
|
|
3647
|
+
Uint8Array.of(1),
|
|
3648
|
+
encodeString(layerName),
|
|
3649
|
+
encodeVarints([extent, metadata.length]),
|
|
3650
|
+
...metadata,
|
|
3651
|
+
...columns
|
|
3652
|
+
]);
|
|
3653
|
+
return concatenateBytes([encodeVarints([body.length]), body]).buffer;
|
|
3654
|
+
}
|
|
3655
|
+
function getColumnType(type) {
|
|
3656
|
+
if (arrow6.DataType.isDictionary(type))
|
|
3657
|
+
return getColumnType(type.dictionary);
|
|
3658
|
+
switch (type.typeId) {
|
|
3659
|
+
case arrow6.Type.Bool:
|
|
3660
|
+
return 10;
|
|
3661
|
+
case arrow6.Type.Utf8:
|
|
3662
|
+
return 28;
|
|
3663
|
+
case arrow6.Type.Null:
|
|
3664
|
+
case arrow6.Type.Int:
|
|
3665
|
+
case arrow6.Type.Float:
|
|
3666
|
+
return 26;
|
|
3667
|
+
default:
|
|
3668
|
+
throw new Error("Unsupported MLT attribute type; select scalar mlt.propertyColumns");
|
|
3669
|
+
}
|
|
3670
|
+
}
|
|
3671
|
+
function getScalar(value) {
|
|
3672
|
+
if (typeof value === "bigint") {
|
|
3673
|
+
if (value < BigInt(Number.MIN_SAFE_INTEGER) || value > BigInt(Number.MAX_SAFE_INTEGER))
|
|
3674
|
+
throw new Error("MLT integer exceeds the supported safe integer range");
|
|
3675
|
+
return Number(value);
|
|
3676
|
+
}
|
|
3677
|
+
if (typeof value === "number") {
|
|
3678
|
+
if (!Number.isFinite(value) || Number.isInteger(value) && !Number.isSafeInteger(value))
|
|
3679
|
+
throw new Error("Invalid or unsafe MLT number");
|
|
3680
|
+
return value;
|
|
3681
|
+
}
|
|
3682
|
+
if (typeof value === "string" || typeof value === "boolean")
|
|
3683
|
+
return value;
|
|
3684
|
+
throw new Error("Unsupported MLT scalar value");
|
|
3685
|
+
}
|
|
3686
|
+
|
|
3687
|
+
// dist/mlt/mlt-writer.js
|
|
3688
|
+
init_mlt_format();
|
|
3689
|
+
var VERSION3 = true ? "5.0.0-alpha.13" : "latest";
|
|
3690
|
+
var MLTWriter = {
|
|
3691
|
+
...MLTFormat,
|
|
3692
|
+
name: "MLT Writer",
|
|
3693
|
+
version: VERSION3,
|
|
3694
|
+
binary: true,
|
|
3695
|
+
options: { mlt: {} },
|
|
3696
|
+
/** Encodes a materialized tile asynchronously for the core writer API. */
|
|
3697
|
+
encode: async (data, options) => encodeMLT(data, options),
|
|
3698
|
+
/** Encodes one tile synchronously. */
|
|
3699
|
+
encodeSync: encodeMLT
|
|
3700
|
+
};
|
|
3701
|
+
//# sourceMappingURL=index.cjs.map
|