@math.gl/geospatial 5.0.0-beta.3 → 5.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +192 -2
- package/THIRD-PARTY-NOTICES.md +192 -20
- package/dist/expressions.d.ts +1 -1
- package/dist/expressions.d.ts.map +1 -1
- package/dist/index.cjs +456 -4614
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +9 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/dist/projection/experimental/common/adjust_lat.js +1 -1
- package/dist/projection/experimental/common/adjust_lat.js.map +1 -1
- package/dist/projection/experimental/common/adjust_lon.js +1 -1
- package/dist/projection/experimental/common/adjust_lon.js.map +1 -1
- package/dist/projection/experimental/common/asinhy.js +1 -1
- package/dist/projection/experimental/common/asinhy.js.map +1 -1
- package/dist/projection/experimental/common/asinz.js +1 -1
- package/dist/projection/experimental/common/asinz.js.map +1 -1
- package/dist/projection/experimental/common/authlat.js +1 -1
- package/dist/projection/experimental/common/authlat.js.map +1 -1
- package/dist/projection/experimental/common/authset.js +1 -1
- package/dist/projection/experimental/common/authset.js.map +1 -1
- package/dist/projection/experimental/common/clens.js +1 -1
- package/dist/projection/experimental/common/clens.js.map +1 -1
- package/dist/projection/experimental/common/clens_cmplx.js +1 -1
- package/dist/projection/experimental/common/clens_cmplx.js.map +1 -1
- package/dist/projection/experimental/common/constants.js +1 -1
- package/dist/projection/experimental/common/constants.js.map +1 -1
- package/dist/projection/experimental/common/cosh.js +1 -1
- package/dist/projection/experimental/common/cosh.js.map +1 -1
- package/dist/projection/experimental/common/e0fn.js +1 -1
- package/dist/projection/experimental/common/e0fn.js.map +1 -1
- package/dist/projection/experimental/common/e1fn.js +1 -1
- package/dist/projection/experimental/common/e1fn.js.map +1 -1
- package/dist/projection/experimental/common/e2fn.js +1 -1
- package/dist/projection/experimental/common/e2fn.js.map +1 -1
- package/dist/projection/experimental/common/e3fn.js +1 -1
- package/dist/projection/experimental/common/e3fn.js.map +1 -1
- package/dist/projection/experimental/common/fL.js +1 -1
- package/dist/projection/experimental/common/fL.js.map +1 -1
- package/dist/projection/experimental/common/gN.js +1 -1
- package/dist/projection/experimental/common/gN.js.map +1 -1
- package/dist/projection/experimental/common/gatg.js +1 -1
- package/dist/projection/experimental/common/gatg.js.map +1 -1
- package/dist/projection/experimental/common/hypot.js +1 -1
- package/dist/projection/experimental/common/hypot.js.map +1 -1
- package/dist/projection/experimental/common/imlfn.js +1 -1
- package/dist/projection/experimental/common/imlfn.js.map +1 -1
- package/dist/projection/experimental/common/invlatiso.js +1 -1
- package/dist/projection/experimental/common/invlatiso.js.map +1 -1
- package/dist/projection/experimental/common/iqsfnz.js +1 -1
- package/dist/projection/experimental/common/iqsfnz.js.map +1 -1
- package/dist/projection/experimental/common/latiso.js +1 -1
- package/dist/projection/experimental/common/latiso.js.map +1 -1
- package/dist/projection/experimental/common/log1py.js +1 -1
- package/dist/projection/experimental/common/log1py.js.map +1 -1
- package/dist/projection/experimental/common/mlfn.js +1 -1
- package/dist/projection/experimental/common/mlfn.js.map +1 -1
- package/dist/projection/experimental/common/msfnz.js +1 -1
- package/dist/projection/experimental/common/msfnz.js.map +1 -1
- package/dist/projection/experimental/common/phi2z.js +1 -1
- package/dist/projection/experimental/common/phi2z.js.map +1 -1
- package/dist/projection/experimental/common/pj_enfn.js +1 -1
- package/dist/projection/experimental/common/pj_enfn.js.map +1 -1
- package/dist/projection/experimental/common/pj_inv_mlfn.js +1 -1
- package/dist/projection/experimental/common/pj_inv_mlfn.js.map +1 -1
- package/dist/projection/experimental/common/pj_mlfn.js +1 -1
- package/dist/projection/experimental/common/pj_mlfn.js.map +1 -1
- package/dist/projection/experimental/common/qsfnz.js +1 -1
- package/dist/projection/experimental/common/qsfnz.js.map +1 -1
- package/dist/projection/experimental/common/sign.js +1 -1
- package/dist/projection/experimental/common/sign.js.map +1 -1
- package/dist/projection/experimental/common/sinh.js +1 -1
- package/dist/projection/experimental/common/sinh.js.map +1 -1
- package/dist/projection/experimental/common/srat.js +1 -1
- package/dist/projection/experimental/common/srat.js.map +1 -1
- package/dist/projection/experimental/common/tsfnz.js +1 -1
- package/dist/projection/experimental/common/tsfnz.js.map +1 -1
- package/dist/projection/experimental/common/vincenty.js +1 -1
- package/dist/projection/experimental/common/vincenty.js.map +1 -1
- package/dist/projection/experimental/core.cjs +100 -2
- package/dist/projection/experimental/core.cjs.map +2 -2
- package/dist/projection/experimental/core.d.ts +1 -0
- package/dist/projection/experimental/core.d.ts.map +1 -1
- package/dist/projection/experimental/crs/datum-table.js +1 -1
- package/dist/projection/experimental/crs/datum-table.js.map +1 -1
- package/dist/projection/experimental/crs/ellipsoid-table.js +1 -1
- package/dist/projection/experimental/crs/ellipsoid-table.js.map +1 -1
- package/dist/projection/experimental/crs/primemeridian-table.js +1 -1
- package/dist/projection/experimental/crs/primemeridian-table.js.map +1 -1
- package/dist/projection/experimental/crs/structured.js +1 -1
- package/dist/projection/experimental/crs/structured.js.map +1 -1
- package/dist/projection/experimental/crs/wkt.js +1 -1
- package/dist/projection/experimental/crs/wkt.js.map +1 -1
- package/dist/projection/experimental/datum.js +1 -1
- package/dist/projection/experimental/datum.js.map +1 -1
- package/dist/projection/experimental/ellipsoidal-gnomonic.js +1 -1
- package/dist/projection/experimental/ellipsoidal-gnomonic.js.map +1 -1
- package/dist/projection/experimental/entries/projections/eqc.cjs +1 -0
- package/dist/projection/experimental/entries/projections/eqc.cjs.map +1 -1
- package/dist/projection/experimental/entries/projections/merc.cjs +1 -0
- package/dist/projection/experimental/entries/projections/merc.cjs.map +1 -1
- package/dist/projection/experimental/grids/geotiff.js +1 -1
- package/dist/projection/experimental/grids/geotiff.js.map +1 -1
- package/dist/projection/experimental/grids/ntv2.js +1 -1
- package/dist/projection/experimental/grids/ntv2.js.map +1 -1
- package/dist/projection/experimental/index.cjs +102 -2
- package/dist/projection/experimental/index.cjs.map +3 -3
- package/dist/projection/experimental/kernels/aea.js +1 -1
- package/dist/projection/experimental/kernels/aea.js.map +1 -1
- package/dist/projection/experimental/kernels/aeqd.js +1 -1
- package/dist/projection/experimental/kernels/aeqd.js.map +1 -1
- package/dist/projection/experimental/kernels/bonne.js +1 -1
- package/dist/projection/experimental/kernels/bonne.js.map +1 -1
- package/dist/projection/experimental/kernels/cass.js +1 -1
- package/dist/projection/experimental/kernels/cass.js.map +1 -1
- package/dist/projection/experimental/kernels/cea.js +1 -1
- package/dist/projection/experimental/kernels/cea.js.map +1 -1
- package/dist/projection/experimental/kernels/eck6.js +1 -1
- package/dist/projection/experimental/kernels/eck6.js.map +1 -1
- package/dist/projection/experimental/kernels/eqdc.js +1 -1
- package/dist/projection/experimental/kernels/eqdc.js.map +1 -1
- package/dist/projection/experimental/kernels/eqearth.js +1 -1
- package/dist/projection/experimental/kernels/eqearth.js.map +1 -1
- package/dist/projection/experimental/kernels/equi.js +1 -1
- package/dist/projection/experimental/kernels/equi.js.map +1 -1
- package/dist/projection/experimental/kernels/etmerc.js +1 -1
- package/dist/projection/experimental/kernels/etmerc.js.map +1 -1
- package/dist/projection/experimental/kernels/gauss.js +1 -1
- package/dist/projection/experimental/kernels/gauss.js.map +1 -1
- package/dist/projection/experimental/kernels/geos.js +1 -1
- package/dist/projection/experimental/kernels/geos.js.map +1 -1
- package/dist/projection/experimental/kernels/gnom.js +1 -1
- package/dist/projection/experimental/kernels/gnom.js.map +1 -1
- package/dist/projection/experimental/kernels/gstmerc.js +1 -1
- package/dist/projection/experimental/kernels/gstmerc.js.map +1 -1
- package/dist/projection/experimental/kernels/krovak.js +1 -1
- package/dist/projection/experimental/kernels/krovak.js.map +1 -1
- package/dist/projection/experimental/kernels/laea.js +1 -1
- package/dist/projection/experimental/kernels/laea.js.map +1 -1
- package/dist/projection/experimental/kernels/lcc.js +1 -1
- package/dist/projection/experimental/kernels/lcc.js.map +1 -1
- package/dist/projection/experimental/kernels/mill.js +1 -1
- package/dist/projection/experimental/kernels/mill.js.map +1 -1
- package/dist/projection/experimental/kernels/moll.js +1 -1
- package/dist/projection/experimental/kernels/moll.js.map +1 -1
- package/dist/projection/experimental/kernels/nzmg.js +1 -1
- package/dist/projection/experimental/kernels/nzmg.js.map +1 -1
- package/dist/projection/experimental/kernels/omerc.js +1 -1
- package/dist/projection/experimental/kernels/omerc.js.map +1 -1
- package/dist/projection/experimental/kernels/poly.js +1 -1
- package/dist/projection/experimental/kernels/poly.js.map +1 -1
- package/dist/projection/experimental/kernels/qsc.js +1 -1
- package/dist/projection/experimental/kernels/qsc.js.map +1 -1
- package/dist/projection/experimental/kernels/robin.js +1 -1
- package/dist/projection/experimental/kernels/robin.js.map +1 -1
- package/dist/projection/experimental/kernels/sinu.js +1 -1
- package/dist/projection/experimental/kernels/sinu.js.map +1 -1
- package/dist/projection/experimental/kernels/somerc.js +1 -1
- package/dist/projection/experimental/kernels/somerc.js.map +1 -1
- package/dist/projection/experimental/kernels/stere.js +1 -1
- package/dist/projection/experimental/kernels/stere.js.map +1 -1
- package/dist/projection/experimental/kernels/sterea.js +1 -1
- package/dist/projection/experimental/kernels/sterea.js.map +1 -1
- package/dist/projection/experimental/kernels/tmerc.js +1 -1
- package/dist/projection/experimental/kernels/tmerc.js.map +1 -1
- package/dist/projection/experimental/kernels/tpers.js +1 -1
- package/dist/projection/experimental/kernels/tpers.js.map +1 -1
- package/dist/projection/experimental/kernels/vandg.js +1 -1
- package/dist/projection/experimental/kernels/vandg.js.map +1 -1
- package/dist/projection/experimental/kinematic-helmert.js +1 -1
- package/dist/projection/experimental/kinematic-helmert.js.map +1 -1
- package/dist/projection/experimental/lazy-projections/index.cjs +100 -2
- package/dist/projection/experimental/lazy-projections/index.cjs.map +2 -2
- package/dist/projection/experimental/projections/equidistant-cylindrical.d.ts.map +1 -1
- package/dist/projection/experimental/projections/equidistant-cylindrical.js +1 -0
- package/dist/projection/experimental/projections/equidistant-cylindrical.js.map +1 -1
- package/dist/projection/experimental/projections/mercator.d.ts.map +1 -1
- package/dist/projection/experimental/projections/mercator.js +1 -0
- package/dist/projection/experimental/projections/mercator.js.map +1 -1
- package/dist/projection/experimental/transform-description.d.ts +8 -0
- package/dist/projection/experimental/transform-description.d.ts.map +1 -0
- package/dist/projection/experimental/transform-description.js +57 -0
- package/dist/projection/experimental/transform-description.js.map +1 -0
- package/dist/projection/experimental/types.d.ts +5 -0
- package/dist/projection/experimental/types.d.ts.map +1 -1
- package/dist/projection/experimental/typescript-projection.d.ts +4 -0
- package/dist/projection/experimental/typescript-projection.d.ts.map +1 -1
- package/dist/projection/experimental/typescript-projection.js +54 -5
- package/dist/projection/experimental/typescript-projection.js.map +1 -1
- package/dist/projection/index.cjs +102 -2
- package/dist/projection/index.cjs.map +3 -3
- package/dist/projection/transform-analysis.cjs +100 -2
- package/dist/projection/transform-analysis.cjs.map +2 -2
- package/dist/projection/transform-description.d.ts +44 -0
- package/dist/projection/transform-description.d.ts.map +1 -0
- package/dist/projection/transform-description.js +5 -0
- package/dist/projection/transform-description.js.map +1 -0
- package/dist/projection/types.d.ts +4 -0
- package/dist/projection/types.d.ts.map +1 -1
- package/dist/tasks/definitions.d.ts +3 -3
- package/dist/tasks/index.cjs +107 -2
- package/dist/tasks/index.cjs.map +3 -3
- package/dist/tasks/index.d.ts +1 -1
- package/dist/tasks/index.d.ts.map +1 -1
- package/dist/tasks/map-worker.js +1 -1
- package/dist/tasks/map-worker.js.map +1 -1
- package/dist/tasks/operations.d.ts +1 -1
- package/dist/tasks/operations.d.ts.map +1 -1
- package/dist/tasks/projection-worker.js +1 -1
- package/dist/tasks/projection-worker.js.map +1 -1
- package/dist/terrain/contour-boundary-diagnostics.d.ts +23 -0
- package/dist/terrain/contour-boundary-diagnostics.d.ts.map +1 -0
- package/dist/terrain/contour-boundary-diagnostics.js +62 -0
- package/dist/terrain/contour-boundary-diagnostics.js.map +1 -0
- package/dist/terrain/contour-mixed-weld.d.ts +25 -0
- package/dist/terrain/contour-mixed-weld.d.ts.map +1 -0
- package/dist/terrain/contour-mixed-weld.js +194 -0
- package/dist/terrain/contour-mixed-weld.js.map +1 -0
- package/dist/terrain/contour-tile-paths.d.ts +7 -0
- package/dist/terrain/contour-tile-paths.d.ts.map +1 -0
- package/dist/terrain/contour-tile-paths.js +12 -0
- package/dist/terrain/contour-tile-paths.js.map +1 -0
- package/dist/terrain/contour-tile-weld.d.ts +24 -0
- package/dist/terrain/contour-tile-weld.d.ts.map +1 -0
- package/dist/terrain/contour-tile-weld.js +147 -0
- package/dist/terrain/contour-tile-weld.js.map +1 -0
- package/dist/terrain/gradient-pyramid.d.ts +29 -0
- package/dist/terrain/gradient-pyramid.d.ts.map +1 -0
- package/dist/terrain/gradient-pyramid.js +94 -0
- package/dist/terrain/gradient-pyramid.js.map +1 -0
- package/dist/terrain/height-field.d.ts.map +1 -1
- package/dist/terrain/height-field.js +48 -5
- package/dist/terrain/height-field.js.map +1 -1
- package/dist/terrain/index.cjs +448 -4
- package/dist/terrain/index.cjs.map +3 -3
- package/dist/terrain/index.d.ts +9 -0
- package/dist/terrain/index.d.ts.map +1 -1
- package/dist/terrain/index.js +5 -0
- package/dist/terrain/index.js.map +1 -1
- package/dist/terrain/tiled.d.ts +10 -2
- package/dist/terrain/tiled.d.ts.map +1 -1
- package/dist/terrain/tiled.js +5 -1
- package/dist/terrain/tiled.js.map +1 -1
- package/dist/terrain/types.d.ts +6 -0
- package/dist/terrain/types.d.ts.map +1 -1
- package/dist/turf.cjs +25 -671
- package/dist/turf.cjs.map +3 -3
- package/dist/turf.d.ts +1 -1
- package/dist/turf.d.ts.map +1 -1
- package/dist/turf.js +2 -2
- package/dist/turf.js.map +1 -1
- package/package.json +15 -19
- package/src/expressions.ts +1 -1
- package/src/index.ts +15 -123
- package/src/projection/experimental/common/adjust_lat.ts +1 -1
- package/src/projection/experimental/common/adjust_lon.ts +1 -1
- package/src/projection/experimental/common/asinhy.ts +1 -1
- package/src/projection/experimental/common/asinz.ts +1 -1
- package/src/projection/experimental/common/authlat.ts +1 -1
- package/src/projection/experimental/common/authset.ts +1 -1
- package/src/projection/experimental/common/clens.ts +1 -1
- package/src/projection/experimental/common/clens_cmplx.ts +1 -1
- package/src/projection/experimental/common/constants.ts +1 -1
- package/src/projection/experimental/common/cosh.ts +1 -1
- package/src/projection/experimental/common/e0fn.ts +1 -1
- package/src/projection/experimental/common/e1fn.ts +1 -1
- package/src/projection/experimental/common/e2fn.ts +1 -1
- package/src/projection/experimental/common/e3fn.ts +1 -1
- package/src/projection/experimental/common/fL.ts +1 -1
- package/src/projection/experimental/common/gN.ts +1 -1
- package/src/projection/experimental/common/gatg.ts +1 -1
- package/src/projection/experimental/common/hypot.ts +1 -1
- package/src/projection/experimental/common/imlfn.ts +1 -1
- package/src/projection/experimental/common/invlatiso.ts +1 -1
- package/src/projection/experimental/common/iqsfnz.ts +1 -1
- package/src/projection/experimental/common/latiso.ts +1 -1
- package/src/projection/experimental/common/log1py.ts +1 -1
- package/src/projection/experimental/common/mlfn.ts +1 -1
- package/src/projection/experimental/common/msfnz.ts +1 -1
- package/src/projection/experimental/common/phi2z.ts +1 -1
- package/src/projection/experimental/common/pj_enfn.ts +1 -1
- package/src/projection/experimental/common/pj_inv_mlfn.ts +1 -1
- package/src/projection/experimental/common/pj_mlfn.ts +1 -1
- package/src/projection/experimental/common/qsfnz.ts +1 -1
- package/src/projection/experimental/common/sign.ts +1 -1
- package/src/projection/experimental/common/sinh.ts +1 -1
- package/src/projection/experimental/common/srat.ts +1 -1
- package/src/projection/experimental/common/tsfnz.ts +1 -1
- package/src/projection/experimental/common/vincenty.ts +1 -1
- package/src/projection/experimental/core.ts +8 -0
- package/src/projection/experimental/crs/datum-table.ts +1 -1
- package/src/projection/experimental/crs/ellipsoid-table.ts +1 -1
- package/src/projection/experimental/crs/primemeridian-table.ts +1 -1
- package/src/projection/experimental/crs/structured.ts +1 -1
- package/src/projection/experimental/crs/wkt.ts +1 -1
- package/src/projection/experimental/datum.ts +1 -1
- package/src/projection/experimental/ellipsoidal-gnomonic.ts +1 -1
- package/src/projection/experimental/exact-helmert.ts +1 -1
- package/src/projection/experimental/grids/geotiff.ts +1 -1
- package/src/projection/experimental/grids/grid.ts +1 -1
- package/src/projection/experimental/grids/ntv2.ts +1 -1
- package/src/projection/experimental/helmert-flat.ts +1 -1
- package/src/projection/experimental/kernels/aea.ts +1 -1
- package/src/projection/experimental/kernels/aeqd.ts +1 -1
- package/src/projection/experimental/kernels/bonne.ts +1 -1
- package/src/projection/experimental/kernels/cass.ts +1 -1
- package/src/projection/experimental/kernels/cea.ts +1 -1
- package/src/projection/experimental/kernels/eck6.ts +1 -1
- package/src/projection/experimental/kernels/eqdc.ts +1 -1
- package/src/projection/experimental/kernels/eqearth.ts +1 -1
- package/src/projection/experimental/kernels/equi.ts +1 -1
- package/src/projection/experimental/kernels/etmerc.ts +1 -1
- package/src/projection/experimental/kernels/gauss.ts +1 -1
- package/src/projection/experimental/kernels/geos.ts +1 -1
- package/src/projection/experimental/kernels/gnom.ts +1 -1
- package/src/projection/experimental/kernels/gstmerc.ts +1 -1
- package/src/projection/experimental/kernels/krovak.ts +1 -1
- package/src/projection/experimental/kernels/laea.ts +1 -1
- package/src/projection/experimental/kernels/lcc.ts +1 -1
- package/src/projection/experimental/kernels/mill.ts +1 -1
- package/src/projection/experimental/kernels/moll.ts +1 -1
- package/src/projection/experimental/kernels/nzmg.ts +1 -1
- package/src/projection/experimental/kernels/omerc.ts +1 -1
- package/src/projection/experimental/kernels/ortho.ts +1 -1
- package/src/projection/experimental/kernels/poly.ts +1 -1
- package/src/projection/experimental/kernels/qsc.ts +1 -1
- package/src/projection/experimental/kernels/robin.ts +1 -1
- package/src/projection/experimental/kernels/sinu.ts +1 -1
- package/src/projection/experimental/kernels/somerc.ts +1 -1
- package/src/projection/experimental/kernels/stere.ts +1 -1
- package/src/projection/experimental/kernels/sterea.ts +1 -1
- package/src/projection/experimental/kernels/tmerc.ts +1 -1
- package/src/projection/experimental/kernels/tpers.ts +1 -1
- package/src/projection/experimental/kernels/vandg.ts +1 -1
- package/src/projection/experimental/kinematic-helmert-flat.ts +1 -1
- package/src/projection/experimental/kinematic-helmert.ts +1 -1
- package/src/projection/experimental/projection-pipeline.ts +1 -1
- package/src/projection/experimental/projections/equidistant-cylindrical.ts +1 -0
- package/src/projection/experimental/projections/mercator.ts +1 -0
- package/src/projection/experimental/projections/ob-tran.ts +1 -1
- package/src/projection/experimental/transform-description.ts +82 -0
- package/src/projection/experimental/types.ts +5 -0
- package/src/projection/experimental/typescript-projection.ts +54 -6
- package/src/projection/transform-description.ts +69 -0
- package/src/projection/types.ts +11 -0
- package/src/tasks/definitions.ts +1 -1
- package/src/tasks/index.ts +1 -1
- package/src/tasks/map-worker.ts +1 -1
- package/src/tasks/operations.ts +1 -1
- package/src/tasks/projection-worker.ts +1 -1
- package/src/terrain/contour-boundary-diagnostics.ts +90 -0
- package/src/terrain/contour-mixed-weld.ts +254 -0
- package/src/terrain/contour-tile-paths.ts +20 -0
- package/src/terrain/contour-tile-weld.ts +182 -0
- package/src/terrain/gradient-pyramid.ts +129 -0
- package/src/terrain/height-field.ts +45 -5
- package/src/terrain/index.ts +12 -0
- package/src/terrain/tiled.ts +16 -3
- package/src/terrain/types.ts +9 -1
- package/src/turf.ts +7 -3
- package/crs/README.md +0 -84
- package/crs/schemas/README.md +0 -9
- package/dist/geoarrow/builder-entry.d.ts +0 -4
- package/dist/geoarrow/builder-entry.d.ts.map +0 -1
- package/dist/geoarrow/builder-entry.js +0 -5
- package/dist/geoarrow/builder-entry.js.map +0 -1
- package/dist/geoarrow/builder.d.ts +0 -106
- package/dist/geoarrow/builder.d.ts.map +0 -1
- package/dist/geoarrow/builder.js +0 -668
- package/dist/geoarrow/builder.js.map +0 -1
- package/dist/geoarrow/codecs.d.ts +0 -24
- package/dist/geoarrow/codecs.d.ts.map +0 -1
- package/dist/geoarrow/codecs.js +0 -916
- package/dist/geoarrow/codecs.js.map +0 -1
- package/dist/geoarrow/index.cjs +0 -4352
- package/dist/geoarrow/index.cjs.map +0 -6
- package/dist/geoarrow/index.d.ts +0 -21
- package/dist/geoarrow/index.d.ts.map +0 -1
- package/dist/geoarrow/index.js +0 -15
- package/dist/geoarrow/index.js.map +0 -1
- package/dist/geoarrow/kernels.d.ts +0 -56
- package/dist/geoarrow/kernels.d.ts.map +0 -1
- package/dist/geoarrow/kernels.js +0 -982
- package/dist/geoarrow/kernels.js.map +0 -1
- package/dist/geoarrow/layout.d.ts +0 -66
- package/dist/geoarrow/layout.d.ts.map +0 -1
- package/dist/geoarrow/layout.js +0 -723
- package/dist/geoarrow/layout.js.map +0 -1
- package/dist/geoarrow/stream-tessellate.d.ts +0 -34
- package/dist/geoarrow/stream-tessellate.d.ts.map +0 -1
- package/dist/geoarrow/stream-tessellate.js +0 -171
- package/dist/geoarrow/stream-tessellate.js.map +0 -1
- package/dist/geoarrow/stream.d.ts +0 -29
- package/dist/geoarrow/stream.d.ts.map +0 -1
- package/dist/geoarrow/stream.js +0 -100
- package/dist/geoarrow/stream.js.map +0 -1
- package/dist/geoarrow/tessellate.d.ts +0 -31
- package/dist/geoarrow/tessellate.d.ts.map +0 -1
- package/dist/geoarrow/tessellate.js +0 -102
- package/dist/geoarrow/tessellate.js.map +0 -1
- package/dist/geoarrow/tessellation-entry.d.ts +0 -4
- package/dist/geoarrow/tessellation-entry.d.ts.map +0 -1
- package/dist/geoarrow/tessellation-entry.js +0 -5
- package/dist/geoarrow/tessellation-entry.js.map +0 -1
- package/dist/geoarrow/types.d.ts +0 -155
- package/dist/geoarrow/types.d.ts.map +0 -1
- package/dist/geoarrow/types.js +0 -71
- package/dist/geoarrow/types.js.map +0 -1
- package/dist/geoarrow/views.d.ts +0 -45
- package/dist/geoarrow/views.d.ts.map +0 -1
- package/dist/geoarrow/views.js +0 -114
- package/dist/geoarrow/views.js.map +0 -1
- package/dist/geoarrow/wkb-entry.d.ts +0 -4
- package/dist/geoarrow/wkb-entry.d.ts.map +0 -1
- package/dist/geoarrow/wkb-entry.js +0 -6
- package/dist/geoarrow/wkb-entry.js.map +0 -1
- package/dist/geoarrow/worker.d.ts +0 -11
- package/dist/geoarrow/worker.d.ts.map +0 -1
- package/dist/geoarrow/worker.js +0 -10
- package/dist/geoarrow/worker.js.map +0 -1
- package/dist/wkb/index.d.ts +0 -11
- package/dist/wkb/index.d.ts.map +0 -1
- package/dist/wkb/index.js +0 -9
- package/dist/wkb/index.js.map +0 -1
- package/dist/wkb/types.d.ts +0 -30
- package/dist/wkb/types.d.ts.map +0 -1
- package/dist/wkb/types.js +0 -34
- package/dist/wkb/types.js.map +0 -1
- package/dist/wkb/wkb-builder.d.ts +0 -91
- package/dist/wkb/wkb-builder.d.ts.map +0 -1
- package/dist/wkb/wkb-builder.js +0 -283
- package/dist/wkb/wkb-builder.js.map +0 -1
- package/dist/wkb/wkb-reader.d.ts +0 -74
- package/dist/wkb/wkb-reader.d.ts.map +0 -1
- package/dist/wkb/wkb-reader.js +0 -251
- package/dist/wkb/wkb-reader.js.map +0 -1
- package/dist/wkb/wkb.d.ts +0 -21
- package/dist/wkb/wkb.d.ts.map +0 -1
- package/dist/wkb/wkb.js +0 -204
- package/dist/wkb/wkb.js.map +0 -1
- package/dist/wkb/wkt.d.ts +0 -19
- package/dist/wkb/wkt.d.ts.map +0 -1
- package/dist/wkb/wkt.js +0 -321
- package/dist/wkb/wkt.js.map +0 -1
- package/projection/THIRD-PARTY-NOTICES.md +0 -210
- package/src/discontinuous/elastic/README.md +0 -20
- package/src/discontinuous/spherical-clip/README.md +0 -16
- package/src/discontinuous/world-kernels/README.md +0 -24
- package/src/geoarrow/builder-entry.ts +0 -18
- package/src/geoarrow/builder.ts +0 -860
- package/src/geoarrow/codecs.ts +0 -1268
- package/src/geoarrow/index.ts +0 -111
- package/src/geoarrow/kernels.ts +0 -1290
- package/src/geoarrow/layout.ts +0 -900
- package/src/geoarrow/stream-tessellate.ts +0 -205
- package/src/geoarrow/stream.ts +0 -130
- package/src/geoarrow/tessellate.ts +0 -133
- package/src/geoarrow/tessellation-entry.ts +0 -7
- package/src/geoarrow/types.ts +0 -259
- package/src/geoarrow/views.ts +0 -150
- package/src/geoarrow/wkb-entry.ts +0 -13
- package/src/geoarrow/worker.ts +0 -20
- package/src/terrain/vendor/README.md +0 -20
- package/src/vendor/geographiclib-geodesic/README.md +0 -26
- package/src/wkb/index.ts +0 -38
- package/src/wkb/types.ts +0 -54
- package/src/wkb/wkb-builder.ts +0 -395
- package/src/wkb/wkb-reader.ts +0 -401
- package/src/wkb/wkb.ts +0 -255
- package/src/wkb/wkt.ts +0 -375
- /package/{projection/APACHE-2.0-LICENSE.txt → APACHE-2.0-LICENSE.txt} +0 -0
- /package/{projection/PROJ-LICENSE.txt → PROJ-LICENSE.txt} +0 -0
- /package/{projection/PROJ4-LICENSE.md → PROJ4-LICENSE.md} +0 -0
- /package/{crs/schemas → src/crs}/projjson.schema.json +0 -0
package/dist/geoarrow/codecs.js
DELETED
|
@@ -1,916 +0,0 @@
|
|
|
1
|
-
// math.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
-
import { formatWKT, inspectWKBHeader, parseWKT, visitWKB } from "../wkb/index.js";
|
|
5
|
-
import { WKBBuilder } from "../wkb/index.js";
|
|
6
|
-
import { getGeoArrowDimensionSize, mergeGeoArrowDimensions } from "./types.js";
|
|
7
|
-
import { GeoArrowBuilder, makeGeoArrowColumnFromGeometryRows } from "./builder.js";
|
|
8
|
-
import { getGeoArrowOffset, isGeoArrowValueValid, materializeGeometryRow } from "./layout.js";
|
|
9
|
-
const textEncoder = new TextEncoder();
|
|
10
|
-
const textDecoder = new TextDecoder();
|
|
11
|
-
const NULL_FAMILY = 255;
|
|
12
|
-
/** Decodes a GeoArrow WKB column into final native physical geometry buffers. */
|
|
13
|
-
export function decodeGeoArrowWKB(column, options = {}) {
|
|
14
|
-
if (column.encoding !== 'geoarrow.wkb')
|
|
15
|
-
throw new Error('Expected a geoarrow.wkb column');
|
|
16
|
-
const classifications = [];
|
|
17
|
-
const schemaKeys = new Set();
|
|
18
|
-
const collectionSchemas = [];
|
|
19
|
-
const rootFamilies = new Set();
|
|
20
|
-
let hasNulls = false;
|
|
21
|
-
let inferredDimension = 'xy';
|
|
22
|
-
for (const chunk of column.chunks) {
|
|
23
|
-
if (chunk.kind !== 'serialized')
|
|
24
|
-
throw new Error('Serialized column contains native storage');
|
|
25
|
-
const families = new Uint8Array(chunk.length).fill(NULL_FAMILY);
|
|
26
|
-
const dimensions = new Uint8Array(chunk.length);
|
|
27
|
-
for (let rowIndex = 0; rowIndex < chunk.length; rowIndex++) {
|
|
28
|
-
if (!isGeoArrowValueValid(chunk.validity, rowIndex)) {
|
|
29
|
-
hasNulls = true;
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
const bytes = getSerializedBytes(chunk, rowIndex);
|
|
33
|
-
const rootHeader = inspectWKBHeader(bytes);
|
|
34
|
-
const rootFamily = getGeometryFamilyIndex(rootHeader.geometryType);
|
|
35
|
-
let rowDimension = rootHeader.dimension;
|
|
36
|
-
if (rootHeader.geometryType === 'GeometryCollection') {
|
|
37
|
-
const collectionStack = [];
|
|
38
|
-
let concreteRootDepth = -1;
|
|
39
|
-
visitWKB(bytes, {
|
|
40
|
-
geometry: (header, _count, depth) => {
|
|
41
|
-
var _a;
|
|
42
|
-
rowDimension = mergeGeoArrowDimensions(rowDimension, header.dimension);
|
|
43
|
-
if (concreteRootDepth >= 0 && depth > concreteRootDepth)
|
|
44
|
-
return;
|
|
45
|
-
concreteRootDepth = -1;
|
|
46
|
-
while (collectionStack.length &&
|
|
47
|
-
depth <= collectionStack[collectionStack.length - 1].depth) {
|
|
48
|
-
collectionStack.pop();
|
|
49
|
-
}
|
|
50
|
-
const parent = collectionStack[collectionStack.length - 1];
|
|
51
|
-
if (parent) {
|
|
52
|
-
collectionSchemas[_a = parent.level] || (collectionSchemas[_a] = new Set());
|
|
53
|
-
collectionSchemas[parent.level].add(getGeometryTypeId(header.geometryType, header.dimension));
|
|
54
|
-
}
|
|
55
|
-
if (header.geometryType === 'GeometryCollection') {
|
|
56
|
-
collectionStack.push({ depth, level: parent ? parent.level + 1 : 0 });
|
|
57
|
-
}
|
|
58
|
-
else if (parent) {
|
|
59
|
-
concreteRootDepth = depth;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}, options.traversal);
|
|
63
|
-
}
|
|
64
|
-
families[rowIndex] = rootFamily;
|
|
65
|
-
dimensions[rowIndex] = getDimensionIndex(rowDimension);
|
|
66
|
-
rootFamilies.add(rootFamily);
|
|
67
|
-
schemaKeys.add(getGeometryTypeIdFromIndices(rootFamily, dimensions[rowIndex]));
|
|
68
|
-
inferredDimension = mergeGeoArrowDimensions(inferredDimension, rowDimension);
|
|
69
|
-
}
|
|
70
|
-
classifications.push({ families, dimensions });
|
|
71
|
-
}
|
|
72
|
-
const dimension = resolveDecodeDimension(options.dimension, column.dimension, inferredDimension);
|
|
73
|
-
const forceDimension = Boolean(options.dimension && options.dimension !== 'infer');
|
|
74
|
-
if (forceDimension) {
|
|
75
|
-
schemaKeys.clear();
|
|
76
|
-
for (const classification of classifications) {
|
|
77
|
-
for (let rowIndex = 0; rowIndex < classification.families.length; rowIndex++) {
|
|
78
|
-
const family = classification.families[rowIndex];
|
|
79
|
-
if (family === NULL_FAMILY)
|
|
80
|
-
continue;
|
|
81
|
-
classification.dimensions[rowIndex] = getDimensionIndex(dimension);
|
|
82
|
-
schemaKeys.add(getGeometryTypeIdFromIndices(family, getDimensionIndex(dimension)));
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
const encoding = resolveDecodeEncoding(options.encoding, rootFamilies);
|
|
87
|
-
validateDecodeEncoding(encoding, rootFamilies);
|
|
88
|
-
const builderOptions = {
|
|
89
|
-
dimension,
|
|
90
|
-
coordinateLayout: options.coordinateLayout || 'interleaved',
|
|
91
|
-
coordinateType: options.coordinateType || 'float64',
|
|
92
|
-
offsetType: options.offsetType || 'int32'
|
|
93
|
-
};
|
|
94
|
-
if (encoding !== 'geoarrow.geometry' && encoding !== 'geoarrow.geometrycollection') {
|
|
95
|
-
const chunks = column.chunks.map((chunk, chunkIndex) => decodeConcreteWKBChunk(chunk, classifications[chunkIndex], encoding, builderOptions, options.traversal));
|
|
96
|
-
return copyMetadata(column, {
|
|
97
|
-
encoding,
|
|
98
|
-
dimension,
|
|
99
|
-
coordinateLayout: builderOptions.coordinateLayout,
|
|
100
|
-
chunks
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
if (encoding === 'geoarrow.geometrycollection') {
|
|
104
|
-
const stableCollectionSchemas = normalizeCollectionSchemas(collectionSchemas, dimension, forceDimension);
|
|
105
|
-
const chunks = column.chunks.map((chunk, chunkIndex) => decodeGeometryCollectionWKBChunk(chunk, classifications[chunkIndex], undefined, stableCollectionSchemas, builderOptions, options.traversal, forceDimension ? dimension : undefined));
|
|
106
|
-
return copyMetadata(column, {
|
|
107
|
-
encoding,
|
|
108
|
-
dimension,
|
|
109
|
-
coordinateLayout: builderOptions.coordinateLayout,
|
|
110
|
-
chunks
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
if (schemaKeys.size === 0)
|
|
114
|
-
schemaKeys.add(getGeometryTypeId('Point', dimension));
|
|
115
|
-
if (hasNulls)
|
|
116
|
-
schemaKeys.add(getGeometryTypeId('Point', dimension));
|
|
117
|
-
const stableSchema = [...schemaKeys].sort((left, right) => left - right);
|
|
118
|
-
const chunks = column.chunks.map((chunk, chunkIndex) => decodeUnionWKBChunk(chunk, classifications[chunkIndex], stableSchema, normalizeCollectionSchemas(collectionSchemas, dimension, forceDimension), builderOptions, options.traversal, forceDimension ? dimension : undefined));
|
|
119
|
-
return copyMetadata(column, {
|
|
120
|
-
encoding: 'geoarrow.geometry',
|
|
121
|
-
dimension,
|
|
122
|
-
coordinateLayout: builderOptions.coordinateLayout,
|
|
123
|
-
chunks
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
/** Counts vertices in serialized WKB chunks without decoding ordinates or allocating rows. */
|
|
127
|
-
export function getGeoArrowWKBVertexCount(column, traversal) {
|
|
128
|
-
if (column.encoding !== 'geoarrow.wkb')
|
|
129
|
-
throw new Error('Expected a geoarrow.wkb column');
|
|
130
|
-
let vertexCount = 0;
|
|
131
|
-
for (const chunk of column.chunks) {
|
|
132
|
-
if (chunk.kind !== 'serialized')
|
|
133
|
-
throw new Error('Serialized column contains native storage');
|
|
134
|
-
for (let rowIndex = 0; rowIndex < chunk.length; rowIndex++) {
|
|
135
|
-
if (!isGeoArrowValueValid(chunk.validity, rowIndex))
|
|
136
|
-
continue;
|
|
137
|
-
visitWKB(getSerializedBytes(chunk, rowIndex), {
|
|
138
|
-
geometry: (header, count) => {
|
|
139
|
-
if (header.geometryType === 'Point')
|
|
140
|
-
vertexCount++;
|
|
141
|
-
else if (header.geometryType === 'LineString')
|
|
142
|
-
vertexCount += count || 0;
|
|
143
|
-
},
|
|
144
|
-
ring: pointCount => {
|
|
145
|
-
vertexCount += pointCount;
|
|
146
|
-
}
|
|
147
|
-
}, traversal);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return vertexCount;
|
|
151
|
-
}
|
|
152
|
-
function decodeConcreteWKBChunk(chunk, classification, encoding, options, traversal) {
|
|
153
|
-
const measure = new GeoArrowBuilder({ ...options, encoding, mode: 'measure' });
|
|
154
|
-
replaySerializedChunk(chunk, classification, encoding, measure, traversal);
|
|
155
|
-
const write = new GeoArrowBuilder({
|
|
156
|
-
...options,
|
|
157
|
-
encoding,
|
|
158
|
-
mode: 'write',
|
|
159
|
-
target: measure.allocateTarget()
|
|
160
|
-
});
|
|
161
|
-
replaySerializedChunk(chunk, classification, encoding, write, traversal);
|
|
162
|
-
return write.finish().chunks[0];
|
|
163
|
-
}
|
|
164
|
-
function replaySerializedChunk(chunk, classification, encoding, builder, traversal) {
|
|
165
|
-
const targetType = geometryTypeFromEncoding(encoding);
|
|
166
|
-
for (let rowIndex = 0; rowIndex < chunk.length; rowIndex++) {
|
|
167
|
-
if (classification.families[rowIndex] === NULL_FAMILY)
|
|
168
|
-
builder.append(null);
|
|
169
|
-
else
|
|
170
|
-
visitWKBIntoBuilder(getSerializedBytes(chunk, rowIndex), builder, targetType, traversal);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
function decodeUnionWKBChunk(chunk, classification, stableSchema, collectionSchemas, options, traversal, childDimensionOverride) {
|
|
174
|
-
const measureBuilders = new Map();
|
|
175
|
-
for (const key of stableSchema) {
|
|
176
|
-
const type = getGeometryTypeFromId(key);
|
|
177
|
-
if (type !== 'GeometryCollection') {
|
|
178
|
-
const encoding = encodingFromGeometryType(type);
|
|
179
|
-
measureBuilders.set(key, new GeoArrowBuilder({
|
|
180
|
-
...options,
|
|
181
|
-
encoding,
|
|
182
|
-
dimension: getDimensionFromId(key),
|
|
183
|
-
mode: 'measure'
|
|
184
|
-
}));
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
const typeIds = new Int8Array(chunk.length);
|
|
188
|
-
const valueOffsets = new Int32Array(chunk.length);
|
|
189
|
-
const childCounts = new Map();
|
|
190
|
-
const nullKey = stableSchema[0];
|
|
191
|
-
for (let rowIndex = 0; rowIndex < chunk.length; rowIndex++) {
|
|
192
|
-
const family = classification.families[rowIndex];
|
|
193
|
-
const key = family === NULL_FAMILY
|
|
194
|
-
? nullKey
|
|
195
|
-
: getGeometryTypeIdFromIndices(family, classification.dimensions[rowIndex]);
|
|
196
|
-
typeIds[rowIndex] = key;
|
|
197
|
-
valueOffsets[rowIndex] = childCounts.get(key) || 0;
|
|
198
|
-
childCounts.set(key, valueOffsets[rowIndex] + 1);
|
|
199
|
-
const builder = measureBuilders.get(key);
|
|
200
|
-
if (builder) {
|
|
201
|
-
if (family === NULL_FAMILY)
|
|
202
|
-
builder.append(null);
|
|
203
|
-
else
|
|
204
|
-
visitWKBIntoBuilder(getSerializedBytes(chunk, rowIndex), builder, getConcreteGeometryTypeFromId(key), traversal);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
const writeBuilders = new Map();
|
|
208
|
-
for (const key of stableSchema) {
|
|
209
|
-
if (getGeometryTypeFromId(key) === 'GeometryCollection')
|
|
210
|
-
continue;
|
|
211
|
-
const measure = measureBuilders.get(key);
|
|
212
|
-
writeBuilders.set(key, new GeoArrowBuilder({
|
|
213
|
-
...options,
|
|
214
|
-
encoding: encodingFromGeometryType(getConcreteGeometryTypeFromId(key)),
|
|
215
|
-
dimension: getDimensionFromId(key),
|
|
216
|
-
mode: 'write',
|
|
217
|
-
target: measure.allocateTarget()
|
|
218
|
-
}));
|
|
219
|
-
}
|
|
220
|
-
for (let rowIndex = 0; rowIndex < chunk.length; rowIndex++) {
|
|
221
|
-
const family = classification.families[rowIndex];
|
|
222
|
-
const key = family === NULL_FAMILY
|
|
223
|
-
? nullKey
|
|
224
|
-
: getGeometryTypeIdFromIndices(family, classification.dimensions[rowIndex]);
|
|
225
|
-
const builder = writeBuilders.get(key);
|
|
226
|
-
if (builder) {
|
|
227
|
-
if (family === NULL_FAMILY)
|
|
228
|
-
builder.append(null);
|
|
229
|
-
else
|
|
230
|
-
visitWKBIntoBuilder(getSerializedBytes(chunk, rowIndex), builder, getConcreteGeometryTypeFromId(key), traversal);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
const children = stableSchema.map(key => {
|
|
234
|
-
const type = getGeometryTypeFromId(key);
|
|
235
|
-
if (type === 'GeometryCollection') {
|
|
236
|
-
return {
|
|
237
|
-
name: type,
|
|
238
|
-
typeId: key,
|
|
239
|
-
encoding: 'geoarrow.geometrycollection',
|
|
240
|
-
dimension: getDimensionFromId(key),
|
|
241
|
-
coordinateLayout: options.coordinateLayout,
|
|
242
|
-
data: decodeGeometryCollectionWKBChunk(chunk, classification, key, collectionSchemas, { ...options, dimension: getDimensionFromId(key) }, traversal, childDimensionOverride)
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
const built = writeBuilders.get(key).finish();
|
|
246
|
-
return {
|
|
247
|
-
name: getGeometryTypeFromId(key),
|
|
248
|
-
typeId: key,
|
|
249
|
-
encoding: built.encoding,
|
|
250
|
-
dimension: built.dimension,
|
|
251
|
-
coordinateLayout: built.coordinateLayout,
|
|
252
|
-
data: built.chunks[0]
|
|
253
|
-
};
|
|
254
|
-
});
|
|
255
|
-
return { kind: 'dense-union', length: chunk.length, typeIds, valueOffsets, children };
|
|
256
|
-
}
|
|
257
|
-
function decodeGeometryCollectionWKBChunk(chunk, classification, selectorKey, schemas, options, traversal, childDimensionOverride) {
|
|
258
|
-
const measureLevels = schemas.map(schema => makeCollectionMeasureLevel(schema, options));
|
|
259
|
-
if (measureLevels.length === 0)
|
|
260
|
-
measureLevels.push(makeCollectionMeasureLevel([], options));
|
|
261
|
-
forEachSelectedCollectionRow(chunk, classification, selectorKey, (bytes, valid) => {
|
|
262
|
-
if (!valid) {
|
|
263
|
-
measureLevels[0].rowCount++;
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
replayWKBCollection(bytes, measureLevels, undefined, options.dimension, traversal, childDimensionOverride);
|
|
267
|
-
});
|
|
268
|
-
const writeLevels = measureLevels.map(level => makeCollectionWriteLevel(level, options));
|
|
269
|
-
forEachSelectedCollectionRow(chunk, classification, selectorKey, (bytes, valid) => {
|
|
270
|
-
if (!valid) {
|
|
271
|
-
writeCollectionRow(writeLevels[0], 0);
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
replayWKBCollection(bytes, measureLevels, writeLevels, options.dimension, traversal, childDimensionOverride);
|
|
275
|
-
});
|
|
276
|
-
const root = makeCollectionLevelArray(0, measureLevels, writeLevels, options);
|
|
277
|
-
if (selectorKey !== undefined)
|
|
278
|
-
return root;
|
|
279
|
-
const validity = new Uint8Array(Math.ceil(root.length / 8));
|
|
280
|
-
for (let rowIndex = 0; rowIndex < classification.families.length; rowIndex++) {
|
|
281
|
-
if (classification.families[rowIndex] === getGeometryFamilyIndex('GeometryCollection')) {
|
|
282
|
-
validity[rowIndex >> 3] |= 1 << (rowIndex & 7);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
return { ...root, validity: { values: validity } };
|
|
286
|
-
}
|
|
287
|
-
function forEachSelectedCollectionRow(chunk, classification, selectorKey, visitor) {
|
|
288
|
-
const collectionFamily = getGeometryFamilyIndex('GeometryCollection');
|
|
289
|
-
for (let rowIndex = 0; rowIndex < chunk.length; rowIndex++) {
|
|
290
|
-
const family = classification.families[rowIndex];
|
|
291
|
-
if (selectorKey === undefined) {
|
|
292
|
-
if (family === NULL_FAMILY)
|
|
293
|
-
visitor(undefined, false);
|
|
294
|
-
else if (family === collectionFamily)
|
|
295
|
-
visitor(getSerializedBytes(chunk, rowIndex), true);
|
|
296
|
-
else
|
|
297
|
-
throw new Error('Rows cannot be represented as geoarrow.geometrycollection');
|
|
298
|
-
}
|
|
299
|
-
else if (family === collectionFamily &&
|
|
300
|
-
getGeometryTypeIdFromIndices(family, classification.dimensions[rowIndex]) === selectorKey) {
|
|
301
|
-
visitor(getSerializedBytes(chunk, rowIndex), true);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
function makeCollectionMeasureLevel(schema, options) {
|
|
306
|
-
const builders = new Map();
|
|
307
|
-
for (const key of schema) {
|
|
308
|
-
const type = getGeometryTypeFromId(key);
|
|
309
|
-
if (type !== 'GeometryCollection') {
|
|
310
|
-
builders.set(key, new GeoArrowBuilder({
|
|
311
|
-
...options,
|
|
312
|
-
encoding: encodingFromGeometryType(type),
|
|
313
|
-
dimension: getDimensionFromId(key),
|
|
314
|
-
mode: 'measure'
|
|
315
|
-
}));
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
return { schema, rowCount: 0, childCount: 0, builders };
|
|
319
|
-
}
|
|
320
|
-
function makeCollectionWriteLevel(measure, options) {
|
|
321
|
-
const OffsetArray = options.offsetType === 'int64' ? BigInt64Array : Int32Array;
|
|
322
|
-
const builders = new Map();
|
|
323
|
-
for (const [key, builder] of measure.builders) {
|
|
324
|
-
builders.set(key, new GeoArrowBuilder({
|
|
325
|
-
...options,
|
|
326
|
-
encoding: encodingFromGeometryType(getConcreteGeometryTypeFromId(key)),
|
|
327
|
-
dimension: getDimensionFromId(key),
|
|
328
|
-
mode: 'write',
|
|
329
|
-
target: builder.allocateTarget()
|
|
330
|
-
}));
|
|
331
|
-
}
|
|
332
|
-
return {
|
|
333
|
-
schema: measure.schema,
|
|
334
|
-
rowCursor: 0,
|
|
335
|
-
childCursor: 0,
|
|
336
|
-
offsets: new OffsetArray(measure.rowCount + 1),
|
|
337
|
-
typeIds: new Int8Array(measure.childCount),
|
|
338
|
-
valueOffsets: new Int32Array(measure.childCount),
|
|
339
|
-
childCounts: new Map(),
|
|
340
|
-
builders
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
|
-
function replayWKBCollection(bytes, measureLevels, writeLevels, collectionDimension, traversal, childDimensionOverride) {
|
|
344
|
-
const collectionStack = [];
|
|
345
|
-
let active;
|
|
346
|
-
const finishActive = () => {
|
|
347
|
-
active?.builder.endGeometry();
|
|
348
|
-
active = undefined;
|
|
349
|
-
};
|
|
350
|
-
visitWKB(bytes, {
|
|
351
|
-
geometry: (header, count, depth) => {
|
|
352
|
-
if (active && depth > active.rootDepth) {
|
|
353
|
-
if (active.rootType === 'MultiLineString' && header.geometryType === 'LineString') {
|
|
354
|
-
active.builder.beginRing(count);
|
|
355
|
-
}
|
|
356
|
-
else if (active.rootType === 'MultiPolygon' && header.geometryType === 'Polygon') {
|
|
357
|
-
active.builder.beginPolygon();
|
|
358
|
-
}
|
|
359
|
-
return;
|
|
360
|
-
}
|
|
361
|
-
finishActive();
|
|
362
|
-
while (collectionStack.length &&
|
|
363
|
-
depth <= collectionStack[collectionStack.length - 1].depth) {
|
|
364
|
-
collectionStack.pop();
|
|
365
|
-
}
|
|
366
|
-
const parent = collectionStack[collectionStack.length - 1];
|
|
367
|
-
if (header.geometryType === 'GeometryCollection') {
|
|
368
|
-
if (parent) {
|
|
369
|
-
addCollectionChild(measureLevels[parent.level], writeLevels?.[parent.level], getGeometryTypeId('GeometryCollection', collectionDimension));
|
|
370
|
-
}
|
|
371
|
-
const level = parent ? parent.level + 1 : 0;
|
|
372
|
-
if (!measureLevels[level]) {
|
|
373
|
-
measureLevels[level] = makeCollectionMeasureLevel([], {
|
|
374
|
-
dimension: collectionDimension,
|
|
375
|
-
coordinateLayout: 'interleaved',
|
|
376
|
-
coordinateType: 'float64',
|
|
377
|
-
offsetType: 'int32'
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
if (writeLevels)
|
|
381
|
-
writeCollectionRow(writeLevels[level], count || 0);
|
|
382
|
-
else
|
|
383
|
-
measureLevels[level].rowCount++;
|
|
384
|
-
collectionStack.push({ depth, level });
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
if (!parent)
|
|
388
|
-
throw new Error('Expected a GeometryCollection root');
|
|
389
|
-
const key = getGeometryTypeId(header.geometryType, childDimensionOverride || header.dimension);
|
|
390
|
-
addCollectionChild(measureLevels[parent.level], writeLevels?.[parent.level], key);
|
|
391
|
-
const builder = writeLevels
|
|
392
|
-
? writeLevels[parent.level].builders.get(key)
|
|
393
|
-
: measureLevels[parent.level].builders.get(key);
|
|
394
|
-
if (!builder)
|
|
395
|
-
throw new Error(`Missing GeometryCollection child schema for type ID ${key}`);
|
|
396
|
-
builder.beginGeometry(header.geometryType, header.dimension, count);
|
|
397
|
-
active = { builder, rootDepth: depth, rootType: header.geometryType };
|
|
398
|
-
},
|
|
399
|
-
ring: pointCount => active?.builder.beginRing(pointCount),
|
|
400
|
-
coordinate: (x, y, z, m, dimension) => active?.builder.writeCoordinateFromDimension(x, y, z, m, dimension)
|
|
401
|
-
}, traversal);
|
|
402
|
-
finishActive();
|
|
403
|
-
}
|
|
404
|
-
function addCollectionChild(measure, write, key) {
|
|
405
|
-
if (!write) {
|
|
406
|
-
measure.childCount++;
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
const index = write.childCursor++;
|
|
410
|
-
write.typeIds[index] = key;
|
|
411
|
-
write.valueOffsets[index] = write.childCounts.get(key) || 0;
|
|
412
|
-
write.childCounts.set(key, write.valueOffsets[index] + 1);
|
|
413
|
-
}
|
|
414
|
-
function writeCollectionRow(level, childCount) {
|
|
415
|
-
level.rowCursor++;
|
|
416
|
-
setGeoArrowOffset(level.offsets, level.rowCursor, level.childCursor + childCount);
|
|
417
|
-
}
|
|
418
|
-
function makeCollectionLevelArray(levelIndex, measureLevels, writeLevels, options) {
|
|
419
|
-
const measure = measureLevels[levelIndex];
|
|
420
|
-
const write = writeLevels[levelIndex];
|
|
421
|
-
const children = measure.schema.map(key => {
|
|
422
|
-
const type = getGeometryTypeFromId(key);
|
|
423
|
-
if (type === 'GeometryCollection') {
|
|
424
|
-
return {
|
|
425
|
-
name: type,
|
|
426
|
-
typeId: key,
|
|
427
|
-
encoding: 'geoarrow.geometrycollection',
|
|
428
|
-
dimension: getDimensionFromId(key),
|
|
429
|
-
coordinateLayout: options.coordinateLayout,
|
|
430
|
-
data: makeCollectionLevelArray(levelIndex + 1, measureLevels, writeLevels, options)
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
const built = write.builders.get(key).finish();
|
|
434
|
-
return {
|
|
435
|
-
name: type,
|
|
436
|
-
typeId: key,
|
|
437
|
-
encoding: built.encoding,
|
|
438
|
-
dimension: built.dimension,
|
|
439
|
-
coordinateLayout: built.coordinateLayout,
|
|
440
|
-
data: built.chunks[0]
|
|
441
|
-
};
|
|
442
|
-
});
|
|
443
|
-
return {
|
|
444
|
-
kind: 'list',
|
|
445
|
-
length: measure.rowCount,
|
|
446
|
-
offsets: write.offsets,
|
|
447
|
-
child: {
|
|
448
|
-
kind: 'dense-union',
|
|
449
|
-
length: measure.childCount,
|
|
450
|
-
typeIds: write.typeIds,
|
|
451
|
-
valueOffsets: write.valueOffsets,
|
|
452
|
-
children
|
|
453
|
-
}
|
|
454
|
-
};
|
|
455
|
-
}
|
|
456
|
-
function setGeoArrowOffset(offsets, index, value) {
|
|
457
|
-
if (offsets instanceof BigInt64Array)
|
|
458
|
-
offsets[index] = BigInt(value);
|
|
459
|
-
else
|
|
460
|
-
offsets[index] = value;
|
|
461
|
-
}
|
|
462
|
-
function normalizeCollectionSchemas(schemas, dimension, forceDimension) {
|
|
463
|
-
return schemas.map(schema => [...schema]
|
|
464
|
-
.map(key => forceDimension || getGeometryTypeFromId(key) === 'GeometryCollection'
|
|
465
|
-
? getGeometryTypeId(getGeometryTypeFromId(key), dimension)
|
|
466
|
-
: key)
|
|
467
|
-
.filter((key, index, values) => values.indexOf(key) === index)
|
|
468
|
-
.sort((left, right) => left - right));
|
|
469
|
-
}
|
|
470
|
-
/** Replays one serialized geometry directly into a two-pass GeoArrowBuilder. */
|
|
471
|
-
function visitWKBIntoBuilder(bytes, builder, targetType, traversal) {
|
|
472
|
-
let rootType;
|
|
473
|
-
visitWKB(bytes, {
|
|
474
|
-
geometry: (header, _count, depth) => {
|
|
475
|
-
if (depth === 0) {
|
|
476
|
-
rootType = header.geometryType;
|
|
477
|
-
builder.beginGeometry(targetType, header.dimension, _count);
|
|
478
|
-
if (rootType === 'LineString' && targetType === 'MultiLineString')
|
|
479
|
-
builder.beginRing(_count);
|
|
480
|
-
if (rootType === 'Polygon' && targetType === 'MultiPolygon')
|
|
481
|
-
builder.beginPolygon();
|
|
482
|
-
}
|
|
483
|
-
else if (rootType === 'MultiLineString' && header.geometryType === 'LineString') {
|
|
484
|
-
builder.beginRing(_count);
|
|
485
|
-
}
|
|
486
|
-
else if (rootType === 'MultiPolygon' && header.geometryType === 'Polygon') {
|
|
487
|
-
builder.beginPolygon();
|
|
488
|
-
}
|
|
489
|
-
},
|
|
490
|
-
ring: pointCount => {
|
|
491
|
-
if (rootType === 'Polygon' || rootType === 'MultiPolygon')
|
|
492
|
-
builder.beginRing(pointCount);
|
|
493
|
-
},
|
|
494
|
-
coordinate: (x, y, z, m, dimension) => {
|
|
495
|
-
builder.writeCoordinateFromDimension(x, y, z, m, dimension);
|
|
496
|
-
}
|
|
497
|
-
}, traversal);
|
|
498
|
-
builder.endGeometry();
|
|
499
|
-
}
|
|
500
|
-
function encodingFromGeometryType(type) {
|
|
501
|
-
if (type === 'GeometryCollection')
|
|
502
|
-
throw new Error('GeometryCollection requires collection storage');
|
|
503
|
-
return `geoarrow.${type.toLowerCase()}`;
|
|
504
|
-
}
|
|
505
|
-
function getGeometryTypeId(type, dimension) {
|
|
506
|
-
return getGeometryTypeIdFromIndices(getGeometryFamilyIndex(type), getDimensionIndex(dimension));
|
|
507
|
-
}
|
|
508
|
-
const GEOMETRY_TYPES = [
|
|
509
|
-
'Point',
|
|
510
|
-
'LineString',
|
|
511
|
-
'Polygon',
|
|
512
|
-
'MultiPoint',
|
|
513
|
-
'MultiLineString',
|
|
514
|
-
'MultiPolygon',
|
|
515
|
-
'GeometryCollection'
|
|
516
|
-
];
|
|
517
|
-
const DIMENSIONS = ['xy', 'xyz', 'xym', 'xyzm'];
|
|
518
|
-
function getGeometryFamilyIndex(type) {
|
|
519
|
-
return GEOMETRY_TYPES.indexOf(type);
|
|
520
|
-
}
|
|
521
|
-
function getDimensionIndex(dimension) {
|
|
522
|
-
return DIMENSIONS.indexOf(dimension);
|
|
523
|
-
}
|
|
524
|
-
function getGeometryTypeIdFromIndices(family, dimension) {
|
|
525
|
-
return family * 4 + dimension + 1;
|
|
526
|
-
}
|
|
527
|
-
function getGeometryTypeFromId(typeId) {
|
|
528
|
-
return GEOMETRY_TYPES[Math.floor((typeId - 1) / 4)];
|
|
529
|
-
}
|
|
530
|
-
function getConcreteGeometryTypeFromId(typeId) {
|
|
531
|
-
const type = getGeometryTypeFromId(typeId);
|
|
532
|
-
if (type === 'GeometryCollection')
|
|
533
|
-
throw new Error('GeometryCollection requires collection storage');
|
|
534
|
-
return type;
|
|
535
|
-
}
|
|
536
|
-
function getDimensionFromId(typeId) {
|
|
537
|
-
return DIMENSIONS[(typeId - 1) % 4];
|
|
538
|
-
}
|
|
539
|
-
function resolveDecodeDimension(requested, declared, inferred) {
|
|
540
|
-
if (!requested || requested === 'infer')
|
|
541
|
-
return inferred;
|
|
542
|
-
return requested === 'preserve' ? declared : requested;
|
|
543
|
-
}
|
|
544
|
-
function resolveDecodeEncoding(requested, families) {
|
|
545
|
-
if (requested && requested !== 'native')
|
|
546
|
-
return requested;
|
|
547
|
-
if (families.size !== 1)
|
|
548
|
-
return 'geoarrow.geometry';
|
|
549
|
-
const type = GEOMETRY_TYPES[[...families][0]];
|
|
550
|
-
return type === 'GeometryCollection'
|
|
551
|
-
? 'geoarrow.geometrycollection'
|
|
552
|
-
: encodingFromGeometryType(type);
|
|
553
|
-
}
|
|
554
|
-
function validateDecodeEncoding(encoding, families) {
|
|
555
|
-
if (encoding === 'geoarrow.geometry')
|
|
556
|
-
return;
|
|
557
|
-
if (encoding === 'geoarrow.geometrycollection') {
|
|
558
|
-
const collectionFamily = getGeometryFamilyIndex('GeometryCollection');
|
|
559
|
-
if ([...families].some(family => family !== collectionFamily)) {
|
|
560
|
-
throw new Error('Rows cannot be represented as geoarrow.geometrycollection');
|
|
561
|
-
}
|
|
562
|
-
return;
|
|
563
|
-
}
|
|
564
|
-
const targetType = geometryTypeFromEncoding(encoding);
|
|
565
|
-
for (const family of families) {
|
|
566
|
-
const sourceType = GEOMETRY_TYPES[family];
|
|
567
|
-
const promotable = sourceType === targetType ||
|
|
568
|
-
(sourceType === 'Point' && targetType === 'MultiPoint') ||
|
|
569
|
-
(sourceType === 'LineString' && targetType === 'MultiLineString') ||
|
|
570
|
-
(sourceType === 'Polygon' && targetType === 'MultiPolygon');
|
|
571
|
-
if (!promotable)
|
|
572
|
-
throw new Error(`Rows cannot be represented as ${encoding}`);
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
function geometryTypeFromEncoding(encoding) {
|
|
576
|
-
const type = GEOMETRY_TYPES.find(candidate => `geoarrow.${candidate.toLowerCase()}` === encoding);
|
|
577
|
-
if (!type || type === 'GeometryCollection')
|
|
578
|
-
throw new Error(`Unsupported target encoding ${encoding}`);
|
|
579
|
-
return type;
|
|
580
|
-
}
|
|
581
|
-
/** Encodes a native GeoArrow column as variable-width WKB bytes. */
|
|
582
|
-
export function encodeGeoArrowWKB(column) {
|
|
583
|
-
if (column.encoding === 'geoarrow.wkb')
|
|
584
|
-
return column;
|
|
585
|
-
return copyMetadata(column, {
|
|
586
|
-
encoding: 'geoarrow.wkb',
|
|
587
|
-
dimension: column.dimension,
|
|
588
|
-
coordinateLayout: null,
|
|
589
|
-
chunks: column.chunks.map(chunk => encodeWKBChunk(column, chunk))
|
|
590
|
-
});
|
|
591
|
-
}
|
|
592
|
-
function encodeWKBChunk(column, chunk) {
|
|
593
|
-
const offsets = new Int32Array(chunk.length + 1);
|
|
594
|
-
const validity = new Uint8Array(Math.ceil(chunk.length / 8));
|
|
595
|
-
let nullCount = 0;
|
|
596
|
-
for (let rowIndex = 0; rowIndex < chunk.length; rowIndex++) {
|
|
597
|
-
let byteLength = 0;
|
|
598
|
-
if (isPhysicalGeometryRowValid(chunk, rowIndex, column.encoding)) {
|
|
599
|
-
const dimension = getPhysicalGeometryDimension(chunk, rowIndex, column.encoding, column.dimension);
|
|
600
|
-
const builder = new WKBBuilder({ mode: 'measure', dimension });
|
|
601
|
-
writePhysicalGeometry(builder, chunk, rowIndex, column.encoding, dimension);
|
|
602
|
-
byteLength = builder.finishGeometry();
|
|
603
|
-
validity[rowIndex >> 3] |= 1 << (rowIndex & 7);
|
|
604
|
-
}
|
|
605
|
-
else {
|
|
606
|
-
nullCount++;
|
|
607
|
-
}
|
|
608
|
-
const nextOffset = offsets[rowIndex] + byteLength;
|
|
609
|
-
if (nextOffset > 0x7fffffff)
|
|
610
|
-
throw new Error('WKB geometry chunk exceeds Int32 offsets');
|
|
611
|
-
offsets[rowIndex + 1] = nextOffset;
|
|
612
|
-
}
|
|
613
|
-
const values = new Uint8Array(offsets[offsets.length - 1]);
|
|
614
|
-
for (let rowIndex = 0; rowIndex < chunk.length; rowIndex++) {
|
|
615
|
-
if (!isPhysicalGeometryRowValid(chunk, rowIndex, column.encoding))
|
|
616
|
-
continue;
|
|
617
|
-
const dimension = getPhysicalGeometryDimension(chunk, rowIndex, column.encoding, column.dimension);
|
|
618
|
-
const builder = new WKBBuilder({
|
|
619
|
-
mode: 'write',
|
|
620
|
-
target: values,
|
|
621
|
-
byteOffset: offsets[rowIndex],
|
|
622
|
-
dimension
|
|
623
|
-
});
|
|
624
|
-
writePhysicalGeometry(builder, chunk, rowIndex, column.encoding, dimension);
|
|
625
|
-
if (offsets[rowIndex] + builder.finishGeometry() !== offsets[rowIndex + 1]) {
|
|
626
|
-
throw new Error('WKB measure and write passes produced different byte lengths');
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
return {
|
|
630
|
-
kind: 'serialized',
|
|
631
|
-
encoding: 'binary',
|
|
632
|
-
length: chunk.length,
|
|
633
|
-
offsets,
|
|
634
|
-
values,
|
|
635
|
-
...(nullCount ? { validity: { values: validity } } : {})
|
|
636
|
-
};
|
|
637
|
-
}
|
|
638
|
-
function isPhysicalGeometryRowValid(array, rowIndex, encoding) {
|
|
639
|
-
if (!isGeoArrowValueValid(array.validity, rowIndex))
|
|
640
|
-
return false;
|
|
641
|
-
if (encoding !== 'geoarrow.geometry' || array.kind !== 'dense-union')
|
|
642
|
-
return true;
|
|
643
|
-
const physical = (array.offset || 0) + rowIndex;
|
|
644
|
-
const child = array.children.find(candidate => candidate.typeId === array.typeIds[physical]);
|
|
645
|
-
const childIndex = array.valueOffsets[physical];
|
|
646
|
-
return Boolean(child &&
|
|
647
|
-
childIndex >= 0 &&
|
|
648
|
-
childIndex < child.data.length &&
|
|
649
|
-
isGeoArrowValueValid(child.data.validity, childIndex));
|
|
650
|
-
}
|
|
651
|
-
/** Decodes a GeoArrow WKT column into native physical geometry buffers. */
|
|
652
|
-
export function decodeGeoArrowWKT(column) {
|
|
653
|
-
if (column.encoding !== 'geoarrow.wkt')
|
|
654
|
-
throw new Error('Expected a geoarrow.wkt column');
|
|
655
|
-
const rows = normalizeRowsToDimension(decodeSerializedRows(column, bytes => parseWKT(textDecoder.decode(bytes))), column.dimension);
|
|
656
|
-
return copyMetadata(column, makeGeoArrowColumnFromGeometryRows(rows, { dimension: column.dimension }));
|
|
657
|
-
}
|
|
658
|
-
/** Encodes a native GeoArrow column as variable-width UTF-8 WKT. */
|
|
659
|
-
export function encodeGeoArrowWKT(column) {
|
|
660
|
-
if (column.encoding === 'geoarrow.wkt')
|
|
661
|
-
return column;
|
|
662
|
-
const values = [];
|
|
663
|
-
for (const chunk of column.chunks) {
|
|
664
|
-
for (let rowIndex = 0; rowIndex < chunk.length; rowIndex++) {
|
|
665
|
-
const row = isGeoArrowValueValid(chunk.validity, rowIndex)
|
|
666
|
-
? materializeGeometryRow(chunk, rowIndex, column.encoding)
|
|
667
|
-
: null;
|
|
668
|
-
values.push(row ? textEncoder.encode(formatWKT(row, column.dimension)) : null);
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
return copyMetadata(column, makeSerializedColumn(values, 'geoarrow.wkt', column.dimension));
|
|
672
|
-
}
|
|
673
|
-
function writePhysicalGeometry(builder, array, rowIndex, encoding, dimension) {
|
|
674
|
-
const depth = getEncodingDepth(encoding);
|
|
675
|
-
if (encoding === 'geoarrow.geometry' && array.kind === 'dense-union') {
|
|
676
|
-
const physical = (array.offset || 0) + rowIndex;
|
|
677
|
-
const typeId = array.typeIds[physical];
|
|
678
|
-
const child = array.children.find(candidate => candidate.typeId === typeId);
|
|
679
|
-
if (!child)
|
|
680
|
-
throw new Error('Dense-union row references an unknown child');
|
|
681
|
-
const childDimension = child.dimension || dimension;
|
|
682
|
-
builder.withDimension(childDimension, () => writePhysicalGeometry(builder, child.data, array.valueOffsets[physical], child.encoding || encodingFromName(child.name), childDimension));
|
|
683
|
-
return;
|
|
684
|
-
}
|
|
685
|
-
if (encoding === 'geoarrow.geometrycollection' && array.kind === 'list') {
|
|
686
|
-
const [first, last] = getListRange(array, rowIndex);
|
|
687
|
-
builder.beginGeometry('GeometryCollection', last - first);
|
|
688
|
-
if (array.child.kind !== 'dense-union')
|
|
689
|
-
throw new Error('GeometryCollection requires dense union child');
|
|
690
|
-
const union = array.child;
|
|
691
|
-
for (let index = first; index < last; index++) {
|
|
692
|
-
const physical = (union.offset || 0) + index;
|
|
693
|
-
const child = union.children.find(candidate => candidate.typeId === union.typeIds[physical]);
|
|
694
|
-
if (child) {
|
|
695
|
-
const childDimension = child.dimension || dimension;
|
|
696
|
-
builder.withDimension(childDimension, () => writePhysicalGeometry(builder, child.data, union.valueOffsets[physical], child.encoding || encodingFromName(child.name), childDimension));
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
return;
|
|
700
|
-
}
|
|
701
|
-
if (array.kind !== 'list' && depth > 0)
|
|
702
|
-
throw new Error(`Invalid ${encoding} storage`);
|
|
703
|
-
const writeCoordinate = (leaf, index) => {
|
|
704
|
-
const coordinate = readPhysicalCoordinate(leaf, index);
|
|
705
|
-
if (!coordinate)
|
|
706
|
-
throw new Error('Invalid GeoArrow coordinate storage');
|
|
707
|
-
if (dimension === 'xym')
|
|
708
|
-
builder.writeCoordinate(coordinate[0], coordinate[1], undefined, coordinate[2]);
|
|
709
|
-
else if (dimension === 'xyzm')
|
|
710
|
-
builder.writeCoordinate(coordinate[0], coordinate[1], coordinate[2], coordinate[3]);
|
|
711
|
-
else
|
|
712
|
-
builder.writeCoordinate(coordinate[0], coordinate[1], coordinate[2]);
|
|
713
|
-
};
|
|
714
|
-
const writeSequence = (leaf, first, last) => {
|
|
715
|
-
for (let index = first; index < last; index++)
|
|
716
|
-
writeCoordinate(leaf, index);
|
|
717
|
-
};
|
|
718
|
-
if (encoding === 'geoarrow.point') {
|
|
719
|
-
builder.beginPoint();
|
|
720
|
-
writeCoordinate(array, rowIndex);
|
|
721
|
-
}
|
|
722
|
-
else if (encoding === 'geoarrow.linestring' || encoding === 'geoarrow.multipoint') {
|
|
723
|
-
const [first, last] = getListRange(array, rowIndex);
|
|
724
|
-
if (encoding === 'geoarrow.linestring') {
|
|
725
|
-
builder.beginLineString(last - first);
|
|
726
|
-
writeSequence(array.child, first, last);
|
|
727
|
-
}
|
|
728
|
-
else {
|
|
729
|
-
builder.beginMultiPoint(last - first);
|
|
730
|
-
const leaf = array.child;
|
|
731
|
-
for (let index = first; index < last; index++) {
|
|
732
|
-
builder.beginPoint();
|
|
733
|
-
writeCoordinate(leaf, index);
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
else if (encoding === 'geoarrow.polygon' || encoding === 'geoarrow.multilinestring') {
|
|
738
|
-
const [first, last] = getListRange(array, rowIndex);
|
|
739
|
-
const parts = array.child;
|
|
740
|
-
if (encoding === 'geoarrow.polygon')
|
|
741
|
-
builder.beginPolygon(last - first);
|
|
742
|
-
else
|
|
743
|
-
builder.beginMultiLineString(last - first);
|
|
744
|
-
for (let partIndex = first; partIndex < last; partIndex++) {
|
|
745
|
-
const [ringFirst, ringLast] = getListRange(parts, partIndex);
|
|
746
|
-
const leaf = parts.child;
|
|
747
|
-
if (encoding === 'geoarrow.polygon')
|
|
748
|
-
builder.beginLinearRing(ringLast - ringFirst);
|
|
749
|
-
else
|
|
750
|
-
builder.beginLineString(ringLast - ringFirst);
|
|
751
|
-
writeSequence(leaf, ringFirst, ringLast);
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
else if (encoding === 'geoarrow.multipolygon') {
|
|
755
|
-
const [first, last] = getListRange(array, rowIndex);
|
|
756
|
-
const polygons = array.child;
|
|
757
|
-
builder.beginMultiPolygon(last - first);
|
|
758
|
-
for (let polygonIndex = first; polygonIndex < last; polygonIndex++) {
|
|
759
|
-
const [partFirst, partLast] = getListRange(polygons, polygonIndex);
|
|
760
|
-
const parts = polygons.child;
|
|
761
|
-
builder.beginPolygon(partLast - partFirst);
|
|
762
|
-
for (let partIndex = partFirst; partIndex < partLast; partIndex++) {
|
|
763
|
-
const [ringFirst, ringLast] = getListRange(parts, partIndex);
|
|
764
|
-
builder.beginLinearRing(ringLast - ringFirst);
|
|
765
|
-
writeSequence(parts.child, ringFirst, ringLast);
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
function getPhysicalGeometryDimension(array, rowIndex, encoding, dimension) {
|
|
771
|
-
if (encoding !== 'geoarrow.geometry' || array.kind !== 'dense-union')
|
|
772
|
-
return dimension;
|
|
773
|
-
const physical = (array.offset || 0) + rowIndex;
|
|
774
|
-
const child = array.children.find(candidate => candidate.typeId === array.typeIds[physical]);
|
|
775
|
-
return child?.dimension || dimension;
|
|
776
|
-
}
|
|
777
|
-
function readPhysicalCoordinate(array, index) {
|
|
778
|
-
if (array.kind === 'fixed-size-list' && array.child.kind === 'primitive') {
|
|
779
|
-
const logical = (array.offset || 0) + index;
|
|
780
|
-
const values = [];
|
|
781
|
-
for (let component = 0; component < array.size; component++)
|
|
782
|
-
values.push(Number(array.child.values[(array.child.offset || 0) +
|
|
783
|
-
(logical * array.size + component) * (array.child.stride || 1)]));
|
|
784
|
-
return values;
|
|
785
|
-
}
|
|
786
|
-
if (array.kind === 'struct') {
|
|
787
|
-
const logical = (array.offset || 0) + index;
|
|
788
|
-
return ['x', 'y', 'z', 'm'].flatMap(name => {
|
|
789
|
-
const child = array.children[name];
|
|
790
|
-
return child?.kind === 'primitive'
|
|
791
|
-
? [Number(child.values[(child.offset || 0) + logical * (child.stride || 1)])]
|
|
792
|
-
: [];
|
|
793
|
-
});
|
|
794
|
-
}
|
|
795
|
-
return null;
|
|
796
|
-
}
|
|
797
|
-
function getListRange(list, index) {
|
|
798
|
-
const offset = (list.offset || 0) + index;
|
|
799
|
-
const base = typeof (list.offsetBase ?? 0) === 'bigint'
|
|
800
|
-
? Number(list.offsetBase)
|
|
801
|
-
: Number(list.offsetBase ?? 0);
|
|
802
|
-
return [
|
|
803
|
-
getGeoArrowOffset(list.offsets, offset) - base,
|
|
804
|
-
getGeoArrowOffset(list.offsets, offset + 1) - base
|
|
805
|
-
];
|
|
806
|
-
}
|
|
807
|
-
function getEncodingDepth(encoding) {
|
|
808
|
-
return encoding === 'geoarrow.point'
|
|
809
|
-
? 0
|
|
810
|
-
: encoding === 'geoarrow.linestring' || encoding === 'geoarrow.multipoint'
|
|
811
|
-
? 1
|
|
812
|
-
: encoding === 'geoarrow.polygon' || encoding === 'geoarrow.multilinestring'
|
|
813
|
-
? 2
|
|
814
|
-
: 3;
|
|
815
|
-
}
|
|
816
|
-
function encodingFromName(name) {
|
|
817
|
-
return `geoarrow.${name.toLowerCase()}`;
|
|
818
|
-
}
|
|
819
|
-
function normalizeRowsToDimension(rows, dimension) {
|
|
820
|
-
const size = getGeoArrowDimensionSize(dimension);
|
|
821
|
-
const normalizeGeometry = (geometry) => {
|
|
822
|
-
if (geometry.type === 'GeometryCollection') {
|
|
823
|
-
return { ...geometry, geometries: geometry.geometries.map(normalizeGeometry) };
|
|
824
|
-
}
|
|
825
|
-
return {
|
|
826
|
-
...geometry,
|
|
827
|
-
coordinates: normalizeCoordinateNesting(geometry.coordinates, size)
|
|
828
|
-
};
|
|
829
|
-
};
|
|
830
|
-
return rows.map(row => (row ? normalizeGeometry(row) : null));
|
|
831
|
-
}
|
|
832
|
-
function normalizeCoordinateNesting(value, size) {
|
|
833
|
-
if (value.length === 0)
|
|
834
|
-
return [];
|
|
835
|
-
if (typeof value[0] === 'number') {
|
|
836
|
-
const coordinate = value.slice(0, size);
|
|
837
|
-
while (coordinate.length < size)
|
|
838
|
-
coordinate.push(0);
|
|
839
|
-
return coordinate;
|
|
840
|
-
}
|
|
841
|
-
return value.map(child => normalizeCoordinateNesting(child, size));
|
|
842
|
-
}
|
|
843
|
-
function decodeSerializedRows(column, decoder) {
|
|
844
|
-
const rows = [];
|
|
845
|
-
for (const chunk of column.chunks) {
|
|
846
|
-
if (chunk.kind !== 'serialized')
|
|
847
|
-
throw new Error('Serialized column contains native storage');
|
|
848
|
-
for (let rowIndex = 0; rowIndex < chunk.length; rowIndex++) {
|
|
849
|
-
if (!isGeoArrowValueValid(chunk.validity, rowIndex)) {
|
|
850
|
-
rows.push(null);
|
|
851
|
-
continue;
|
|
852
|
-
}
|
|
853
|
-
rows.push(decoder(getSerializedBytes(chunk, rowIndex)));
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
return rows;
|
|
857
|
-
}
|
|
858
|
-
function getSerializedBytes(array, rowIndex) {
|
|
859
|
-
if (array.views) {
|
|
860
|
-
const viewIndex = ((array.offset || 0) + rowIndex) * 4;
|
|
861
|
-
const length = array.views[viewIndex];
|
|
862
|
-
// Arrow BinaryView stores short values inline in the 16-byte view record.
|
|
863
|
-
if (length <= 12) {
|
|
864
|
-
const byteOffset = array.views.byteOffset + viewIndex * 4 + 4;
|
|
865
|
-
return new Uint8Array(array.views.buffer, byteOffset, length);
|
|
866
|
-
}
|
|
867
|
-
const bufferIndex = array.views[viewIndex + 2];
|
|
868
|
-
const byteOffset = array.views[viewIndex + 3];
|
|
869
|
-
const data = array.dataBuffers?.[bufferIndex];
|
|
870
|
-
if (!data)
|
|
871
|
-
throw new Error(`Serialized view references missing data buffer ${bufferIndex}`);
|
|
872
|
-
return data.subarray(byteOffset, byteOffset + length);
|
|
873
|
-
}
|
|
874
|
-
const offsetIndex = (array.offset || 0) + rowIndex;
|
|
875
|
-
const baseValue = array.offsetBase ?? 0;
|
|
876
|
-
const base = typeof baseValue === 'bigint' ? Number(baseValue) : baseValue;
|
|
877
|
-
const first = getGeoArrowOffset(array.offsets, offsetIndex) - base;
|
|
878
|
-
const last = getGeoArrowOffset(array.offsets, offsetIndex + 1) - base;
|
|
879
|
-
return array.values.subarray(first, last);
|
|
880
|
-
}
|
|
881
|
-
function makeSerializedColumn(rows, encoding, dimension) {
|
|
882
|
-
let byteLength = 0;
|
|
883
|
-
for (const row of rows)
|
|
884
|
-
byteLength += row?.byteLength || 0;
|
|
885
|
-
const values = new Uint8Array(byteLength);
|
|
886
|
-
const offsets = new Int32Array(rows.length + 1);
|
|
887
|
-
const validity = new Uint8Array(Math.ceil(rows.length / 8));
|
|
888
|
-
let byteOffset = 0;
|
|
889
|
-
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
|
|
890
|
-
const row = rows[rowIndex];
|
|
891
|
-
if (row) {
|
|
892
|
-
values.set(row, byteOffset);
|
|
893
|
-
byteOffset += row.byteLength;
|
|
894
|
-
validity[rowIndex >> 3] |= 1 << (rowIndex & 7);
|
|
895
|
-
}
|
|
896
|
-
offsets[rowIndex + 1] = byteOffset;
|
|
897
|
-
}
|
|
898
|
-
const chunk = {
|
|
899
|
-
kind: 'serialized',
|
|
900
|
-
encoding: encoding === 'geoarrow.wkb' ? 'binary' : 'utf8',
|
|
901
|
-
length: rows.length,
|
|
902
|
-
offsets,
|
|
903
|
-
values,
|
|
904
|
-
validity: { values: validity }
|
|
905
|
-
};
|
|
906
|
-
return { encoding, dimension, coordinateLayout: null, chunks: [chunk] };
|
|
907
|
-
}
|
|
908
|
-
function copyMetadata(source, target) {
|
|
909
|
-
return {
|
|
910
|
-
...target,
|
|
911
|
-
spatialReference: source.spatialReference,
|
|
912
|
-
edges: source.edges,
|
|
913
|
-
metadata: source.metadata
|
|
914
|
-
};
|
|
915
|
-
}
|
|
916
|
-
//# sourceMappingURL=codecs.js.map
|