geokernel-electron 1.0.2

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.
Files changed (136) hide show
  1. package/LICENSE +6 -0
  2. package/README.md +52 -0
  3. package/assets/images/FullExtent.svg +29 -0
  4. package/assets/images/GeoKernelAppIcon.ico +0 -0
  5. package/assets/images/Pan.svg +6 -0
  6. package/assets/images/RectangularZoom.svg +82 -0
  7. package/assets/images/ZoomIn.svg +10 -0
  8. package/assets/images/ZoomOut.svg +10 -0
  9. package/bin/GeoKernel.Core.dll +0 -0
  10. package/bin/GeoKernel.Formats.dll +0 -0
  11. package/bin/GeoKernel.Viewer.dll +0 -0
  12. package/bin/Qt6Core.dll +0 -0
  13. package/bin/Qt6Gui.dll +0 -0
  14. package/bin/Qt6Network.dll +0 -0
  15. package/bin/Qt6OpenGL.dll +0 -0
  16. package/bin/Qt6OpenGLWidgets.dll +0 -0
  17. package/bin/Qt6Sql.dll +0 -0
  18. package/bin/Qt6Widgets.dll +0 -0
  19. package/bin/README_LICENSE_PROFILE.txt +21 -0
  20. package/bin/gdal-data/GDALLogoBW.svg +138 -0
  21. package/bin/gdal-data/GDALLogoColor.svg +126 -0
  22. package/bin/gdal-data/GDALLogoGS.svg +126 -0
  23. package/bin/gdal-data/LICENSE.TXT +467 -0
  24. package/bin/gdal-data/cubewerx_extra.wkt +48 -0
  25. package/bin/gdal-data/ecw_cs.wkt +1453 -0
  26. package/bin/gdal-data/epsg.wkt +1 -0
  27. package/bin/gdal-data/esri_StatePlane_extra.wkt +631 -0
  28. package/bin/gdal-data/gdal_algorithm.schema.json +220 -0
  29. package/bin/gdal-data/gdalicon.png +0 -0
  30. package/bin/gdal-data/gdalinfo_output.schema.json +390 -0
  31. package/bin/gdal-data/gdalmdiminfo_output.schema.json +326 -0
  32. package/bin/gdal-data/gdalvrt.xsd +927 -0
  33. package/bin/gdal-data/gfs.xsd +246 -0
  34. package/bin/gdal-data/gml_registry.xml +117 -0
  35. package/bin/gdal-data/gml_registry.xsd +66 -0
  36. package/bin/gdal-data/inspire_cp_BasicPropertyUnit.gfs +57 -0
  37. package/bin/gdal-data/inspire_cp_CadastralBoundary.gfs +60 -0
  38. package/bin/gdal-data/inspire_cp_CadastralParcel.gfs +81 -0
  39. package/bin/gdal-data/inspire_cp_CadastralZoning.gfs +161 -0
  40. package/bin/gdal-data/jpfgdgml_AdmArea.gfs +59 -0
  41. package/bin/gdal-data/jpfgdgml_AdmBdry.gfs +49 -0
  42. package/bin/gdal-data/jpfgdgml_AdmPt.gfs +59 -0
  43. package/bin/gdal-data/jpfgdgml_BldA.gfs +54 -0
  44. package/bin/gdal-data/jpfgdgml_BldL.gfs +54 -0
  45. package/bin/gdal-data/jpfgdgml_Cntr.gfs +54 -0
  46. package/bin/gdal-data/jpfgdgml_CommBdry.gfs +49 -0
  47. package/bin/gdal-data/jpfgdgml_CommPt.gfs +59 -0
  48. package/bin/gdal-data/jpfgdgml_Cstline.gfs +54 -0
  49. package/bin/gdal-data/jpfgdgml_ElevPt.gfs +54 -0
  50. package/bin/gdal-data/jpfgdgml_GCP.gfs +94 -0
  51. package/bin/gdal-data/jpfgdgml_LeveeEdge.gfs +49 -0
  52. package/bin/gdal-data/jpfgdgml_RailCL.gfs +54 -0
  53. package/bin/gdal-data/jpfgdgml_RdASL.gfs +44 -0
  54. package/bin/gdal-data/jpfgdgml_RdArea.gfs +54 -0
  55. package/bin/gdal-data/jpfgdgml_RdCompt.gfs +59 -0
  56. package/bin/gdal-data/jpfgdgml_RdEdg.gfs +59 -0
  57. package/bin/gdal-data/jpfgdgml_RdMgtBdry.gfs +49 -0
  58. package/bin/gdal-data/jpfgdgml_RdSgmtA.gfs +59 -0
  59. package/bin/gdal-data/jpfgdgml_RvrMgtBdry.gfs +49 -0
  60. package/bin/gdal-data/jpfgdgml_SBAPt.gfs +49 -0
  61. package/bin/gdal-data/jpfgdgml_SBArea.gfs +54 -0
  62. package/bin/gdal-data/jpfgdgml_SBBdry.gfs +44 -0
  63. package/bin/gdal-data/jpfgdgml_WA.gfs +54 -0
  64. package/bin/gdal-data/jpfgdgml_WL.gfs +54 -0
  65. package/bin/gdal-data/jpfgdgml_WStrA.gfs +54 -0
  66. package/bin/gdal-data/jpfgdgml_WStrL.gfs +54 -0
  67. package/bin/gdal-data/leaflet_template.html +102 -0
  68. package/bin/gdal-data/ogr_fields_override.schema.json +125 -0
  69. package/bin/gdal-data/ogrinfo_output.schema.json +528 -0
  70. package/bin/gdal-data/ogrvrt.xsd +528 -0
  71. package/bin/gdal-data/osmconf.ini +134 -0
  72. package/bin/gdal-data/ozi_datum.csv +131 -0
  73. package/bin/gdal-data/ozi_ellips.csv +35 -0
  74. package/bin/gdal-data/pci_datum.txt +530 -0
  75. package/bin/gdal-data/pci_ellips.txt +129 -0
  76. package/bin/gdal-data/ruian_vf_ob_v1.gfs +1455 -0
  77. package/bin/gdal-data/ruian_vf_st_uvoh_v1.gfs +86 -0
  78. package/bin/gdal-data/ruian_vf_st_v1.gfs +1489 -0
  79. package/bin/gdal-data/ruian_vf_v1.gfs +2126 -0
  80. package/bin/gdal-data/stateplane.csv +259 -0
  81. package/bin/gdal-data/template_tiles.mapml +28 -0
  82. package/bin/gdal-data/tms_LINZAntarticaMapTileGrid.json +190 -0
  83. package/bin/gdal-data/tms_MapML_APSTILE.json +268 -0
  84. package/bin/gdal-data/tms_MapML_CBMTILE.json +346 -0
  85. package/bin/gdal-data/tms_NZTM2000.json +243 -0
  86. package/bin/gdal.dll +0 -0
  87. package/bin/gdalplugins/drivers.ini +279 -0
  88. package/bin/gdalplugins/gdal_ECW_JP2ECW.dll +0 -0
  89. package/bin/gdalplugins/gdal_JPEG.dll +0 -0
  90. package/bin/gdalplugins/gdal_MrSID.dll +0 -0
  91. package/bin/gdalplugins/gdal_PNG.dll +0 -0
  92. package/bin/gdalplugins/ogr_Arrow.dll +0 -0
  93. package/bin/gdalplugins/ogr_LIBKML.dll +0 -0
  94. package/bin/gdalplugins/ogr_Parquet.dll +0 -0
  95. package/bin/gdalplugins/ogr_XLS.dll +0 -0
  96. package/bin/license-profile.json +17 -0
  97. package/bin/licenses/README.txt +1 -0
  98. package/bin/proj-data/CH +22 -0
  99. package/bin/proj-data/GL27 +23 -0
  100. package/bin/proj-data/ITRF2000 +24 -0
  101. package/bin/proj-data/ITRF2008 +94 -0
  102. package/bin/proj-data/ITRF2014 +55 -0
  103. package/bin/proj-data/ITRF2020 +91 -0
  104. package/bin/proj-data/copyright +34 -0
  105. package/bin/proj-data/deformation_model.schema.json +582 -0
  106. package/bin/proj-data/nad.lst +142 -0
  107. package/bin/proj-data/nad27 +810 -0
  108. package/bin/proj-data/nad83 +745 -0
  109. package/bin/proj-data/other.extra +53 -0
  110. package/bin/proj-data/proj-config-version.cmake +44 -0
  111. package/bin/proj-data/proj-config.cmake +79 -0
  112. package/bin/proj-data/proj-targets-debug.cmake +19 -0
  113. package/bin/proj-data/proj-targets-release.cmake +19 -0
  114. package/bin/proj-data/proj-targets.cmake +107 -0
  115. package/bin/proj-data/proj.db +0 -0
  116. package/bin/proj-data/proj.ini +59 -0
  117. package/bin/proj-data/proj4-targets-debug.cmake +19 -0
  118. package/bin/proj-data/proj4-targets-release.cmake +19 -0
  119. package/bin/proj-data/proj4-targets.cmake +107 -0
  120. package/bin/proj-data/projjson.schema.json +1174 -0
  121. package/bin/proj-data/triangulation.schema.json +214 -0
  122. package/bin/proj-data/usage +9 -0
  123. package/bin/proj-data/vcpkg.spdx.json +1103 -0
  124. package/bin/proj-data/vcpkg_abi_info.txt +29 -0
  125. package/bin/proj-data/world +214 -0
  126. package/bin/use-license-profile.ps1 +4 -0
  127. package/package.json +42 -0
  128. package/src/index.js +20 -0
  129. package/src/native-signatures.js +251 -0
  130. package/src/native-types.js +101 -0
  131. package/src/native.js +63 -0
  132. package/src/runtime.js +71 -0
  133. package/src/styles.js +70 -0
  134. package/src/types.js +120 -0
  135. package/src/viewer-helpers.js +124 -0
  136. package/src/viewer.js +524 -0
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+
3
+ const koffi = require("koffi");
4
+
5
+ const GeoKernelViewerExtent = koffi.struct("GeoKernelViewerExtent", {
6
+ xMin: "double",
7
+ yMin: "double",
8
+ xMax: "double",
9
+ yMax: "double",
10
+ });
11
+
12
+ const GeoKernelViewerScreenRectangle = koffi.struct("GeoKernelViewerScreenRectangle", {
13
+ left: "int",
14
+ top: "int",
15
+ right: "int",
16
+ bottom: "int",
17
+ });
18
+
19
+ const GeoKernelViewerRouteSummary = koffi.struct("GeoKernelViewerRouteSummary", {
20
+ succeeded: "bool",
21
+ totalDistance: "double",
22
+ totalTime: "double",
23
+ cost: "double",
24
+ fromSnapDistance: "double",
25
+ toSnapDistance: "double",
26
+ routeLayerIndex: "int",
27
+ });
28
+
29
+ const GeoKernelViewerEventData = koffi.struct("GeoKernelViewerEventData", {
30
+ eventType: "int",
31
+ intValue: "int",
32
+ intValue2: "int",
33
+ doubleValue: "double",
34
+ extent: GeoKernelViewerExtent,
35
+ screenRectangle: GeoKernelViewerScreenRectangle,
36
+ });
37
+
38
+ const GeoKernelViewerEventCallback = koffi.proto("GeoKernelViewerEventCallback", "void", [
39
+ koffi.pointer(GeoKernelViewerEventData),
40
+ "str16",
41
+ "void *",
42
+ ]);
43
+
44
+ const GeoKernelViewerLayerLoadProgressCallback = koffi.proto(
45
+ "GeoKernelViewerLayerLoadProgressCallback",
46
+ "void",
47
+ ["int", "str16", "void *"],
48
+ );
49
+
50
+ const GeoKernelViewerLayerLoadCancellationCallback = koffi.proto(
51
+ "GeoKernelViewerLayerLoadCancellationCallback",
52
+ "bool",
53
+ ["void *"],
54
+ );
55
+
56
+ const GeoKernelViewerSpatialIndexStateCallback = koffi.proto(
57
+ "GeoKernelViewerSpatialIndexStateCallback",
58
+ "void",
59
+ ["int", "void *"],
60
+ );
61
+
62
+ const TYPES = Object.freeze({
63
+ void: "void",
64
+ void_p: "void *",
65
+ size_t: "size_t",
66
+ int: "int",
67
+ bool: "bool",
68
+ double: "double",
69
+ wchar_p: "str16",
70
+ out_wchar_p: koffi.out("str16"),
71
+ double_p: koffi.pointer("double"),
72
+ out_double_p: koffi.out(koffi.pointer("double")),
73
+ int_p: koffi.pointer("int"),
74
+ out_int_p: koffi.out(koffi.pointer("int")),
75
+ ubyte_p: koffi.pointer("uint8_t"),
76
+ out_ubyte_p: koffi.out(koffi.pointer("uint8_t")),
77
+ extent: GeoKernelViewerExtent,
78
+ extent_p: koffi.pointer(GeoKernelViewerExtent),
79
+ out_extent_p: koffi.out(koffi.pointer(GeoKernelViewerExtent)),
80
+ screen_rect: GeoKernelViewerScreenRectangle,
81
+ screen_rect_p: koffi.pointer(GeoKernelViewerScreenRectangle),
82
+ out_screen_rect_p: koffi.out(koffi.pointer(GeoKernelViewerScreenRectangle)),
83
+ route_summary_p: koffi.pointer(GeoKernelViewerRouteSummary),
84
+ out_route_summary_p: koffi.out(koffi.pointer(GeoKernelViewerRouteSummary)),
85
+ event_callback: koffi.pointer(GeoKernelViewerEventCallback),
86
+ progress_callback: koffi.pointer(GeoKernelViewerLayerLoadProgressCallback),
87
+ cancel_callback: koffi.pointer(GeoKernelViewerLayerLoadCancellationCallback),
88
+ index_state_callback: koffi.pointer(GeoKernelViewerSpatialIndexStateCallback),
89
+ });
90
+
91
+ module.exports = {
92
+ GeoKernelViewerEventCallback,
93
+ GeoKernelViewerEventData,
94
+ GeoKernelViewerExtent,
95
+ GeoKernelViewerLayerLoadCancellationCallback,
96
+ GeoKernelViewerLayerLoadProgressCallback,
97
+ GeoKernelViewerRouteSummary,
98
+ GeoKernelViewerScreenRectangle,
99
+ GeoKernelViewerSpatialIndexStateCallback,
100
+ TYPES,
101
+ };
package/src/native.js ADDED
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ const path = require("path");
4
+ const koffi = require("koffi");
5
+
6
+ const { configureRuntimeEnvironment, findBinDir } = require("./runtime");
7
+ const { SIGNATURES } = require("./native-signatures");
8
+ const nativeTypes = require("./native-types");
9
+
10
+ class GeoKernelNativeLibrary {
11
+ constructor(binDir) {
12
+ this.binDir = findBinDir(binDir);
13
+ configureRuntimeEnvironment(this.binDir);
14
+ this.dll = koffi.load(path.join(this.binDir, "GeoKernel.Viewer.dll"));
15
+ this.functions = new Map();
16
+ }
17
+
18
+ getFunction(name) {
19
+ if (!Object.prototype.hasOwnProperty.call(SIGNATURES, name)) {
20
+ throw new Error(`Unknown GeoKernel native function: ${name}`);
21
+ }
22
+
23
+ if (!this.functions.has(name)) {
24
+ const [returnTypeName, argTypeNames] = SIGNATURES[name];
25
+ const returnType = typeFor(returnTypeName);
26
+ const argTypes = argTypeNames.map(typeFor);
27
+ this.functions.set(name, this.dll.func(name, returnType, argTypes));
28
+ }
29
+
30
+ return this.functions.get(name);
31
+ }
32
+
33
+ bindAll() {
34
+ for (const name of functionNames()) {
35
+ this.getFunction(name);
36
+ }
37
+ }
38
+ }
39
+
40
+ function typeFor(name) {
41
+ const type = nativeTypes.TYPES[name];
42
+ if (type === undefined) {
43
+ throw new Error(`Unknown GeoKernel native type: ${name}`);
44
+ }
45
+
46
+ return type;
47
+ }
48
+
49
+ function functionNames() {
50
+ return Object.keys(SIGNATURES);
51
+ }
52
+
53
+ function createNativeLibrary(binDir) {
54
+ return new GeoKernelNativeLibrary(binDir);
55
+ }
56
+
57
+ module.exports = {
58
+ ...nativeTypes,
59
+ GeoKernelNativeLibrary,
60
+ SIGNATURES,
61
+ createNativeLibrary,
62
+ functionNames,
63
+ };
package/src/runtime.js ADDED
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+
6
+ function packageRoot() {
7
+ return path.resolve(__dirname, "..");
8
+ }
9
+
10
+ function findBinDir(binDir) {
11
+ const candidates = [
12
+ binDir,
13
+ process.env.GEOKERNEL_BIN,
14
+ path.join(packageRoot(), "bin"),
15
+ "D:\\projects\\GeoKernel\\outputs\\Release",
16
+ ].filter(Boolean);
17
+
18
+ for (const candidate of candidates) {
19
+ const dllPath = path.join(candidate, "GeoKernel.Viewer.dll");
20
+ if (fs.existsSync(dllPath)) {
21
+ return candidate;
22
+ }
23
+ }
24
+
25
+ throw new Error(`Could not find GeoKernel.Viewer.dll. Searched: ${candidates.join(", ")}`);
26
+ }
27
+
28
+ function prependPath(value) {
29
+ const parts = (process.env.PATH || "").split(path.delimiter).filter(Boolean);
30
+ const exists = parts.some((part) => part.toLowerCase() === value.toLowerCase());
31
+ if (!exists) {
32
+ process.env.PATH = `${value}${path.delimiter}${process.env.PATH || ""}`;
33
+ }
34
+ }
35
+
36
+ function configureRuntimeEnvironment(binDir) {
37
+ prependPath(binDir);
38
+
39
+ const assetsDir = path.join(packageRoot(), "assets", "images");
40
+ if (fs.existsSync(assetsDir)) {
41
+ process.env.GEOKERNEL_ICON_DIR ||= assetsDir;
42
+ }
43
+
44
+ const gdalData = path.join(binDir, "gdal-data");
45
+ if (fs.existsSync(gdalData)) {
46
+ process.env.GDAL_DATA ||= gdalData;
47
+ }
48
+
49
+ const projData = path.join(binDir, "proj-data");
50
+ if (fs.existsSync(projData)) {
51
+ process.env.PROJ_LIB ||= projData;
52
+ }
53
+
54
+ const gdalPlugins = path.join(binDir, "gdalplugins");
55
+ if (fs.existsSync(gdalPlugins)) {
56
+ process.env.GDAL_DRIVER_PATH ||= gdalPlugins;
57
+ }
58
+
59
+ const qtPlugins = path.join(binDir, "plugins");
60
+ const qtPlatforms = path.join(qtPlugins, "platforms");
61
+ if (fs.existsSync(qtPlatforms)) {
62
+ process.env.QT_PLUGIN_PATH ||= qtPlugins;
63
+ process.env.QT_QPA_PLATFORM_PLUGIN_PATH ||= qtPlatforms;
64
+ }
65
+ }
66
+
67
+ module.exports = {
68
+ configureRuntimeEnvironment,
69
+ findBinDir,
70
+ packageRoot,
71
+ };
package/src/styles.js ADDED
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ class MapStyle {
4
+ constructor(background, fillColor, lineColor, pointColor, selectedLineColor, fillOpacity = 220, lineWidth = 0.9, pointSize = 6.0) {
5
+ this.background = background;
6
+ this.fillColor = fillColor;
7
+ this.lineColor = lineColor;
8
+ this.pointColor = pointColor;
9
+ this.selectedLineColor = selectedLineColor;
10
+ this.fillOpacity = fillOpacity;
11
+ this.lineWidth = lineWidth;
12
+ this.pointSize = pointSize;
13
+ }
14
+
15
+ toLayerStyleJson() {
16
+ return {
17
+ fillColor: this.fillColor,
18
+ fillOpacity: this.fillOpacity,
19
+ lineColor: this.lineColor,
20
+ lineWidth: this.lineWidth,
21
+ pointColor: this.pointColor,
22
+ pointSize: this.pointSize,
23
+ selectedLineColor: this.selectedLineColor,
24
+ selectedLineWidth: Math.max(2.0, this.lineWidth + 1.2),
25
+ labelColor: "#263B3A",
26
+ labelFontFamily: "Segoe UI",
27
+ labelFontSize: 10,
28
+ labelHaloEnabled: true,
29
+ labelHaloColor: "#FFFFFF",
30
+ labelHaloWidth: 1.8,
31
+ };
32
+ }
33
+ }
34
+
35
+ const MAP_STYLES = {
36
+ "soft-professional": new MapStyle("#F7F9F8", "#DDEBE7", "#6F8D88", "#E85D3D", "#FFD166", 215, 0.9, 6.0),
37
+ "classic-gis": new MapStyle("#FFFFFF", "#E8F0EA", "#7B8F88", "#D9534F", "#00AEEF", 220, 0.9, 6.0),
38
+ "dark": new MapStyle("#101418", "#1F2A2E", "#5F7F7A", "#FF6B4A", "#FFD166", 225, 0.9, 6.0),
39
+ "blueprint": new MapStyle("#0F2A44", "#143E5E", "#6AB7FF", "#FFD166", "#FF595E", 210, 1.0, 6.0),
40
+ "satellite-overlay": new MapStyle("#1B1B1B", "#FFFFFF", "#FFFFFF", "#FFD166", "#FF9F1C", 8, 1.1, 6.0),
41
+ "vintage-map": new MapStyle("#F8F2DE", "#EFE6C9", "#947E52", "#8B5E34", "#B85C38", 230, 1.0, 6.0),
42
+ "pastel": new MapStyle("#FAFAFA", "#E8F4F0", "#95B8AF", "#F28C6A", "#7DCE82", 225, 0.9, 6.0),
43
+ "midnight-blue": new MapStyle("#08141D", "#112531", "#5B9FB2", "#FF8A5B", "#49D6FF", 230, 1.0, 6.0),
44
+ "monochrome": new MapStyle("#FFFFFF", "#FFFFFF", "#000000", "#000000", "#666666", 255, 1.0, 6.0),
45
+ "neon": new MapStyle("#0B0B0B", "#1B1B1B", "#00FFFF", "#00FF88", "#FF00FF", 230, 1.0, 7.0),
46
+ "google-light": new MapStyle("#F2F1EC", "#F2F1EC", "#C9C9C9", "#EA4335", "#4285F4", 235, 0.8, 6.0),
47
+ "arcgis-pro-modern": new MapStyle("#EEF4EF", "#EEF4EF", "#A3B2A4", "#C94F3D", "#00A2FF", 230, 0.9, 6.0),
48
+ "qgis-green": new MapStyle("#E4F1D9", "#E4F1D9", "#719C5A", "#D95F02", "#F3B600", 230, 0.9, 6.0),
49
+ "github": new MapStyle("#F6F8FA", "#EAF2F8", "#8AA4B0", "#CF222E", "#0969DA", 230, 0.9, 6.0),
50
+ "material-design": new MapStyle("#FAFAFA", "#FAFAFA", "#79747E", "#6750A4", "#FFB74D", 230, 0.9, 6.0),
51
+ };
52
+
53
+ function argb(color, alpha = 255) {
54
+ const normalized = color.trim().replace(/^#/, "");
55
+ if (!/^[0-9a-fA-F]{6}$/.test(normalized)) {
56
+ throw new Error(`Expected #RRGGBB color, got ${color}`);
57
+ }
58
+
59
+ const red = parseInt(normalized.slice(0, 2), 16);
60
+ const green = parseInt(normalized.slice(2, 4), 16);
61
+ const blue = parseInt(normalized.slice(4, 6), 16);
62
+ const unsigned = ((alpha & 0xff) << 24) | (red << 16) | (green << 8) | blue;
63
+ return unsigned > 0x7fffffff ? unsigned - 0x100000000 : unsigned;
64
+ }
65
+
66
+ module.exports = {
67
+ MAP_STYLES,
68
+ MapStyle,
69
+ argb,
70
+ };
package/src/types.js ADDED
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+
3
+ const ViewerTool = Object.freeze({
4
+ PAN: 0,
5
+ ZOOM_BOX: 1,
6
+ INFO: 2,
7
+ SELECT: 3,
8
+ ADD_POINT: 4,
9
+ ADD_POLYLINE: 5,
10
+ ADD_POLYGON: 6,
11
+ MOVE_FEATURE: 7,
12
+ ROUTE: 8,
13
+ EDIT_VERTICES: 9,
14
+ });
15
+
16
+ const ShapeType = Object.freeze({
17
+ UNKNOWN: 0,
18
+ POINT: 1,
19
+ POLYLINE: 3,
20
+ POLYGON: 5,
21
+ MULTI_POINT: 8,
22
+ POINT_Z: 11,
23
+ POLYLINE_Z: 13,
24
+ POLYGON_Z: 15,
25
+ MULTI_POINT_Z: 18,
26
+ });
27
+
28
+ const SpatialIndexType = Object.freeze({
29
+ LINEAR: 0,
30
+ RTREE: 1,
31
+ RTREE_HILBERT: 2,
32
+ QUAD_TREE: 3,
33
+ });
34
+
35
+ const RenderBackendPreference = Object.freeze({
36
+ AUTO: 0,
37
+ QT_PAINTER: 1,
38
+ SKIA_CPU: 2,
39
+ SKIA_GPU: 3,
40
+ });
41
+
42
+ const RoutingCostMetric = Object.freeze({
43
+ DISTANCE: 0,
44
+ TRAVEL_TIME: 1,
45
+ });
46
+
47
+ const OverlayAnchor = Object.freeze({
48
+ NONE: 0,
49
+ TOP_LEFT: 1,
50
+ TOP_RIGHT: 2,
51
+ BOTTOM_LEFT: 3,
52
+ BOTTOM_RIGHT: 4,
53
+ });
54
+
55
+ const MeasureMode = Object.freeze({
56
+ DISTANCE: 0,
57
+ AREA: 1,
58
+ });
59
+
60
+ const ClassificationMethod = Object.freeze({
61
+ MANUAL: 0,
62
+ DEFINED_INTERVAL: 1,
63
+ EQUAL_INTERVAL: 2,
64
+ QUANTILE: 3,
65
+ NATURAL_BREAKS: 4,
66
+ QUARTILE: 5,
67
+ STANDARD_DEVIATION: 6,
68
+ STANDARD_DEVIATION_WITH_CENTRAL: 7,
69
+ GEOMETRICAL_INTERVAL: 8,
70
+ KMEANS: 9,
71
+ KMEANS_SPATIAL: 10,
72
+ });
73
+
74
+ const ColorRampMode = Object.freeze({
75
+ CONTINUOUS: 0,
76
+ DISCRETE: 1,
77
+ });
78
+
79
+ const SymbolStyleTarget = Object.freeze({
80
+ COLOR: 0,
81
+ SIZE_OR_WIDTH: 1,
82
+ OUTLINE_COLOR: 2,
83
+ OUTLINE_WIDTH: 3,
84
+ });
85
+
86
+ function point(x, y) {
87
+ return Object.freeze({ x, y });
88
+ }
89
+
90
+ function extent(xMin, yMin, xMax, yMax) {
91
+ return Object.freeze({ xMin, yMin, xMax, yMax });
92
+ }
93
+
94
+ function routeSummary(value) {
95
+ return Object.freeze({
96
+ succeeded: Boolean(value.succeeded),
97
+ totalDistance: value.totalDistance,
98
+ totalTime: value.totalTime,
99
+ cost: value.cost,
100
+ fromSnapDistance: value.fromSnapDistance,
101
+ toSnapDistance: value.toSnapDistance,
102
+ routeLayerIndex: value.routeLayerIndex,
103
+ });
104
+ }
105
+
106
+ module.exports = {
107
+ ClassificationMethod,
108
+ ColorRampMode,
109
+ MeasureMode,
110
+ OverlayAnchor,
111
+ RenderBackendPreference,
112
+ RoutingCostMetric,
113
+ ShapeType,
114
+ SpatialIndexType,
115
+ SymbolStyleTarget,
116
+ ViewerTool,
117
+ extent,
118
+ point,
119
+ routeSummary,
120
+ };
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+
3
+ function jsonText(value) {
4
+ if (value === undefined || value === null) {
5
+ return "";
6
+ }
7
+
8
+ return typeof value === "string" ? value : JSON.stringify(value);
9
+ }
10
+
11
+ function parseJson(text, fallback) {
12
+ const trimmed = text.trim();
13
+ if (!trimmed) {
14
+ return fallback;
15
+ }
16
+
17
+ return JSON.parse(trimmed);
18
+ }
19
+
20
+ function readWideText(fn, handle, ...args) {
21
+ let bufferLength = 4096;
22
+
23
+ for (let attempt = 0; attempt < 4; attempt += 1) {
24
+ const out = ["\0".repeat(bufferLength)];
25
+ const length = fn(handle, ...args, out, bufferLength);
26
+ if (length < 0) {
27
+ throw new Error(`GeoKernel text call failed with result ${length}.`);
28
+ }
29
+
30
+ const text = trimNull(out[0]);
31
+ if (length < bufferLength - 1) {
32
+ return text;
33
+ }
34
+
35
+ bufferLength = Math.max(bufferLength * 2, length + 1);
36
+ }
37
+
38
+ throw new Error("GeoKernel text buffer was too small after multiple attempts.");
39
+ }
40
+
41
+ function trimNull(value) {
42
+ const index = value.indexOf("\0");
43
+ return index >= 0 ? value.slice(0, index) : value;
44
+ }
45
+
46
+ function readWideJson(fn, handle, ...args) {
47
+ return readWideText(fn, handle, ...args);
48
+ }
49
+
50
+ function xyArray(points) {
51
+ if (points instanceof Float64Array) {
52
+ return points;
53
+ }
54
+
55
+ if (!Array.isArray(points)) {
56
+ throw new TypeError("Expected an array of points.");
57
+ }
58
+
59
+ if (points.length === 0) {
60
+ return new Float64Array();
61
+ }
62
+
63
+ if (typeof points[0] === "number") {
64
+ return Float64Array.from(points);
65
+ }
66
+
67
+ const values = [];
68
+ for (const point of points) {
69
+ if (Array.isArray(point)) {
70
+ values.push(Number(point[0]), Number(point[1]));
71
+ } else {
72
+ values.push(Number(point.x), Number(point.y));
73
+ }
74
+ }
75
+
76
+ return Float64Array.from(values);
77
+ }
78
+
79
+ function partsArrays(parts) {
80
+ if (!Array.isArray(parts)) {
81
+ throw new TypeError("Expected an array of parts.");
82
+ }
83
+
84
+ const values = [];
85
+ const counts = [];
86
+ for (const part of parts) {
87
+ const flat = xyArray(part);
88
+ values.push(...flat);
89
+ counts.push(flat.length / 2);
90
+ }
91
+
92
+ return {
93
+ xy: Float64Array.from(values),
94
+ counts: Int32Array.from(counts),
95
+ };
96
+ }
97
+
98
+ function extentObject(value) {
99
+ if (Array.isArray(value)) {
100
+ return {
101
+ xMin: Number(value[0]),
102
+ yMin: Number(value[1]),
103
+ xMax: Number(value[2]),
104
+ yMax: Number(value[3]),
105
+ };
106
+ }
107
+
108
+ return {
109
+ xMin: Number(value.xMin ?? value.x_min),
110
+ yMin: Number(value.yMin ?? value.y_min),
111
+ xMax: Number(value.xMax ?? value.x_max),
112
+ yMax: Number(value.yMax ?? value.y_max),
113
+ };
114
+ }
115
+
116
+ module.exports = {
117
+ extentObject,
118
+ jsonText,
119
+ parseJson,
120
+ partsArrays,
121
+ readWideJson,
122
+ readWideText,
123
+ xyArray,
124
+ };