@walkthru-earth/objex-utils 1.4.0 → 1.5.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/dist/index.cjs +71 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +68 -18
- package/dist/index.js.map +1 -1
- package/docs/app-config.md +4 -4
- package/docs/cog-asset.md +3 -3
- package/docs/lru.md +2 -2
- package/docs/map-pixel-inspect.md +2 -2
- package/docs/stac-hydrate.md +19 -19
- package/docs/stac-source.md +15 -15
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -16,6 +16,9 @@ var SQL_PREVIEW_LENGTH = 120;
|
|
|
16
16
|
var VIEWER_DIR_EXTENSIONS = /* @__PURE__ */ new Set(["zarr", "zr3"]);
|
|
17
17
|
var LAYER_HUE_MULTIPLIER = 137;
|
|
18
18
|
var COPY_FEEDBACK_MS = 2e3;
|
|
19
|
+
var DEFAULT_AWS_REGION = "us-east-1";
|
|
20
|
+
var TILE_DEBOUNCE_MS = 200;
|
|
21
|
+
var FIRST_FEATURE_FLY_ZOOM = 14;
|
|
19
22
|
|
|
20
23
|
// ../../src/lib/file-icons/index.ts
|
|
21
24
|
var DEFAULT_INFO = {
|
|
@@ -1366,7 +1369,7 @@ function buildProviderBaseUrl(provider, endpoint, bucket, region) {
|
|
|
1366
1369
|
const resolved = def.endpointTemplate.replace("{region}", region || def.defaultRegion);
|
|
1367
1370
|
return `${resolved}/${bucket}`;
|
|
1368
1371
|
}
|
|
1369
|
-
return `https://s3.${region ||
|
|
1372
|
+
return `https://s3.${region || DEFAULT_AWS_REGION}.amazonaws.com/${bucket}`;
|
|
1370
1373
|
}
|
|
1371
1374
|
function isGcsProvider(provider, endpoint) {
|
|
1372
1375
|
return provider === "gcs" || !!endpoint && /storage\.googleapis\.com/i.test(endpoint);
|
|
@@ -1430,8 +1433,23 @@ var UrlAdapter = class {
|
|
|
1430
1433
|
var DEFAULT_APP_CONFIG = {
|
|
1431
1434
|
defaults: { theme: "system", locale: "en", featureLimit: 1e3, mosaicItemLimit: 2e3 },
|
|
1432
1435
|
ui: { showConnectionRail: true, showFileTree: true, showSettings: true },
|
|
1433
|
-
basemaps: [
|
|
1434
|
-
|
|
1436
|
+
basemaps: [
|
|
1437
|
+
{
|
|
1438
|
+
id: "positron",
|
|
1439
|
+
label: "Positron",
|
|
1440
|
+
type: "vector",
|
|
1441
|
+
url: "https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",
|
|
1442
|
+
variant: "light"
|
|
1443
|
+
},
|
|
1444
|
+
{
|
|
1445
|
+
id: "dark-matter",
|
|
1446
|
+
label: "Dark Matter",
|
|
1447
|
+
type: "vector",
|
|
1448
|
+
url: "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",
|
|
1449
|
+
variant: "dark"
|
|
1450
|
+
}
|
|
1451
|
+
],
|
|
1452
|
+
defaultBasemap: { light: "positron", dark: "dark-matter" },
|
|
1435
1453
|
connections: []
|
|
1436
1454
|
};
|
|
1437
1455
|
function asObject(v) {
|
|
@@ -1898,7 +1916,7 @@ function resolveCloudUrl(url) {
|
|
|
1898
1916
|
if (s3Match) {
|
|
1899
1917
|
const [, bucket, key] = s3Match;
|
|
1900
1918
|
const regionMatch = bucket.match(AWS_REGION_RE);
|
|
1901
|
-
const region = regionMatch ? regionMatch[0] :
|
|
1919
|
+
const region = regionMatch ? regionMatch[0] : DEFAULT_AWS_REGION;
|
|
1902
1920
|
const base = buildProviderBaseUrl("s3", "", bucket, region);
|
|
1903
1921
|
return key ? `${base}/${key}` : base;
|
|
1904
1922
|
}
|
|
@@ -2229,6 +2247,18 @@ function isSameConnectionIdentity(a, b) {
|
|
|
2229
2247
|
return key !== "" && key === connectionIdentityKey(b);
|
|
2230
2248
|
}
|
|
2231
2249
|
|
|
2250
|
+
// src/crs.ts
|
|
2251
|
+
var WGS84_STRINGS = /* @__PURE__ */ new Set(["epsg:4326", "epsg:4979", DEFAULT_TARGET_CRS.toLowerCase()]);
|
|
2252
|
+
function isWgs84(crs) {
|
|
2253
|
+
if (crs === null || crs === void 0) return false;
|
|
2254
|
+
if (typeof crs === "number") return Number.isFinite(crs) && WGS84_CODES.has(crs);
|
|
2255
|
+
const s = crs.trim().toLowerCase();
|
|
2256
|
+
if (s.length === 0) return false;
|
|
2257
|
+
if (WGS84_STRINGS.has(s)) return true;
|
|
2258
|
+
const m = s.match(/(?:epsg:)?(\d+)/);
|
|
2259
|
+
return m ? WGS84_CODES.has(Number(m[1])) : false;
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2232
2262
|
// src/error.ts
|
|
2233
2263
|
function isAbortError(err) {
|
|
2234
2264
|
if (!err) return false;
|
|
@@ -2957,12 +2987,19 @@ function buildGeoArrowTables(wkbArrays, attributes, knownGeomType) {
|
|
|
2957
2987
|
}
|
|
2958
2988
|
|
|
2959
2989
|
// src/geometry-type.ts
|
|
2960
|
-
var GEOMETRY_PREFIX = /^GEOMETRY(
|
|
2990
|
+
var GEOMETRY_PREFIX = /^GEOMETRY(?:\s*\(([^)]*)\))?/i;
|
|
2991
|
+
function stripCrsQuotes(inner) {
|
|
2992
|
+
let crs = inner.trim();
|
|
2993
|
+
if (crs.length >= 2 && crs.startsWith("'") && crs.endsWith("'")) {
|
|
2994
|
+
crs = crs.slice(1, -1).trim();
|
|
2995
|
+
}
|
|
2996
|
+
return crs || null;
|
|
2997
|
+
}
|
|
2961
2998
|
function parseGeometryTypeCrs(typeStr) {
|
|
2962
2999
|
if (!typeStr) return { isGeometry: false, hasCrs: false, rawCrs: null, nonWgs84Crs: null };
|
|
2963
3000
|
const match = typeStr.match(GEOMETRY_PREFIX);
|
|
2964
3001
|
if (!match) return { isGeometry: false, hasCrs: false, rawCrs: null, nonWgs84Crs: null };
|
|
2965
|
-
const rawCrs = match[
|
|
3002
|
+
const rawCrs = match[1] != null ? stripCrsQuotes(match[1]) : null;
|
|
2966
3003
|
if (!rawCrs) return { isGeometry: true, hasCrs: false, rawCrs: null, nonWgs84Crs: null };
|
|
2967
3004
|
return {
|
|
2968
3005
|
isGeometry: true,
|
|
@@ -3212,7 +3249,7 @@ function isKnownBucketHost(host) {
|
|
|
3212
3249
|
function defaultResult(defaults) {
|
|
3213
3250
|
return {
|
|
3214
3251
|
bucket: "",
|
|
3215
|
-
region: defaults.region ||
|
|
3252
|
+
region: defaults.region || DEFAULT_AWS_REGION,
|
|
3216
3253
|
endpoint: defaults.endpoint || "",
|
|
3217
3254
|
provider: defaults.provider || "s3",
|
|
3218
3255
|
prefix: ""
|
|
@@ -3237,7 +3274,7 @@ function parseStorageUrl(input, defaults = {}) {
|
|
|
3237
3274
|
const { bucket, prefix } = splitBucketPrefix(rest);
|
|
3238
3275
|
return {
|
|
3239
3276
|
bucket,
|
|
3240
|
-
region: defaults.region ||
|
|
3277
|
+
region: defaults.region || DEFAULT_AWS_REGION,
|
|
3241
3278
|
endpoint: defaults.endpoint || "",
|
|
3242
3279
|
provider,
|
|
3243
3280
|
prefix
|
|
@@ -3272,7 +3309,7 @@ function parseStorageUrl(input, defaults = {}) {
|
|
|
3272
3309
|
if (host === AWS_GLOBAL_HOST && pathParts.length > 0) {
|
|
3273
3310
|
return {
|
|
3274
3311
|
bucket: pathParts[0],
|
|
3275
|
-
region: defaults.region ||
|
|
3312
|
+
region: defaults.region || DEFAULT_AWS_REGION,
|
|
3276
3313
|
endpoint: "",
|
|
3277
3314
|
provider: "s3",
|
|
3278
3315
|
prefix: pathParts.slice(1).join("/")
|
|
@@ -3439,7 +3476,7 @@ function parseStorageUrl(input, defaults = {}) {
|
|
|
3439
3476
|
if (isMinioLikeHost(host) && pathParts.length > 0) {
|
|
3440
3477
|
return {
|
|
3441
3478
|
bucket: pathParts[0],
|
|
3442
|
-
region: defaults.region ||
|
|
3479
|
+
region: defaults.region || DEFAULT_AWS_REGION,
|
|
3443
3480
|
endpoint: `${url.protocol}//${url.host}`,
|
|
3444
3481
|
provider: "minio",
|
|
3445
3482
|
prefix: pathParts.slice(1).join("/")
|
|
@@ -3485,7 +3522,7 @@ function parseStorageUrl(input, defaults = {}) {
|
|
|
3485
3522
|
const endpoint = `${url.protocol}//${url.host}`;
|
|
3486
3523
|
return {
|
|
3487
3524
|
bucket: pathParts[0],
|
|
3488
|
-
region: defaults.region ||
|
|
3525
|
+
region: defaults.region || DEFAULT_AWS_REGION,
|
|
3489
3526
|
endpoint,
|
|
3490
3527
|
provider: defaults.provider || "s3",
|
|
3491
3528
|
prefix: pathParts.slice(1).join("/")
|
|
@@ -3501,7 +3538,7 @@ function parseStorageUrl(input, defaults = {}) {
|
|
|
3501
3538
|
const cleaned = stripEdgeSlashes2(trimmed);
|
|
3502
3539
|
return {
|
|
3503
3540
|
bucket: cleaned,
|
|
3504
|
-
region: defaults.region ||
|
|
3541
|
+
region: defaults.region || DEFAULT_AWS_REGION,
|
|
3505
3542
|
endpoint: defaults.endpoint || "",
|
|
3506
3543
|
provider: defaults.provider || "s3",
|
|
3507
3544
|
prefix: ""
|
|
@@ -3519,7 +3556,8 @@ function describeParseResult(parsed) {
|
|
|
3519
3556
|
const parts = [];
|
|
3520
3557
|
if (parsed.bucket) parts.push(`bucket="${parsed.bucket}"`);
|
|
3521
3558
|
if (parsed.endpoint) parts.push(`endpoint="${parsed.endpoint}"`);
|
|
3522
|
-
if (parsed.region && parsed.region !==
|
|
3559
|
+
if (parsed.region && parsed.region !== DEFAULT_AWS_REGION)
|
|
3560
|
+
parts.push(`region="${parsed.region}"`);
|
|
3523
3561
|
if (parsed.provider !== "s3") parts.push(`provider=${parsed.provider}`);
|
|
3524
3562
|
if (parsed.prefix) parts.push(`prefix="${parsed.prefix}"`);
|
|
3525
3563
|
return parts.length > 0 ? `Detected: ${parts.join(", ")}` : "";
|
|
@@ -5702,17 +5740,29 @@ function looksLikeWKB(value) {
|
|
|
5702
5740
|
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
5703
5741
|
let typeInt = view.getUint32(1, le);
|
|
5704
5742
|
typeInt = (typeInt & 65535) % 1e3;
|
|
5705
|
-
return typeInt >= 1 && typeInt <=
|
|
5743
|
+
return typeInt >= 1 && typeInt <= 6;
|
|
5706
5744
|
}
|
|
5707
5745
|
function findGeoColumnFromRows(rows, schema) {
|
|
5708
5746
|
if (rows.length === 0) return null;
|
|
5709
|
-
const
|
|
5747
|
+
const MAX_SCAN = 50;
|
|
5748
|
+
const scan = rows.slice(0, MAX_SCAN);
|
|
5749
|
+
const firstNonNull = (key) => {
|
|
5750
|
+
for (const row of scan) {
|
|
5751
|
+
const v = row[key];
|
|
5752
|
+
if (v !== null && v !== void 0) return v;
|
|
5753
|
+
}
|
|
5754
|
+
return void 0;
|
|
5755
|
+
};
|
|
5710
5756
|
for (const f of schema) {
|
|
5711
5757
|
const t = f.type.toLowerCase();
|
|
5712
5758
|
const isBinary = t.includes("blob") || t.includes("binary") || t.includes("bytea");
|
|
5713
|
-
if (isBinary && looksLikeWKB(
|
|
5759
|
+
if (isBinary && looksLikeWKB(firstNonNull(f.name))) return f.name;
|
|
5714
5760
|
}
|
|
5715
|
-
|
|
5761
|
+
const keys = /* @__PURE__ */ new Set();
|
|
5762
|
+
for (const row of scan) for (const k of Object.keys(row)) keys.add(k);
|
|
5763
|
+
for (const key of keys) {
|
|
5764
|
+
const value = firstNonNull(key);
|
|
5765
|
+
if (value === void 0) continue;
|
|
5716
5766
|
if (value instanceof Uint8Array || value instanceof ArrayBuffer) {
|
|
5717
5767
|
if (looksLikeWKB(value)) return key;
|
|
5718
5768
|
}
|
|
@@ -5750,8 +5800,10 @@ exports.COPY_FEEDBACK_MS = COPY_FEEDBACK_MS;
|
|
|
5750
5800
|
exports.DATETIME_HISTOGRAM_BINS = DATETIME_HISTOGRAM_BINS;
|
|
5751
5801
|
exports.DATETIME_HISTOGRAM_BINS_MAX = DATETIME_HISTOGRAM_BINS_MAX;
|
|
5752
5802
|
exports.DEFAULT_APP_CONFIG = DEFAULT_APP_CONFIG;
|
|
5803
|
+
exports.DEFAULT_AWS_REGION = DEFAULT_AWS_REGION;
|
|
5753
5804
|
exports.DEFAULT_TARGET_CRS = DEFAULT_TARGET_CRS;
|
|
5754
5805
|
exports.DUCKDB_INIT_TIMEOUT_MS = DUCKDB_INIT_TIMEOUT_MS;
|
|
5806
|
+
exports.FIRST_FEATURE_FLY_ZOOM = FIRST_FEATURE_FLY_ZOOM;
|
|
5755
5807
|
exports.LAYER_HUE_MULTIPLIER = LAYER_HUE_MULTIPLIER;
|
|
5756
5808
|
exports.LruCache = LruCache;
|
|
5757
5809
|
exports.MAX_QUERY_HISTORY_ENTRIES = MAX_QUERY_HISTORY_ENTRIES;
|
|
@@ -5766,6 +5818,7 @@ exports.STAC_API_PATH_RE = STAC_API_PATH_RE;
|
|
|
5766
5818
|
exports.STAC_COG_ASSET_KEYS = STAC_COG_ASSET_KEYS;
|
|
5767
5819
|
exports.STAC_GEOPARQUET_REQUIRED_COLUMNS = STAC_GEOPARQUET_REQUIRED_COLUMNS;
|
|
5768
5820
|
exports.STORAGE_KEYS = STORAGE_KEYS;
|
|
5821
|
+
exports.TILE_DEBOUNCE_MS = TILE_DEBOUNCE_MS;
|
|
5769
5822
|
exports.UrlAdapter = UrlAdapter;
|
|
5770
5823
|
exports.VIEWER_DIR_EXTENSIONS = VIEWER_DIR_EXTENSIONS;
|
|
5771
5824
|
exports.WGS84_CODES = WGS84_CODES;
|
|
@@ -5854,6 +5907,7 @@ exports.isStacCollection = isStacCollection;
|
|
|
5854
5907
|
exports.isStacFeatureCollection = isStacFeatureCollection;
|
|
5855
5908
|
exports.isStacGeoparquetSchema = isStacGeoparquetSchema;
|
|
5856
5909
|
exports.isStacItem = isStacItem;
|
|
5910
|
+
exports.isWgs84 = isWgs84;
|
|
5857
5911
|
exports.isWgs84Crs = isWgs84Crs;
|
|
5858
5912
|
exports.jsonReplacerBigInt = jsonReplacerBigInt;
|
|
5859
5913
|
exports.loadFromStorage = loadFromStorage;
|