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.
- package/LICENSE +6 -0
- package/README.md +52 -0
- package/assets/images/FullExtent.svg +29 -0
- package/assets/images/GeoKernelAppIcon.ico +0 -0
- package/assets/images/Pan.svg +6 -0
- package/assets/images/RectangularZoom.svg +82 -0
- package/assets/images/ZoomIn.svg +10 -0
- package/assets/images/ZoomOut.svg +10 -0
- package/bin/GeoKernel.Core.dll +0 -0
- package/bin/GeoKernel.Formats.dll +0 -0
- package/bin/GeoKernel.Viewer.dll +0 -0
- package/bin/Qt6Core.dll +0 -0
- package/bin/Qt6Gui.dll +0 -0
- package/bin/Qt6Network.dll +0 -0
- package/bin/Qt6OpenGL.dll +0 -0
- package/bin/Qt6OpenGLWidgets.dll +0 -0
- package/bin/Qt6Sql.dll +0 -0
- package/bin/Qt6Widgets.dll +0 -0
- package/bin/README_LICENSE_PROFILE.txt +21 -0
- package/bin/gdal-data/GDALLogoBW.svg +138 -0
- package/bin/gdal-data/GDALLogoColor.svg +126 -0
- package/bin/gdal-data/GDALLogoGS.svg +126 -0
- package/bin/gdal-data/LICENSE.TXT +467 -0
- package/bin/gdal-data/cubewerx_extra.wkt +48 -0
- package/bin/gdal-data/ecw_cs.wkt +1453 -0
- package/bin/gdal-data/epsg.wkt +1 -0
- package/bin/gdal-data/esri_StatePlane_extra.wkt +631 -0
- package/bin/gdal-data/gdal_algorithm.schema.json +220 -0
- package/bin/gdal-data/gdalicon.png +0 -0
- package/bin/gdal-data/gdalinfo_output.schema.json +390 -0
- package/bin/gdal-data/gdalmdiminfo_output.schema.json +326 -0
- package/bin/gdal-data/gdalvrt.xsd +927 -0
- package/bin/gdal-data/gfs.xsd +246 -0
- package/bin/gdal-data/gml_registry.xml +117 -0
- package/bin/gdal-data/gml_registry.xsd +66 -0
- package/bin/gdal-data/inspire_cp_BasicPropertyUnit.gfs +57 -0
- package/bin/gdal-data/inspire_cp_CadastralBoundary.gfs +60 -0
- package/bin/gdal-data/inspire_cp_CadastralParcel.gfs +81 -0
- package/bin/gdal-data/inspire_cp_CadastralZoning.gfs +161 -0
- package/bin/gdal-data/jpfgdgml_AdmArea.gfs +59 -0
- package/bin/gdal-data/jpfgdgml_AdmBdry.gfs +49 -0
- package/bin/gdal-data/jpfgdgml_AdmPt.gfs +59 -0
- package/bin/gdal-data/jpfgdgml_BldA.gfs +54 -0
- package/bin/gdal-data/jpfgdgml_BldL.gfs +54 -0
- package/bin/gdal-data/jpfgdgml_Cntr.gfs +54 -0
- package/bin/gdal-data/jpfgdgml_CommBdry.gfs +49 -0
- package/bin/gdal-data/jpfgdgml_CommPt.gfs +59 -0
- package/bin/gdal-data/jpfgdgml_Cstline.gfs +54 -0
- package/bin/gdal-data/jpfgdgml_ElevPt.gfs +54 -0
- package/bin/gdal-data/jpfgdgml_GCP.gfs +94 -0
- package/bin/gdal-data/jpfgdgml_LeveeEdge.gfs +49 -0
- package/bin/gdal-data/jpfgdgml_RailCL.gfs +54 -0
- package/bin/gdal-data/jpfgdgml_RdASL.gfs +44 -0
- package/bin/gdal-data/jpfgdgml_RdArea.gfs +54 -0
- package/bin/gdal-data/jpfgdgml_RdCompt.gfs +59 -0
- package/bin/gdal-data/jpfgdgml_RdEdg.gfs +59 -0
- package/bin/gdal-data/jpfgdgml_RdMgtBdry.gfs +49 -0
- package/bin/gdal-data/jpfgdgml_RdSgmtA.gfs +59 -0
- package/bin/gdal-data/jpfgdgml_RvrMgtBdry.gfs +49 -0
- package/bin/gdal-data/jpfgdgml_SBAPt.gfs +49 -0
- package/bin/gdal-data/jpfgdgml_SBArea.gfs +54 -0
- package/bin/gdal-data/jpfgdgml_SBBdry.gfs +44 -0
- package/bin/gdal-data/jpfgdgml_WA.gfs +54 -0
- package/bin/gdal-data/jpfgdgml_WL.gfs +54 -0
- package/bin/gdal-data/jpfgdgml_WStrA.gfs +54 -0
- package/bin/gdal-data/jpfgdgml_WStrL.gfs +54 -0
- package/bin/gdal-data/leaflet_template.html +102 -0
- package/bin/gdal-data/ogr_fields_override.schema.json +125 -0
- package/bin/gdal-data/ogrinfo_output.schema.json +528 -0
- package/bin/gdal-data/ogrvrt.xsd +528 -0
- package/bin/gdal-data/osmconf.ini +134 -0
- package/bin/gdal-data/ozi_datum.csv +131 -0
- package/bin/gdal-data/ozi_ellips.csv +35 -0
- package/bin/gdal-data/pci_datum.txt +530 -0
- package/bin/gdal-data/pci_ellips.txt +129 -0
- package/bin/gdal-data/ruian_vf_ob_v1.gfs +1455 -0
- package/bin/gdal-data/ruian_vf_st_uvoh_v1.gfs +86 -0
- package/bin/gdal-data/ruian_vf_st_v1.gfs +1489 -0
- package/bin/gdal-data/ruian_vf_v1.gfs +2126 -0
- package/bin/gdal-data/stateplane.csv +259 -0
- package/bin/gdal-data/template_tiles.mapml +28 -0
- package/bin/gdal-data/tms_LINZAntarticaMapTileGrid.json +190 -0
- package/bin/gdal-data/tms_MapML_APSTILE.json +268 -0
- package/bin/gdal-data/tms_MapML_CBMTILE.json +346 -0
- package/bin/gdal-data/tms_NZTM2000.json +243 -0
- package/bin/gdal.dll +0 -0
- package/bin/gdalplugins/drivers.ini +279 -0
- package/bin/gdalplugins/gdal_ECW_JP2ECW.dll +0 -0
- package/bin/gdalplugins/gdal_JPEG.dll +0 -0
- package/bin/gdalplugins/gdal_MrSID.dll +0 -0
- package/bin/gdalplugins/gdal_PNG.dll +0 -0
- package/bin/gdalplugins/ogr_Arrow.dll +0 -0
- package/bin/gdalplugins/ogr_LIBKML.dll +0 -0
- package/bin/gdalplugins/ogr_Parquet.dll +0 -0
- package/bin/gdalplugins/ogr_XLS.dll +0 -0
- package/bin/license-profile.json +17 -0
- package/bin/licenses/README.txt +1 -0
- package/bin/proj-data/CH +22 -0
- package/bin/proj-data/GL27 +23 -0
- package/bin/proj-data/ITRF2000 +24 -0
- package/bin/proj-data/ITRF2008 +94 -0
- package/bin/proj-data/ITRF2014 +55 -0
- package/bin/proj-data/ITRF2020 +91 -0
- package/bin/proj-data/copyright +34 -0
- package/bin/proj-data/deformation_model.schema.json +582 -0
- package/bin/proj-data/nad.lst +142 -0
- package/bin/proj-data/nad27 +810 -0
- package/bin/proj-data/nad83 +745 -0
- package/bin/proj-data/other.extra +53 -0
- package/bin/proj-data/proj-config-version.cmake +44 -0
- package/bin/proj-data/proj-config.cmake +79 -0
- package/bin/proj-data/proj-targets-debug.cmake +19 -0
- package/bin/proj-data/proj-targets-release.cmake +19 -0
- package/bin/proj-data/proj-targets.cmake +107 -0
- package/bin/proj-data/proj.db +0 -0
- package/bin/proj-data/proj.ini +59 -0
- package/bin/proj-data/proj4-targets-debug.cmake +19 -0
- package/bin/proj-data/proj4-targets-release.cmake +19 -0
- package/bin/proj-data/proj4-targets.cmake +107 -0
- package/bin/proj-data/projjson.schema.json +1174 -0
- package/bin/proj-data/triangulation.schema.json +214 -0
- package/bin/proj-data/usage +9 -0
- package/bin/proj-data/vcpkg.spdx.json +1103 -0
- package/bin/proj-data/vcpkg_abi_info.txt +29 -0
- package/bin/proj-data/world +214 -0
- package/bin/use-license-profile.ps1 +4 -0
- package/package.json +42 -0
- package/src/index.js +20 -0
- package/src/native-signatures.js +251 -0
- package/src/native-types.js +101 -0
- package/src/native.js +63 -0
- package/src/runtime.js +71 -0
- package/src/styles.js +70 -0
- package/src/types.js +120 -0
- package/src/viewer-helpers.js +124 -0
- package/src/viewer.js +524 -0
package/src/viewer.js
ADDED
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
|
|
5
|
+
const { createNativeLibrary } = require("./native");
|
|
6
|
+
const { MAP_STYLES, argb } = require("./styles");
|
|
7
|
+
const {
|
|
8
|
+
ViewerTool,
|
|
9
|
+
extent,
|
|
10
|
+
point,
|
|
11
|
+
} = require("./types");
|
|
12
|
+
const {
|
|
13
|
+
extentObject,
|
|
14
|
+
jsonText,
|
|
15
|
+
parseJson,
|
|
16
|
+
partsArrays,
|
|
17
|
+
readWideJson,
|
|
18
|
+
readWideText,
|
|
19
|
+
xyArray,
|
|
20
|
+
} = require("./viewer-helpers");
|
|
21
|
+
|
|
22
|
+
class GeoKernelLibrary {
|
|
23
|
+
constructor(binDir) {
|
|
24
|
+
this.native = createNativeLibrary(binDir);
|
|
25
|
+
this.bind();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
bind() {
|
|
29
|
+
this.windowCreate = this.native.getFunction("GeoKernelWindow_Create");
|
|
30
|
+
this.windowDestroy = this.native.getFunction("GeoKernelWindow_Destroy");
|
|
31
|
+
this.windowShow = this.native.getFunction("GeoKernelWindow_Show");
|
|
32
|
+
this.windowIsVisible = this.native.getFunction("GeoKernelWindow_IsVisible");
|
|
33
|
+
this.windowSetCentralViewer = this.native.getFunction("GeoKernelWindow_SetCentralViewer");
|
|
34
|
+
this.windowAddNavigationToolbar = this.native.getFunction("GeoKernelWindow_AddNavigationToolbar");
|
|
35
|
+
this.processEvents = this.native.getFunction("GeoKernelViewer_ProcessEvents");
|
|
36
|
+
this.setActivationType = this.native.getFunction("GeoKernelViewer_SetActivationTypeName");
|
|
37
|
+
this.setLicenseKey = this.native.getFunction("GeoKernelViewer_SetLicenseKey");
|
|
38
|
+
this.setTool = this.native.getFunction("GeoKernelViewer_SetTool");
|
|
39
|
+
this.addLayerFile = this.native.getFunction("GeoKernelViewer_AddLayerFile");
|
|
40
|
+
this.setMapBackgroundColor = this.native.getFunction("GeoKernelViewer_SetMapBackgroundColor");
|
|
41
|
+
this.setLayerStyleJson = this.native.getFunction("GeoKernelViewer_SetLayerStyleJson");
|
|
42
|
+
this.fullExtent = this.native.getFunction("GeoKernelViewer_FullExtent");
|
|
43
|
+
this.zoomIn = this.native.getFunction("GeoKernelViewer_ZoomIn");
|
|
44
|
+
this.zoomOut = this.native.getFunction("GeoKernelViewer_ZoomOut");
|
|
45
|
+
this.refreshLayers = this.native.getFunction("GeoKernelViewer_RefreshLayers");
|
|
46
|
+
this.clearAll = this.native.getFunction("GeoKernelViewer_ClearAll");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function(name) {
|
|
50
|
+
return this.native.getFunction(name);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
class ViewerWindow {
|
|
55
|
+
constructor(options = {}) {
|
|
56
|
+
const width = options.width ?? 1200;
|
|
57
|
+
const height = options.height ?? 800;
|
|
58
|
+
const title = options.title ?? "GeoKernel";
|
|
59
|
+
this.library = new GeoKernelLibrary(options.binDir);
|
|
60
|
+
this.windowHandle = this.library.windowCreate(width, height, title);
|
|
61
|
+
if (!this.windowHandle) {
|
|
62
|
+
throw new Error("GeoKernelWindow_Create failed.");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
this.viewerHandle = this.library.windowSetCentralViewer(this.windowHandle);
|
|
66
|
+
if (!this.viewerHandle) {
|
|
67
|
+
this.library.windowDestroy(this.windowHandle);
|
|
68
|
+
throw new Error("GeoKernelWindow_SetCentralViewer failed.");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (options.navigationToolbar !== false) {
|
|
72
|
+
this.library.windowAddNavigationToolbar(this.windowHandle, this.viewerHandle);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
this.interval = null;
|
|
76
|
+
this.visibleOnce = false;
|
|
77
|
+
this.startedAt = 0;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
setActivationType(value) {
|
|
81
|
+
this.library.setActivationType(this.viewerHandle, value);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
setLicenseKey(value) {
|
|
85
|
+
this.library.setLicenseKey(this.viewerHandle, value);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
setTool(tool) {
|
|
89
|
+
this.library.setTool(this.viewerHandle, tool);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
getTool() {
|
|
93
|
+
return this._call("GeoKernelViewer_GetTool");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
addLayerFile(filePath, options) {
|
|
97
|
+
if (!fs.existsSync(filePath)) {
|
|
98
|
+
throw new Error(`Layer file not found: ${filePath}`);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const ok = options === undefined
|
|
102
|
+
? this.library.addLayerFile(this.viewerHandle, filePath)
|
|
103
|
+
: this._call("GeoKernelViewer_AddLayerFileWithOptionsJson", filePath, jsonText(options));
|
|
104
|
+
if (!ok) {
|
|
105
|
+
throw new Error(`GeoKernelViewer_AddLayerFile failed: ${filePath}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
addLayer(filePath, options) {
|
|
110
|
+
this.addLayerFile(filePath, options);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
addOpenStreetMapLayer(localCacheEnabled = true) {
|
|
114
|
+
return this._call("GeoKernelViewer_AddOpenStreetMapLayer", Boolean(localCacheEnabled));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
addXyzLayer(options) {
|
|
118
|
+
return this._call(
|
|
119
|
+
"GeoKernelViewer_AddXyzLayer",
|
|
120
|
+
options.name,
|
|
121
|
+
options.urlTemplate,
|
|
122
|
+
options.minZoom ?? 0,
|
|
123
|
+
options.maxZoom ?? 19,
|
|
124
|
+
options.tileSize ?? 256,
|
|
125
|
+
options.attribution ?? "",
|
|
126
|
+
options.localCacheEnabled ?? true,
|
|
127
|
+
options.cacheDirectory ?? "",
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
addWmsLayer(options) {
|
|
132
|
+
return this._call(
|
|
133
|
+
"GeoKernelViewer_AddWmsLayer",
|
|
134
|
+
options.name,
|
|
135
|
+
options.serviceUrl,
|
|
136
|
+
options.layers,
|
|
137
|
+
options.styles ?? "",
|
|
138
|
+
options.version ?? "1.3.0",
|
|
139
|
+
options.crs ?? "EPSG:3857",
|
|
140
|
+
options.format ?? "image/png",
|
|
141
|
+
options.transparent ?? true,
|
|
142
|
+
options.minZoom ?? 0,
|
|
143
|
+
options.maxZoom ?? 19,
|
|
144
|
+
options.tileSize ?? 256,
|
|
145
|
+
options.attribution ?? "",
|
|
146
|
+
options.localCacheEnabled ?? true,
|
|
147
|
+
options.cacheDirectory ?? "",
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
addWmtsLayer(options) {
|
|
152
|
+
return this._call(
|
|
153
|
+
"GeoKernelViewer_AddWmtsLayer",
|
|
154
|
+
options.name,
|
|
155
|
+
options.serviceUrl,
|
|
156
|
+
options.layer,
|
|
157
|
+
options.style ?? "",
|
|
158
|
+
options.format ?? "image/png",
|
|
159
|
+
options.tileMatrixSet ?? "",
|
|
160
|
+
options.customUrlTemplate ?? "",
|
|
161
|
+
options.minZoom ?? 0,
|
|
162
|
+
options.maxZoom ?? 19,
|
|
163
|
+
options.tileSize ?? 256,
|
|
164
|
+
options.attribution ?? "",
|
|
165
|
+
options.localCacheEnabled ?? true,
|
|
166
|
+
options.cacheDirectory ?? "",
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
addWfsLayer(options) {
|
|
171
|
+
return this._call(
|
|
172
|
+
"GeoKernelViewer_AddWfsLayer",
|
|
173
|
+
options.name,
|
|
174
|
+
options.serviceUrl,
|
|
175
|
+
options.typeName,
|
|
176
|
+
options.version ?? "2.0.0",
|
|
177
|
+
options.srsName ?? "EPSG:4326",
|
|
178
|
+
options.outputFormat ?? "application/json",
|
|
179
|
+
options.maxFeatures ?? 0,
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
addEmptyVectorLayer(name, shapeType, style) {
|
|
184
|
+
return this._call("GeoKernelViewer_AddEmptyVectorLayer", name, Number(shapeType), jsonText(style));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
addPointLayer(name, points, style) {
|
|
188
|
+
const xy = xyArray(points);
|
|
189
|
+
return this._call("GeoKernelViewer_AddPointLayer", name, xy, xy.length / 2, jsonText(style));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
addPolylineLayer(name, parts, style) {
|
|
193
|
+
const arrays = partsArrays(parts);
|
|
194
|
+
return this._call("GeoKernelViewer_AddPolylineLayer", name, arrays.xy, arrays.counts, arrays.counts.length, jsonText(style));
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
addPolygonLayer(name, rings, style) {
|
|
198
|
+
const arrays = partsArrays(rings);
|
|
199
|
+
return this._call("GeoKernelViewer_AddPolygonLayer", name, arrays.xy, arrays.counts, arrays.counts.length, jsonText(style));
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
setBackground(color) {
|
|
203
|
+
this.library.setMapBackgroundColor(this.viewerHandle, argb(color));
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
getBackground() {
|
|
207
|
+
return this._call("GeoKernelViewer_GetMapBackgroundColor");
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
setLayerStyle(index, style) {
|
|
211
|
+
const payload = typeof style.toLayerStyleJson === "function" ? style.toLayerStyleJson() : style;
|
|
212
|
+
const ok = this.library.setLayerStyleJson(this.viewerHandle, index, jsonText(payload));
|
|
213
|
+
if (!ok) {
|
|
214
|
+
throw new Error(`GeoKernelViewer_SetLayerStyleJson failed for layer ${index}.`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
layerStyle(index) {
|
|
219
|
+
return this._readJson("GeoKernelViewer_GetLayerStyleJson", {}, Number(index));
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
setMapStyle(name, layerIndex = 0) {
|
|
223
|
+
const style = MAP_STYLES[name];
|
|
224
|
+
if (!style) {
|
|
225
|
+
throw new Error(`Unknown map style '${name}'. Available: ${Object.keys(MAP_STYLES).sort().join(", ")}`);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
this.setBackground(style.background);
|
|
229
|
+
this.setLayerStyle(layerIndex, style);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
setMapStyleName(themeName, applyToExistingLayers = true) {
|
|
233
|
+
const ok = this._call("GeoKernelViewer_SetMapStyleName", themeName, Boolean(applyToExistingLayers));
|
|
234
|
+
if (!ok) {
|
|
235
|
+
throw new Error(`GeoKernelViewer_SetMapStyleName failed: ${themeName}`);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
setLayerSymbolRenderer(index, renderer) {
|
|
240
|
+
return this._call("GeoKernelViewer_SetLayerSymbolRendererJson", Number(index), jsonText(renderer));
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
layerSymbolRenderer(index) {
|
|
244
|
+
return this._readJson("GeoKernelViewer_GetLayerSymbolRendererJson", {}, Number(index));
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
clearLayerSymbolRenderer(index) {
|
|
248
|
+
return this._call("GeoKernelViewer_ClearLayerSymbolRenderer", Number(index));
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
colorRampNames() {
|
|
252
|
+
return this._readJson("GeoKernelViewer_GetColorRampNamesJson", []);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
containsColorRamp(name) {
|
|
256
|
+
return this._call("GeoKernelViewer_ContainsColorRamp", name);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
applyCategorizedRenderer(index, options) {
|
|
260
|
+
return this._call(
|
|
261
|
+
"GeoKernelViewer_ApplyLayerCategorizedRenderer",
|
|
262
|
+
Number(index),
|
|
263
|
+
options.fieldName,
|
|
264
|
+
options.colorRampName ?? "Unique",
|
|
265
|
+
options.categoryLimit ?? 64,
|
|
266
|
+
options.reverseColorRamp ?? false,
|
|
267
|
+
options.sampleLimit ?? 0,
|
|
268
|
+
options.styleTarget ?? 0,
|
|
269
|
+
options.startSize ?? 4.0,
|
|
270
|
+
options.endSize ?? 14.0,
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
applyGraduatedRenderer(index, options) {
|
|
275
|
+
const breaks = Float64Array.from(options.manualBreaks ?? []);
|
|
276
|
+
return this._call(
|
|
277
|
+
"GeoKernelViewer_ApplyLayerGraduatedRenderer",
|
|
278
|
+
Number(index),
|
|
279
|
+
options.fieldName,
|
|
280
|
+
options.method ?? 4,
|
|
281
|
+
options.classCount ?? 5,
|
|
282
|
+
options.colorRampName ?? "Viridis",
|
|
283
|
+
options.interval ?? 0.0,
|
|
284
|
+
breaks,
|
|
285
|
+
breaks.length,
|
|
286
|
+
options.colorRampMode ?? 0,
|
|
287
|
+
options.reverseColorRamp ?? false,
|
|
288
|
+
options.sampleLimit ?? 0,
|
|
289
|
+
options.styleTarget ?? 0,
|
|
290
|
+
options.startSize ?? 4.0,
|
|
291
|
+
options.endSize ?? 18.0,
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
show() {
|
|
296
|
+
this.library.windowShow(this.windowHandle);
|
|
297
|
+
this.processEvents();
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
openProject(projectPath) {
|
|
301
|
+
return this._call("GeoKernelViewer_OpenProject", projectPath);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
saveProject(projectPath) {
|
|
305
|
+
return this._call("GeoKernelViewer_SaveProject", projectPath);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
closeProject() {
|
|
309
|
+
this._call("GeoKernelViewer_CloseProject");
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
getViewExtent() {
|
|
313
|
+
const value = {};
|
|
314
|
+
const ok = this._call("GeoKernelViewer_GetViewExtent", value);
|
|
315
|
+
return ok ? extent(value.xMin, value.yMin, value.xMax, value.yMax) : null;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
setViewExtent(value) {
|
|
319
|
+
this._call("GeoKernelViewer_SetViewExtent", extentObject(value));
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
worldToScreen(x, y) {
|
|
323
|
+
const screenX = [0];
|
|
324
|
+
const screenY = [0];
|
|
325
|
+
const ok = this._call("GeoKernelViewer_WorldToScreen", Number(x), Number(y), screenX, screenY);
|
|
326
|
+
return ok ? point(screenX[0], screenY[0]) : null;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
screenToWorld(x, y) {
|
|
330
|
+
const worldX = [0];
|
|
331
|
+
const worldY = [0];
|
|
332
|
+
const ok = this._call("GeoKernelViewer_ScreenToWorld", Number(x), Number(y), worldX, worldY);
|
|
333
|
+
return ok ? point(worldX[0], worldY[0]) : null;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
fullExtent() {
|
|
337
|
+
this.library.fullExtent(this.viewerHandle);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
zoomIn(factor = 1.5) {
|
|
341
|
+
this.library.zoomIn(this.viewerHandle, factor);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
zoomOut(factor = 1.5) {
|
|
345
|
+
this.library.zoomOut(this.viewerHandle, factor);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
zoomAtPoint(screenX, screenY, factor = 1.5) {
|
|
349
|
+
this._call("GeoKernelViewer_ZoomAtPoint", Number(screenX), Number(screenY), Number(factor));
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
zoomToScreenRect(left, top, right, bottom) {
|
|
353
|
+
this._call("GeoKernelViewer_ZoomToScreenRect", Number(left), Number(top), Number(right), Number(bottom));
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
zoomToLayer(index) {
|
|
357
|
+
return this._call("GeoKernelViewer_ZoomToLayer", Number(index));
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
refreshLayers() {
|
|
361
|
+
this.library.refreshLayers(this.viewerHandle);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
layerCount() {
|
|
365
|
+
return this._call("GeoKernelViewer_GetLayerCount");
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
layerInfo(index) {
|
|
369
|
+
return this._readJson("GeoKernelViewer_GetLayerInfoJson", {}, Number(index));
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
layerInfoByName(name) {
|
|
373
|
+
return this._readJson("GeoKernelViewer_GetLayerInfoByNameJson", {}, name);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
layersInfo() {
|
|
377
|
+
return this._readJson("GeoKernelViewer_GetLayersInfoJson", []);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
layerDisplayText(index) {
|
|
381
|
+
return this._readText("GeoKernelViewer_GetLayerDisplayText", Number(index));
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
layerAttributeDefinitions(index) {
|
|
385
|
+
return this._readJson("GeoKernelViewer_GetLayerAttributeDefinitionsJson", [], Number(index));
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
layerFeatureCount(index) {
|
|
389
|
+
return this._call("GeoKernelViewer_GetLayerFeatureCount", Number(index));
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
layerFeatureAttributes(index, rowIndex) {
|
|
393
|
+
return this._readJson("GeoKernelViewer_GetLayerFeatureAttributesJson", {}, Number(index), Number(rowIndex));
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
layerProjectedExtent(index) {
|
|
397
|
+
const value = {};
|
|
398
|
+
const ok = this._call("GeoKernelViewer_GetLayerProjectedExtent", Number(index), value);
|
|
399
|
+
return ok ? extent(value.xMin, value.yMin, value.xMax, value.yMax) : null;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
layerShapeType(index) {
|
|
403
|
+
return this._call("GeoKernelViewer_GetLayerShapeType", Number(index));
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
moveLayer(fromIndex, toIndex) {
|
|
407
|
+
return this._call("GeoKernelViewer_MoveLayer", Number(fromIndex), Number(toIndex));
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
removeLayer(index) {
|
|
411
|
+
return this._call("GeoKernelViewer_RemoveLayer", Number(index));
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
removeLayerByName(name) {
|
|
415
|
+
return this._call("GeoKernelViewer_RemoveLayerByName", name);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
setLayerName(index, name) {
|
|
419
|
+
return this._call("GeoKernelViewer_SetLayerName", Number(index), name);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
setLayerVisible(index, visible) {
|
|
423
|
+
return this._call("GeoKernelViewer_SetLayerVisible", Number(index), Boolean(visible));
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
setLayerVisibleScaleRange(index, minVisibleScale, maxVisibleScale) {
|
|
427
|
+
return this._call(
|
|
428
|
+
"GeoKernelViewer_SetLayerVisibleScaleRange",
|
|
429
|
+
Number(index),
|
|
430
|
+
Number(minVisibleScale),
|
|
431
|
+
Number(maxVisibleScale),
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
clearLayerVisibleScaleRange(index) {
|
|
436
|
+
return this._call("GeoKernelViewer_ClearLayerVisibleScaleRange", Number(index));
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
clearShapes() {
|
|
440
|
+
this._call("GeoKernelViewer_ClearShapes");
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
clearLayers() {
|
|
444
|
+
this._call("GeoKernelViewer_ClearLayers");
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
clearAll() {
|
|
448
|
+
this._call("GeoKernelViewer_ClearAll");
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
processEvents() {
|
|
452
|
+
this.library.processEvents();
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
isVisible() {
|
|
456
|
+
return Boolean(this.library.windowIsVisible(this.windowHandle));
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
runUntilClosed(onClosed) {
|
|
460
|
+
if (this.interval) {
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
this.startedAt = Date.now();
|
|
465
|
+
this.visibleOnce = false;
|
|
466
|
+
this.interval = setInterval(() => {
|
|
467
|
+
this.processEvents();
|
|
468
|
+
const visible = this.isVisible();
|
|
469
|
+
if (visible) {
|
|
470
|
+
this.visibleOnce = true;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
if (!visible && (this.visibleOnce || Date.now() - this.startedAt > 1500)) {
|
|
474
|
+
this.close();
|
|
475
|
+
if (typeof onClosed === "function") {
|
|
476
|
+
onClosed();
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}, 16);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
close() {
|
|
483
|
+
if (this.interval) {
|
|
484
|
+
clearInterval(this.interval);
|
|
485
|
+
this.interval = null;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
if (this.viewerHandle) {
|
|
489
|
+
this.clearAll();
|
|
490
|
+
this.viewerHandle = null;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
if (this.windowHandle) {
|
|
494
|
+
this.library.windowDestroy(this.windowHandle);
|
|
495
|
+
this.windowHandle = null;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
_call(name, ...args) {
|
|
500
|
+
this._requireViewer();
|
|
501
|
+
return this.library.function(name)(this.viewerHandle, ...args);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
_readText(name, ...args) {
|
|
505
|
+
this._requireViewer();
|
|
506
|
+
return readWideText(this.library.function(name), this.viewerHandle, ...args);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
_readJson(name, fallback, ...args) {
|
|
510
|
+
this._requireViewer();
|
|
511
|
+
return parseJson(readWideJson(this.library.function(name), this.viewerHandle, ...args), fallback);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
_requireViewer() {
|
|
515
|
+
if (!this.viewerHandle) {
|
|
516
|
+
throw new Error("GeoKernel viewer is closed.");
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
module.exports = {
|
|
522
|
+
ViewerTool,
|
|
523
|
+
ViewerWindow,
|
|
524
|
+
};
|