maplibre-gl-components 0.16.2 → 0.17.0
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 +4 -3
- package/dist/{ControlGrid-DQ4w_Nf9.js → ControlGrid-C6zp03Vq.js} +125375 -115454
- package/dist/ControlGrid-DIAcXRBe.cjs +17278 -0
- package/dist/DuckDBConverter-5a2FWwmf.js +354 -0
- package/dist/DuckDBConverter-pfXSUi_l.cjs +23 -0
- package/dist/ShapefileConverter-DGCXPY_S.cjs +1 -0
- package/dist/ShapefileConverter-DN3fVOuo.js +102 -0
- package/dist/basedecoder-BliCKuUS.js +62 -0
- package/dist/basedecoder-Zw0CbD9L.cjs +1 -0
- package/dist/deflate-DBL0msKQ.js +10 -0
- package/dist/deflate-DNeBKDsy.cjs +1 -0
- package/dist/esm-Bp6m44bk.js +811 -0
- package/dist/esm-oEp_aN1n.cjs +1 -0
- package/dist/geojson-Bnoe76Pm.js +2002 -0
- package/dist/geojson-CxMdRvJX.cjs +1 -0
- package/dist/geotiff-Bzy-Zyc2.js +1882 -0
- package/dist/geotiff-DYylEFA9.cjs +8 -0
- package/dist/globals-B4iCNAg9.cjs +1 -0
- package/dist/globals-BKIWameS.js +572 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +150 -147
- package/dist/jpeg-B6Sg6W8k.cjs +1 -0
- package/dist/jpeg-CJcNvScS.js +545 -0
- package/dist/lerc-2QwcA_K7.js +840 -0
- package/dist/lerc-DQRITnja.cjs +1 -0
- package/dist/lib-B4jvG7hB.cjs +4 -0
- package/dist/lib-CNQtqzfc.js +4060 -0
- package/dist/lzw-1HaU0PJK.cjs +1 -0
- package/dist/lzw-DF5VHuii.js +76 -0
- package/dist/main-dist-CbHNdsir.js +18314 -0
- package/dist/main-dist-DOx_Axbx.cjs +2 -0
- package/dist/maplibre-geoman.es-C0F1ydoG.cjs +213 -0
- package/dist/maplibre-geoman.es-D1CztSQd.js +27213 -0
- package/dist/maplibre-gl-components.css +2 -1
- package/dist/packbits-CK8RPU_B.js +22 -0
- package/dist/packbits-D5Zovac7.cjs +1 -0
- package/dist/pako.esm-DFyPB7cO.cjs +1 -0
- package/dist/pako.esm-hTfpTBhd.js +1536 -0
- package/dist/raw-Brljg6vy.js +9 -0
- package/dist/raw-C-CSxCoU.cjs +1 -0
- package/dist/react.cjs +1 -1
- package/dist/react.mjs +1357 -1004
- package/dist/{types → src}/lib/core/CogLayer.d.ts.map +1 -1
- package/dist/{types → src}/lib/core/PMTilesLayer.d.ts.map +1 -1
- package/dist/{types → src}/lib/core/SpinGlobeControl.d.ts +6 -7
- package/dist/src/lib/core/SpinGlobeControl.d.ts.map +1 -0
- package/dist/{types → src}/lib/core/StacLayer.d.ts.map +1 -1
- package/dist/{types → src}/lib/core/types.d.ts +3 -1
- package/dist/{types → src}/lib/core/types.d.ts.map +1 -1
- package/dist/{types → src}/lib/utils/color.d.ts +8 -0
- package/dist/src/lib/utils/color.d.ts.map +1 -0
- package/dist/{types → src}/lib/utils/index.d.ts +1 -1
- package/dist/{types → src}/lib/utils/index.d.ts.map +1 -1
- package/dist/webimage-Bh2pNwjN.cjs +1 -0
- package/dist/webimage-rg-Z9Sbn.js +25 -0
- package/dist/zstd-B3Xa90HD.cjs +1 -0
- package/dist/zstd-BwwN0X3K.js +51 -0
- package/package.json +66 -53
- package/dist/ControlGrid-Bukna_at.cjs +0 -17062
- package/dist/DuckDBConverter-B98M0DFs.cjs +0 -23
- package/dist/DuckDBConverter-RPq48-t0.js +0 -434
- package/dist/ShapefileConverter-AjbEjEyq.cjs +0 -1
- package/dist/ShapefileConverter-trvt8J3z.js +0 -125
- package/dist/decoder-CLokFc0V.js +0 -8
- package/dist/decoder-D9LU4bUo.cjs +0 -1
- package/dist/deflate-Bay-vzHJ.cjs +0 -1
- package/dist/deflate-yeu3ogBn.js +0 -10
- package/dist/geojson-BQSVgKFt.cjs +0 -1
- package/dist/geojson-BSUuDj5k.js +0 -2551
- package/dist/geotiff-BNxc90fm.cjs +0 -8
- package/dist/geotiff-BUZniE5g.js +0 -3105
- package/dist/index-8ZZtuDTp.js +0 -705
- package/dist/index-DQXdX5y1.js +0 -4666
- package/dist/index-Dh1kpCb6.cjs +0 -1
- package/dist/index-IrsIiQNM.cjs +0 -4
- package/dist/jpeg-B7yImnpY.js +0 -533
- package/dist/jpeg-BiN8bMT5.cjs +0 -1
- package/dist/lerc-BvSjGMM2.cjs +0 -1
- package/dist/lerc-CqgA9njy.js +0 -1031
- package/dist/lzw-C-_B7Jis.cjs +0 -1
- package/dist/lzw-DL9RcHOz.js +0 -84
- package/dist/main-dist-Bymiy5aM.cjs +0 -2
- package/dist/main-dist-Cv8AKwrY.js +0 -629
- package/dist/maplibre-geoman.es-Bxdg-2EU.cjs +0 -129
- package/dist/maplibre-geoman.es-CFgM2ajb.js +0 -22827
- package/dist/packbits-DRGSjtn-.cjs +0 -1
- package/dist/packbits-YEJGULcy.js +0 -24
- package/dist/pako.esm-Bx5X36Wo.js +0 -1074
- package/dist/pako.esm-DZC2QrbJ.cjs +0 -1
- package/dist/raw-CoQHiEnn.js +0 -9
- package/dist/raw-D6OidBKc.cjs +0 -1
- package/dist/types/lib/core/SpinGlobeControl.d.ts.map +0 -1
- package/dist/types/lib/utils/color.d.ts.map +0 -1
- package/dist/webimage-BXLN-zu8.js +0 -19
- package/dist/webimage-mWTez3Wv.cjs +0 -1
- /package/dist/{types → src}/index.d.ts +0 -0
- /package/dist/{types → src}/index.d.ts.map +0 -0
- /package/dist/{types → src}/lib/adapters/AddVectorAdapter.d.ts +0 -0
- /package/dist/{types → src}/lib/adapters/AddVectorAdapter.d.ts.map +0 -0
- /package/dist/{types → src}/lib/adapters/CogLayerAdapter.d.ts +0 -0
- /package/dist/{types → src}/lib/adapters/CogLayerAdapter.d.ts.map +0 -0
- /package/dist/{types → src}/lib/adapters/PMTilesLayerAdapter.d.ts +0 -0
- /package/dist/{types → src}/lib/adapters/PMTilesLayerAdapter.d.ts.map +0 -0
- /package/dist/{types → src}/lib/adapters/StacLayerAdapter.d.ts +0 -0
- /package/dist/{types → src}/lib/adapters/StacLayerAdapter.d.ts.map +0 -0
- /package/dist/{types → src}/lib/adapters/ZarrLayerAdapter.d.ts +0 -0
- /package/dist/{types → src}/lib/adapters/ZarrLayerAdapter.d.ts.map +0 -0
- /package/dist/{types → src}/lib/adapters/index.d.ts +0 -0
- /package/dist/{types → src}/lib/adapters/index.d.ts.map +0 -0
- /package/dist/{types → src}/lib/addControlGrid.d.ts +0 -0
- /package/dist/{types → src}/lib/addControlGrid.d.ts.map +0 -0
- /package/dist/{types → src}/lib/colormaps/diverging.d.ts +0 -0
- /package/dist/{types → src}/lib/colormaps/diverging.d.ts.map +0 -0
- /package/dist/{types → src}/lib/colormaps/index.d.ts +0 -0
- /package/dist/{types → src}/lib/colormaps/index.d.ts.map +0 -0
- /package/dist/{types → src}/lib/colormaps/misc.d.ts +0 -0
- /package/dist/{types → src}/lib/colormaps/misc.d.ts.map +0 -0
- /package/dist/{types → src}/lib/colormaps/sequential.d.ts +0 -0
- /package/dist/{types → src}/lib/colormaps/sequential.d.ts.map +0 -0
- /package/dist/{types → src}/lib/converters/DuckDBConverter.d.ts +0 -0
- /package/dist/{types → src}/lib/converters/DuckDBConverter.d.ts.map +0 -0
- /package/dist/{types → src}/lib/converters/ShapefileConverter.d.ts +0 -0
- /package/dist/{types → src}/lib/converters/ShapefileConverter.d.ts.map +0 -0
- /package/dist/{types → src}/lib/converters/index.d.ts +0 -0
- /package/dist/{types → src}/lib/converters/index.d.ts.map +0 -0
- /package/dist/{types → src}/lib/converters/types.d.ts +0 -0
- /package/dist/{types → src}/lib/converters/types.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/AddVector.d.ts +0 -0
- /package/dist/{types → src}/lib/core/AddVector.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/Basemap.d.ts +0 -0
- /package/dist/{types → src}/lib/core/Basemap.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/BasemapReact.d.ts +0 -0
- /package/dist/{types → src}/lib/core/BasemapReact.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/BookmarkControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/BookmarkControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/ChoroplethControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/ChoroplethControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/CogLayer.d.ts +0 -0
- /package/dist/{types → src}/lib/core/CogLayerReact.d.ts +0 -0
- /package/dist/{types → src}/lib/core/CogLayerReact.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/Colorbar.d.ts +0 -0
- /package/dist/{types → src}/lib/core/Colorbar.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/ColorbarGuiControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/ColorbarGuiControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/ColorbarReact.d.ts +0 -0
- /package/dist/{types → src}/lib/core/ColorbarReact.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/ControlGrid.d.ts +0 -0
- /package/dist/{types → src}/lib/core/ControlGrid.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/ControlGridReact.d.ts +0 -0
- /package/dist/{types → src}/lib/core/ControlGridReact.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/HtmlControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/HtmlControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/HtmlControlReact.d.ts +0 -0
- /package/dist/{types → src}/lib/core/HtmlControlReact.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/HtmlGuiControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/HtmlGuiControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/InspectControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/InspectControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/InspectControlReact.d.ts +0 -0
- /package/dist/{types → src}/lib/core/InspectControlReact.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/Legend.d.ts +0 -0
- /package/dist/{types → src}/lib/core/Legend.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/LegendGuiControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/LegendGuiControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/LegendReact.d.ts +0 -0
- /package/dist/{types → src}/lib/core/LegendReact.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/MeasureControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/MeasureControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/MinimapControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/MinimapControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/MinimapControlReact.d.ts +0 -0
- /package/dist/{types → src}/lib/core/MinimapControlReact.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/PMTilesLayer.d.ts +0 -0
- /package/dist/{types → src}/lib/core/PrintControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/PrintControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/SearchControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/SearchControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/SearchControlReact.d.ts +0 -0
- /package/dist/{types → src}/lib/core/SearchControlReact.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/StacLayer.d.ts +0 -0
- /package/dist/{types → src}/lib/core/StacSearch.d.ts +0 -0
- /package/dist/{types → src}/lib/core/StacSearch.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/Terrain.d.ts +0 -0
- /package/dist/{types → src}/lib/core/Terrain.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/TerrainReact.d.ts +0 -0
- /package/dist/{types → src}/lib/core/TerrainReact.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/TileLayerControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/TileLayerControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/VectorDataset.d.ts +0 -0
- /package/dist/{types → src}/lib/core/VectorDataset.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/VectorDatasetReact.d.ts +0 -0
- /package/dist/{types → src}/lib/core/VectorDatasetReact.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/ViewStateControl.d.ts +0 -0
- /package/dist/{types → src}/lib/core/ViewStateControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/ViewStateControlReact.d.ts +0 -0
- /package/dist/{types → src}/lib/core/ViewStateControlReact.d.ts.map +0 -0
- /package/dist/{types → src}/lib/core/ZarrLayer.d.ts +0 -0
- /package/dist/{types → src}/lib/core/ZarrLayer.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/index.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/index.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/useBasemap.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/useBasemap.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/useCogLayer.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/useCogLayer.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/useColorbar.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/useColorbar.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/useControlGrid.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/useControlGrid.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/useHtmlControl.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/useHtmlControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/useInspectControl.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/useInspectControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/useLegend.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/useLegend.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/useMinimapControl.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/useMinimapControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/useSearchControl.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/useSearchControl.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/useTerrain.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/useTerrain.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/useVectorDataset.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/useVectorDataset.d.ts.map +0 -0
- /package/dist/{types → src}/lib/hooks/useViewState.d.ts +0 -0
- /package/dist/{types → src}/lib/hooks/useViewState.d.ts.map +0 -0
- /package/dist/{types → src}/lib/utils/fileHelpers.d.ts +0 -0
- /package/dist/{types → src}/lib/utils/fileHelpers.d.ts.map +0 -0
- /package/dist/{types → src}/lib/utils/helpers.d.ts +0 -0
- /package/dist/{types → src}/lib/utils/helpers.d.ts.map +0 -0
- /package/dist/{types → src}/lib/utils/providers.d.ts +0 -0
- /package/dist/{types → src}/lib/utils/providers.d.ts.map +0 -0
- /package/dist/{types → src}/react.d.ts +0 -0
- /package/dist/{types → src}/react.d.ts.map +0 -0
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import { sn as R } from "./ControlGrid-C6zp03Vq.js";
|
|
2
|
+
var G = /* @__PURE__ */ R({
|
|
3
|
+
DuckDBConverter: () => O,
|
|
4
|
+
getDuckDBConverter: () => A
|
|
5
|
+
}), B = null;
|
|
6
|
+
function A() {
|
|
7
|
+
return B || (B = new O()), B;
|
|
8
|
+
}
|
|
9
|
+
var O = class {
|
|
10
|
+
_duckdb = null;
|
|
11
|
+
_db = null;
|
|
12
|
+
_worker = null;
|
|
13
|
+
_initialized = !1;
|
|
14
|
+
_initializing = !1;
|
|
15
|
+
_bundleUrl;
|
|
16
|
+
constructor(t) {
|
|
17
|
+
this._bundleUrl = t;
|
|
18
|
+
}
|
|
19
|
+
isReady() {
|
|
20
|
+
return this._initialized && this._db !== null;
|
|
21
|
+
}
|
|
22
|
+
async initialize(t) {
|
|
23
|
+
if (!this._initialized) {
|
|
24
|
+
if (this._initializing) {
|
|
25
|
+
for (; this._initializing; ) await new Promise((r) => setTimeout(r, 50));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
this._initializing = !0;
|
|
29
|
+
try {
|
|
30
|
+
t?.({
|
|
31
|
+
stage: "initializing",
|
|
32
|
+
percent: 0,
|
|
33
|
+
message: "Loading DuckDB WASM..."
|
|
34
|
+
});
|
|
35
|
+
let r;
|
|
36
|
+
try {
|
|
37
|
+
const e = await import(
|
|
38
|
+
/* @vite-ignore */
|
|
39
|
+
"@duckdb/duckdb-wasm"
|
|
40
|
+
);
|
|
41
|
+
r = e.default || e;
|
|
42
|
+
} catch (e) {
|
|
43
|
+
throw new Error(`DuckDB WASM is not installed or failed to load. Install it with: npm install @duckdb/duckdb-wasm. Error: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
44
|
+
}
|
|
45
|
+
this._duckdb = r, t?.({
|
|
46
|
+
stage: "initializing",
|
|
47
|
+
percent: 30,
|
|
48
|
+
message: "Selecting DuckDB bundle..."
|
|
49
|
+
});
|
|
50
|
+
let n;
|
|
51
|
+
if (this._duckdb.getJsDelivrBundles) {
|
|
52
|
+
const e = this._duckdb.getJsDelivrBundles();
|
|
53
|
+
n = await this._duckdb.selectBundle(e);
|
|
54
|
+
} else {
|
|
55
|
+
const e = this._getJsDelivrBundles();
|
|
56
|
+
n = await this._duckdb.selectBundle(e);
|
|
57
|
+
}
|
|
58
|
+
t?.({
|
|
59
|
+
stage: "initializing",
|
|
60
|
+
percent: 50,
|
|
61
|
+
message: "Instantiating DuckDB..."
|
|
62
|
+
});
|
|
63
|
+
const h = new this._duckdb.ConsoleLogger(4);
|
|
64
|
+
let l, i = null;
|
|
65
|
+
try {
|
|
66
|
+
i = URL.createObjectURL(new Blob([`importScripts("${n.mainWorker}");`], { type: "text/javascript" })), l = new Worker(i);
|
|
67
|
+
} catch (e) {
|
|
68
|
+
throw i && URL.revokeObjectURL(i), new Error(`Failed to create DuckDB worker: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
69
|
+
}
|
|
70
|
+
this._worker = l;
|
|
71
|
+
const p = new this._duckdb.AsyncDuckDB(h, l);
|
|
72
|
+
try {
|
|
73
|
+
await p.instantiate(n.mainModule, n.pthreadWorker);
|
|
74
|
+
} catch (e) {
|
|
75
|
+
throw new Error(`Failed to instantiate DuckDB: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
76
|
+
}
|
|
77
|
+
i && URL.revokeObjectURL(i), this._db = p, t?.({
|
|
78
|
+
stage: "initializing",
|
|
79
|
+
percent: 70,
|
|
80
|
+
message: "Loading spatial extension..."
|
|
81
|
+
});
|
|
82
|
+
const s = await this._db.connect();
|
|
83
|
+
try {
|
|
84
|
+
await s.query("INSTALL spatial"), await s.query("LOAD spatial");
|
|
85
|
+
} catch (e) {
|
|
86
|
+
console.warn("Failed to load spatial extension, some features may not work:", e);
|
|
87
|
+
} finally {
|
|
88
|
+
await s.close();
|
|
89
|
+
}
|
|
90
|
+
this._initialized = !0, t?.({
|
|
91
|
+
stage: "initializing",
|
|
92
|
+
percent: 100,
|
|
93
|
+
message: "DuckDB ready"
|
|
94
|
+
});
|
|
95
|
+
} catch (r) {
|
|
96
|
+
throw t?.({
|
|
97
|
+
stage: "error",
|
|
98
|
+
message: `Failed to initialize DuckDB: ${r instanceof Error ? r.message : "Unknown error"}`
|
|
99
|
+
}), r;
|
|
100
|
+
} finally {
|
|
101
|
+
this._initializing = !1;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
_getJsDelivrBundles() {
|
|
106
|
+
const t = this._bundleUrl || "https://cdn.jsdelivr.net/npm/@duckdb/duckdb-wasm@latest/dist";
|
|
107
|
+
return {
|
|
108
|
+
mvp: {
|
|
109
|
+
mainModule: `${t}/duckdb-mvp.wasm`,
|
|
110
|
+
mainWorker: `${t}/duckdb-browser-mvp.worker.js`
|
|
111
|
+
},
|
|
112
|
+
eh: {
|
|
113
|
+
mainModule: `${t}/duckdb-eh.wasm`,
|
|
114
|
+
mainWorker: `${t}/duckdb-browser-eh.worker.js`
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
async convert(t, r, n) {
|
|
119
|
+
const h = performance.now(), l = this._detectFormat(r);
|
|
120
|
+
if (this.isReady() || await this.initialize(n), !this._db) throw new Error("DuckDB not initialized");
|
|
121
|
+
n?.({
|
|
122
|
+
stage: "loading",
|
|
123
|
+
percent: 0,
|
|
124
|
+
message: `Loading ${r}...`
|
|
125
|
+
});
|
|
126
|
+
const i = new Uint8Array(t);
|
|
127
|
+
await this._db.registerFileBuffer(r, i);
|
|
128
|
+
const p = await this._db.connect();
|
|
129
|
+
try {
|
|
130
|
+
n?.({
|
|
131
|
+
stage: "converting",
|
|
132
|
+
percent: 30,
|
|
133
|
+
message: "Reading spatial data..."
|
|
134
|
+
});
|
|
135
|
+
let s;
|
|
136
|
+
l === "geoparquet" || l === "parquet" ? s = `read_parquet('${r}')` : s = `ST_Read('${r}')`;
|
|
137
|
+
const e = (await p.query(`
|
|
138
|
+
DESCRIBE SELECT * FROM ${s}
|
|
139
|
+
`)).toArray();
|
|
140
|
+
let c = null, f = "", g = null, u = null, a = null;
|
|
141
|
+
const d = [], S = [
|
|
142
|
+
"lat",
|
|
143
|
+
"latitude",
|
|
144
|
+
"y",
|
|
145
|
+
"lat_y",
|
|
146
|
+
"point_y"
|
|
147
|
+
], $ = [
|
|
148
|
+
"lon",
|
|
149
|
+
"lng",
|
|
150
|
+
"long",
|
|
151
|
+
"longitude",
|
|
152
|
+
"x",
|
|
153
|
+
"lon_x",
|
|
154
|
+
"long_x",
|
|
155
|
+
"point_x"
|
|
156
|
+
], w = [
|
|
157
|
+
"wkt",
|
|
158
|
+
"wkt_geom",
|
|
159
|
+
"wkt_geometry",
|
|
160
|
+
"geometry_wkt"
|
|
161
|
+
];
|
|
162
|
+
for (const m of e) {
|
|
163
|
+
const o = m.column_name, E = m.column_type?.toUpperCase() || "", _ = o.toLowerCase(), z = E.includes("GEOMETRY"), N = _ === "geom" || _ === "geometry" || _ === "wkb_geometry" || _ === "the_geom" || _ === "shape", j = E.includes("BLOB") && N;
|
|
164
|
+
z || N || j ? c || (c = o, f = E) : S.includes(_) && !g ? (g = o, d.push(o)) : $.includes(_) && !u ? (u = o, d.push(o)) : w.includes(_) && !a ? a = o : d.push(o);
|
|
165
|
+
}
|
|
166
|
+
let y = !1, T = !1;
|
|
167
|
+
if (!c) if (a) T = !0;
|
|
168
|
+
else if (g && u) {
|
|
169
|
+
y = !0;
|
|
170
|
+
const m = d.indexOf(g);
|
|
171
|
+
m > -1 && d.splice(m, 1);
|
|
172
|
+
const o = d.indexOf(u);
|
|
173
|
+
o > -1 && d.splice(o, 1);
|
|
174
|
+
} else throw new Error("No geometry column found in the file. For CSV/Excel files, include a geometry column, WKT column, or lat/lon columns.");
|
|
175
|
+
n?.({
|
|
176
|
+
stage: "converting",
|
|
177
|
+
percent: 50,
|
|
178
|
+
message: "Converting to GeoJSON..."
|
|
179
|
+
});
|
|
180
|
+
const v = d.length > 0 ? `json_object(${d.map((m) => `'${m}', "${m}"`).join(", ")})` : "'{}'::JSON";
|
|
181
|
+
let k, b;
|
|
182
|
+
y && g && u ? (k = `ST_AsGeoJSON(ST_Point("${u}", "${g}"))`, b = `"${g}" IS NOT NULL AND "${u}" IS NOT NULL`) : T && a ? (k = `ST_AsGeoJSON(ST_GeomFromText("${a}"))`, b = `"${a}" IS NOT NULL AND "${a}" != ''`) : f.includes("BLOB") ? (k = `ST_AsGeoJSON(ST_GeomFromWKB("${c}"))`, b = `"${c}" IS NOT NULL`) : (k = `ST_AsGeoJSON("${c}")`, b = `"${c}" IS NOT NULL`);
|
|
183
|
+
const x = (await p.query(`
|
|
184
|
+
SELECT json_object(
|
|
185
|
+
'type', 'Feature',
|
|
186
|
+
'geometry', ${k}::JSON,
|
|
187
|
+
'properties', ${v}
|
|
188
|
+
) as feature
|
|
189
|
+
FROM ${s}
|
|
190
|
+
WHERE ${b}
|
|
191
|
+
`)).toArray();
|
|
192
|
+
n?.({
|
|
193
|
+
stage: "converting",
|
|
194
|
+
percent: 80,
|
|
195
|
+
message: "Building feature collection..."
|
|
196
|
+
});
|
|
197
|
+
const D = [], L = /* @__PURE__ */ new Set();
|
|
198
|
+
for (const m of x) if (m.feature) try {
|
|
199
|
+
const o = typeof m.feature == "string" ? JSON.parse(m.feature) : m.feature;
|
|
200
|
+
D.push(o), o.geometry?.type && L.add(o.geometry.type);
|
|
201
|
+
} catch (o) {
|
|
202
|
+
console.warn("Failed to parse feature:", o);
|
|
203
|
+
}
|
|
204
|
+
const C = {
|
|
205
|
+
type: "FeatureCollection",
|
|
206
|
+
features: D
|
|
207
|
+
}, F = performance.now(), U = {
|
|
208
|
+
originalFormat: l,
|
|
209
|
+
featureCount: D.length,
|
|
210
|
+
geometryTypes: Array.from(L),
|
|
211
|
+
fileSize: t.byteLength,
|
|
212
|
+
conversionTimeMs: Math.round(F - h)
|
|
213
|
+
};
|
|
214
|
+
return n?.({
|
|
215
|
+
stage: "complete",
|
|
216
|
+
percent: 100,
|
|
217
|
+
message: `Converted ${D.length} features`
|
|
218
|
+
}), {
|
|
219
|
+
geojson: C,
|
|
220
|
+
warnings: [],
|
|
221
|
+
metadata: U
|
|
222
|
+
};
|
|
223
|
+
} catch (s) {
|
|
224
|
+
throw n?.({
|
|
225
|
+
stage: "error",
|
|
226
|
+
message: `Failed to convert: ${s instanceof Error ? s.message : "Unknown error"}`
|
|
227
|
+
}), s;
|
|
228
|
+
} finally {
|
|
229
|
+
await p.close();
|
|
230
|
+
try {
|
|
231
|
+
await this._db.dropFile(r);
|
|
232
|
+
} catch {
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
_detectFormat(t) {
|
|
237
|
+
switch (t.toLowerCase().split(".").pop()) {
|
|
238
|
+
case "gpkg":
|
|
239
|
+
return "geopackage";
|
|
240
|
+
case "parquet":
|
|
241
|
+
case "geoparquet":
|
|
242
|
+
return "geoparquet";
|
|
243
|
+
case "shp":
|
|
244
|
+
return "shapefile";
|
|
245
|
+
case "geojson":
|
|
246
|
+
case "json":
|
|
247
|
+
return "geojson";
|
|
248
|
+
case "kml":
|
|
249
|
+
return "kml";
|
|
250
|
+
case "kmz":
|
|
251
|
+
return "kmz";
|
|
252
|
+
case "gpx":
|
|
253
|
+
return "gpx";
|
|
254
|
+
case "fgb":
|
|
255
|
+
return "flatgeobuf";
|
|
256
|
+
case "gml":
|
|
257
|
+
return "gml";
|
|
258
|
+
case "topojson":
|
|
259
|
+
return "topojson";
|
|
260
|
+
case "csv":
|
|
261
|
+
return "csv";
|
|
262
|
+
case "xlsx":
|
|
263
|
+
case "xls":
|
|
264
|
+
return "xlsx";
|
|
265
|
+
case "dxf":
|
|
266
|
+
return "dxf";
|
|
267
|
+
default:
|
|
268
|
+
return "unknown";
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
async registerRemoteParquet(t, r) {
|
|
272
|
+
if (this.isReady() || await this.initialize(), !this._db || !this._duckdb) throw new Error("DuckDB not initialized");
|
|
273
|
+
await this._db.registerFileURL(r, t, this._duckdb.DuckDBDataProtocol.HTTP, !1);
|
|
274
|
+
}
|
|
275
|
+
async getParquetSchema(t) {
|
|
276
|
+
if (!this._db) throw new Error("DuckDB not initialized");
|
|
277
|
+
const r = await this._db.connect();
|
|
278
|
+
try {
|
|
279
|
+
const n = (await r.query(`DESCRIBE SELECT * FROM read_parquet('${t}')`)).toArray(), h = n.map((e) => ({
|
|
280
|
+
name: e.column_name,
|
|
281
|
+
type: e.column_type
|
|
282
|
+
}));
|
|
283
|
+
let l = null, i = null;
|
|
284
|
+
const p = [], s = [
|
|
285
|
+
"geom",
|
|
286
|
+
"geometry",
|
|
287
|
+
"wkb_geometry",
|
|
288
|
+
"the_geom",
|
|
289
|
+
"shape"
|
|
290
|
+
];
|
|
291
|
+
for (const e of n) {
|
|
292
|
+
const c = e.column_name, f = e.column_type?.toUpperCase() || "", g = c.toLowerCase(), u = f.includes("GEOMETRY"), a = s.includes(g), d = f.includes("BLOB") && a;
|
|
293
|
+
(u || a || d) && !l ? (l = c, i = f) : p.push(c);
|
|
294
|
+
}
|
|
295
|
+
return {
|
|
296
|
+
geometryColumn: l,
|
|
297
|
+
geometryColumnType: i,
|
|
298
|
+
propertyColumns: p,
|
|
299
|
+
allColumns: h
|
|
300
|
+
};
|
|
301
|
+
} finally {
|
|
302
|
+
await r.close();
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
async queryByBounds(t, r, n, h, l) {
|
|
306
|
+
if (!this._db) throw new Error("DuckDB not initialized");
|
|
307
|
+
const i = await this._db.connect(), [p, s, e, c] = r;
|
|
308
|
+
try {
|
|
309
|
+
const f = h.length > 0 ? `json_object(${h.map((w) => `'${w}', "${w}"`).join(", ")})` : "'{}'::JSON", g = (l?.toUpperCase() || "").includes("BLOB");
|
|
310
|
+
let u, a;
|
|
311
|
+
g ? (u = `ST_AsGeoJSON(ST_GeomFromWKB("${n}"))`, a = `ST_GeomFromWKB("${n}")`) : (u = `ST_AsGeoJSON("${n}")`, a = `"${n}"`);
|
|
312
|
+
const d = `
|
|
313
|
+
SELECT json_object(
|
|
314
|
+
'type', 'Feature',
|
|
315
|
+
'geometry', ${u}::JSON,
|
|
316
|
+
'properties', ${f}
|
|
317
|
+
) as feature
|
|
318
|
+
FROM read_parquet('${t}')
|
|
319
|
+
WHERE "${n}" IS NOT NULL
|
|
320
|
+
AND ST_Intersects(
|
|
321
|
+
${a},
|
|
322
|
+
ST_MakeEnvelope(${p}, ${s}, ${e}, ${c})
|
|
323
|
+
)
|
|
324
|
+
`, S = (await i.query(d)).toArray(), $ = [];
|
|
325
|
+
for (const w of S) if (w.feature) try {
|
|
326
|
+
const y = typeof w.feature == "string" ? JSON.parse(w.feature) : w.feature;
|
|
327
|
+
$.push(y);
|
|
328
|
+
} catch (y) {
|
|
329
|
+
console.warn("Failed to parse feature:", y);
|
|
330
|
+
}
|
|
331
|
+
return {
|
|
332
|
+
type: "FeatureCollection",
|
|
333
|
+
features: $
|
|
334
|
+
};
|
|
335
|
+
} finally {
|
|
336
|
+
await i.close();
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
async unregisterFile(t) {
|
|
340
|
+
if (this._db)
|
|
341
|
+
try {
|
|
342
|
+
await this._db.dropFile(t);
|
|
343
|
+
} catch {
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
dispose() {
|
|
347
|
+
this._db && (this._db.terminate().catch(console.error), this._db = null), this._worker && (this._worker.terminate(), this._worker = null), this._initialized = !1, this._duckdb = null, B === this && (B = null);
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
export {
|
|
351
|
+
G as n,
|
|
352
|
+
A as r,
|
|
353
|
+
O as t
|
|
354
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var q=Object.create;var v=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var M=(e,t,r,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of J(t))!I.call(e,o)&&o!==r&&v(e,o,{get:()=>t[o],enumerable:!(p=G(t,o))||p.enumerable});return e};var K=(e,t,r)=>(r=e!=null?q(W(e)):{},M(t||!e||!e.__esModule?v(r,"default",{value:e,enumerable:!0}):r,e));const H=require("./ControlGrid-DIAcXRBe.cjs");var Y=H.__exportAll({DuckDBConverter:()=>T,getDuckDBConverter:()=>C}),D=null;function C(){return D||(D=new T),D}var T=class{_duckdb=null;_db=null;_worker=null;_initialized=!1;_initializing=!1;_bundleUrl;constructor(e){this._bundleUrl=e}isReady(){return this._initialized&&this._db!==null}async initialize(e){if(!this._initialized){if(this._initializing){for(;this._initializing;)await new Promise(t=>setTimeout(t,50));return}this._initializing=!0;try{e?.({stage:"initializing",percent:0,message:"Loading DuckDB WASM..."});let t;try{const n=await import("@duckdb/duckdb-wasm");t=n.default||n}catch(n){throw new Error(`DuckDB WASM is not installed or failed to load. Install it with: npm install @duckdb/duckdb-wasm. Error: ${n instanceof Error?n.message:"Unknown error"}`)}this._duckdb=t,e?.({stage:"initializing",percent:30,message:"Selecting DuckDB bundle..."});let r;if(this._duckdb.getJsDelivrBundles){const n=this._duckdb.getJsDelivrBundles();r=await this._duckdb.selectBundle(n)}else{const n=this._getJsDelivrBundles();r=await this._duckdb.selectBundle(n)}e?.({stage:"initializing",percent:50,message:"Instantiating DuckDB..."});const p=new this._duckdb.ConsoleLogger(4);let o,a=null;try{a=URL.createObjectURL(new Blob([`importScripts("${r.mainWorker}");`],{type:"text/javascript"})),o=new Worker(a)}catch(n){throw a&&URL.revokeObjectURL(a),new Error(`Failed to create DuckDB worker: ${n instanceof Error?n.message:"Unknown error"}`)}this._worker=o;const g=new this._duckdb.AsyncDuckDB(p,o);try{await g.instantiate(r.mainModule,r.pthreadWorker)}catch(n){throw new Error(`Failed to instantiate DuckDB: ${n instanceof Error?n.message:"Unknown error"}`)}a&&URL.revokeObjectURL(a),this._db=g,e?.({stage:"initializing",percent:70,message:"Loading spatial extension..."});const s=await this._db.connect();try{await s.query("INSTALL spatial"),await s.query("LOAD spatial")}catch(n){console.warn("Failed to load spatial extension, some features may not work:",n)}finally{await s.close()}this._initialized=!0,e?.({stage:"initializing",percent:100,message:"DuckDB ready"})}catch(t){throw e?.({stage:"error",message:`Failed to initialize DuckDB: ${t instanceof Error?t.message:"Unknown error"}`}),t}finally{this._initializing=!1}}}_getJsDelivrBundles(){const e=this._bundleUrl||"https://cdn.jsdelivr.net/npm/@duckdb/duckdb-wasm@latest/dist";return{mvp:{mainModule:`${e}/duckdb-mvp.wasm`,mainWorker:`${e}/duckdb-browser-mvp.worker.js`},eh:{mainModule:`${e}/duckdb-eh.wasm`,mainWorker:`${e}/duckdb-browser-eh.worker.js`}}}async convert(e,t,r){const p=performance.now(),o=this._detectFormat(t);if(this.isReady()||await this.initialize(r),!this._db)throw new Error("DuckDB not initialized");r?.({stage:"loading",percent:0,message:`Loading ${t}...`});const a=new Uint8Array(e);await this._db.registerFileBuffer(t,a);const g=await this._db.connect();try{r?.({stage:"converting",percent:30,message:"Reading spatial data..."});let s;o==="geoparquet"||o==="parquet"?s=`read_parquet('${t}')`:s=`ST_Read('${t}')`;const n=(await g.query(`
|
|
2
|
+
DESCRIBE SELECT * FROM ${s}
|
|
3
|
+
`)).toArray();let c=null,h="",f=null,u=null,l=null;const d=[],S=["lat","latitude","y","lat_y","point_y"],B=["lon","lng","long","longitude","x","lon_x","long_x","point_x"],w=["wkt","wkt_geom","wkt_geometry","geometry_wkt"];for(const m of n){const i=m.column_name,E=m.column_type?.toUpperCase()||"",_=i.toLowerCase(),R=E.includes("GEOMETRY"),O=_==="geom"||_==="geometry"||_==="wkb_geometry"||_==="the_geom"||_==="shape",A=E.includes("BLOB")&&O;R||O||A?c||(c=i,h=E):S.includes(_)&&!f?(f=i,d.push(i)):B.includes(_)&&!u?(u=i,d.push(i)):w.includes(_)&&!l?l=i:d.push(i)}let y=!1,L=!1;if(!c)if(l)L=!0;else if(f&&u){y=!0;const m=d.indexOf(f);m>-1&&d.splice(m,1);const i=d.indexOf(u);i>-1&&d.splice(i,1)}else throw new Error("No geometry column found in the file. For CSV/Excel files, include a geometry column, WKT column, or lat/lon columns.");r?.({stage:"converting",percent:50,message:"Converting to GeoJSON..."});const x=d.length>0?`json_object(${d.map(m=>`'${m}', "${m}"`).join(", ")})`:"'{}'::JSON";let k,b;y&&f&&u?(k=`ST_AsGeoJSON(ST_Point("${u}", "${f}"))`,b=`"${f}" IS NOT NULL AND "${u}" IS NOT NULL`):L&&l?(k=`ST_AsGeoJSON(ST_GeomFromText("${l}"))`,b=`"${l}" IS NOT NULL AND "${l}" != ''`):h.includes("BLOB")?(k=`ST_AsGeoJSON(ST_GeomFromWKB("${c}"))`,b=`"${c}" IS NOT NULL`):(k=`ST_AsGeoJSON("${c}")`,b=`"${c}" IS NOT NULL`);const F=(await g.query(`
|
|
4
|
+
SELECT json_object(
|
|
5
|
+
'type', 'Feature',
|
|
6
|
+
'geometry', ${k}::JSON,
|
|
7
|
+
'properties', ${x}
|
|
8
|
+
) as feature
|
|
9
|
+
FROM ${s}
|
|
10
|
+
WHERE ${b}
|
|
11
|
+
`)).toArray();r?.({stage:"converting",percent:80,message:"Building feature collection..."});const $=[],N=new Set;for(const m of F)if(m.feature)try{const i=typeof m.feature=="string"?JSON.parse(m.feature):m.feature;$.push(i),i.geometry?.type&&N.add(i.geometry.type)}catch(i){console.warn("Failed to parse feature:",i)}const U={type:"FeatureCollection",features:$},j=performance.now(),z={originalFormat:o,featureCount:$.length,geometryTypes:Array.from(N),fileSize:e.byteLength,conversionTimeMs:Math.round(j-p)};return r?.({stage:"complete",percent:100,message:`Converted ${$.length} features`}),{geojson:U,warnings:[],metadata:z}}catch(s){throw r?.({stage:"error",message:`Failed to convert: ${s instanceof Error?s.message:"Unknown error"}`}),s}finally{await g.close();try{await this._db.dropFile(t)}catch{}}}_detectFormat(e){switch(e.toLowerCase().split(".").pop()){case"gpkg":return"geopackage";case"parquet":case"geoparquet":return"geoparquet";case"shp":return"shapefile";case"geojson":case"json":return"geojson";case"kml":return"kml";case"kmz":return"kmz";case"gpx":return"gpx";case"fgb":return"flatgeobuf";case"gml":return"gml";case"topojson":return"topojson";case"csv":return"csv";case"xlsx":case"xls":return"xlsx";case"dxf":return"dxf";default:return"unknown"}}async registerRemoteParquet(e,t){if(this.isReady()||await this.initialize(),!this._db||!this._duckdb)throw new Error("DuckDB not initialized");await this._db.registerFileURL(t,e,this._duckdb.DuckDBDataProtocol.HTTP,!1)}async getParquetSchema(e){if(!this._db)throw new Error("DuckDB not initialized");const t=await this._db.connect();try{const r=(await t.query(`DESCRIBE SELECT * FROM read_parquet('${e}')`)).toArray(),p=r.map(n=>({name:n.column_name,type:n.column_type}));let o=null,a=null;const g=[],s=["geom","geometry","wkb_geometry","the_geom","shape"];for(const n of r){const c=n.column_name,h=n.column_type?.toUpperCase()||"",f=c.toLowerCase(),u=h.includes("GEOMETRY"),l=s.includes(f),d=h.includes("BLOB")&&l;(u||l||d)&&!o?(o=c,a=h):g.push(c)}return{geometryColumn:o,geometryColumnType:a,propertyColumns:g,allColumns:p}}finally{await t.close()}}async queryByBounds(e,t,r,p,o){if(!this._db)throw new Error("DuckDB not initialized");const a=await this._db.connect(),[g,s,n,c]=t;try{const h=p.length>0?`json_object(${p.map(w=>`'${w}', "${w}"`).join(", ")})`:"'{}'::JSON",f=(o?.toUpperCase()||"").includes("BLOB");let u,l;f?(u=`ST_AsGeoJSON(ST_GeomFromWKB("${r}"))`,l=`ST_GeomFromWKB("${r}")`):(u=`ST_AsGeoJSON("${r}")`,l=`"${r}"`);const d=`
|
|
12
|
+
SELECT json_object(
|
|
13
|
+
'type', 'Feature',
|
|
14
|
+
'geometry', ${u}::JSON,
|
|
15
|
+
'properties', ${h}
|
|
16
|
+
) as feature
|
|
17
|
+
FROM read_parquet('${e}')
|
|
18
|
+
WHERE "${r}" IS NOT NULL
|
|
19
|
+
AND ST_Intersects(
|
|
20
|
+
${l},
|
|
21
|
+
ST_MakeEnvelope(${g}, ${s}, ${n}, ${c})
|
|
22
|
+
)
|
|
23
|
+
`,S=(await a.query(d)).toArray(),B=[];for(const w of S)if(w.feature)try{const y=typeof w.feature=="string"?JSON.parse(w.feature):w.feature;B.push(y)}catch(y){console.warn("Failed to parse feature:",y)}return{type:"FeatureCollection",features:B}}finally{await a.close()}}async unregisterFile(e){if(this._db)try{await this._db.dropFile(e)}catch{}}dispose(){this._db&&(this._db.terminate().catch(console.error),this._db=null),this._worker&&(this._worker.terminate(),this._worker=null),this._initialized=!1,this._duckdb=null,D===this&&(D=null)}};Object.defineProperty(exports,"DuckDBConverter",{enumerable:!0,get:function(){return T}});Object.defineProperty(exports,"DuckDBConverter_exports",{enumerable:!0,get:function(){return Y}});Object.defineProperty(exports,"getDuckDBConverter",{enumerable:!0,get:function(){return C}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var g=Object.create;var f=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var C=(t,i,r,n)=>{if(i&&typeof i=="object"||typeof i=="function")for(let e of m(i))!v.call(t,e)&&e!==r&&f(t,e,{get:()=>i[e],enumerable:!(n=y(i,e))||n.enumerable});return t};var _=(t,i,r)=>(r=t!=null?g(d(t)):{},C(i||!t||!t.__esModule?f(r,"default",{value:t,enumerable:!0}):r,t));const j=require("./ControlGrid-DIAcXRBe.cjs");var w=j.__exportAll({ShapefileConverter:()=>o,getShapefileConverter:()=>u}),o=class{_shpjs=null;_initialized=!1;isReady(){return this._initialized&&this._shpjs!==null}async initialize(t){if(!this._initialized){t?.({stage:"initializing",percent:0,message:"Loading shapefile parser..."});try{this._shpjs=await import("shpjs"),this._initialized=!0,t?.({stage:"initializing",percent:100,message:"Shapefile parser ready"})}catch{throw new Error("shpjs is not installed. Install it with: npm install shpjs")}}}async convert(t,i,r){const n=performance.now();this.isReady()||await this.initialize(r),r?.({stage:"loading",percent:10,message:`Loading ${i}...`});try{r?.({stage:"converting",percent:30,message:"Parsing shapefile..."});const e=await(this._shpjs.default||this._shpjs)(t);r?.({stage:"converting",percent:80,message:"Building feature collection..."});let a;Array.isArray(e)?a={type:"FeatureCollection",features:e.flatMap(s=>s.features||[])}:e.type==="FeatureCollection"?a=e:e.type==="Feature"?a={type:"FeatureCollection",features:[e]}:a={type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:e}]};const p=new Set;for(const s of a.features)s.geometry&&p.add(s.geometry.type);const c=performance.now(),h={originalFormat:"shapefile",featureCount:a.features.length,geometryTypes:Array.from(p),fileSize:t.byteLength,conversionTimeMs:Math.round(c-n)};return r?.({stage:"complete",percent:100,message:`Converted ${a.features.length} features`}),{geojson:a,warnings:[],metadata:h}}catch(e){throw r?.({stage:"error",message:`Failed to parse shapefile: ${e instanceof Error?e.message:"Unknown error"}`}),e}}dispose(){this._shpjs=null,this._initialized=!1}},l=null;function u(){return l||(l=new o),l}Object.defineProperty(exports,"ShapefileConverter",{enumerable:!0,get:function(){return o}});Object.defineProperty(exports,"ShapefileConverter_exports",{enumerable:!0,get:function(){return w}});Object.defineProperty(exports,"getShapefileConverter",{enumerable:!0,get:function(){return u}});
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { sn as c } from "./ControlGrid-C6zp03Vq.js";
|
|
2
|
+
var m = /* @__PURE__ */ c({
|
|
3
|
+
ShapefileConverter: () => l,
|
|
4
|
+
getShapefileConverter: () => g
|
|
5
|
+
}), l = class {
|
|
6
|
+
_shpjs = null;
|
|
7
|
+
_initialized = !1;
|
|
8
|
+
isReady() {
|
|
9
|
+
return this._initialized && this._shpjs !== null;
|
|
10
|
+
}
|
|
11
|
+
async initialize(a) {
|
|
12
|
+
if (!this._initialized) {
|
|
13
|
+
a?.({
|
|
14
|
+
stage: "initializing",
|
|
15
|
+
percent: 0,
|
|
16
|
+
message: "Loading shapefile parser..."
|
|
17
|
+
});
|
|
18
|
+
try {
|
|
19
|
+
this._shpjs = await import(
|
|
20
|
+
/* @vite-ignore */
|
|
21
|
+
"shpjs"
|
|
22
|
+
), this._initialized = !0, a?.({
|
|
23
|
+
stage: "initializing",
|
|
24
|
+
percent: 100,
|
|
25
|
+
message: "Shapefile parser ready"
|
|
26
|
+
});
|
|
27
|
+
} catch {
|
|
28
|
+
throw new Error("shpjs is not installed. Install it with: npm install shpjs");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async convert(a, o, i) {
|
|
33
|
+
const p = performance.now();
|
|
34
|
+
this.isReady() || await this.initialize(i), i?.({
|
|
35
|
+
stage: "loading",
|
|
36
|
+
percent: 10,
|
|
37
|
+
message: `Loading ${o}...`
|
|
38
|
+
});
|
|
39
|
+
try {
|
|
40
|
+
i?.({
|
|
41
|
+
stage: "converting",
|
|
42
|
+
percent: 30,
|
|
43
|
+
message: "Parsing shapefile..."
|
|
44
|
+
});
|
|
45
|
+
const e = await (this._shpjs.default || this._shpjs)(a);
|
|
46
|
+
i?.({
|
|
47
|
+
stage: "converting",
|
|
48
|
+
percent: 80,
|
|
49
|
+
message: "Building feature collection..."
|
|
50
|
+
});
|
|
51
|
+
let t;
|
|
52
|
+
Array.isArray(e) ? t = {
|
|
53
|
+
type: "FeatureCollection",
|
|
54
|
+
features: e.flatMap((r) => r.features || [])
|
|
55
|
+
} : e.type === "FeatureCollection" ? t = e : e.type === "Feature" ? t = {
|
|
56
|
+
type: "FeatureCollection",
|
|
57
|
+
features: [e]
|
|
58
|
+
} : t = {
|
|
59
|
+
type: "FeatureCollection",
|
|
60
|
+
features: [{
|
|
61
|
+
type: "Feature",
|
|
62
|
+
properties: {},
|
|
63
|
+
geometry: e
|
|
64
|
+
}]
|
|
65
|
+
};
|
|
66
|
+
const n = /* @__PURE__ */ new Set();
|
|
67
|
+
for (const r of t.features) r.geometry && n.add(r.geometry.type);
|
|
68
|
+
const f = performance.now(), h = {
|
|
69
|
+
originalFormat: "shapefile",
|
|
70
|
+
featureCount: t.features.length,
|
|
71
|
+
geometryTypes: Array.from(n),
|
|
72
|
+
fileSize: a.byteLength,
|
|
73
|
+
conversionTimeMs: Math.round(f - p)
|
|
74
|
+
};
|
|
75
|
+
return i?.({
|
|
76
|
+
stage: "complete",
|
|
77
|
+
percent: 100,
|
|
78
|
+
message: `Converted ${t.features.length} features`
|
|
79
|
+
}), {
|
|
80
|
+
geojson: t,
|
|
81
|
+
warnings: [],
|
|
82
|
+
metadata: h
|
|
83
|
+
};
|
|
84
|
+
} catch (e) {
|
|
85
|
+
throw i?.({
|
|
86
|
+
stage: "error",
|
|
87
|
+
message: `Failed to parse shapefile: ${e instanceof Error ? e.message : "Unknown error"}`
|
|
88
|
+
}), e;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
dispose() {
|
|
92
|
+
this._shpjs = null, this._initialized = !1;
|
|
93
|
+
}
|
|
94
|
+
}, s = null;
|
|
95
|
+
function g() {
|
|
96
|
+
return s || (s = new l()), s;
|
|
97
|
+
}
|
|
98
|
+
export {
|
|
99
|
+
m as n,
|
|
100
|
+
g as r,
|
|
101
|
+
l as t
|
|
102
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
function s(e, o) {
|
|
2
|
+
let r = e.length - o, a = 0;
|
|
3
|
+
do {
|
|
4
|
+
for (let n = o; n > 0; n--)
|
|
5
|
+
e[a + o] += e[a], a++;
|
|
6
|
+
r -= o;
|
|
7
|
+
} while (r > 0);
|
|
8
|
+
}
|
|
9
|
+
function h(e, o, r) {
|
|
10
|
+
let a = 0, n = e.length;
|
|
11
|
+
const f = n / r;
|
|
12
|
+
for (; n > o; ) {
|
|
13
|
+
for (let t = o; t > 0; --t)
|
|
14
|
+
e[a + o] += e[a], ++a;
|
|
15
|
+
n -= o;
|
|
16
|
+
}
|
|
17
|
+
const i = e.slice();
|
|
18
|
+
for (let t = 0; t < f; ++t) for (let c = 0; c < r; ++c) e[r * t + c] = i[(r - c - 1) * f + t];
|
|
19
|
+
}
|
|
20
|
+
function d(e, o, r, a, n, f) {
|
|
21
|
+
if (!o || o === 1) return e;
|
|
22
|
+
for (let c = 0; c < n.length; ++c) {
|
|
23
|
+
if (n[c] % 8 !== 0) throw new Error("When decoding with predictor, only multiple of 8 bits are supported.");
|
|
24
|
+
if (n[c] !== n[0]) throw new Error("When decoding with predictor, all samples must have the same size.");
|
|
25
|
+
}
|
|
26
|
+
const i = n[0] / 8, t = f === 2 ? 1 : n.length;
|
|
27
|
+
for (let c = 0; c < a && !(c * t * r * i >= e.byteLength); ++c) {
|
|
28
|
+
let l;
|
|
29
|
+
if (o === 2) {
|
|
30
|
+
switch (n[0]) {
|
|
31
|
+
case 8:
|
|
32
|
+
l = new Uint8Array(e, c * t * r * i, t * r * i);
|
|
33
|
+
break;
|
|
34
|
+
case 16:
|
|
35
|
+
l = new Uint16Array(e, c * t * r * i, t * r * i / 2);
|
|
36
|
+
break;
|
|
37
|
+
case 32:
|
|
38
|
+
l = new Uint32Array(e, c * t * r * i, t * r * i / 4);
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
throw new Error(`Predictor 2 not allowed with ${n[0]} bits per sample.`);
|
|
42
|
+
}
|
|
43
|
+
s(l, t);
|
|
44
|
+
} else o === 3 && (l = new Uint8Array(e, c * t * r * i, t * r * i), h(l, t, i));
|
|
45
|
+
}
|
|
46
|
+
return e;
|
|
47
|
+
}
|
|
48
|
+
var u = class {
|
|
49
|
+
constructor(e) {
|
|
50
|
+
this.parameters = e;
|
|
51
|
+
}
|
|
52
|
+
decodeBlock(e) {
|
|
53
|
+
throw new Error("decodeBlock not implemented");
|
|
54
|
+
}
|
|
55
|
+
async decode(e) {
|
|
56
|
+
const o = await this.decodeBlock(e), { tileWidth: r, tileHeight: a, predictor: n, bitsPerSample: f, planarConfiguration: i } = this.parameters;
|
|
57
|
+
return n !== 1 ? d(o, n, r, a, Array.isArray(f) || ArrayBuffer.isView(f) ? Array.from(f) : [f], i) : o;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
export {
|
|
61
|
+
u as t
|
|
62
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function s(e,o){let r=e.length-o,a=0;do{for(let n=o;n>0;n--)e[a+o]+=e[a],a++;r-=o}while(r>0)}function u(e,o,r){let a=0,n=e.length;const f=n/r;for(;n>o;){for(let t=o;t>0;--t)e[a+o]+=e[a],++a;n-=o}const i=e.slice();for(let t=0;t<f;++t)for(let c=0;c<r;++c)e[r*t+c]=i[(r-c-1)*f+t]}function d(e,o,r,a,n,f){if(!o||o===1)return e;for(let c=0;c<n.length;++c){if(n[c]%8!==0)throw new Error("When decoding with predictor, only multiple of 8 bits are supported.");if(n[c]!==n[0])throw new Error("When decoding with predictor, all samples must have the same size.")}const i=n[0]/8,t=f===2?1:n.length;for(let c=0;c<a&&!(c*t*r*i>=e.byteLength);++c){let l;if(o===2){switch(n[0]){case 8:l=new Uint8Array(e,c*t*r*i,t*r*i);break;case 16:l=new Uint16Array(e,c*t*r*i,t*r*i/2);break;case 32:l=new Uint32Array(e,c*t*r*i,t*r*i/4);break;default:throw new Error(`Predictor 2 not allowed with ${n[0]} bits per sample.`)}s(l,t)}else o===3&&(l=new Uint8Array(e,c*t*r*i,t*r*i),u(l,t,i))}return e}var h=class{constructor(e){this.parameters=e}decodeBlock(e){throw new Error("decodeBlock not implemented")}async decode(e){const o=await this.decodeBlock(e),{tileWidth:r,tileHeight:a,predictor:n,bitsPerSample:f,planarConfiguration:i}=this.parameters;return n!==1?d(o,n,r,a,Array.isArray(f)||ArrayBuffer.isView(f)?Array.from(f):[f],i):o}};Object.defineProperty(exports,"BaseDecoder",{enumerable:!0,get:function(){return h}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const r=require("./pako.esm-DFyPB7cO.cjs"),a=require("./basedecoder-Zw0CbD9L.cjs");var c=class extends a.BaseDecoder{decodeBlock(e){return r.inflate_1(new Uint8Array(e)).buffer}};exports.default=c;
|