geokernel-electron 1.1.50 → 1.1.52
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.
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
package/src/viewer.js
CHANGED
|
@@ -344,6 +344,59 @@ class ViewerWindow {
|
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
|
|
347
|
+
addLayerFileWithCallbacks(filePath, options = {}, callbacks = {}) {
|
|
348
|
+
if (!fs.existsSync(filePath)) {
|
|
349
|
+
throw new Error(`Layer file not found: ${filePath}`);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
const callbackErrors = [];
|
|
353
|
+
const progressCallback = koffi.register((percent, message) => {
|
|
354
|
+
try {
|
|
355
|
+
callbacks.progress?.(Number(percent), message ?? "");
|
|
356
|
+
} catch (error) {
|
|
357
|
+
callbackErrors.push(error);
|
|
358
|
+
}
|
|
359
|
+
}, TYPES.progress_callback);
|
|
360
|
+
const cancellationCallback = koffi.register(() => {
|
|
361
|
+
if (callbackErrors.length > 0) return true;
|
|
362
|
+
try {
|
|
363
|
+
return Boolean(callbacks.isCancelled?.());
|
|
364
|
+
} catch (error) {
|
|
365
|
+
callbackErrors.push(error);
|
|
366
|
+
return true;
|
|
367
|
+
}
|
|
368
|
+
}, TYPES.cancel_callback);
|
|
369
|
+
const indexStateCallback = koffi.register((state) => {
|
|
370
|
+
try {
|
|
371
|
+
callbacks.spatialIndexStateChanged?.(Number(state));
|
|
372
|
+
} catch (error) {
|
|
373
|
+
callbackErrors.push(error);
|
|
374
|
+
}
|
|
375
|
+
}, TYPES.index_state_callback);
|
|
376
|
+
|
|
377
|
+
let ok;
|
|
378
|
+
try {
|
|
379
|
+
ok = this._call(
|
|
380
|
+
"GeoKernelViewer_AddLayerFileWithCallbacks",
|
|
381
|
+
filePath,
|
|
382
|
+
jsonText(options),
|
|
383
|
+
progressCallback,
|
|
384
|
+
cancellationCallback,
|
|
385
|
+
indexStateCallback,
|
|
386
|
+
null,
|
|
387
|
+
);
|
|
388
|
+
} finally {
|
|
389
|
+
koffi.unregister(progressCallback);
|
|
390
|
+
koffi.unregister(cancellationCallback);
|
|
391
|
+
koffi.unregister(indexStateCallback);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
if (callbackErrors.length > 0) throw callbackErrors[0];
|
|
395
|
+
if (!ok && callbacks.isCancelled?.()) return false;
|
|
396
|
+
if (!ok) throw new Error(`GeoKernelViewer_AddLayerFileWithCallbacks failed: ${filePath}`);
|
|
397
|
+
return true;
|
|
398
|
+
}
|
|
399
|
+
|
|
347
400
|
addLayer(filePath, options) {
|
|
348
401
|
this.addLayerFile(filePath, options);
|
|
349
402
|
}
|
|
@@ -1225,6 +1278,14 @@ class ViewerWindow {
|
|
|
1225
1278
|
);
|
|
1226
1279
|
}
|
|
1227
1280
|
|
|
1281
|
+
polygonCentroidInfo(points) {
|
|
1282
|
+
const xy = xyArray(points);
|
|
1283
|
+
return this._readJson(
|
|
1284
|
+
"GeoKernelViewer_GetPolygonCentroidInfoJson", {},
|
|
1285
|
+
xy, xy.length / 2,
|
|
1286
|
+
);
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1228
1289
|
convexHullTwoPolygons(left, right) {
|
|
1229
1290
|
const leftXy = xyArray(left);
|
|
1230
1291
|
const rightXy = xyArray(right);
|