@loaders.gl/geospatial 0.0.0-stage → 5.0.0-alpha.14
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 +52 -0
- package/README.md +8 -2
- package/dist/dbf-worker.js +17099 -0
- package/dist/dbf.d.ts +2 -0
- package/dist/dbf.d.ts.map +1 -0
- package/dist/dbf.js +5 -0
- package/dist/dbf.js.map +1 -0
- package/dist/flatgeobuf/bundled.d.ts +3 -0
- package/dist/flatgeobuf/bundled.d.ts.map +1 -0
- package/dist/flatgeobuf/bundled.js +5 -0
- package/dist/flatgeobuf/bundled.js.map +1 -0
- package/dist/flatgeobuf/flatgeobuf-format.d.ts +12 -0
- package/dist/flatgeobuf/flatgeobuf-format.d.ts.map +1 -0
- package/dist/flatgeobuf/flatgeobuf-format.js +15 -0
- package/dist/flatgeobuf/flatgeobuf-format.js.map +1 -0
- package/dist/flatgeobuf/flatgeobuf-loader-types.d.ts +104 -0
- package/dist/flatgeobuf/flatgeobuf-loader-types.d.ts.map +1 -0
- package/dist/flatgeobuf/flatgeobuf-loader-types.js +36 -0
- package/dist/flatgeobuf/flatgeobuf-loader-types.js.map +1 -0
- package/dist/flatgeobuf/flatgeobuf-loader.d.ts +59 -0
- package/dist/flatgeobuf/flatgeobuf-loader.d.ts.map +1 -0
- package/dist/flatgeobuf/flatgeobuf-loader.js +38 -0
- package/dist/flatgeobuf/flatgeobuf-loader.js.map +1 -0
- package/dist/flatgeobuf/flatgeobuf-source-loader.d.ts +105 -0
- package/dist/flatgeobuf/flatgeobuf-source-loader.d.ts.map +1 -0
- package/dist/flatgeobuf/flatgeobuf-source-loader.js +240 -0
- package/dist/flatgeobuf/flatgeobuf-source-loader.js.map +1 -0
- package/dist/flatgeobuf/flatgeobuf-table-query-capabilities.d.ts +4 -0
- package/dist/flatgeobuf/flatgeobuf-table-query-capabilities.d.ts.map +1 -0
- package/dist/flatgeobuf/flatgeobuf-table-query-capabilities.js +12 -0
- package/dist/flatgeobuf/flatgeobuf-table-query-capabilities.js.map +1 -0
- package/dist/flatgeobuf/index.cjs +5543 -0
- package/dist/flatgeobuf/index.cjs.map +6 -0
- package/dist/flatgeobuf/index.d.ts +9 -0
- package/dist/flatgeobuf/index.d.ts.map +1 -0
- package/dist/flatgeobuf/index.js +11 -0
- package/dist/flatgeobuf/index.js.map +1 -0
- package/dist/flatgeobuf/lib/flatgeobuf-reader.d.ts +97 -0
- package/dist/flatgeobuf/lib/flatgeobuf-reader.d.ts.map +1 -0
- package/dist/flatgeobuf/lib/flatgeobuf-reader.js +577 -0
- package/dist/flatgeobuf/lib/flatgeobuf-reader.js.map +1 -0
- package/dist/flatgeobuf/lib/flatgeobuf-worker-transport.d.ts +8 -0
- package/dist/flatgeobuf/lib/flatgeobuf-worker-transport.d.ts.map +1 -0
- package/dist/flatgeobuf/lib/flatgeobuf-worker-transport.js +44 -0
- package/dist/flatgeobuf/lib/flatgeobuf-worker-transport.js.map +1 -0
- package/dist/flatgeobuf/lib/parse-flatgeobuf.d.ts +36 -0
- package/dist/flatgeobuf/lib/parse-flatgeobuf.d.ts.map +1 -0
- package/dist/flatgeobuf/lib/parse-flatgeobuf.js +269 -0
- package/dist/flatgeobuf/lib/parse-flatgeobuf.js.map +1 -0
- package/dist/flatgeobuf/unbundled.d.ts +3 -0
- package/dist/flatgeobuf/unbundled.d.ts.map +1 -0
- package/dist/flatgeobuf/unbundled.js +5 -0
- package/dist/flatgeobuf/unbundled.js.map +1 -0
- package/dist/flatgeobuf-worker.js +32891 -0
- package/dist/flatgeobuf.d.ts +2 -0
- package/dist/flatgeobuf.d.ts.map +1 -0
- package/dist/flatgeobuf.js +5 -0
- package/dist/flatgeobuf.js.map +1 -0
- package/dist/geopackage/bundled.d.ts +3 -0
- package/dist/geopackage/bundled.d.ts.map +1 -0
- package/dist/geopackage/bundled.js +5 -0
- package/dist/geopackage/bundled.js.map +1 -0
- package/dist/geopackage/geopackage-format.d.ts +11 -0
- package/dist/geopackage/geopackage-format.d.ts.map +1 -0
- package/dist/geopackage/geopackage-format.js +14 -0
- package/dist/geopackage/geopackage-format.js.map +1 -0
- package/dist/geopackage/geopackage-loader-options.d.ts +5 -0
- package/dist/geopackage/geopackage-loader-options.d.ts.map +1 -0
- package/dist/geopackage/geopackage-loader-options.js +12 -0
- package/dist/geopackage/geopackage-loader-options.js.map +1 -0
- package/dist/geopackage/geopackage-loader-types.d.ts +72 -0
- package/dist/geopackage/geopackage-loader-types.d.ts.map +1 -0
- package/dist/geopackage/geopackage-loader-types.js +30 -0
- package/dist/geopackage/geopackage-loader-types.js.map +1 -0
- package/dist/geopackage/geopackage-loader.d.ts +26 -0
- package/dist/geopackage/geopackage-loader.d.ts.map +1 -0
- package/dist/geopackage/geopackage-loader.js +12 -0
- package/dist/geopackage/geopackage-loader.js.map +1 -0
- package/dist/geopackage/geopackage-source-loader.d.ts +99 -0
- package/dist/geopackage/geopackage-source-loader.d.ts.map +1 -0
- package/dist/geopackage/geopackage-source-loader.js +258 -0
- package/dist/geopackage/geopackage-source-loader.js.map +1 -0
- package/dist/geopackage/index.cjs +4433 -0
- package/dist/geopackage/index.cjs.map +6 -0
- package/dist/geopackage/index.d.ts +7 -0
- package/dist/geopackage/index.d.ts.map +1 -0
- package/dist/geopackage/index.js +7 -0
- package/dist/geopackage/index.js.map +1 -0
- package/dist/geopackage/lib/geopackage-tile-metadata.d.ts +22 -0
- package/dist/geopackage/lib/geopackage-tile-metadata.d.ts.map +1 -0
- package/dist/geopackage/lib/geopackage-tile-metadata.js +105 -0
- package/dist/geopackage/lib/geopackage-tile-metadata.js.map +1 -0
- package/dist/geopackage/lib/parse-geopackage.d.ts +39 -0
- package/dist/geopackage/lib/parse-geopackage.d.ts.map +1 -0
- package/dist/geopackage/lib/parse-geopackage.js +485 -0
- package/dist/geopackage/lib/parse-geopackage.js.map +1 -0
- package/dist/geopackage/lib/types.d.ts +216 -0
- package/dist/geopackage/lib/types.d.ts.map +1 -0
- package/dist/geopackage/lib/types.js +5 -0
- package/dist/geopackage/lib/types.js.map +1 -0
- package/dist/geopackage/unbundled.d.ts +3 -0
- package/dist/geopackage/unbundled.d.ts.map +1 -0
- package/dist/geopackage/unbundled.js +5 -0
- package/dist/geopackage/unbundled.js.map +1 -0
- package/dist/geopackage.d.ts +2 -0
- package/dist/geopackage.d.ts.map +1 -0
- package/dist/geopackage.js +5 -0
- package/dist/geopackage.js.map +1 -0
- package/dist/gpx.d.ts +2 -0
- package/dist/gpx.d.ts.map +1 -0
- package/dist/gpx.js +5 -0
- package/dist/gpx.js.map +1 -0
- package/dist/index.cjs +15191 -0
- package/dist/index.cjs.map +6 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/kml/bundled.d.ts +13 -0
- package/dist/kml/bundled.d.ts.map +1 -0
- package/dist/kml/bundled.js +10 -0
- package/dist/kml/bundled.js.map +1 -0
- package/dist/kml/gpx-loader-types.d.ts +61 -0
- package/dist/kml/gpx-loader-types.d.ts.map +1 -0
- package/dist/kml/gpx-loader-types.js +25 -0
- package/dist/kml/gpx-loader-types.js.map +1 -0
- package/dist/kml/gpx-loader.d.ts +56 -0
- package/dist/kml/gpx-loader.d.ts.map +1 -0
- package/dist/kml/gpx-loader.js +62 -0
- package/dist/kml/gpx-loader.js.map +1 -0
- package/dist/kml/index.cjs +11435 -0
- package/dist/kml/index.cjs.map +6 -0
- package/dist/kml/index.d.ts +18 -0
- package/dist/kml/index.d.ts.map +1 -0
- package/dist/kml/index.js +13 -0
- package/dist/kml/index.js.map +1 -0
- package/dist/kml/kml-format.d.ts +50 -0
- package/dist/kml/kml-format.d.ts.map +1 -0
- package/dist/kml/kml-format.js +62 -0
- package/dist/kml/kml-format.js.map +1 -0
- package/dist/kml/kml-loader-types.d.ts +61 -0
- package/dist/kml/kml-loader-types.d.ts.map +1 -0
- package/dist/kml/kml-loader-types.js +25 -0
- package/dist/kml/kml-loader-types.js.map +1 -0
- package/dist/kml/kml-loader.d.ts +56 -0
- package/dist/kml/kml-loader.d.ts.map +1 -0
- package/dist/kml/kml-loader.js +60 -0
- package/dist/kml/kml-loader.js.map +1 -0
- package/dist/kml/kml-parser.d.ts +98 -0
- package/dist/kml/kml-parser.d.ts.map +1 -0
- package/dist/kml/kml-parser.js +461 -0
- package/dist/kml/kml-parser.js.map +1 -0
- package/dist/kml/kml-writer.d.ts +64 -0
- package/dist/kml/kml-writer.d.ts.map +1 -0
- package/dist/kml/kml-writer.js +202 -0
- package/dist/kml/kml-writer.js.map +1 -0
- package/dist/kml/kmz-archive.d.ts +19 -0
- package/dist/kml/kmz-archive.d.ts.map +1 -0
- package/dist/kml/kmz-archive.js +72 -0
- package/dist/kml/kmz-archive.js.map +1 -0
- package/dist/kml/kmz-loader-types.d.ts +58 -0
- package/dist/kml/kmz-loader-types.d.ts.map +1 -0
- package/dist/kml/kmz-loader-types.js +24 -0
- package/dist/kml/kmz-loader-types.js.map +1 -0
- package/dist/kml/kmz-loader.d.ts +29 -0
- package/dist/kml/kmz-loader.d.ts.map +1 -0
- package/dist/kml/kmz-loader.js +41 -0
- package/dist/kml/kmz-loader.js.map +1 -0
- package/dist/kml/kmz-source.d.ts +62 -0
- package/dist/kml/kmz-source.d.ts.map +1 -0
- package/dist/kml/kmz-source.js +177 -0
- package/dist/kml/kmz-source.js.map +1 -0
- package/dist/kml/lib/feature-collection-to-arrow.d.ts +90 -0
- package/dist/kml/lib/feature-collection-to-arrow.d.ts.map +1 -0
- package/dist/kml/lib/feature-collection-to-arrow.js +181 -0
- package/dist/kml/lib/feature-collection-to-arrow.js.map +1 -0
- package/dist/kml/sports-track-parser.d.ts +6 -0
- package/dist/kml/sports-track-parser.d.ts.map +1 -0
- package/dist/kml/sports-track-parser.js +411 -0
- package/dist/kml/sports-track-parser.js.map +1 -0
- package/dist/kml/tcx-loader-types.d.ts +61 -0
- package/dist/kml/tcx-loader-types.d.ts.map +1 -0
- package/dist/kml/tcx-loader-types.js +25 -0
- package/dist/kml/tcx-loader-types.js.map +1 -0
- package/dist/kml/tcx-loader.d.ts +56 -0
- package/dist/kml/tcx-loader.d.ts.map +1 -0
- package/dist/kml/tcx-loader.js +62 -0
- package/dist/kml/tcx-loader.js.map +1 -0
- package/dist/kml/unbundled.d.ts +13 -0
- package/dist/kml/unbundled.d.ts.map +1 -0
- package/dist/kml/unbundled.js +10 -0
- package/dist/kml/unbundled.js.map +1 -0
- package/dist/kml.d.ts +2 -0
- package/dist/kml.d.ts.map +1 -0
- package/dist/kml.js +5 -0
- package/dist/kml.js.map +1 -0
- package/dist/kmz.d.ts +2 -0
- package/dist/kmz.d.ts.map +1 -0
- package/dist/kmz.js +5 -0
- package/dist/kmz.js.map +1 -0
- package/dist/shapefile/bundled.d.ts +7 -0
- package/dist/shapefile/bundled.d.ts.map +1 -0
- package/dist/shapefile/bundled.js +7 -0
- package/dist/shapefile/bundled.js.map +1 -0
- package/dist/shapefile/dbf-format.d.ts +12 -0
- package/dist/shapefile/dbf-format.d.ts.map +1 -0
- package/dist/shapefile/dbf-format.js +15 -0
- package/dist/shapefile/dbf-format.js.map +1 -0
- package/dist/shapefile/dbf-loader-types.d.ts +15 -0
- package/dist/shapefile/dbf-loader-types.d.ts.map +1 -0
- package/dist/shapefile/dbf-loader-types.js +34 -0
- package/dist/shapefile/dbf-loader-types.js.map +1 -0
- package/dist/shapefile/dbf-loader.d.ts +49 -0
- package/dist/shapefile/dbf-loader.d.ts.map +1 -0
- package/dist/shapefile/dbf-loader.js +39 -0
- package/dist/shapefile/dbf-loader.js.map +1 -0
- package/dist/shapefile/index.cjs +5742 -0
- package/dist/shapefile/index.cjs.map +6 -0
- package/dist/shapefile/index.d.ts +16 -0
- package/dist/shapefile/index.d.ts.map +1 -0
- package/dist/shapefile/index.js +18 -0
- package/dist/shapefile/index.js.map +1 -0
- package/dist/shapefile/lib/parsers/build-geoarrow-geometry-arrow.d.ts +18 -0
- package/dist/shapefile/lib/parsers/build-geoarrow-geometry-arrow.d.ts.map +1 -0
- package/dist/shapefile/lib/parsers/build-geoarrow-geometry-arrow.js +129 -0
- package/dist/shapefile/lib/parsers/build-geoarrow-geometry-arrow.js.map +1 -0
- package/dist/shapefile/lib/parsers/build-wkb-geometry-arrow.d.ts +12 -0
- package/dist/shapefile/lib/parsers/build-wkb-geometry-arrow.d.ts.map +1 -0
- package/dist/shapefile/lib/parsers/build-wkb-geometry-arrow.js +206 -0
- package/dist/shapefile/lib/parsers/build-wkb-geometry-arrow.js.map +1 -0
- package/dist/shapefile/lib/parsers/parse-dbf-to-arrow.d.ts +26 -0
- package/dist/shapefile/lib/parsers/parse-dbf-to-arrow.d.ts.map +1 -0
- package/dist/shapefile/lib/parsers/parse-dbf-to-arrow.js +347 -0
- package/dist/shapefile/lib/parsers/parse-dbf-to-arrow.js.map +1 -0
- package/dist/shapefile/lib/parsers/parse-dbf.d.ts +14 -0
- package/dist/shapefile/lib/parsers/parse-dbf.d.ts.map +1 -0
- package/dist/shapefile/lib/parsers/parse-dbf.js +352 -0
- package/dist/shapefile/lib/parsers/parse-dbf.js.map +1 -0
- package/dist/shapefile/lib/parsers/parse-shapefile.d.ts +50 -0
- package/dist/shapefile/lib/parsers/parse-shapefile.d.ts.map +1 -0
- package/dist/shapefile/lib/parsers/parse-shapefile.js +306 -0
- package/dist/shapefile/lib/parsers/parse-shapefile.js.map +1 -0
- package/dist/shapefile/lib/parsers/parse-shp-geometry.d.ts +50 -0
- package/dist/shapefile/lib/parsers/parse-shp-geometry.d.ts.map +1 -0
- package/dist/shapefile/lib/parsers/parse-shp-geometry.js +384 -0
- package/dist/shapefile/lib/parsers/parse-shp-geometry.js.map +1 -0
- package/dist/shapefile/lib/parsers/parse-shp-header.d.ts +26 -0
- package/dist/shapefile/lib/parsers/parse-shp-header.d.ts.map +1 -0
- package/dist/shapefile/lib/parsers/parse-shp-header.js +43 -0
- package/dist/shapefile/lib/parsers/parse-shp-header.js.map +1 -0
- package/dist/shapefile/lib/parsers/parse-shp-to-arrow.d.ts +5 -0
- package/dist/shapefile/lib/parsers/parse-shp-to-arrow.d.ts.map +1 -0
- package/dist/shapefile/lib/parsers/parse-shp-to-arrow.js +130 -0
- package/dist/shapefile/lib/parsers/parse-shp-to-arrow.js.map +1 -0
- package/dist/shapefile/lib/parsers/parse-shp.d.ts +24 -0
- package/dist/shapefile/lib/parsers/parse-shp.d.ts.map +1 -0
- package/dist/shapefile/lib/parsers/parse-shp.js +194 -0
- package/dist/shapefile/lib/parsers/parse-shp.js.map +1 -0
- package/dist/shapefile/lib/parsers/parse-shx.d.ts +10 -0
- package/dist/shapefile/lib/parsers/parse-shx.d.ts.map +1 -0
- package/dist/shapefile/lib/parsers/parse-shx.js +28 -0
- package/dist/shapefile/lib/parsers/parse-shx.js.map +1 -0
- package/dist/shapefile/lib/parsers/types.d.ts +85 -0
- package/dist/shapefile/lib/parsers/types.d.ts.map +1 -0
- package/dist/shapefile/lib/parsers/types.js +5 -0
- package/dist/shapefile/lib/parsers/types.js.map +1 -0
- package/dist/shapefile/lib/shapefile-worker-transport.d.ts +10 -0
- package/dist/shapefile/lib/shapefile-worker-transport.d.ts.map +1 -0
- package/dist/shapefile/lib/shapefile-worker-transport.js +46 -0
- package/dist/shapefile/lib/shapefile-worker-transport.js.map +1 -0
- package/dist/shapefile/lib/streaming/binary-chunk-reader.d.ts +2 -0
- package/dist/shapefile/lib/streaming/binary-chunk-reader.d.ts.map +1 -0
- package/dist/shapefile/lib/streaming/binary-chunk-reader.js +5 -0
- package/dist/shapefile/lib/streaming/binary-chunk-reader.js.map +1 -0
- package/dist/shapefile/lib/streaming/binary-reader.d.ts +32 -0
- package/dist/shapefile/lib/streaming/binary-reader.d.ts.map +1 -0
- package/dist/shapefile/lib/streaming/binary-reader.js +55 -0
- package/dist/shapefile/lib/streaming/binary-reader.js.map +1 -0
- package/dist/shapefile/lib/streaming/zip-batch-iterators.d.ts +11 -0
- package/dist/shapefile/lib/streaming/zip-batch-iterators.d.ts.map +1 -0
- package/dist/shapefile/lib/streaming/zip-batch-iterators.js +67 -0
- package/dist/shapefile/lib/streaming/zip-batch-iterators.js.map +1 -0
- package/dist/shapefile/shapefile-arrow-loader.d.ts +8 -0
- package/dist/shapefile/shapefile-arrow-loader.d.ts.map +1 -0
- package/dist/shapefile/shapefile-arrow-loader.js +316 -0
- package/dist/shapefile/shapefile-arrow-loader.js.map +1 -0
- package/dist/shapefile/shapefile-loader-types.d.ts +80 -0
- package/dist/shapefile/shapefile-loader-types.d.ts.map +1 -0
- package/dist/shapefile/shapefile-loader-types.js +29 -0
- package/dist/shapefile/shapefile-loader-types.js.map +1 -0
- package/dist/shapefile/shapefile-loader.d.ts +57 -0
- package/dist/shapefile/shapefile-loader.d.ts.map +1 -0
- package/dist/shapefile/shapefile-loader.js +29 -0
- package/dist/shapefile/shapefile-loader.js.map +1 -0
- package/dist/shapefile/shp-format.d.ts +27 -0
- package/dist/shapefile/shp-format.d.ts.map +1 -0
- package/dist/shapefile/shp-format.js +31 -0
- package/dist/shapefile/shp-format.js.map +1 -0
- package/dist/shapefile/shp-loader-types.d.ts +28 -0
- package/dist/shapefile/shp-loader-types.d.ts.map +1 -0
- package/dist/shapefile/shp-loader-types.js +31 -0
- package/dist/shapefile/shp-loader-types.js.map +1 -0
- package/dist/shapefile/shp-loader.d.ts +54 -0
- package/dist/shapefile/shp-loader.d.ts.map +1 -0
- package/dist/shapefile/shp-loader.js +38 -0
- package/dist/shapefile/shp-loader.js.map +1 -0
- package/dist/shapefile/unbundled.d.ts +7 -0
- package/dist/shapefile/unbundled.d.ts.map +1 -0
- package/dist/shapefile/unbundled.js +7 -0
- package/dist/shapefile/unbundled.js.map +1 -0
- package/dist/shapefile.d.ts +2 -0
- package/dist/shapefile.d.ts.map +1 -0
- package/dist/shapefile.js +5 -0
- package/dist/shapefile.js.map +1 -0
- package/dist/shp-worker.js +20232 -0
- package/dist/shp.d.ts +2 -0
- package/dist/shp.d.ts.map +1 -0
- package/dist/shp.js +5 -0
- package/dist/shp.js.map +1 -0
- package/dist/tcx.d.ts +2 -0
- package/dist/tcx.d.ts.map +1 -0
- package/dist/tcx.js +5 -0
- package/dist/tcx.js.map +1 -0
- package/dist/workers/dbf-worker.d.ts +2 -0
- package/dist/workers/dbf-worker.d.ts.map +1 -0
- package/dist/workers/dbf-worker.js +7 -0
- package/dist/workers/dbf-worker.js.map +1 -0
- package/dist/workers/flatgeobuf-worker.d.ts +2 -0
- package/dist/workers/flatgeobuf-worker.d.ts.map +1 -0
- package/dist/workers/flatgeobuf-worker.js +7 -0
- package/dist/workers/flatgeobuf-worker.js.map +1 -0
- package/dist/workers/geopackage-worker.d.ts +2 -0
- package/dist/workers/geopackage-worker.d.ts.map +1 -0
- package/dist/workers/geopackage-worker.js +7 -0
- package/dist/workers/geopackage-worker.js.map +1 -0
- package/dist/workers/shp-worker.d.ts +2 -0
- package/dist/workers/shp-worker.d.ts.map +1 -0
- package/dist/workers/shp-worker.js +7 -0
- package/dist/workers/shp-worker.js.map +1 -0
- package/package.json +291 -4
- package/src/dbf.ts +5 -0
- package/src/flatgeobuf/LICENSE +9 -0
- package/src/flatgeobuf/bundled.ts +9 -0
- package/src/flatgeobuf/flatgeobuf-format.ts +17 -0
- package/src/flatgeobuf/flatgeobuf-loader-types.ts +70 -0
- package/src/flatgeobuf/flatgeobuf-loader.ts +66 -0
- package/src/flatgeobuf/flatgeobuf-source-loader.ts +338 -0
- package/src/flatgeobuf/flatgeobuf-table-query-capabilities.ts +14 -0
- package/src/flatgeobuf/index.ts +24 -0
- package/src/flatgeobuf/lib/flatgeobuf-reader.ts +719 -0
- package/src/flatgeobuf/lib/flatgeobuf-worker-transport.ts +63 -0
- package/src/flatgeobuf/lib/parse-flatgeobuf.ts +383 -0
- package/src/flatgeobuf/unbundled.ts +6 -0
- package/src/flatgeobuf.ts +5 -0
- package/src/geopackage/bundled.ts +6 -0
- package/src/geopackage/geopackage-format.ts +16 -0
- package/src/geopackage/geopackage-loader-options.ts +13 -0
- package/src/geopackage/geopackage-loader-types.ts +60 -0
- package/src/geopackage/geopackage-loader.ts +21 -0
- package/src/geopackage/geopackage-source-loader.ts +364 -0
- package/src/geopackage/index.ts +16 -0
- package/src/geopackage/lib/geopackage-tile-metadata.ts +156 -0
- package/src/geopackage/lib/parse-geopackage.ts +679 -0
- package/src/geopackage/lib/types.ts +293 -0
- package/src/geopackage/unbundled.ts +6 -0
- package/src/geopackage.ts +5 -0
- package/src/gpx.ts +5 -0
- package/src/index.ts +30 -0
- package/src/kml/bundled.ts +21 -0
- package/src/kml/gpx-loader-types.ts +50 -0
- package/src/kml/gpx-loader.ts +101 -0
- package/src/kml/index.ts +39 -0
- package/src/kml/kml-format.ts +70 -0
- package/src/kml/kml-loader-types.ts +46 -0
- package/src/kml/kml-loader.ts +98 -0
- package/src/kml/kml-parser.ts +593 -0
- package/src/kml/kml-writer.ts +252 -0
- package/src/kml/kmz-archive.ts +92 -0
- package/src/kml/kmz-loader-types.ts +37 -0
- package/src/kml/kmz-loader.ts +56 -0
- package/src/kml/kmz-source.ts +234 -0
- package/src/kml/lib/feature-collection-to-arrow.ts +231 -0
- package/src/kml/sports-track-parser.ts +426 -0
- package/src/kml/tcx-loader-types.ts +50 -0
- package/src/kml/tcx-loader.ts +101 -0
- package/src/kml/unbundled.ts +21 -0
- package/src/kml.ts +5 -0
- package/src/kmz.ts +5 -0
- package/src/shapefile/bundled.ts +18 -0
- package/src/shapefile/dbf-format.ts +17 -0
- package/src/shapefile/dbf-loader-types.ts +51 -0
- package/src/shapefile/dbf-loader.ts +79 -0
- package/src/shapefile/index.ts +25 -0
- package/src/shapefile/lib/parsers/build-geoarrow-geometry-arrow.ts +172 -0
- package/src/shapefile/lib/parsers/build-wkb-geometry-arrow.ts +340 -0
- package/src/shapefile/lib/parsers/parse-dbf-to-arrow.ts +429 -0
- package/src/shapefile/lib/parsers/parse-dbf.ts +422 -0
- package/src/shapefile/lib/parsers/parse-shapefile.ts +417 -0
- package/src/shapefile/lib/parsers/parse-shp-geometry.ts +527 -0
- package/src/shapefile/lib/parsers/parse-shp-header.ts +64 -0
- package/src/shapefile/lib/parsers/parse-shp-to-arrow.ts +184 -0
- package/src/shapefile/lib/parsers/parse-shp.ts +245 -0
- package/src/shapefile/lib/parsers/parse-shx.ts +39 -0
- package/src/shapefile/lib/parsers/types.ts +96 -0
- package/src/shapefile/lib/shapefile-worker-transport.ts +72 -0
- package/src/shapefile/lib/streaming/binary-chunk-reader.ts +8 -0
- package/src/shapefile/lib/streaming/binary-reader.ts +60 -0
- package/src/shapefile/lib/streaming/zip-batch-iterators.ts +78 -0
- package/src/shapefile/shapefile-arrow-loader.ts +448 -0
- package/src/shapefile/shapefile-loader-types.ts +70 -0
- package/src/shapefile/shapefile-loader.ts +76 -0
- package/src/shapefile/shp-format.ts +34 -0
- package/src/shapefile/shp-loader-types.ts +60 -0
- package/src/shapefile/shp-loader.ts +80 -0
- package/src/shapefile/unbundled.ts +12 -0
- package/src/shapefile.ts +5 -0
- package/src/shp.ts +5 -0
- package/src/tcx.ts +5 -0
- package/src/workers/dbf-worker.ts +8 -0
- package/src/workers/flatgeobuf-worker.ts +8 -0
- package/src/workers/geopackage-worker.ts +8 -0
- package/src/workers/shp-worker.ts +8 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/core/loader-utils';
|
|
6
|
+
// import {GeoJSONTable} from '@loaders.gl/core/schema';
|
|
7
|
+
import {
|
|
8
|
+
FeatureCollection,
|
|
9
|
+
GeoJSONTable,
|
|
10
|
+
ObjectRowTable,
|
|
11
|
+
ArrowTable,
|
|
12
|
+
GeoArrowEncodingPreference
|
|
13
|
+
} from '@loaders.gl/core/schema';
|
|
14
|
+
import {
|
|
15
|
+
buildFeatureTableSchema,
|
|
16
|
+
convertFeatureCollectionToArrowTable
|
|
17
|
+
} from './lib/feature-collection-to-arrow';
|
|
18
|
+
import {KMLLoader as KMLLoaderMetadata} from './kml-loader-types';
|
|
19
|
+
import {convertKMLDocumentToFeatureCollection, parseKMLDocument} from './kml-parser';
|
|
20
|
+
|
|
21
|
+
const {preload: _KMLLoaderPreload, ...KMLLoaderMetadataWithoutPreload} = KMLLoaderMetadata;
|
|
22
|
+
|
|
23
|
+
export type KMLLoaderOptions = LoaderOptions & {
|
|
24
|
+
/** Preferred encoding for Arrow geometry output. */
|
|
25
|
+
geoarrow?: {encodingPreference?: GeoArrowEncodingPreference};
|
|
26
|
+
kml?: {
|
|
27
|
+
shape?: 'object-row-table' | 'geojson-table' | 'arrow-table' | 'raw';
|
|
28
|
+
geoarrow?: {encodingPreference?: GeoArrowEncodingPreference};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Loader for KML (Keyhole Markup Language)
|
|
34
|
+
*/
|
|
35
|
+
export const KMLLoaderWithParser = {
|
|
36
|
+
...KMLLoaderMetadataWithoutPreload,
|
|
37
|
+
parse: async (arrayBuffer, options?: KMLLoaderOptions) =>
|
|
38
|
+
parseTextSync(new TextDecoder().decode(arrayBuffer), options),
|
|
39
|
+
parseTextSync
|
|
40
|
+
} as const satisfies LoaderWithParser<
|
|
41
|
+
ObjectRowTable | GeoJSONTable | ArrowTable,
|
|
42
|
+
never,
|
|
43
|
+
KMLLoaderOptions
|
|
44
|
+
>;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Parses KML XML text into a GeoJSON feature collection.
|
|
48
|
+
*
|
|
49
|
+
* @param text - KML XML document text.
|
|
50
|
+
* @returns Parsed GeoJSON feature collection.
|
|
51
|
+
*/
|
|
52
|
+
export function parseKMLTextToFeatureCollection(text: string): FeatureCollection {
|
|
53
|
+
return convertKMLDocumentToFeatureCollection(parseKMLDocument(text));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Parses KML text into the requested table shape.
|
|
58
|
+
*
|
|
59
|
+
* @param text - KML XML document text.
|
|
60
|
+
* @param options - Loader options controlling the output shape.
|
|
61
|
+
* @returns A GeoJSON or object-row table.
|
|
62
|
+
*/
|
|
63
|
+
function parseTextSync(
|
|
64
|
+
text: string,
|
|
65
|
+
options?: KMLLoaderOptions
|
|
66
|
+
): ObjectRowTable | GeoJSONTable | ArrowTable {
|
|
67
|
+
const geojson = parseKMLTextToFeatureCollection(text);
|
|
68
|
+
const schema = buildFeatureTableSchema(geojson.features);
|
|
69
|
+
|
|
70
|
+
const kmlOptions = {...KMLLoaderWithParser.options.kml, ...options?.kml};
|
|
71
|
+
|
|
72
|
+
switch (kmlOptions.shape) {
|
|
73
|
+
case 'geojson-table': {
|
|
74
|
+
const table: GeoJSONTable = {
|
|
75
|
+
shape: 'geojson-table',
|
|
76
|
+
schema,
|
|
77
|
+
type: 'FeatureCollection',
|
|
78
|
+
features: geojson.features
|
|
79
|
+
};
|
|
80
|
+
return table;
|
|
81
|
+
}
|
|
82
|
+
case 'arrow-table':
|
|
83
|
+
return convertFeatureCollectionToArrowTable(
|
|
84
|
+
geojson.features,
|
|
85
|
+
options?.geoarrow || kmlOptions.geoarrow
|
|
86
|
+
);
|
|
87
|
+
// case 'raw':
|
|
88
|
+
// return doc;
|
|
89
|
+
case 'object-row-table':
|
|
90
|
+
const table: ObjectRowTable = {
|
|
91
|
+
shape: 'object-row-table',
|
|
92
|
+
data: geojson.features
|
|
93
|
+
};
|
|
94
|
+
return table;
|
|
95
|
+
default:
|
|
96
|
+
throw new Error(kmlOptions.shape);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,593 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
Feature,
|
|
7
|
+
FeatureCollection,
|
|
8
|
+
Geometry,
|
|
9
|
+
GeoJsonProperties,
|
|
10
|
+
Position
|
|
11
|
+
} from '@loaders.gl/core/schema';
|
|
12
|
+
import {parseXMLSync} from '@loaders.gl/xml';
|
|
13
|
+
|
|
14
|
+
interface XMLValueArray extends Array<XMLValue> {}
|
|
15
|
+
interface XMLObject {
|
|
16
|
+
[key: string]: XMLValue;
|
|
17
|
+
}
|
|
18
|
+
type XMLValue = string | number | boolean | XMLObject | XMLValueArray;
|
|
19
|
+
|
|
20
|
+
/** A parsed KML style in the normalized loaders.gl representation. */
|
|
21
|
+
export type KMLStyle = {
|
|
22
|
+
id: string;
|
|
23
|
+
line?: {color?: string; opacity?: number; width?: number};
|
|
24
|
+
polygon?: {color?: string; opacity?: number; fill?: boolean; outline?: boolean};
|
|
25
|
+
icon?: {href?: string; scale?: number};
|
|
26
|
+
label?: {color?: string; opacity?: number; scale?: number};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** A KML screen or ground overlay retained by the document parser. */
|
|
30
|
+
export type KMLOverlay = {
|
|
31
|
+
type: 'ground-overlay' | 'screen-overlay' | 'photo-overlay';
|
|
32
|
+
name?: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
href?: string;
|
|
35
|
+
visibility?: boolean;
|
|
36
|
+
bounds?: {north: number; south: number; east: number; west: number; rotation?: number};
|
|
37
|
+
raw: unknown;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** A KML NetworkLink retained without following external content. */
|
|
41
|
+
export type KMLNetworkLink = {
|
|
42
|
+
name?: string;
|
|
43
|
+
href?: string;
|
|
44
|
+
refreshMode?: string;
|
|
45
|
+
refreshInterval?: number;
|
|
46
|
+
viewRefreshMode?: string;
|
|
47
|
+
raw: unknown;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/** A KML COLLADA model reference retained by the document parser. */
|
|
51
|
+
export type KMLModel = {
|
|
52
|
+
name?: string;
|
|
53
|
+
href?: string;
|
|
54
|
+
location?: [number, number, number?];
|
|
55
|
+
orientation?: {heading?: number; tilt?: number; roll?: number};
|
|
56
|
+
scale?: {x?: number; y?: number; z?: number};
|
|
57
|
+
raw: unknown;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/** Rich parsed representation of one KML document. */
|
|
61
|
+
export type KMLDocument = {
|
|
62
|
+
type: 'KMLDocument';
|
|
63
|
+
name?: string;
|
|
64
|
+
description?: string;
|
|
65
|
+
features: Feature[];
|
|
66
|
+
folders: KMLFolder[];
|
|
67
|
+
overlays: KMLOverlay[];
|
|
68
|
+
networkLinks: KMLNetworkLink[];
|
|
69
|
+
models: KMLModel[];
|
|
70
|
+
styles: Record<string, KMLStyle>;
|
|
71
|
+
coordinateReferenceSystem: 'OGC:CRS84';
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/** A KML folder and its child folder hierarchy. */
|
|
75
|
+
export type KMLFolder = {
|
|
76
|
+
name?: string;
|
|
77
|
+
description?: string;
|
|
78
|
+
path: string[];
|
|
79
|
+
features: Feature[];
|
|
80
|
+
folders: KMLFolder[];
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/** Options controlling conversion from the rich KML document to GeoJSON. */
|
|
84
|
+
export type KMLFeatureConversionOptions = {
|
|
85
|
+
/** Preserve KML-only metadata such as altitude mode under `kml` properties. */
|
|
86
|
+
includeKMLMetadata?: boolean;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/** Parses KML XML into the loaders.gl KML document model. */
|
|
90
|
+
export function parseKMLDocument(text: string): KMLDocument {
|
|
91
|
+
const parsed = parseXMLSync(text, {
|
|
92
|
+
removeNSPrefix: true,
|
|
93
|
+
textNodeName: '#text',
|
|
94
|
+
_fastXML: {parseTagValue: false, parseAttributeValue: false}
|
|
95
|
+
}) as XMLObject;
|
|
96
|
+
const root = asObject(parsed.kml);
|
|
97
|
+
if (!root) throw new Error('Invalid KML document: root element must be <kml>');
|
|
98
|
+
|
|
99
|
+
const styles: Record<string, KMLStyle> = {};
|
|
100
|
+
for (const definition of findDescendants(root)) {
|
|
101
|
+
if (definition.__type === 'Style') {
|
|
102
|
+
const id = getAttribute(definition, 'id');
|
|
103
|
+
if (id) styles[id] = parseStyle(definition, id);
|
|
104
|
+
} else if (definition.__type === 'StyleMap') {
|
|
105
|
+
parseStyleMap(definition, styles);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const overlays: KMLOverlay[] = [];
|
|
110
|
+
const networkLinks: KMLNetworkLink[] = [];
|
|
111
|
+
const models: KMLModel[] = [];
|
|
112
|
+
const folders: KMLFolder[] = [];
|
|
113
|
+
const features: Feature[] = [];
|
|
114
|
+
const rootContainer = getFirstObject(root, 'Document') || root;
|
|
115
|
+
parseContainer(
|
|
116
|
+
rootContainer,
|
|
117
|
+
[],
|
|
118
|
+
styles,
|
|
119
|
+
overlays,
|
|
120
|
+
networkLinks,
|
|
121
|
+
models,
|
|
122
|
+
folders,
|
|
123
|
+
features,
|
|
124
|
+
true
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
type: 'KMLDocument',
|
|
129
|
+
name: getChildText(rootContainer, 'name'),
|
|
130
|
+
description: getChildText(rootContainer, 'description'),
|
|
131
|
+
features,
|
|
132
|
+
folders,
|
|
133
|
+
overlays,
|
|
134
|
+
networkLinks,
|
|
135
|
+
models,
|
|
136
|
+
styles,
|
|
137
|
+
coordinateReferenceSystem: 'OGC:CRS84'
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Converts a parsed KML document to the public GeoJSON feature collection shape. */
|
|
142
|
+
export function convertKMLDocumentToFeatureCollection(
|
|
143
|
+
document: KMLDocument,
|
|
144
|
+
options: KMLFeatureConversionOptions = {}
|
|
145
|
+
): FeatureCollection {
|
|
146
|
+
const features = document.features.map(feature => {
|
|
147
|
+
if (options.includeKMLMetadata || !feature.properties?.kml) return feature;
|
|
148
|
+
const properties = {...feature.properties};
|
|
149
|
+
delete properties.kml;
|
|
150
|
+
return {...feature, properties};
|
|
151
|
+
});
|
|
152
|
+
return {type: 'FeatureCollection', features};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function parseContainer(
|
|
156
|
+
node: XMLObject,
|
|
157
|
+
parentPath: string[],
|
|
158
|
+
styles: Record<string, KMLStyle>,
|
|
159
|
+
overlays: KMLOverlay[],
|
|
160
|
+
networkLinks: KMLNetworkLink[],
|
|
161
|
+
models: KMLModel[],
|
|
162
|
+
folders: KMLFolder[],
|
|
163
|
+
features: Feature[],
|
|
164
|
+
flattenFolderFeatures: boolean
|
|
165
|
+
): void {
|
|
166
|
+
for (const placemark of getChildObjects(node, 'Placemark')) {
|
|
167
|
+
for (const model of findDescendants(placemark, 'Model')) models.push(parseModel(model));
|
|
168
|
+
features.push(parsePlacemark(placemark, parentPath, styles));
|
|
169
|
+
}
|
|
170
|
+
for (const folderNode of getChildObjects(node, 'Folder')) {
|
|
171
|
+
const folder = parseFolder(folderNode, parentPath, styles, overlays, networkLinks, models);
|
|
172
|
+
folders.push(folder);
|
|
173
|
+
if (flattenFolderFeatures) features.push(...folderFeatures(folder));
|
|
174
|
+
}
|
|
175
|
+
for (const documentNode of getChildObjects(node, 'Document')) {
|
|
176
|
+
parseContainer(
|
|
177
|
+
documentNode,
|
|
178
|
+
parentPath,
|
|
179
|
+
styles,
|
|
180
|
+
overlays,
|
|
181
|
+
networkLinks,
|
|
182
|
+
models,
|
|
183
|
+
folders,
|
|
184
|
+
features,
|
|
185
|
+
flattenFolderFeatures
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
for (const name of ['GroundOverlay', 'ScreenOverlay', 'PhotoOverlay']) {
|
|
189
|
+
for (const overlay of getChildObjects(node, name)) overlays.push(parseOverlay(overlay));
|
|
190
|
+
}
|
|
191
|
+
for (const link of getChildObjects(node, 'NetworkLink'))
|
|
192
|
+
networkLinks.push(parseNetworkLink(link));
|
|
193
|
+
for (const model of getChildObjects(node, 'Model')) models.push(parseModel(model));
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function parseFolder(
|
|
197
|
+
node: XMLObject,
|
|
198
|
+
parentPath: string[],
|
|
199
|
+
styles: Record<string, KMLStyle>,
|
|
200
|
+
overlays: KMLOverlay[],
|
|
201
|
+
networkLinks: KMLNetworkLink[],
|
|
202
|
+
models: KMLModel[]
|
|
203
|
+
): KMLFolder {
|
|
204
|
+
const name = getChildText(node, 'name');
|
|
205
|
+
const path = name ? [...parentPath, name] : parentPath;
|
|
206
|
+
const features: Feature[] = [];
|
|
207
|
+
const folders: KMLFolder[] = [];
|
|
208
|
+
parseContainer(node, path, styles, overlays, networkLinks, models, folders, features, false);
|
|
209
|
+
return {name, description: getChildText(node, 'description'), path, features, folders};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function folderFeatures(folder: KMLFolder): Feature[] {
|
|
213
|
+
return [...folder.features, ...folder.folders.flatMap(folderFeatures)];
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function parsePlacemark(
|
|
217
|
+
node: XMLObject,
|
|
218
|
+
folderPath: string[],
|
|
219
|
+
styles: Record<string, KMLStyle>
|
|
220
|
+
): Feature {
|
|
221
|
+
const geometryNode = getGeometryNode(node);
|
|
222
|
+
const geometry = geometryNode ? parseGeometry(geometryNode) : null;
|
|
223
|
+
const properties = parsePlacemarkProperties(node, folderPath, styles, geometryNode);
|
|
224
|
+
return geometry
|
|
225
|
+
? {type: 'Feature', geometry, properties}
|
|
226
|
+
: ({type: 'Feature', geometry: null, properties} as unknown as Feature);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function parsePlacemarkProperties(
|
|
230
|
+
node: XMLObject,
|
|
231
|
+
folderPath: string[],
|
|
232
|
+
styles: Record<string, KMLStyle>,
|
|
233
|
+
geometryNode: XMLObject | undefined
|
|
234
|
+
): GeoJsonProperties {
|
|
235
|
+
const properties: Record<string, unknown> = {};
|
|
236
|
+
for (const name of ['name', 'description', 'visibility', 'open', 'address', 'phoneNumber']) {
|
|
237
|
+
const value = getChildText(node, name);
|
|
238
|
+
if (value !== undefined) properties[name] = value;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const styleUrl = getChildText(node, 'styleUrl');
|
|
242
|
+
if (styleUrl) {
|
|
243
|
+
properties.styleUrl = styleUrl;
|
|
244
|
+
const style = styles[styleUrl.replace(/^#/, '')];
|
|
245
|
+
if (style) Object.assign(properties, styleToProperties(style));
|
|
246
|
+
}
|
|
247
|
+
Object.assign(properties, parseExtendedData(getFirstObject(node, 'ExtendedData')));
|
|
248
|
+
|
|
249
|
+
const kmlMetadata: Record<string, unknown> = {};
|
|
250
|
+
if (geometryNode) {
|
|
251
|
+
const altitudeMode =
|
|
252
|
+
getChildText(geometryNode, 'altitudeMode') || getChildText(geometryNode, 'gx:altitudeMode');
|
|
253
|
+
const extrude = getChildText(geometryNode, 'extrude');
|
|
254
|
+
const tessellate = getChildText(geometryNode, 'tessellate');
|
|
255
|
+
if (altitudeMode !== undefined) kmlMetadata.altitudeMode = altitudeMode;
|
|
256
|
+
if (extrude !== undefined) kmlMetadata.extrude = extrude === '1' || extrude === 'true';
|
|
257
|
+
if (tessellate !== undefined)
|
|
258
|
+
kmlMetadata.tessellate = tessellate === '1' || tessellate === 'true';
|
|
259
|
+
}
|
|
260
|
+
const timeStamp = getFirstObject(node, 'TimeStamp');
|
|
261
|
+
const timeSpan = getFirstObject(node, 'TimeSpan');
|
|
262
|
+
if (timeStamp) kmlMetadata.timeStamp = getChildText(timeStamp, 'when');
|
|
263
|
+
if (timeSpan) {
|
|
264
|
+
kmlMetadata.timeSpan = {
|
|
265
|
+
begin: getChildText(timeSpan, 'begin'),
|
|
266
|
+
end: getChildText(timeSpan, 'end')
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
if (folderPath.length) kmlMetadata.folderPath = folderPath;
|
|
270
|
+
if (Object.keys(kmlMetadata).length) properties.kml = kmlMetadata;
|
|
271
|
+
return properties;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function getGeometryNode(node: XMLObject): XMLObject | undefined {
|
|
275
|
+
for (const name of [
|
|
276
|
+
'Point',
|
|
277
|
+
'LineString',
|
|
278
|
+
'LinearRing',
|
|
279
|
+
'Polygon',
|
|
280
|
+
'MultiGeometry',
|
|
281
|
+
'Track',
|
|
282
|
+
'MultiTrack',
|
|
283
|
+
'Model'
|
|
284
|
+
]) {
|
|
285
|
+
const geometry = getFirstObject(node, name);
|
|
286
|
+
if (geometry) return withType(geometry, name);
|
|
287
|
+
}
|
|
288
|
+
return undefined;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function parseGeometry(node: XMLObject): Geometry | null {
|
|
292
|
+
switch (node.__type) {
|
|
293
|
+
case 'Point': {
|
|
294
|
+
const coordinates = parseCoordinates(getChildText(node, 'coordinates'));
|
|
295
|
+
return coordinates.length ? {type: 'Point', coordinates: coordinates[0]} : null;
|
|
296
|
+
}
|
|
297
|
+
case 'LineString':
|
|
298
|
+
case 'LinearRing': {
|
|
299
|
+
const coordinates = parseCoordinates(getChildText(node, 'coordinates'));
|
|
300
|
+
return coordinates.length ? {type: 'LineString', coordinates} : null;
|
|
301
|
+
}
|
|
302
|
+
case 'Polygon':
|
|
303
|
+
return parsePolygon(node);
|
|
304
|
+
case 'MultiGeometry': {
|
|
305
|
+
const geometries = getGeometryObjects(node)
|
|
306
|
+
.map(parseGeometry)
|
|
307
|
+
.filter((geometry): geometry is Geometry => Boolean(geometry));
|
|
308
|
+
return geometries.length ? {type: 'GeometryCollection', geometries} : null;
|
|
309
|
+
}
|
|
310
|
+
case 'Track':
|
|
311
|
+
case 'MultiTrack':
|
|
312
|
+
return parseTrack(node);
|
|
313
|
+
case 'Model':
|
|
314
|
+
return null;
|
|
315
|
+
default:
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function parsePolygon(node: XMLObject): Geometry | null {
|
|
321
|
+
const outerBoundary = getFirstObject(node, 'outerBoundaryIs');
|
|
322
|
+
const outerRing = outerBoundary && getFirstObject(outerBoundary, 'LinearRing');
|
|
323
|
+
const outerCoordinates = outerRing && parseCoordinates(getChildText(outerRing, 'coordinates'));
|
|
324
|
+
if (!outerCoordinates?.length) return null;
|
|
325
|
+
|
|
326
|
+
const holes = getChildObjects(node, 'innerBoundaryIs')
|
|
327
|
+
.map(boundary => getFirstObject(boundary, 'LinearRing'))
|
|
328
|
+
.map(ring => ring && parseCoordinates(getChildText(ring, 'coordinates')))
|
|
329
|
+
.filter((coordinates): coordinates is Position[] => Boolean(coordinates?.length));
|
|
330
|
+
return {type: 'Polygon', coordinates: [outerCoordinates, ...holes]};
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function parseTrack(node: XMLObject): Geometry | null {
|
|
334
|
+
const coordinateNodes = findDescendants(node, 'coord');
|
|
335
|
+
if (!coordinateNodes.length) coordinateNodes.push(...findDescendants(node, 'coordinates'));
|
|
336
|
+
const coordinates = coordinateNodes.flatMap(coordinateNode => {
|
|
337
|
+
const value = getNodeText(coordinateNode);
|
|
338
|
+
if (coordinateNode.__type === 'coord') {
|
|
339
|
+
const values = (value || '').split(/\s+/).map(Number);
|
|
340
|
+
return values.length >= 2 && values.every(Number.isFinite) ? [values as Position] : [];
|
|
341
|
+
}
|
|
342
|
+
return parseCoordinates(value);
|
|
343
|
+
});
|
|
344
|
+
return coordinates.length ? {type: 'LineString', coordinates} : null;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function parseCoordinates(value?: string): Position[] {
|
|
348
|
+
if (!value) return [];
|
|
349
|
+
const coordinates: Position[] = [];
|
|
350
|
+
for (const tuple of value.trim().split(/\s+/)) {
|
|
351
|
+
const values = tuple.split(',').map(Number);
|
|
352
|
+
if (values.length < 2 || values.length > 3 || values.some(value => !Number.isFinite(value)))
|
|
353
|
+
continue;
|
|
354
|
+
coordinates.push(values as Position);
|
|
355
|
+
}
|
|
356
|
+
return coordinates;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function parseExtendedData(node: XMLObject | undefined): Record<string, unknown> {
|
|
360
|
+
const properties: Record<string, unknown> = {};
|
|
361
|
+
if (!node) return properties;
|
|
362
|
+
for (const data of getChildObjects(node, 'Data')) {
|
|
363
|
+
const name = getAttribute(data, 'name');
|
|
364
|
+
const value = getChildText(data, 'value');
|
|
365
|
+
if (name && value !== undefined) properties[name] = value;
|
|
366
|
+
}
|
|
367
|
+
for (const data of findDescendants(node, 'SimpleData')) {
|
|
368
|
+
const name = getAttribute(data, 'name');
|
|
369
|
+
if (name) properties[name] = getNodeText(data);
|
|
370
|
+
}
|
|
371
|
+
return properties;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function parseStyle(node: XMLObject, id: string): KMLStyle {
|
|
375
|
+
const lineStyle = getFirstObject(node, 'LineStyle');
|
|
376
|
+
const polyStyle = getFirstObject(node, 'PolyStyle');
|
|
377
|
+
const iconStyle = getFirstObject(node, 'IconStyle');
|
|
378
|
+
const labelStyle = getFirstObject(node, 'LabelStyle');
|
|
379
|
+
const icon = iconStyle && getFirstObject(iconStyle, 'Icon');
|
|
380
|
+
return {
|
|
381
|
+
id,
|
|
382
|
+
line: lineStyle
|
|
383
|
+
? {...parseColorStyle(lineStyle), width: parseNumber(getChildText(lineStyle, 'width'))}
|
|
384
|
+
: undefined,
|
|
385
|
+
polygon: polyStyle
|
|
386
|
+
? {
|
|
387
|
+
...parseColorStyle(polyStyle),
|
|
388
|
+
fill: parseBoolean(getChildText(polyStyle, 'fill')),
|
|
389
|
+
outline: parseBoolean(getChildText(polyStyle, 'outline'))
|
|
390
|
+
}
|
|
391
|
+
: undefined,
|
|
392
|
+
icon: iconStyle
|
|
393
|
+
? {
|
|
394
|
+
href: icon && getChildText(icon, 'href'),
|
|
395
|
+
scale: parseNumber(getChildText(iconStyle, 'scale'))
|
|
396
|
+
}
|
|
397
|
+
: undefined,
|
|
398
|
+
label: labelStyle
|
|
399
|
+
? {...parseColorStyle(labelStyle), scale: parseNumber(getChildText(labelStyle, 'scale'))}
|
|
400
|
+
: undefined
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
function parseStyleMap(node: XMLObject, styles: Record<string, KMLStyle>): void {
|
|
405
|
+
const id = getAttribute(node, 'id');
|
|
406
|
+
if (!id) return;
|
|
407
|
+
let normalStyle: KMLStyle | undefined;
|
|
408
|
+
let fallbackStyle: KMLStyle | undefined;
|
|
409
|
+
for (const pair of getChildObjects(node, 'Pair')) {
|
|
410
|
+
const key = getChildText(pair, 'key');
|
|
411
|
+
const styleUrl = getChildText(pair, 'styleUrl');
|
|
412
|
+
const style = styleUrl && styles[styleUrl.replace(/^#/, '')];
|
|
413
|
+
if (!style) continue;
|
|
414
|
+
fallbackStyle ||= style;
|
|
415
|
+
if (key === 'normal') normalStyle = style;
|
|
416
|
+
}
|
|
417
|
+
const style = normalStyle || fallbackStyle;
|
|
418
|
+
if (style) styles[id] = style;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
function parseColorStyle(node: XMLObject): {color?: string; opacity?: number} {
|
|
422
|
+
const value = getChildText(node, 'color');
|
|
423
|
+
if (!value || !/^[0-9a-f]{8}$/i.test(value)) return {};
|
|
424
|
+
return {
|
|
425
|
+
color: `#${value.slice(6, 8)}${value.slice(4, 6)}${value.slice(2, 4)}`,
|
|
426
|
+
opacity: parseInt(value.slice(0, 2), 16) / 255
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function styleToProperties(style: KMLStyle): Record<string, unknown> {
|
|
431
|
+
const properties: Record<string, unknown> = {};
|
|
432
|
+
if (style.line?.color) properties.stroke = style.line.color;
|
|
433
|
+
if (style.line?.opacity !== undefined) properties['stroke-opacity'] = style.line.opacity;
|
|
434
|
+
if (style.line?.width !== undefined) properties['stroke-width'] = style.line.width;
|
|
435
|
+
if (style.polygon?.color) properties.fill = style.polygon.color;
|
|
436
|
+
if (style.polygon?.opacity !== undefined) properties['fill-opacity'] = style.polygon.opacity;
|
|
437
|
+
if (style.icon?.href) properties.icon = style.icon.href;
|
|
438
|
+
return properties;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
function parseOverlay(node: XMLObject): KMLOverlay {
|
|
442
|
+
const box = getFirstObject(node, 'LatLonBox');
|
|
443
|
+
const type = node.__type;
|
|
444
|
+
return {
|
|
445
|
+
type:
|
|
446
|
+
type === 'GroundOverlay'
|
|
447
|
+
? 'ground-overlay'
|
|
448
|
+
: type === 'PhotoOverlay'
|
|
449
|
+
? 'photo-overlay'
|
|
450
|
+
: 'screen-overlay',
|
|
451
|
+
name: getChildText(node, 'name'),
|
|
452
|
+
description: getChildText(node, 'description'),
|
|
453
|
+
href: getChildText(getFirstObject(node, 'Icon'), 'href'),
|
|
454
|
+
visibility: parseBoolean(getChildText(node, 'visibility')),
|
|
455
|
+
bounds: box ? parseOverlayBounds(box) : undefined,
|
|
456
|
+
raw: node
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
function parseOverlayBounds(node: XMLObject): KMLOverlay['bounds'] | undefined {
|
|
461
|
+
const north = parseNumber(getChildText(node, 'north'));
|
|
462
|
+
const south = parseNumber(getChildText(node, 'south'));
|
|
463
|
+
const east = parseNumber(getChildText(node, 'east'));
|
|
464
|
+
const west = parseNumber(getChildText(node, 'west'));
|
|
465
|
+
if ([north, south, east, west].some(value => value === undefined)) return undefined;
|
|
466
|
+
return {
|
|
467
|
+
north: north as number,
|
|
468
|
+
south: south as number,
|
|
469
|
+
east: east as number,
|
|
470
|
+
west: west as number,
|
|
471
|
+
rotation: parseNumber(getChildText(node, 'rotation'))
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
function parseNetworkLink(node: XMLObject): KMLNetworkLink {
|
|
476
|
+
const link = getFirstObject(node, 'Link') || getFirstObject(node, 'Url');
|
|
477
|
+
return {
|
|
478
|
+
name: getChildText(node, 'name'),
|
|
479
|
+
href: getChildText(link, 'href'),
|
|
480
|
+
refreshMode: getChildText(link, 'refreshMode'),
|
|
481
|
+
refreshInterval: parseNumber(getChildText(link, 'refreshInterval')),
|
|
482
|
+
viewRefreshMode: getChildText(link, 'viewRefreshMode'),
|
|
483
|
+
raw: node
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
function parseModel(node: XMLObject): KMLModel {
|
|
488
|
+
const location = getFirstObject(node, 'Location');
|
|
489
|
+
const orientation = getFirstObject(node, 'Orientation');
|
|
490
|
+
const scale = getFirstObject(node, 'Scale');
|
|
491
|
+
const locationValues = [
|
|
492
|
+
parseNumber(getChildText(location, 'longitude')),
|
|
493
|
+
parseNumber(getChildText(location, 'latitude')),
|
|
494
|
+
parseNumber(getChildText(location, 'altitude'))
|
|
495
|
+
];
|
|
496
|
+
return {
|
|
497
|
+
name: getChildText(node, 'name'),
|
|
498
|
+
href: getChildText(getFirstObject(node, 'Link'), 'href'),
|
|
499
|
+
location: locationValues.every(value => value !== undefined)
|
|
500
|
+
? (locationValues as [number, number, number])
|
|
501
|
+
: undefined,
|
|
502
|
+
orientation: orientation
|
|
503
|
+
? {
|
|
504
|
+
heading: parseNumber(getChildText(orientation, 'heading')),
|
|
505
|
+
tilt: parseNumber(getChildText(orientation, 'tilt')),
|
|
506
|
+
roll: parseNumber(getChildText(orientation, 'roll'))
|
|
507
|
+
}
|
|
508
|
+
: undefined,
|
|
509
|
+
scale: scale
|
|
510
|
+
? {
|
|
511
|
+
x: parseNumber(getChildText(scale, 'x')),
|
|
512
|
+
y: parseNumber(getChildText(scale, 'y')),
|
|
513
|
+
z: parseNumber(getChildText(scale, 'z'))
|
|
514
|
+
}
|
|
515
|
+
: undefined,
|
|
516
|
+
raw: node
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function getGeometryObjects(node: XMLObject): XMLObject[] {
|
|
521
|
+
return [
|
|
522
|
+
'Point',
|
|
523
|
+
'LineString',
|
|
524
|
+
'LinearRing',
|
|
525
|
+
'Polygon',
|
|
526
|
+
'MultiGeometry',
|
|
527
|
+
'Track',
|
|
528
|
+
'MultiTrack',
|
|
529
|
+
'Model'
|
|
530
|
+
].flatMap(name => getChildObjects(node, name).map(child => withType(child, name)));
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
function withType(node: XMLObject, type: string): XMLObject {
|
|
534
|
+
return {...node, __type: type};
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
function findDescendants(node: XMLObject, name?: string): XMLObject[] {
|
|
538
|
+
const result: XMLObject[] = [];
|
|
539
|
+
for (const [key, value] of Object.entries(node)) {
|
|
540
|
+
if (key === '__type') continue;
|
|
541
|
+
for (const child of asObjects(value)) {
|
|
542
|
+
if (!name || key === name) result.push(withType(child, key));
|
|
543
|
+
result.push(...findDescendants(child, name));
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
return result;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
function getFirstObject(node: XMLObject | undefined, name: string): XMLObject | undefined {
|
|
550
|
+
return node ? asObjects(node[name])[0] : undefined;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
function getChildObjects(node: XMLObject, name: string): XMLObject[] {
|
|
554
|
+
return asObjects(node[name]);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
function asObjects(value: XMLValue | undefined): XMLObject[] {
|
|
558
|
+
if (!value) return [];
|
|
559
|
+
const values = Array.isArray(value) ? value : [value];
|
|
560
|
+
return values.filter(
|
|
561
|
+
(item): item is XMLObject => typeof item === 'object' && !Array.isArray(item)
|
|
562
|
+
);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
function asObject(value: XMLValue | undefined): XMLObject | undefined {
|
|
566
|
+
return typeof value === 'object' && !Array.isArray(value) ? value : undefined;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
function getChildText(node: XMLObject | undefined, name: string): string | undefined {
|
|
570
|
+
return node ? getNodeText(node[name]) : undefined;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
function getNodeText(value: XMLValue | undefined): string | undefined {
|
|
574
|
+
if (value === undefined || value === null) return undefined;
|
|
575
|
+
if (typeof value !== 'object') return String(value);
|
|
576
|
+
if (Array.isArray(value)) return getNodeText(value[0]);
|
|
577
|
+
return getNodeText(value['#text']);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
function getAttribute(node: XMLObject | undefined, name: string): string | undefined {
|
|
581
|
+
return node ? getNodeText(node[name]) : undefined;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
function parseNumber(value?: string): number | undefined {
|
|
585
|
+
if (value === undefined || value === '') return undefined;
|
|
586
|
+
const number = Number(value);
|
|
587
|
+
return Number.isFinite(number) ? number : undefined;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
function parseBoolean(value?: string): boolean | undefined {
|
|
591
|
+
if (value === undefined) return undefined;
|
|
592
|
+
return value === '1' || value.toLowerCase() === 'true';
|
|
593
|
+
}
|