@kispace-io/gs-lib 1.3.9 → 1.3.10
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/base-map-builder.d.ts +2 -2
- package/dist/base-map-builder.d.ts.map +1 -1
- package/dist/index.js +1728 -1886
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/base-map-builder.ts +4 -4
- package/tsconfig.json +12 -5
package/dist/index.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { v4 } from "@eclipse-lyra/core/externals/third-party";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
export * from "ol";
|
|
5
|
-
import * as olGeom from "ol/geom";
|
|
2
|
+
import { Feature, Map as Map$1, Overlay, View } from "ol";
|
|
3
|
+
import * as geom from "ol/geom";
|
|
6
4
|
import * as style from "ol/style";
|
|
7
5
|
import { Circle, Fill, Icon, RegularShape, Stroke, Style, Text } from "ol/style";
|
|
8
6
|
import * as source from "ol/source";
|
|
9
|
-
import {
|
|
7
|
+
import { GeoTIFF, OSM, TileWMS, WMTS, XYZ } from "ol/source";
|
|
10
8
|
import { optionsFromCapabilities } from "ol/source/WMTS";
|
|
11
9
|
import WMTSCapabilities from "ol/format/WMTSCapabilities";
|
|
12
10
|
import VectorSource from "ol/source/Vector";
|
|
@@ -14,348 +12,295 @@ import { bbox } from "ol/loadingstrategy";
|
|
|
14
12
|
import * as proj from "ol/proj";
|
|
15
13
|
import { transformExtent } from "ol/proj";
|
|
16
14
|
import * as format from "ol/format";
|
|
17
|
-
import {
|
|
15
|
+
import { GPX, GeoJSON } from "ol/format";
|
|
18
16
|
import TileLayer from "ol/layer/Tile";
|
|
19
17
|
import VectorLayer from "ol/layer/Vector";
|
|
20
|
-
import { apply } from "ol-mapbox-style";
|
|
21
|
-
import { apply as apply2 } from "ol-mapbox-style";
|
|
18
|
+
import { apply, apply as applyMapboxStyle } from "ol-mapbox-style";
|
|
22
19
|
import LayerGroup from "ol/layer/Group";
|
|
23
20
|
import { Control } from "ol/control";
|
|
24
|
-
import * as
|
|
25
|
-
import * as
|
|
21
|
+
import * as layer from "ol/layer";
|
|
22
|
+
import * as interaction from "ol/interaction";
|
|
26
23
|
import * as sphere from "ol/sphere";
|
|
27
24
|
import * as extent from "ol/extent";
|
|
28
25
|
import * as events from "ol/events";
|
|
29
26
|
import * as eventsCondition from "ol/events/condition";
|
|
30
|
-
import
|
|
31
|
-
import {
|
|
32
|
-
import { defaults } from "ol/
|
|
33
|
-
import { defaults as defaults2 } from "ol/control/defaults";
|
|
34
|
-
import { defaults as defaults$1 } from "ol/interaction/defaults";
|
|
35
|
-
import { defaults as defaults3 } from "ol/interaction/defaults";
|
|
27
|
+
import BaseLayer from "ol/layer/Base";
|
|
28
|
+
import { defaults as defaultControls } from "ol/control/defaults";
|
|
29
|
+
import { defaults as defaultInteractions } from "ol/interaction/defaults";
|
|
36
30
|
import * as lit from "@eclipse-lyra/core/externals/lit";
|
|
37
31
|
import { render } from "@eclipse-lyra/core/externals/lit";
|
|
38
|
-
import {
|
|
32
|
+
import { publish, subscribe, unsubscribe } from "@eclipse-lyra/core/core/events";
|
|
39
33
|
import "ol/ol.css";
|
|
40
34
|
import { v4 as v4$1 } from "uuid";
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
35
|
+
export * from "ol";
|
|
36
|
+
//#region \0rolldown/runtime.js
|
|
37
|
+
var __defProp = Object.defineProperty;
|
|
38
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
39
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
40
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
41
|
+
var __exportAll = (all, no_symbols) => {
|
|
42
|
+
let target = {};
|
|
43
|
+
for (var name in all) __defProp(target, name, {
|
|
44
|
+
get: all[name],
|
|
45
|
+
enumerable: true
|
|
46
|
+
});
|
|
47
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
48
|
+
return target;
|
|
49
|
+
};
|
|
50
|
+
var __copyProps = (to, from, except, desc) => {
|
|
51
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
52
|
+
key = keys[i];
|
|
53
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
54
|
+
get: ((k) => from[k]).bind(null, key),
|
|
55
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return to;
|
|
59
|
+
};
|
|
60
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/gs-model.ts
|
|
63
|
+
var KEY_LABEL = "label";
|
|
64
|
+
var KEY_NAME = "name";
|
|
65
|
+
var KEY_URL = "url";
|
|
66
|
+
var KEY_FORMAT = "format";
|
|
67
|
+
var KEY_ICON_PATH = "iconPath";
|
|
68
|
+
var KEY_STATE = "_state";
|
|
69
|
+
var KEY_SRC = "src";
|
|
70
|
+
var KEY_SOURCETYPE = "sourceType";
|
|
71
|
+
var KEY_ENV = "_env";
|
|
72
|
+
var KEY_GS_MANAGED = "gsManaged";
|
|
73
|
+
var KEY_SETTINGS = "settings";
|
|
74
|
+
var KEY_UUID = "uuid";
|
|
75
|
+
var KEY_EVENT_SUBSCRIPTIONS = "_eventSubscriptions";
|
|
76
|
+
var LAYER_GEOCODED_MARKERS = "geocoded-markers";
|
|
74
77
|
function ensureUuid(obj) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
return obj;
|
|
78
|
+
if (!obj.uuid) obj.uuid = v4();
|
|
79
|
+
return obj;
|
|
79
80
|
}
|
|
80
81
|
function ensureUuidsRecursive(obj) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
if ("overlays" in obj && Array.isArray(obj.overlays)) {
|
|
96
|
-
obj.overlays.forEach((overlay) => ensureUuid(overlay));
|
|
97
|
-
}
|
|
98
|
-
if ("controls" in obj && Array.isArray(obj.controls)) {
|
|
99
|
-
obj.controls.forEach((control) => ensureUuid(control));
|
|
100
|
-
}
|
|
101
|
-
if ("interactions" in obj && Array.isArray(obj.interactions)) {
|
|
102
|
-
obj.interactions.forEach((interaction) => ensureUuid(interaction));
|
|
103
|
-
}
|
|
104
|
-
if ("view" in obj && obj.view) {
|
|
105
|
-
ensureUuid(obj.view);
|
|
106
|
-
}
|
|
107
|
-
return obj;
|
|
82
|
+
ensureUuid(obj);
|
|
83
|
+
if ("geometry" in obj && obj.geometry) ensureUuid(obj.geometry);
|
|
84
|
+
if ("source" in obj && obj.source) {
|
|
85
|
+
const source = obj.source;
|
|
86
|
+
ensureUuid(source);
|
|
87
|
+
if (source.features && Array.isArray(source.features)) source.features.forEach((feature) => ensureUuidsRecursive(feature));
|
|
88
|
+
}
|
|
89
|
+
if ("layers" in obj && Array.isArray(obj.layers)) obj.layers.forEach((layer) => ensureUuidsRecursive(layer));
|
|
90
|
+
if ("overlays" in obj && Array.isArray(obj.overlays)) obj.overlays.forEach((overlay) => ensureUuid(overlay));
|
|
91
|
+
if ("controls" in obj && Array.isArray(obj.controls)) obj.controls.forEach((control) => ensureUuid(control));
|
|
92
|
+
if ("interactions" in obj && Array.isArray(obj.interactions)) obj.interactions.forEach((interaction) => ensureUuid(interaction));
|
|
93
|
+
if ("view" in obj && obj.view) ensureUuid(obj.view);
|
|
94
|
+
return obj;
|
|
108
95
|
}
|
|
109
|
-
var GsSourceType = /* @__PURE__ */ (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
var GsLayerType = /* @__PURE__ */ (
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
var GsGeometryType = /* @__PURE__ */ (
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
96
|
+
var GsSourceType = /* @__PURE__ */ function(GsSourceType) {
|
|
97
|
+
GsSourceType["OSM"] = "OSM";
|
|
98
|
+
GsSourceType["GeoJSON"] = "GeoJSON";
|
|
99
|
+
GsSourceType["Features"] = "Features";
|
|
100
|
+
GsSourceType["KML"] = "KML";
|
|
101
|
+
GsSourceType["GeoTIFF"] = "GeoTIFF";
|
|
102
|
+
GsSourceType["GPX"] = "GPX";
|
|
103
|
+
GsSourceType["BM"] = "BM";
|
|
104
|
+
GsSourceType["WMS"] = "WMS";
|
|
105
|
+
GsSourceType["WMTS"] = "WMTS";
|
|
106
|
+
GsSourceType["XYZ"] = "XYZ";
|
|
107
|
+
GsSourceType["Scripted"] = "Scripted";
|
|
108
|
+
return GsSourceType;
|
|
109
|
+
}({});
|
|
110
|
+
var GsLayerType = /* @__PURE__ */ function(GsLayerType) {
|
|
111
|
+
GsLayerType["TILE"] = "TILE";
|
|
112
|
+
GsLayerType["VECTOR"] = "VECTOR";
|
|
113
|
+
GsLayerType["GROUP"] = "GROUP";
|
|
114
|
+
GsLayerType["SCRIPTED"] = "SCRIPTED";
|
|
115
|
+
return GsLayerType;
|
|
116
|
+
}({});
|
|
117
|
+
var GsGeometryType = /* @__PURE__ */ function(GsGeometryType) {
|
|
118
|
+
GsGeometryType["Point"] = "Point";
|
|
119
|
+
GsGeometryType["MultiPoint"] = "MultiPoint";
|
|
120
|
+
GsGeometryType["Polygon"] = "Polygon";
|
|
121
|
+
GsGeometryType["MultiPolygon"] = "MultiPolygon";
|
|
122
|
+
GsGeometryType["LineString"] = "LineString";
|
|
123
|
+
GsGeometryType["MultiLineString"] = "MultiLineString";
|
|
124
|
+
GsGeometryType["Circle"] = "Circle";
|
|
125
|
+
GsGeometryType["LinearRing"] = "LinearRing";
|
|
126
|
+
return GsGeometryType;
|
|
127
|
+
}({});
|
|
128
|
+
var DEFAULT_STYLES = {
|
|
129
|
+
"default-point": {
|
|
130
|
+
id: "default-point",
|
|
131
|
+
image: {
|
|
132
|
+
type: "circle",
|
|
133
|
+
radius: 5,
|
|
134
|
+
fill: { color: "rgba(0, 100, 255, 0.8)" },
|
|
135
|
+
stroke: {
|
|
136
|
+
color: "white",
|
|
137
|
+
width: 2
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
"default-line": {
|
|
142
|
+
id: "default-line",
|
|
143
|
+
stroke: {
|
|
144
|
+
color: "rgba(0, 100, 255, 0.8)",
|
|
145
|
+
width: 2
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
"default-polygon": {
|
|
149
|
+
id: "default-polygon",
|
|
150
|
+
fill: { color: "rgba(0, 100, 255, 0.3)" },
|
|
151
|
+
stroke: {
|
|
152
|
+
color: "rgba(0, 100, 255, 0.8)",
|
|
153
|
+
width: 2
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
"selection": {
|
|
157
|
+
id: "selection",
|
|
158
|
+
image: {
|
|
159
|
+
type: "circle",
|
|
160
|
+
radius: 7,
|
|
161
|
+
fill: { color: "rgba(255, 255, 0, 0.3)" },
|
|
162
|
+
stroke: {
|
|
163
|
+
color: "rgba(255, 255, 0, 1)",
|
|
164
|
+
width: 3
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
stroke: {
|
|
168
|
+
color: "rgba(255, 255, 0, 1)",
|
|
169
|
+
width: 3
|
|
170
|
+
},
|
|
171
|
+
fill: { color: "rgba(255, 255, 0, 0.3)" }
|
|
172
|
+
}
|
|
182
173
|
};
|
|
183
174
|
function evaluateStyleRule(rule, feature, layerName) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
if (prop.operator === "equals") {
|
|
201
|
-
return featureValue === prop.value;
|
|
202
|
-
}
|
|
203
|
-
if (prop.operator === "not-equals") {
|
|
204
|
-
return featureValue !== prop.value;
|
|
205
|
-
}
|
|
206
|
-
if (prop.operator === "contains" && typeof featureValue === "string" && typeof prop.value === "string") {
|
|
207
|
-
return featureValue.includes(prop.value);
|
|
208
|
-
}
|
|
209
|
-
if (prop.operator === "greater-than" && typeof featureValue === "number" && typeof prop.value === "number") {
|
|
210
|
-
return featureValue > prop.value;
|
|
211
|
-
}
|
|
212
|
-
if (prop.operator === "less-than" && typeof featureValue === "number" && typeof prop.value === "number") {
|
|
213
|
-
return featureValue < prop.value;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
return true;
|
|
175
|
+
const condition = rule.condition;
|
|
176
|
+
if (condition.geometryType) {
|
|
177
|
+
if (!(Array.isArray(condition.geometryType) ? condition.geometryType : [condition.geometryType]).includes(feature.geometry.type)) return false;
|
|
178
|
+
}
|
|
179
|
+
if (condition.layerName && condition.layerName !== layerName) return false;
|
|
180
|
+
if (condition.property) {
|
|
181
|
+
const prop = condition.property;
|
|
182
|
+
const featureValue = feature.state?.[prop.key];
|
|
183
|
+
if (!prop.operator || prop.operator === "exists") return featureValue !== void 0;
|
|
184
|
+
if (prop.operator === "equals") return featureValue === prop.value;
|
|
185
|
+
if (prop.operator === "not-equals") return featureValue !== prop.value;
|
|
186
|
+
if (prop.operator === "contains" && typeof featureValue === "string" && typeof prop.value === "string") return featureValue.includes(prop.value);
|
|
187
|
+
if (prop.operator === "greater-than" && typeof featureValue === "number" && typeof prop.value === "number") return featureValue > prop.value;
|
|
188
|
+
if (prop.operator === "less-than" && typeof featureValue === "number" && typeof prop.value === "number") return featureValue < prop.value;
|
|
189
|
+
}
|
|
190
|
+
return true;
|
|
217
191
|
}
|
|
218
192
|
function getStyleForFeature(feature, rules, stylesMap, layerName) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
if (evaluateStyleRule(rule, feature, layerName)) {
|
|
222
|
-
return stylesMap[rule.styleId];
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
return void 0;
|
|
193
|
+
const sortedRules = [...rules].sort((a, b) => (b.priority || 0) - (a.priority || 0));
|
|
194
|
+
for (const rule of sortedRules) if (evaluateStyleRule(rule, feature, layerName)) return stylesMap[rule.styleId];
|
|
226
195
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
priority: 0
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
id: "default-polygons",
|
|
254
|
-
condition: {
|
|
255
|
-
geometryType: [
|
|
256
|
-
"Polygon",
|
|
257
|
-
"MultiPolygon",
|
|
258
|
-
"Circle"
|
|
259
|
-
/* Circle */
|
|
260
|
-
]
|
|
261
|
-
},
|
|
262
|
-
styleId: "default-polygon",
|
|
263
|
-
priority: 0
|
|
264
|
-
}
|
|
196
|
+
var DEFAULT_STYLE_RULES = [
|
|
197
|
+
{
|
|
198
|
+
id: "default-points",
|
|
199
|
+
condition: { geometryType: [GsGeometryType.Point, GsGeometryType.MultiPoint] },
|
|
200
|
+
styleId: "default-point",
|
|
201
|
+
priority: 0
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
id: "default-lines",
|
|
205
|
+
condition: { geometryType: [GsGeometryType.LineString, GsGeometryType.MultiLineString] },
|
|
206
|
+
styleId: "default-line",
|
|
207
|
+
priority: 0
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
id: "default-polygons",
|
|
211
|
+
condition: { geometryType: [
|
|
212
|
+
GsGeometryType.Polygon,
|
|
213
|
+
GsGeometryType.MultiPolygon,
|
|
214
|
+
GsGeometryType.Circle
|
|
215
|
+
] },
|
|
216
|
+
styleId: "default-polygon",
|
|
217
|
+
priority: 0
|
|
218
|
+
}
|
|
265
219
|
];
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
state: {},
|
|
283
|
-
styles: { ...DEFAULT_STYLES },
|
|
284
|
-
styleRules: [...DEFAULT_STYLE_RULES]
|
|
220
|
+
var DEFAULT_GSMAP = ensureUuid({
|
|
221
|
+
view: ensureUuid({
|
|
222
|
+
center: [0, 0],
|
|
223
|
+
zoom: 0,
|
|
224
|
+
projection: "EPSG:3857"
|
|
225
|
+
}),
|
|
226
|
+
layers: [ensureUuid({
|
|
227
|
+
type: GsLayerType.TILE,
|
|
228
|
+
source: ensureUuid({ type: GsSourceType.OSM })
|
|
229
|
+
})],
|
|
230
|
+
overlays: [],
|
|
231
|
+
controls: [],
|
|
232
|
+
interactions: [],
|
|
233
|
+
state: {},
|
|
234
|
+
styles: { ...DEFAULT_STYLES },
|
|
235
|
+
styleRules: [...DEFAULT_STYLE_RULES]
|
|
285
236
|
});
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
const jsRuntime = {
|
|
299
|
-
async run(src, vars) {
|
|
300
|
-
const mod = await import(
|
|
301
|
-
/* @vite-ignore */
|
|
302
|
-
src
|
|
303
|
-
);
|
|
304
|
-
const fn = mod instanceof Function ? mod : mod.default;
|
|
305
|
-
if (typeof fn !== "function") {
|
|
306
|
-
throw new Error(`Scripted layer module at "${src}" must export a default function`);
|
|
307
|
-
}
|
|
308
|
-
return fn(vars);
|
|
309
|
-
}
|
|
237
|
+
//#endregion
|
|
238
|
+
//#region src/scripted-runtime-registry.ts
|
|
239
|
+
var ScriptedRuntimeRegistryImpl = class {
|
|
240
|
+
constructor() {
|
|
241
|
+
this.runtimes = /* @__PURE__ */ new Map();
|
|
242
|
+
}
|
|
243
|
+
register(lang, runtime) {
|
|
244
|
+
this.runtimes.set(lang, runtime);
|
|
245
|
+
}
|
|
246
|
+
get(lang) {
|
|
247
|
+
return this.runtimes.get(lang);
|
|
248
|
+
}
|
|
310
249
|
};
|
|
311
|
-
scriptedRuntimeRegistry
|
|
250
|
+
var scriptedRuntimeRegistry = new ScriptedRuntimeRegistryImpl();
|
|
251
|
+
scriptedRuntimeRegistry.register("javascript", { async run(src, vars) {
|
|
252
|
+
const mod = await import(
|
|
253
|
+
/* @vite-ignore */
|
|
254
|
+
src
|
|
255
|
+
);
|
|
256
|
+
const fn = mod instanceof Function ? mod : mod.default;
|
|
257
|
+
if (typeof fn !== "function") throw new Error(`Scripted layer module at "${src}" must export a default function`);
|
|
258
|
+
return fn(vars);
|
|
259
|
+
} });
|
|
260
|
+
//#endregion
|
|
261
|
+
//#region src/map-renderer.ts
|
|
312
262
|
function findLayerByUuid(gsMap, uuid) {
|
|
313
|
-
|
|
263
|
+
return gsMap.layers.find((layer) => layer.uuid === uuid);
|
|
314
264
|
}
|
|
315
265
|
function findLayerIndexByUuid(gsMap, uuid) {
|
|
316
|
-
|
|
266
|
+
return gsMap.layers.findIndex((layer) => layer.uuid === uuid);
|
|
317
267
|
}
|
|
318
268
|
function findControlByUuid(gsMap, uuid) {
|
|
319
|
-
|
|
269
|
+
return gsMap.controls.find((control) => control.uuid === uuid);
|
|
320
270
|
}
|
|
321
271
|
function findControlIndexByUuid(gsMap, uuid) {
|
|
322
|
-
|
|
272
|
+
return gsMap.controls.findIndex((control) => control.uuid === uuid);
|
|
323
273
|
}
|
|
324
274
|
function findOverlayByUuid(gsMap, uuid) {
|
|
325
|
-
|
|
275
|
+
return gsMap.overlays.find((overlay) => overlay.uuid === uuid);
|
|
326
276
|
}
|
|
327
277
|
function findOverlayIndexByUuid(gsMap, uuid) {
|
|
328
|
-
|
|
278
|
+
return gsMap.overlays.findIndex((overlay) => overlay.uuid === uuid);
|
|
329
279
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}
|
|
340
|
-
return void 0;
|
|
341
|
-
})
|
|
342
|
-
);
|
|
343
|
-
};
|
|
344
|
-
}
|
|
345
|
-
});
|
|
280
|
+
var createProxy = (operations) => {
|
|
281
|
+
return new Proxy({}, { get: (_, prop) => {
|
|
282
|
+
return async (...args) => {
|
|
283
|
+
await Promise.all(operations.map((operation) => {
|
|
284
|
+
const fn = operation[prop];
|
|
285
|
+
if (typeof fn === "function") return fn.apply(operation, args);
|
|
286
|
+
}));
|
|
287
|
+
};
|
|
288
|
+
} });
|
|
346
289
|
};
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region src/base-map-builder.ts
|
|
292
|
+
/**
|
|
293
|
+
* Generate the entry point JavaScript code for the map application
|
|
294
|
+
*/
|
|
347
295
|
function generateAppJs(vars) {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
return `${escapedSrc}: script${index}`;
|
|
357
|
-
}).join(",\n ");
|
|
358
|
-
return `
|
|
296
|
+
const scriptPaths = [...vars.gsMap.controls || [], ...vars.gsMap.overlays || []].map((script) => script.src).filter((src) => src);
|
|
297
|
+
const scriptImports = scriptPaths.map((src, index) => {
|
|
298
|
+
return `import script${index} from '${src.replace(/`/g, "\\`").replace(/\$/g, "\\$")}'`;
|
|
299
|
+
});
|
|
300
|
+
const modulesMap = scriptPaths.map((src, index) => {
|
|
301
|
+
return `${JSON.stringify(src)}: script${index}`;
|
|
302
|
+
}).join(",\n ");
|
|
303
|
+
return `
|
|
359
304
|
import {gsLib} from "${vars.gsLibPath}"
|
|
360
305
|
import "./gs-lib/gs-lib.css"
|
|
361
306
|
|
|
@@ -377,1645 +322,1542 @@ export const renderMap = (mapContainerSelector) => {
|
|
|
377
322
|
}
|
|
378
323
|
`;
|
|
379
324
|
}
|
|
325
|
+
/**
|
|
326
|
+
* Generate precache manifest for Workbox
|
|
327
|
+
*/
|
|
380
328
|
function generatePrecacheManifest(assets) {
|
|
381
|
-
|
|
329
|
+
return JSON.stringify(assets, null, 2);
|
|
382
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* Process service worker content by injecting precache manifest
|
|
333
|
+
*/
|
|
383
334
|
function processServiceWorker(content, precacheManifest) {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
);
|
|
391
|
-
} else {
|
|
392
|
-
return content.replace(
|
|
393
|
-
/workbox\.precaching\.precacheAndRoute\(/,
|
|
394
|
-
`self.__WB_MANIFEST = ${manifestJson};
|
|
395
|
-
workbox.precaching.precacheAndRoute(`
|
|
396
|
-
);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
return content;
|
|
335
|
+
if (precacheManifest) {
|
|
336
|
+
const manifestJson = generatePrecacheManifest(precacheManifest);
|
|
337
|
+
if (content.includes("self.__WB_MANIFEST")) return content.replace("self.__WB_MANIFEST || []", `${manifestJson}`);
|
|
338
|
+
else return content.replace(/workbox\.precaching\.precacheAndRoute\(/, `self.__WB_MANIFEST = ${manifestJson};\nworkbox.precaching.precacheAndRoute(`);
|
|
339
|
+
}
|
|
340
|
+
return content;
|
|
400
341
|
}
|
|
342
|
+
/**
|
|
343
|
+
* Process manifest content by updating title and version
|
|
344
|
+
*/
|
|
401
345
|
function processManifest(content, title, version) {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
346
|
+
const manifest = JSON.parse(content);
|
|
347
|
+
manifest.name = title;
|
|
348
|
+
manifest.short_name = title;
|
|
349
|
+
manifest.description = title;
|
|
350
|
+
manifest.version = version;
|
|
351
|
+
return JSON.stringify(manifest, null, 2);
|
|
408
352
|
}
|
|
353
|
+
/**
|
|
354
|
+
* Process HTML template by replacing title placeholder, app.js reference, and app.css reference
|
|
355
|
+
*/
|
|
409
356
|
function processHtml(content, title, appJsFilename, appCssFilename) {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
if (appCssFilename) {
|
|
415
|
-
processed = processed.replace(/href=["']app\.css["']/g, `href="${appCssFilename}"`);
|
|
416
|
-
}
|
|
417
|
-
return processed;
|
|
357
|
+
let processed = content.replace(/\$TITLE/g, title);
|
|
358
|
+
if (appJsFilename) processed = processed.replace(/\.\/app\.js/g, `./${appJsFilename}`);
|
|
359
|
+
if (appCssFilename) processed = processed.replace(/href=["']app\.css["']/g, `href="${appCssFilename}"`);
|
|
360
|
+
return processed;
|
|
418
361
|
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
relativePath = filePath.startsWith(outputDir) ? filePath : `${outputDir}/${filePath}`;
|
|
479
|
-
}
|
|
480
|
-
await fileSys.writeFile(relativePath, file.contents);
|
|
481
|
-
if (!mainOutputFile && filename.includes("app-") && filename.endsWith(".js")) {
|
|
482
|
-
mainOutputFile = filename;
|
|
483
|
-
}
|
|
484
|
-
if (!cssOutputFile && filename.includes("app-") && filename.endsWith(".css")) {
|
|
485
|
-
cssOutputFile = filename;
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
if (!mainOutputFile) {
|
|
489
|
-
throw new Error("Could not find main output file");
|
|
490
|
-
}
|
|
491
|
-
return {
|
|
492
|
-
js: extractFilename(mainOutputFile),
|
|
493
|
-
css: cssOutputFile ? extractFilename(cssOutputFile) : null
|
|
494
|
-
};
|
|
362
|
+
/**
|
|
363
|
+
* Bundle the application code using esbuild with hashed filenames
|
|
364
|
+
* @param esbuildInstance - The esbuild instance to use (esbuild-wasm for browser, esbuild for Node.js)
|
|
365
|
+
* @returns Object with both JS and CSS filenames (CSS may be null if not generated)
|
|
366
|
+
*/
|
|
367
|
+
async function bundleApp(entryPointPath, outputDir, _gsLibPath, fileSys, resolvePlugin, esbuildInstance, progress, currentStep, totalSteps) {
|
|
368
|
+
const updateProgress = (message) => {
|
|
369
|
+
if (progress) if (currentStep !== void 0) progress(++currentStep.value, message, totalSteps);
|
|
370
|
+
else progress(0, message, totalSteps);
|
|
371
|
+
};
|
|
372
|
+
updateProgress("Bundling and minifying code...");
|
|
373
|
+
const result = await esbuildInstance.build({
|
|
374
|
+
entryPoints: [entryPointPath],
|
|
375
|
+
bundle: true,
|
|
376
|
+
outdir: outputDir,
|
|
377
|
+
format: "esm",
|
|
378
|
+
minify: true,
|
|
379
|
+
plugins: [resolvePlugin],
|
|
380
|
+
entryNames: "[name]-[hash]",
|
|
381
|
+
external: [],
|
|
382
|
+
packages: "bundle",
|
|
383
|
+
write: false,
|
|
384
|
+
metafile: true
|
|
385
|
+
});
|
|
386
|
+
updateProgress("Saving bundled output...");
|
|
387
|
+
if (!result.outputFiles || result.outputFiles.length === 0) throw new Error("No output files generated by esbuild");
|
|
388
|
+
let mainOutputFile = null;
|
|
389
|
+
let cssOutputFile = null;
|
|
390
|
+
if (result.metafile && result.metafile.outputs) {
|
|
391
|
+
const entryName = "app";
|
|
392
|
+
for (const [outputPath, output] of Object.entries(result.metafile.outputs)) if (output && typeof output === "object" && "entryPoint" in output) {
|
|
393
|
+
if (outputPath.includes(entryName) && outputPath.endsWith(".js")) mainOutputFile = outputPath;
|
|
394
|
+
else if (outputPath.endsWith(".css")) cssOutputFile = outputPath;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
const extractFilename = (filePath) => {
|
|
398
|
+
const lastSlash = Math.max(filePath.lastIndexOf("/"), filePath.lastIndexOf("\\"));
|
|
399
|
+
return lastSlash >= 0 ? filePath.substring(lastSlash + 1) : filePath;
|
|
400
|
+
};
|
|
401
|
+
for (const file of result.outputFiles) {
|
|
402
|
+
let filePath = file.path || "";
|
|
403
|
+
let relativePath;
|
|
404
|
+
let filename;
|
|
405
|
+
if (filePath.startsWith("/") || filePath.length > 2 && filePath[1] === ":") {
|
|
406
|
+
filename = extractFilename(filePath);
|
|
407
|
+
relativePath = `${outputDir}/${filename}`;
|
|
408
|
+
} else {
|
|
409
|
+
filename = extractFilename(filePath);
|
|
410
|
+
relativePath = filePath.startsWith(outputDir) ? filePath : `${outputDir}/${filePath}`;
|
|
411
|
+
}
|
|
412
|
+
await fileSys.writeFile(relativePath, file.contents);
|
|
413
|
+
if (!mainOutputFile && filename.includes("app-") && filename.endsWith(".js")) mainOutputFile = filename;
|
|
414
|
+
if (!cssOutputFile && filename.includes("app-") && filename.endsWith(".css")) cssOutputFile = filename;
|
|
415
|
+
}
|
|
416
|
+
if (!mainOutputFile) throw new Error("Could not find main output file");
|
|
417
|
+
return {
|
|
418
|
+
js: extractFilename(mainOutputFile),
|
|
419
|
+
css: cssOutputFile ? extractFilename(cssOutputFile) : null
|
|
420
|
+
};
|
|
495
421
|
}
|
|
422
|
+
/**
|
|
423
|
+
* Create a standard GsLibFileCopier that uses FileSystem to read from gs-lib package
|
|
424
|
+
*/
|
|
496
425
|
function createFileSystemGsLibCopier(fs, gsLibPackagePath) {
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
},
|
|
516
|
-
async copyBinaryFile(srcPath, destPath) {
|
|
517
|
-
await copyFile(srcPath, destPath, false);
|
|
518
|
-
}
|
|
519
|
-
};
|
|
426
|
+
const copyFile = async (srcPath, destPath, asText, processor) => {
|
|
427
|
+
const fullSrcPath = `${gsLibPackagePath}/${srcPath}`;
|
|
428
|
+
let content = await fs.readFile(fullSrcPath);
|
|
429
|
+
if (asText) {
|
|
430
|
+
if (content instanceof Uint8Array) content = new TextDecoder().decode(content);
|
|
431
|
+
else content = content;
|
|
432
|
+
if (processor) content = await processor(content);
|
|
433
|
+
}
|
|
434
|
+
await fs.writeFile(destPath, content);
|
|
435
|
+
};
|
|
436
|
+
return {
|
|
437
|
+
async copyTextFile(srcPath, destPath, processor) {
|
|
438
|
+
await copyFile(srcPath, destPath, true, processor);
|
|
439
|
+
},
|
|
440
|
+
async copyBinaryFile(srcPath, destPath) {
|
|
441
|
+
await copyFile(srcPath, destPath, false);
|
|
442
|
+
}
|
|
443
|
+
};
|
|
520
444
|
}
|
|
445
|
+
/**
|
|
446
|
+
* Unified build function that works in both browser and Node.js
|
|
447
|
+
* This is the single source of truth for the build process
|
|
448
|
+
*/
|
|
521
449
|
async function buildMap(options, fs, resolvePlugin, esbuildInstance, config = {}, progress) {
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
// Hashed CSS filename handles versioning
|
|
620
|
-
...iconFiles.map((icon) => ({ url: `/assets/icons/${icon}`, revision: null }))
|
|
621
|
-
// Workbox will check file content
|
|
622
|
-
];
|
|
623
|
-
updateProgress("Processing service worker...");
|
|
624
|
-
await gsLibCopier.copyTextFile(
|
|
625
|
-
"public/pwa/sw.js",
|
|
626
|
-
`${outputDir}/sw.js`,
|
|
627
|
-
(content) => processServiceWorker(content, precacheManifest)
|
|
628
|
-
);
|
|
629
|
-
if (cleanAfterBuild) {
|
|
630
|
-
updateProgress("Cleaning up temporary files...");
|
|
631
|
-
if (fs.deleteDir) {
|
|
632
|
-
await fs.deleteDir(buildDir);
|
|
633
|
-
} else {
|
|
634
|
-
try {
|
|
635
|
-
const nodeFs = await import("fs/promises");
|
|
636
|
-
const path = await import("path");
|
|
637
|
-
const fullPath = path.resolve(process.cwd(), buildDir);
|
|
638
|
-
await nodeFs.rm(fullPath, { recursive: true, force: true });
|
|
639
|
-
} catch (error) {
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
updateProgress("Build completed!");
|
|
644
|
-
}
|
|
645
|
-
const ol = /* @__PURE__ */ _mergeNamespaces({
|
|
646
|
-
__proto__: null,
|
|
647
|
-
BaseLayer: Base,
|
|
648
|
-
applyMapboxStyle: apply,
|
|
649
|
-
defaultControls: defaults,
|
|
650
|
-
defaultInteractions: defaults$1,
|
|
651
|
-
events,
|
|
652
|
-
eventsCondition,
|
|
653
|
-
extent,
|
|
654
|
-
format,
|
|
655
|
-
geom: olGeom,
|
|
656
|
-
interaction: interactionNS,
|
|
657
|
-
layer: layerNS,
|
|
658
|
-
proj,
|
|
659
|
-
source,
|
|
660
|
-
sphere,
|
|
661
|
-
style
|
|
662
|
-
}, [ol$1]);
|
|
663
|
-
class GsOlAdapter {
|
|
664
|
-
constructor(olObject) {
|
|
665
|
-
this.map = olObject.getMap();
|
|
666
|
-
this.olObject = olObject;
|
|
667
|
-
}
|
|
668
|
-
getMap() {
|
|
669
|
-
return this.map;
|
|
670
|
-
}
|
|
671
|
-
getElement() {
|
|
672
|
-
return this.olObject.getElement();
|
|
673
|
-
}
|
|
674
|
-
render(strings) {
|
|
675
|
-
if (strings === void 0 && this.templateFunction) {
|
|
676
|
-
strings = this.templateFunction();
|
|
677
|
-
} else if (strings instanceof Function) {
|
|
678
|
-
this.templateFunction = strings;
|
|
679
|
-
strings = this.templateFunction();
|
|
680
|
-
}
|
|
681
|
-
if (strings) {
|
|
682
|
-
render(strings, this.getElement());
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
onRendered() {
|
|
686
|
-
}
|
|
687
|
-
style(styleJson) {
|
|
688
|
-
const style2 = this.getElement().style;
|
|
689
|
-
for (const property in styleJson) {
|
|
690
|
-
const value = styleJson[property];
|
|
691
|
-
style2.setProperty(property, value);
|
|
692
|
-
}
|
|
693
|
-
}
|
|
450
|
+
const { outputDir = "dist", buildDir = "__build", gsLibPath = `${buildDir}/gs-lib/index.js`, gsLibPackagePath, gsLibCopier: providedGsLibCopier, cleanBeforeBuild = true, cleanAfterBuild = true, copyAssets } = config;
|
|
451
|
+
const gsLibCopier = providedGsLibCopier || (gsLibPackagePath ? createFileSystemGsLibCopier(fs, gsLibPackagePath) : null);
|
|
452
|
+
if (!gsLibCopier) throw new Error("Either gsLibCopier or gsLibPackagePath must be provided");
|
|
453
|
+
const buildGsLibPath = gsLibPath;
|
|
454
|
+
let step = config.startingStep ?? 0;
|
|
455
|
+
const totalSteps = config.totalSteps;
|
|
456
|
+
const updateProgress = (message) => {
|
|
457
|
+
if (progress) progress(++step, message, totalSteps);
|
|
458
|
+
};
|
|
459
|
+
if (cleanBeforeBuild) {
|
|
460
|
+
updateProgress("Cleaning build directories...");
|
|
461
|
+
const cleanupPromises = [];
|
|
462
|
+
if (fs.deleteDir) cleanupPromises.push(fs.deleteDir(buildDir).catch(() => {}), fs.deleteDir(outputDir).catch(() => {}));
|
|
463
|
+
else try {
|
|
464
|
+
const nodeFs = await import("fs/promises");
|
|
465
|
+
const path = await import("path");
|
|
466
|
+
const projectRoot = process.cwd();
|
|
467
|
+
cleanupPromises.push(nodeFs.rm(path.resolve(projectRoot, buildDir), {
|
|
468
|
+
recursive: true,
|
|
469
|
+
force: true
|
|
470
|
+
}).catch(() => {}), nodeFs.rm(path.resolve(projectRoot, outputDir), {
|
|
471
|
+
recursive: true,
|
|
472
|
+
force: true
|
|
473
|
+
}).catch(() => {}));
|
|
474
|
+
} catch {}
|
|
475
|
+
await Promise.all(cleanupPromises);
|
|
476
|
+
}
|
|
477
|
+
updateProgress("Preparing build directories...");
|
|
478
|
+
await Promise.all([fs.ensureDir(`${outputDir}/assets/icons/`), fs.ensureDir(`${buildDir}/gs-lib/`)]);
|
|
479
|
+
updateProgress("Copying gs-lib package...");
|
|
480
|
+
await Promise.all([gsLibCopier.copyTextFile("dist/index.js", `${buildDir}/gs-lib/index.js`), gsLibCopier.copyTextFile("dist/gs-lib.css", `${buildDir}/gs-lib/gs-lib.css`)]);
|
|
481
|
+
updateProgress("Copying PWA core files...");
|
|
482
|
+
await gsLibCopier.copyTextFile("public/pwa/staticwebapp.config.json", `${outputDir}/staticwebapp.config.json`);
|
|
483
|
+
updateProgress("Creating manifest file...");
|
|
484
|
+
await gsLibCopier.copyTextFile("public/pwa/manifest.json", `${outputDir}/manifest.json`, (content) => processManifest(content, options.title, options.version));
|
|
485
|
+
updateProgress("Copying PWA icons...");
|
|
486
|
+
const iconFiles = [
|
|
487
|
+
"24x24.png",
|
|
488
|
+
"48x48.png",
|
|
489
|
+
"192x192.png",
|
|
490
|
+
"512x512.png",
|
|
491
|
+
"icon_24.png",
|
|
492
|
+
"icon_48.png",
|
|
493
|
+
"icon_192.png",
|
|
494
|
+
"icon_512.png"
|
|
495
|
+
];
|
|
496
|
+
await Promise.all(iconFiles.map((icon) => gsLibCopier.copyBinaryFile(`public/pwa/assets/icons/${icon}`, `${outputDir}/assets/icons/${icon}`)));
|
|
497
|
+
if (copyAssets) {
|
|
498
|
+
updateProgress("Copying workspace assets...");
|
|
499
|
+
await copyAssets(fs, outputDir, progress);
|
|
500
|
+
}
|
|
501
|
+
updateProgress("Generating application code...");
|
|
502
|
+
const entryPointContent = generateAppJs({
|
|
503
|
+
gsMap: options.gsMap,
|
|
504
|
+
gsLibPath: buildGsLibPath,
|
|
505
|
+
env: {
|
|
506
|
+
...options.env,
|
|
507
|
+
BUILD_TIME: /* @__PURE__ */ new Date()
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
await fs.writeFile(`${buildDir}/app.js`, entryPointContent);
|
|
511
|
+
const stepRef = { value: step };
|
|
512
|
+
const bundleResult = await bundleApp(`${buildDir}/app.js`, outputDir, buildGsLibPath, fs, resolvePlugin, esbuildInstance, progress, stepRef, totalSteps);
|
|
513
|
+
step = stepRef.value;
|
|
514
|
+
const appJsFilename = bundleResult.js;
|
|
515
|
+
const appCssFilename = bundleResult.css;
|
|
516
|
+
updateProgress("Generating HTML file...");
|
|
517
|
+
await gsLibCopier.copyTextFile("public/index.html", `${outputDir}/index.html`, (content) => processHtml(content, options.title, appJsFilename, appCssFilename || void 0));
|
|
518
|
+
const precacheManifest = [
|
|
519
|
+
{
|
|
520
|
+
url: `/${appJsFilename}`,
|
|
521
|
+
revision: null
|
|
522
|
+
},
|
|
523
|
+
...appCssFilename ? [{
|
|
524
|
+
url: `/${appCssFilename}`,
|
|
525
|
+
revision: null
|
|
526
|
+
}] : [],
|
|
527
|
+
...iconFiles.map((icon) => ({
|
|
528
|
+
url: `/assets/icons/${icon}`,
|
|
529
|
+
revision: null
|
|
530
|
+
}))
|
|
531
|
+
];
|
|
532
|
+
updateProgress("Processing service worker...");
|
|
533
|
+
await gsLibCopier.copyTextFile("public/pwa/sw.js", `${outputDir}/sw.js`, (content) => processServiceWorker(content, precacheManifest));
|
|
534
|
+
if (cleanAfterBuild) {
|
|
535
|
+
updateProgress("Cleaning up temporary files...");
|
|
536
|
+
if (fs.deleteDir) await fs.deleteDir(buildDir);
|
|
537
|
+
else try {
|
|
538
|
+
const nodeFs = await import("fs/promises");
|
|
539
|
+
const fullPath = (await import("path")).resolve(process.cwd(), buildDir);
|
|
540
|
+
await nodeFs.rm(fullPath, {
|
|
541
|
+
recursive: true,
|
|
542
|
+
force: true
|
|
543
|
+
});
|
|
544
|
+
} catch (error) {}
|
|
545
|
+
}
|
|
546
|
+
updateProgress("Build completed!");
|
|
694
547
|
}
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
548
|
+
//#endregion
|
|
549
|
+
//#region src/ol/gs-olns.ts
|
|
550
|
+
var gs_olns_exports = /* @__PURE__ */ __exportAll({
|
|
551
|
+
BaseLayer: () => BaseLayer,
|
|
552
|
+
applyMapboxStyle: () => applyMapboxStyle,
|
|
553
|
+
defaultControls: () => defaultControls,
|
|
554
|
+
defaultInteractions: () => defaultInteractions,
|
|
555
|
+
events: () => events,
|
|
556
|
+
eventsCondition: () => eventsCondition,
|
|
557
|
+
extent: () => extent,
|
|
558
|
+
format: () => format,
|
|
559
|
+
geom: () => geom,
|
|
560
|
+
interaction: () => interaction,
|
|
561
|
+
layer: () => layer,
|
|
562
|
+
proj: () => proj,
|
|
563
|
+
source: () => source,
|
|
564
|
+
sphere: () => sphere,
|
|
565
|
+
style: () => style
|
|
566
|
+
});
|
|
567
|
+
import * as import_ol from "ol";
|
|
568
|
+
__reExport(gs_olns_exports, import_ol);
|
|
569
|
+
//#endregion
|
|
570
|
+
//#region src/ol/gs-ol-adapters.ts
|
|
571
|
+
var GsOlAdapter = class {
|
|
572
|
+
constructor(olObject) {
|
|
573
|
+
this.map = olObject.getMap();
|
|
574
|
+
this.olObject = olObject;
|
|
575
|
+
}
|
|
576
|
+
getMap() {
|
|
577
|
+
return this.map;
|
|
578
|
+
}
|
|
579
|
+
getElement() {
|
|
580
|
+
return this.olObject.getElement();
|
|
581
|
+
}
|
|
582
|
+
render(strings) {
|
|
583
|
+
if (strings === void 0 && this.templateFunction) strings = this.templateFunction();
|
|
584
|
+
else if (strings instanceof Function) {
|
|
585
|
+
this.templateFunction = strings;
|
|
586
|
+
strings = this.templateFunction();
|
|
587
|
+
}
|
|
588
|
+
if (strings) render(strings, this.getElement());
|
|
589
|
+
}
|
|
590
|
+
onRendered() {}
|
|
591
|
+
style(styleJson) {
|
|
592
|
+
const style = this.getElement().style;
|
|
593
|
+
for (const property in styleJson) {
|
|
594
|
+
const value = styleJson[property];
|
|
595
|
+
style.setProperty(property, value);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
743
598
|
};
|
|
744
|
-
|
|
745
|
-
|
|
599
|
+
var GsControlAdapter = class extends GsOlAdapter {
|
|
600
|
+
style(styleJson) {
|
|
601
|
+
super.style(styleJson);
|
|
602
|
+
if ("--gs-contribution" in styleJson) this.retargetSelector = styleJson["--gs-contribution"];
|
|
603
|
+
}
|
|
604
|
+
rendered() {
|
|
605
|
+
if (this.retargetSelector) {
|
|
606
|
+
const [parentPath, queryString] = this.retargetSelector.split("?");
|
|
607
|
+
const parent = this.map.getTargetElement().querySelector(parentPath);
|
|
608
|
+
if (parent) {
|
|
609
|
+
const element = this.olObject.getElement();
|
|
610
|
+
if (queryString) {
|
|
611
|
+
const params = new URLSearchParams(queryString);
|
|
612
|
+
const sibling = parent.querySelector(`[name='${params.get("before")}']`);
|
|
613
|
+
if (sibling) parent.insertBefore(element, sibling);
|
|
614
|
+
} else parent.appendChild(element);
|
|
615
|
+
this.olObject.setTarget(element);
|
|
616
|
+
this.render();
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
746
620
|
};
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
621
|
+
var GsOverlayAdapter = class extends GsOlAdapter {
|
|
622
|
+
show(coords) {
|
|
623
|
+
this.getElement().style.display = "block";
|
|
624
|
+
this.olObject.setPosition(coords);
|
|
625
|
+
}
|
|
626
|
+
hide() {
|
|
627
|
+
this.getElement().style.display = "none";
|
|
628
|
+
}
|
|
751
629
|
};
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
630
|
+
//#endregion
|
|
631
|
+
//#region src/ol/gs-gs2ol.ts
|
|
632
|
+
var withState = (state, olObject) => {
|
|
633
|
+
if (state.uuid) olObject.set(KEY_UUID, state.uuid);
|
|
634
|
+
if (state.state) {
|
|
635
|
+
for (let stateKey in state.state) olObject.set(stateKey, state.state[stateKey]);
|
|
636
|
+
olObject.set(KEY_STATE, state.state);
|
|
637
|
+
}
|
|
638
|
+
return olObject;
|
|
761
639
|
};
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
color: gsFill.color
|
|
765
|
-
});
|
|
640
|
+
var toOLGeometry = (geometry) => {
|
|
641
|
+
return withState(geometry, new geom[geometry.type](geometry.coordinates));
|
|
766
642
|
};
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
radius: gsImage.radius || 5,
|
|
770
|
-
fill: gsImage.fill ? toOlFill(gsImage.fill) : void 0,
|
|
771
|
-
stroke: gsImage.stroke ? toOlStroke(gsImage.stroke) : void 0,
|
|
772
|
-
displacement: gsImage.displacement,
|
|
773
|
-
scale: gsImage.scale,
|
|
774
|
-
rotation: gsImage.rotation,
|
|
775
|
-
rotateWithView: gsImage.rotateWithView,
|
|
776
|
-
declutterMode: void 0
|
|
777
|
-
});
|
|
643
|
+
var toOlResource = (resource) => {
|
|
644
|
+
return new Icon({ src: resource.src });
|
|
778
645
|
};
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
anchorOrigin: gsImage.anchorOrigin,
|
|
789
|
-
scale: gsImage.scale || 1,
|
|
790
|
-
opacity: gsImage.opacity,
|
|
791
|
-
rotation: gsImage.rotation,
|
|
792
|
-
rotateWithView: gsImage.rotateWithView,
|
|
793
|
-
displacement: gsImage.displacement,
|
|
794
|
-
offset: gsImage.offset,
|
|
795
|
-
offsetOrigin: gsImage.offsetOrigin,
|
|
796
|
-
size: gsImage.size,
|
|
797
|
-
color: gsImage.color,
|
|
798
|
-
crossOrigin: gsImage.crossOrigin,
|
|
799
|
-
declutterMode: void 0
|
|
800
|
-
});
|
|
646
|
+
var toOlStroke = (gsStroke) => {
|
|
647
|
+
return new Stroke({
|
|
648
|
+
color: gsStroke.color,
|
|
649
|
+
width: gsStroke.width,
|
|
650
|
+
lineDash: gsStroke.lineDash,
|
|
651
|
+
lineCap: gsStroke.lineCap,
|
|
652
|
+
lineJoin: gsStroke.lineJoin,
|
|
653
|
+
miterLimit: gsStroke.miterLimit
|
|
654
|
+
});
|
|
801
655
|
};
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
points: gsImage.points || 3,
|
|
805
|
-
radius: gsImage.radius || gsImage.radius1 || 5,
|
|
806
|
-
radius2: gsImage.radius2,
|
|
807
|
-
angle: gsImage.angle || 0,
|
|
808
|
-
displacement: gsImage.displacement,
|
|
809
|
-
fill: gsImage.fill ? toOlFill(gsImage.fill) : void 0,
|
|
810
|
-
stroke: gsImage.stroke ? toOlStroke(gsImage.stroke) : void 0,
|
|
811
|
-
rotation: gsImage.rotation,
|
|
812
|
-
rotateWithView: gsImage.rotateWithView,
|
|
813
|
-
scale: gsImage.scale,
|
|
814
|
-
declutterMode: void 0
|
|
815
|
-
});
|
|
656
|
+
var toOlFill = (gsFill) => {
|
|
657
|
+
return new Fill({ color: gsFill.color });
|
|
816
658
|
};
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
659
|
+
var toOlCircleImage = (gsImage) => {
|
|
660
|
+
return new Circle({
|
|
661
|
+
radius: gsImage.radius || 5,
|
|
662
|
+
fill: gsImage.fill ? toOlFill(gsImage.fill) : void 0,
|
|
663
|
+
stroke: gsImage.stroke ? toOlStroke(gsImage.stroke) : void 0,
|
|
664
|
+
displacement: gsImage.displacement,
|
|
665
|
+
scale: gsImage.scale,
|
|
666
|
+
rotation: gsImage.rotation,
|
|
667
|
+
rotateWithView: gsImage.rotateWithView,
|
|
668
|
+
declutterMode: void 0
|
|
669
|
+
});
|
|
828
670
|
};
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
padding: gsText.padding,
|
|
850
|
-
declutterMode: void 0
|
|
851
|
-
});
|
|
671
|
+
var toOlIconImage = (gsImage) => {
|
|
672
|
+
if (!gsImage.src) throw new Error("Icon image requires src property");
|
|
673
|
+
return new Icon({
|
|
674
|
+
src: gsImage.src,
|
|
675
|
+
anchor: gsImage.anchor || [.5, 1],
|
|
676
|
+
anchorXUnits: gsImage.anchorXUnits || "fraction",
|
|
677
|
+
anchorYUnits: gsImage.anchorYUnits || "fraction",
|
|
678
|
+
anchorOrigin: gsImage.anchorOrigin,
|
|
679
|
+
scale: gsImage.scale || 1,
|
|
680
|
+
opacity: gsImage.opacity,
|
|
681
|
+
rotation: gsImage.rotation,
|
|
682
|
+
rotateWithView: gsImage.rotateWithView,
|
|
683
|
+
displacement: gsImage.displacement,
|
|
684
|
+
offset: gsImage.offset,
|
|
685
|
+
offsetOrigin: gsImage.offsetOrigin,
|
|
686
|
+
size: gsImage.size,
|
|
687
|
+
color: gsImage.color,
|
|
688
|
+
crossOrigin: gsImage.crossOrigin,
|
|
689
|
+
declutterMode: void 0
|
|
690
|
+
});
|
|
852
691
|
};
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
if (gsStyle.zIndex !== void 0) {
|
|
868
|
-
styleOptions.zIndex = gsStyle.zIndex;
|
|
869
|
-
}
|
|
870
|
-
return new Style(styleOptions);
|
|
692
|
+
var toOlRegularShapeImage = (gsImage) => {
|
|
693
|
+
return new RegularShape({
|
|
694
|
+
points: gsImage.points || 3,
|
|
695
|
+
radius: gsImage.radius || gsImage.radius1 || 5,
|
|
696
|
+
radius2: gsImage.radius2,
|
|
697
|
+
angle: gsImage.angle || 0,
|
|
698
|
+
displacement: gsImage.displacement,
|
|
699
|
+
fill: gsImage.fill ? toOlFill(gsImage.fill) : void 0,
|
|
700
|
+
stroke: gsImage.stroke ? toOlStroke(gsImage.stroke) : void 0,
|
|
701
|
+
rotation: gsImage.rotation,
|
|
702
|
+
rotateWithView: gsImage.rotateWithView,
|
|
703
|
+
scale: gsImage.scale,
|
|
704
|
+
declutterMode: void 0
|
|
705
|
+
});
|
|
871
706
|
};
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
707
|
+
var toOlImage = (gsImage) => {
|
|
708
|
+
switch (gsImage.type) {
|
|
709
|
+
case "circle": return toOlCircleImage(gsImage);
|
|
710
|
+
case "icon": return toOlIconImage(gsImage);
|
|
711
|
+
case "regular-shape": return toOlRegularShapeImage(gsImage);
|
|
712
|
+
default: throw new Error(`Unknown image type: ${gsImage.type}`);
|
|
713
|
+
}
|
|
876
714
|
};
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
715
|
+
var toOlText = (gsText) => {
|
|
716
|
+
return new Text({
|
|
717
|
+
text: gsText.text,
|
|
718
|
+
font: gsText.font,
|
|
719
|
+
maxAngle: gsText.maxAngle,
|
|
720
|
+
offsetX: gsText.offsetX,
|
|
721
|
+
offsetY: gsText.offsetY,
|
|
722
|
+
overflow: gsText.overflow,
|
|
723
|
+
placement: gsText.placement,
|
|
724
|
+
repeat: gsText.repeat,
|
|
725
|
+
scale: gsText.scale,
|
|
726
|
+
rotateWithView: gsText.rotateWithView,
|
|
727
|
+
rotation: gsText.rotation,
|
|
728
|
+
textAlign: gsText.textAlign,
|
|
729
|
+
justify: gsText.justify,
|
|
730
|
+
textBaseline: gsText.textBaseline,
|
|
731
|
+
fill: gsText.fill ? toOlFill(gsText.fill) : void 0,
|
|
732
|
+
stroke: gsText.stroke ? toOlStroke(gsText.stroke) : void 0,
|
|
733
|
+
backgroundFill: gsText.backgroundFill ? toOlFill(gsText.backgroundFill) : void 0,
|
|
734
|
+
backgroundStroke: gsText.backgroundStroke ? toOlStroke(gsText.backgroundStroke) : void 0,
|
|
735
|
+
padding: gsText.padding,
|
|
736
|
+
declutterMode: void 0
|
|
737
|
+
});
|
|
882
738
|
};
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
739
|
+
var toOlStyle = (gsStyle) => {
|
|
740
|
+
const styleOptions = {};
|
|
741
|
+
if (gsStyle.stroke) styleOptions.stroke = toOlStroke(gsStyle.stroke);
|
|
742
|
+
if (gsStyle.fill) styleOptions.fill = toOlFill(gsStyle.fill);
|
|
743
|
+
if (gsStyle.image) styleOptions.image = toOlImage(gsStyle.image);
|
|
744
|
+
if (gsStyle.text) styleOptions.text = toOlText(gsStyle.text);
|
|
745
|
+
if (gsStyle.zIndex !== void 0) styleOptions.zIndex = gsStyle.zIndex;
|
|
746
|
+
return new Style(styleOptions);
|
|
891
747
|
};
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
url: source2.url,
|
|
895
|
-
params: {
|
|
896
|
-
"LAYERS": "",
|
|
897
|
-
// Will be overridden by source.state
|
|
898
|
-
...source2.state || {}
|
|
899
|
-
},
|
|
900
|
-
crossOrigin: "anonymous"
|
|
901
|
-
// Required for COEP, same as OSM default
|
|
902
|
-
});
|
|
903
|
-
olSource.set(KEY_URL, source2.url);
|
|
904
|
-
olSource.set(KEY_LABEL, `${source2.type}@${source2.url}`);
|
|
905
|
-
return olSource;
|
|
748
|
+
var toOlFeature = (feature) => {
|
|
749
|
+
return withState(feature, new Feature({ geometry: toOLGeometry(feature.geometry) }));
|
|
906
750
|
};
|
|
907
|
-
OL_SOURCES
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
layer: state["LAYER"] || "",
|
|
913
|
-
matrixSet: state["MATRIXSET"] || "GLOBAL_WEBMERCATOR",
|
|
914
|
-
style: state["STYLE"] || "default",
|
|
915
|
-
crossOrigin: "anonymous"
|
|
916
|
-
});
|
|
917
|
-
fetch(source2.url).then((response) => response.text()).then((text) => {
|
|
918
|
-
const result = parser.read(text);
|
|
919
|
-
const options = optionsFromCapabilities(result, {
|
|
920
|
-
layer: state["LAYER"] || "",
|
|
921
|
-
matrixSet: state["MATRIXSET"] || "GLOBAL_WEBMERCATOR"
|
|
922
|
-
});
|
|
923
|
-
if (options) {
|
|
924
|
-
const newSource = new WMTS({
|
|
925
|
-
...options,
|
|
926
|
-
crossOrigin: "anonymous"
|
|
927
|
-
});
|
|
928
|
-
newSource.set(KEY_URL, source2.url);
|
|
929
|
-
newSource.set(KEY_LABEL, `${source2.type}@${source2.url}`);
|
|
930
|
-
if (olLayer && olLayer.setSource) {
|
|
931
|
-
olLayer.setSource(newSource);
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
}).catch((error) => {
|
|
935
|
-
console.error("Failed to fetch WMTS capabilities:", error);
|
|
936
|
-
});
|
|
937
|
-
olSource.set(KEY_URL, source2.url);
|
|
938
|
-
olSource.set(KEY_LABEL, `${source2.type}@${source2.url}`);
|
|
939
|
-
return olSource;
|
|
751
|
+
var OL_SOURCES = {};
|
|
752
|
+
OL_SOURCES[GsSourceType.OSM] = (source) => {
|
|
753
|
+
const olSource = new OSM();
|
|
754
|
+
olSource.set(KEY_LABEL, source.type);
|
|
755
|
+
return olSource;
|
|
940
756
|
};
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
return olSource;
|
|
757
|
+
OL_SOURCES[GsSourceType.XYZ] = (source) => {
|
|
758
|
+
const olSource = new XYZ({
|
|
759
|
+
url: source.url,
|
|
760
|
+
crossOrigin: "anonymous"
|
|
761
|
+
});
|
|
762
|
+
olSource.set("url", source.url);
|
|
763
|
+
olSource.set(KEY_LABEL, `${source.type}@${source.url}`);
|
|
764
|
+
return olSource;
|
|
950
765
|
};
|
|
951
|
-
OL_SOURCES[GsSourceType.
|
|
952
|
-
|
|
766
|
+
OL_SOURCES[GsSourceType.WMS] = (source) => {
|
|
767
|
+
const olSource = new TileWMS({
|
|
768
|
+
url: source.url,
|
|
769
|
+
params: {
|
|
770
|
+
"LAYERS": "",
|
|
771
|
+
...source.state || {}
|
|
772
|
+
},
|
|
773
|
+
crossOrigin: "anonymous"
|
|
774
|
+
});
|
|
775
|
+
olSource.set("url", source.url);
|
|
776
|
+
olSource.set(KEY_LABEL, `${source.type}@${source.url}`);
|
|
777
|
+
return olSource;
|
|
953
778
|
};
|
|
954
|
-
OL_SOURCES[GsSourceType.
|
|
955
|
-
|
|
779
|
+
OL_SOURCES[GsSourceType.WMTS] = (source, olLayer) => {
|
|
780
|
+
const state = source.state || {};
|
|
781
|
+
const parser = new WMTSCapabilities();
|
|
782
|
+
const olSource = new WMTS({
|
|
783
|
+
url: source.url,
|
|
784
|
+
layer: state["LAYER"] || "",
|
|
785
|
+
matrixSet: state["MATRIXSET"] || "GLOBAL_WEBMERCATOR",
|
|
786
|
+
style: state["STYLE"] || "default",
|
|
787
|
+
crossOrigin: "anonymous"
|
|
788
|
+
});
|
|
789
|
+
fetch(source.url).then((response) => response.text()).then((text) => {
|
|
790
|
+
const options = optionsFromCapabilities(parser.read(text), {
|
|
791
|
+
layer: state["LAYER"] || "",
|
|
792
|
+
matrixSet: state["MATRIXSET"] || "GLOBAL_WEBMERCATOR"
|
|
793
|
+
});
|
|
794
|
+
if (options) {
|
|
795
|
+
const newSource = new WMTS({
|
|
796
|
+
...options,
|
|
797
|
+
crossOrigin: "anonymous"
|
|
798
|
+
});
|
|
799
|
+
newSource.set("url", source.url);
|
|
800
|
+
newSource.set(KEY_LABEL, `${source.type}@${source.url}`);
|
|
801
|
+
if (olLayer && olLayer.setSource) olLayer.setSource(newSource);
|
|
802
|
+
}
|
|
803
|
+
}).catch((error) => {
|
|
804
|
+
console.error("Failed to fetch WMTS capabilities:", error);
|
|
805
|
+
});
|
|
806
|
+
olSource.set("url", source.url);
|
|
807
|
+
olSource.set(KEY_LABEL, `${source.type}@${source.url}`);
|
|
808
|
+
return olSource;
|
|
956
809
|
};
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
olSource.set(KEY_LABEL, `${source2.type}@${source2.url}`);
|
|
967
|
-
return olSource;
|
|
810
|
+
var formatSource = (source, format) => {
|
|
811
|
+
const olSource = new VectorSource({
|
|
812
|
+
format,
|
|
813
|
+
url: source.url
|
|
814
|
+
});
|
|
815
|
+
olSource.set(KEY_FORMAT, source.type);
|
|
816
|
+
olSource.set("url", source.url);
|
|
817
|
+
olSource.set(KEY_LABEL, `${source.type}@${source.url}`);
|
|
818
|
+
return olSource;
|
|
968
819
|
};
|
|
969
|
-
OL_SOURCES[GsSourceType.
|
|
970
|
-
|
|
971
|
-
const olSource = new VectorSource({
|
|
972
|
-
features
|
|
973
|
-
});
|
|
974
|
-
olSource.set(KEY_LABEL, source2.type);
|
|
975
|
-
return olSource;
|
|
820
|
+
OL_SOURCES[GsSourceType.GeoJSON] = (source) => {
|
|
821
|
+
return formatSource(source, new GeoJSON());
|
|
976
822
|
};
|
|
977
|
-
|
|
978
|
-
|
|
823
|
+
OL_SOURCES[GsSourceType.GPX] = (source) => {
|
|
824
|
+
return formatSource(source, new GPX());
|
|
979
825
|
};
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
826
|
+
OL_SOURCES[GsSourceType.GeoTIFF] = (source) => {
|
|
827
|
+
const olSource = new GeoTIFF({ sources: [{ url: source.url }] });
|
|
828
|
+
olSource.set("url", source.url);
|
|
829
|
+
olSource.set(KEY_LABEL, `${source.type}@${source.url}`);
|
|
830
|
+
return olSource;
|
|
985
831
|
};
|
|
986
|
-
|
|
832
|
+
OL_SOURCES[GsSourceType.Features] = (source) => {
|
|
833
|
+
const olSource = new VectorSource({ features: (source.features || []).map((feature) => toOlFeature(feature)) });
|
|
834
|
+
olSource.set(KEY_LABEL, source.type);
|
|
835
|
+
return olSource;
|
|
836
|
+
};
|
|
837
|
+
var toOlSource = (source, olLayer) => {
|
|
838
|
+
return withState(source, OL_SOURCES[source.type](source, olLayer));
|
|
839
|
+
};
|
|
840
|
+
var resolveScriptLang = (src, lang) => {
|
|
841
|
+
if (lang) return lang;
|
|
842
|
+
if ((src.split("?")[0].split(".").pop()?.toLowerCase() ?? "") === "py") return "python";
|
|
843
|
+
return "javascript";
|
|
844
|
+
};
|
|
845
|
+
var OL_LAYERS = {};
|
|
987
846
|
OL_LAYERS[GsLayerType.TILE] = (layer) => {
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
847
|
+
const tileLayer = new TileLayer();
|
|
848
|
+
const source = toOlSource(layer.source, tileLayer);
|
|
849
|
+
tileLayer.setSource(source);
|
|
850
|
+
return tileLayer;
|
|
992
851
|
};
|
|
993
852
|
OL_LAYERS[GsLayerType.VECTOR] = (layer) => {
|
|
994
|
-
|
|
995
|
-
source: toOlSource(layer.source)
|
|
996
|
-
});
|
|
853
|
+
return new VectorLayer({ source: toOlSource(layer.source) });
|
|
997
854
|
};
|
|
998
855
|
OL_LAYERS[GsLayerType.GROUP] = (layer) => {
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
856
|
+
const group = new LayerGroup();
|
|
857
|
+
group.set("url", layer.source.url);
|
|
858
|
+
group.set(KEY_SOURCETYPE, layer.source.type);
|
|
859
|
+
apply(group, layer.source.url).then();
|
|
860
|
+
return group;
|
|
1004
861
|
};
|
|
1005
862
|
OL_LAYERS[GsLayerType.SCRIPTED] = (layer, env) => {
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
},
|
|
1049
|
-
strategy: bbox
|
|
1050
|
-
});
|
|
1051
|
-
olVectorLayer = new VectorLayer({ source: source2 });
|
|
1052
|
-
return olVectorLayer;
|
|
863
|
+
const src = layer.source.url;
|
|
864
|
+
const lang = resolveScriptLang(src, layer.lang);
|
|
865
|
+
const runtime = scriptedRuntimeRegistry.get(lang);
|
|
866
|
+
if (!runtime) throw new Error(`No scripted runtime registered for lang "${lang}"`);
|
|
867
|
+
let olVectorLayer;
|
|
868
|
+
const source = new VectorSource({
|
|
869
|
+
loader: async (extent, resolution, projection, success, failure) => {
|
|
870
|
+
const view = olVectorLayer?.getMapInternal()?.getView();
|
|
871
|
+
const vars = {
|
|
872
|
+
params: layer.params ?? {},
|
|
873
|
+
env: env ?? {},
|
|
874
|
+
viewState: {
|
|
875
|
+
extent: transformExtent(extent, projection, "EPSG:4326"),
|
|
876
|
+
zoom: view?.getZoomForResolution(resolution) ?? 0,
|
|
877
|
+
projection: "EPSG:4326"
|
|
878
|
+
}
|
|
879
|
+
};
|
|
880
|
+
try {
|
|
881
|
+
const result = await runtime.run(src, vars);
|
|
882
|
+
const format = new GeoJSON();
|
|
883
|
+
source.clear();
|
|
884
|
+
const allFeatures = [];
|
|
885
|
+
const readBatch = (data) => {
|
|
886
|
+
const features = format.readFeatures(data, {
|
|
887
|
+
dataProjection: "EPSG:4326",
|
|
888
|
+
featureProjection: projection
|
|
889
|
+
});
|
|
890
|
+
source.addFeatures(features);
|
|
891
|
+
allFeatures.push(...features);
|
|
892
|
+
};
|
|
893
|
+
if (result && typeof result[Symbol.asyncIterator] === "function") for await (const batch of result) readBatch(batch);
|
|
894
|
+
else readBatch(result);
|
|
895
|
+
success(allFeatures);
|
|
896
|
+
} catch (e) {
|
|
897
|
+
console.error("Scripted layer error:", e);
|
|
898
|
+
failure();
|
|
899
|
+
}
|
|
900
|
+
},
|
|
901
|
+
strategy: bbox
|
|
902
|
+
});
|
|
903
|
+
olVectorLayer = new VectorLayer({ source });
|
|
904
|
+
return olVectorLayer;
|
|
1053
905
|
};
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
906
|
+
var toOlLayer = (layer, env) => {
|
|
907
|
+
const olLayer = withState(layer, OL_LAYERS[layer.type](layer, env));
|
|
908
|
+
olLayer.set(KEY_LABEL, layer.type);
|
|
909
|
+
olLayer.set(KEY_NAME, layer.name);
|
|
910
|
+
olLayer.set(KEY_GS_MANAGED, true);
|
|
911
|
+
olLayer.setVisible(layer.visible ?? true);
|
|
912
|
+
return olLayer;
|
|
1061
913
|
};
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
}
|
|
1076
|
-
class GsOlOverlay extends Overlay {
|
|
1077
|
-
constructor(options) {
|
|
1078
|
-
const element = document.createElement("div");
|
|
1079
|
-
element.style.margin = "0";
|
|
1080
|
-
element.style.padding = "0";
|
|
1081
|
-
super({
|
|
1082
|
-
...options
|
|
1083
|
-
});
|
|
1084
|
-
}
|
|
1085
|
-
getElement() {
|
|
1086
|
-
return this.element;
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
const toOlOverlay = (overlay) => {
|
|
1090
|
-
const olOverlay = withState(overlay, new GsOlOverlay({
|
|
1091
|
-
positioning: overlay.position,
|
|
1092
|
-
stopEvent: true
|
|
1093
|
-
}));
|
|
1094
|
-
olOverlay.set(KEY_SRC, overlay.src);
|
|
1095
|
-
return olOverlay;
|
|
914
|
+
var GsOlControl = class extends Control {
|
|
915
|
+
constructor(options) {
|
|
916
|
+
const element = document.createElement("div");
|
|
917
|
+
element.style.margin = "0";
|
|
918
|
+
element.style.padding = "0";
|
|
919
|
+
super({
|
|
920
|
+
...options,
|
|
921
|
+
element
|
|
922
|
+
});
|
|
923
|
+
}
|
|
924
|
+
getElement() {
|
|
925
|
+
return this.element;
|
|
926
|
+
}
|
|
1096
927
|
};
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
928
|
+
var GsOlOverlay = class extends Overlay {
|
|
929
|
+
constructor(options) {
|
|
930
|
+
const element = document.createElement("div");
|
|
931
|
+
element.style.margin = "0";
|
|
932
|
+
element.style.padding = "0";
|
|
933
|
+
super({ ...options });
|
|
934
|
+
}
|
|
935
|
+
getElement() {
|
|
936
|
+
return this.element;
|
|
937
|
+
}
|
|
1101
938
|
};
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
...lit,
|
|
1110
|
-
// forward compatibility
|
|
1111
|
-
lit,
|
|
1112
|
-
style: adapter.style.bind(adapter),
|
|
1113
|
-
render: adapter.render.bind(adapter),
|
|
1114
|
-
map: olMap,
|
|
1115
|
-
element: adapter.getElement(),
|
|
1116
|
-
querySelector: adapter.getElement().querySelector.bind(adapter.getElement()),
|
|
1117
|
-
querySelectorAll: adapter.getElement().querySelector.bind(adapter.getElement()),
|
|
1118
|
-
ol,
|
|
1119
|
-
env: olMap.get(KEY_ENV) || {},
|
|
1120
|
-
utils: {
|
|
1121
|
-
uuid: v4
|
|
1122
|
-
},
|
|
1123
|
-
asset: (path) => {
|
|
1124
|
-
return rtUtils.resolveUrl(`assets/${path}`);
|
|
1125
|
-
},
|
|
1126
|
-
signal: (_name) => {
|
|
1127
|
-
},
|
|
1128
|
-
events: (topic, callback) => {
|
|
1129
|
-
if (callback instanceof Function) {
|
|
1130
|
-
const token = subscribe(topic, callback);
|
|
1131
|
-
let subscriptions = olMap.get(KEY_EVENT_SUBSCRIPTIONS);
|
|
1132
|
-
if (!subscriptions) {
|
|
1133
|
-
subscriptions = [];
|
|
1134
|
-
olMap.set(KEY_EVENT_SUBSCRIPTIONS, subscriptions);
|
|
1135
|
-
}
|
|
1136
|
-
subscriptions.push(token);
|
|
1137
|
-
return token;
|
|
1138
|
-
} else {
|
|
1139
|
-
return publish(topic, callback);
|
|
1140
|
-
}
|
|
1141
|
-
},
|
|
1142
|
-
settings: (key, callback) => {
|
|
1143
|
-
const mapUuid = olMap.get(KEY_UUID);
|
|
1144
|
-
const storageKey = mapUuid ? `gs-settings-${mapUuid}` : "gs-settings";
|
|
1145
|
-
const loadSettings = () => {
|
|
1146
|
-
try {
|
|
1147
|
-
const stored = localStorage.getItem(storageKey);
|
|
1148
|
-
return stored ? JSON.parse(stored) : {};
|
|
1149
|
-
} catch {
|
|
1150
|
-
return {};
|
|
1151
|
-
}
|
|
1152
|
-
};
|
|
1153
|
-
const saveSettings = (settings2) => {
|
|
1154
|
-
try {
|
|
1155
|
-
localStorage.setItem(storageKey, JSON.stringify(settings2));
|
|
1156
|
-
} catch (error) {
|
|
1157
|
-
console.error("Failed to save settings to localStorage:", error);
|
|
1158
|
-
}
|
|
1159
|
-
};
|
|
1160
|
-
const settings = loadSettings();
|
|
1161
|
-
if (callback === void 0) {
|
|
1162
|
-
return settings[key];
|
|
1163
|
-
}
|
|
1164
|
-
if (callback instanceof Function) {
|
|
1165
|
-
vars.events(key, callback);
|
|
1166
|
-
callback(settings[key]);
|
|
1167
|
-
return settings[key];
|
|
1168
|
-
}
|
|
1169
|
-
settings[key] = callback;
|
|
1170
|
-
saveSettings(settings);
|
|
1171
|
-
return publish(key, callback);
|
|
1172
|
-
}
|
|
1173
|
-
};
|
|
1174
|
-
const objectType = adapter instanceof GsControlAdapter ? "control" : "overlay";
|
|
1175
|
-
vars[objectType] = adapter;
|
|
1176
|
-
const templateFunction = mod instanceof Function ? mod : mod.default;
|
|
1177
|
-
if (templateFunction) {
|
|
1178
|
-
vars.state = (initialValue) => {
|
|
1179
|
-
const createReactiveProperty = (target, key, getValue, setValue) => {
|
|
1180
|
-
Object.defineProperty(target, key, {
|
|
1181
|
-
get() {
|
|
1182
|
-
return getValue();
|
|
1183
|
-
},
|
|
1184
|
-
set(newValue) {
|
|
1185
|
-
const oldValue = getValue();
|
|
1186
|
-
if (oldValue !== newValue) {
|
|
1187
|
-
setValue(newValue);
|
|
1188
|
-
adapter.render();
|
|
1189
|
-
}
|
|
1190
|
-
},
|
|
1191
|
-
enumerable: true,
|
|
1192
|
-
configurable: true
|
|
1193
|
-
});
|
|
1194
|
-
};
|
|
1195
|
-
if (typeof initialValue === "object" && initialValue !== null && !Array.isArray(initialValue)) {
|
|
1196
|
-
const values = { ...initialValue };
|
|
1197
|
-
return new Proxy({}, {
|
|
1198
|
-
get(_target, prop) {
|
|
1199
|
-
return values[prop];
|
|
1200
|
-
},
|
|
1201
|
-
set(_target, prop, newValue) {
|
|
1202
|
-
if (values[prop] !== newValue) {
|
|
1203
|
-
values[prop] = newValue;
|
|
1204
|
-
adapter.render();
|
|
1205
|
-
}
|
|
1206
|
-
return true;
|
|
1207
|
-
},
|
|
1208
|
-
has(_target, prop) {
|
|
1209
|
-
return prop in values;
|
|
1210
|
-
},
|
|
1211
|
-
ownKeys(_target) {
|
|
1212
|
-
return Object.keys(values);
|
|
1213
|
-
},
|
|
1214
|
-
getOwnPropertyDescriptor(_target, prop) {
|
|
1215
|
-
if (prop in values) {
|
|
1216
|
-
return {
|
|
1217
|
-
enumerable: true,
|
|
1218
|
-
configurable: true,
|
|
1219
|
-
value: values[prop]
|
|
1220
|
-
};
|
|
1221
|
-
}
|
|
1222
|
-
return void 0;
|
|
1223
|
-
}
|
|
1224
|
-
});
|
|
1225
|
-
} else {
|
|
1226
|
-
const stateObj = {};
|
|
1227
|
-
let value = initialValue;
|
|
1228
|
-
createReactiveProperty(
|
|
1229
|
-
stateObj,
|
|
1230
|
-
"value",
|
|
1231
|
-
() => value,
|
|
1232
|
-
(v) => {
|
|
1233
|
-
value = v;
|
|
1234
|
-
}
|
|
1235
|
-
);
|
|
1236
|
-
return stateObj;
|
|
1237
|
-
}
|
|
1238
|
-
};
|
|
1239
|
-
const component = templateFunction(vars);
|
|
1240
|
-
if (component instanceof Function) {
|
|
1241
|
-
adapter.render(component);
|
|
1242
|
-
} else {
|
|
1243
|
-
adapter.render(component);
|
|
1244
|
-
}
|
|
1245
|
-
}
|
|
1246
|
-
if (adapter instanceof GsControlAdapter) {
|
|
1247
|
-
adapter.rendered();
|
|
1248
|
-
}
|
|
1249
|
-
olMap.render();
|
|
1250
|
-
};
|
|
1251
|
-
olMap.on("rendercomplete", init);
|
|
1252
|
-
});
|
|
939
|
+
var toOlOverlay = (overlay) => {
|
|
940
|
+
const olOverlay = withState(overlay, new GsOlOverlay({
|
|
941
|
+
positioning: overlay.position,
|
|
942
|
+
stopEvent: true
|
|
943
|
+
}));
|
|
944
|
+
olOverlay.set("src", overlay.src);
|
|
945
|
+
return olOverlay;
|
|
1253
946
|
};
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
947
|
+
var toOlControl = (control) => {
|
|
948
|
+
const olControl = withState(control, new GsOlControl());
|
|
949
|
+
olControl.set("src", control.src);
|
|
950
|
+
return olControl;
|
|
1257
951
|
};
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
952
|
+
var importSrc = async (adapter, src, importer) => {
|
|
953
|
+
const olMap = adapter.getMap();
|
|
954
|
+
return (importer || DefaultImporter)(src).then((mod) => {
|
|
955
|
+
const init = () => {
|
|
956
|
+
olMap.removeEventListener("rendercomplete", init);
|
|
957
|
+
const vars = {
|
|
958
|
+
...lit,
|
|
959
|
+
lit,
|
|
960
|
+
style: adapter.style.bind(adapter),
|
|
961
|
+
render: adapter.render.bind(adapter),
|
|
962
|
+
map: olMap,
|
|
963
|
+
element: adapter.getElement(),
|
|
964
|
+
querySelector: adapter.getElement().querySelector.bind(adapter.getElement()),
|
|
965
|
+
querySelectorAll: adapter.getElement().querySelector.bind(adapter.getElement()),
|
|
966
|
+
ol: gs_olns_exports,
|
|
967
|
+
env: olMap.get("_env") || {},
|
|
968
|
+
utils: { uuid: v4 },
|
|
969
|
+
asset: (path) => {
|
|
970
|
+
return rtUtils.resolveUrl(`assets/${path}`);
|
|
971
|
+
},
|
|
972
|
+
signal: (_name) => {},
|
|
973
|
+
events: (topic, callback) => {
|
|
974
|
+
if (callback instanceof Function) {
|
|
975
|
+
const token = subscribe(topic, callback);
|
|
976
|
+
let subscriptions = olMap.get(KEY_EVENT_SUBSCRIPTIONS);
|
|
977
|
+
if (!subscriptions) {
|
|
978
|
+
subscriptions = [];
|
|
979
|
+
olMap.set(KEY_EVENT_SUBSCRIPTIONS, subscriptions);
|
|
980
|
+
}
|
|
981
|
+
subscriptions.push(token);
|
|
982
|
+
return token;
|
|
983
|
+
} else return publish(topic, callback);
|
|
984
|
+
},
|
|
985
|
+
settings: (key, callback) => {
|
|
986
|
+
const mapUuid = olMap.get(KEY_UUID);
|
|
987
|
+
const storageKey = mapUuid ? `gs-settings-${mapUuid}` : "gs-settings";
|
|
988
|
+
const loadSettings = () => {
|
|
989
|
+
try {
|
|
990
|
+
const stored = localStorage.getItem(storageKey);
|
|
991
|
+
return stored ? JSON.parse(stored) : {};
|
|
992
|
+
} catch {
|
|
993
|
+
return {};
|
|
994
|
+
}
|
|
995
|
+
};
|
|
996
|
+
const saveSettings = (settings) => {
|
|
997
|
+
try {
|
|
998
|
+
localStorage.setItem(storageKey, JSON.stringify(settings));
|
|
999
|
+
} catch (error) {
|
|
1000
|
+
console.error("Failed to save settings to localStorage:", error);
|
|
1001
|
+
}
|
|
1002
|
+
};
|
|
1003
|
+
const settings = loadSettings();
|
|
1004
|
+
if (callback === void 0) return settings[key];
|
|
1005
|
+
if (callback instanceof Function) {
|
|
1006
|
+
vars.events(key, callback);
|
|
1007
|
+
callback(settings[key]);
|
|
1008
|
+
return settings[key];
|
|
1009
|
+
}
|
|
1010
|
+
settings[key] = callback;
|
|
1011
|
+
saveSettings(settings);
|
|
1012
|
+
return publish(key, callback);
|
|
1013
|
+
}
|
|
1014
|
+
};
|
|
1015
|
+
const objectType = adapter instanceof GsControlAdapter ? "control" : "overlay";
|
|
1016
|
+
vars[objectType] = adapter;
|
|
1017
|
+
const templateFunction = mod instanceof Function ? mod : mod.default;
|
|
1018
|
+
if (templateFunction) {
|
|
1019
|
+
vars.state = (initialValue) => {
|
|
1020
|
+
const createReactiveProperty = (target, key, getValue, setValue) => {
|
|
1021
|
+
Object.defineProperty(target, key, {
|
|
1022
|
+
get() {
|
|
1023
|
+
return getValue();
|
|
1024
|
+
},
|
|
1025
|
+
set(newValue) {
|
|
1026
|
+
if (getValue() !== newValue) {
|
|
1027
|
+
setValue(newValue);
|
|
1028
|
+
adapter.render();
|
|
1029
|
+
}
|
|
1030
|
+
},
|
|
1031
|
+
enumerable: true,
|
|
1032
|
+
configurable: true
|
|
1033
|
+
});
|
|
1034
|
+
};
|
|
1035
|
+
if (typeof initialValue === "object" && initialValue !== null && !Array.isArray(initialValue)) {
|
|
1036
|
+
const values = { ...initialValue };
|
|
1037
|
+
return new Proxy({}, {
|
|
1038
|
+
get(_target, prop) {
|
|
1039
|
+
return values[prop];
|
|
1040
|
+
},
|
|
1041
|
+
set(_target, prop, newValue) {
|
|
1042
|
+
if (values[prop] !== newValue) {
|
|
1043
|
+
values[prop] = newValue;
|
|
1044
|
+
adapter.render();
|
|
1045
|
+
}
|
|
1046
|
+
return true;
|
|
1047
|
+
},
|
|
1048
|
+
has(_target, prop) {
|
|
1049
|
+
return prop in values;
|
|
1050
|
+
},
|
|
1051
|
+
ownKeys(_target) {
|
|
1052
|
+
return Object.keys(values);
|
|
1053
|
+
},
|
|
1054
|
+
getOwnPropertyDescriptor(_target, prop) {
|
|
1055
|
+
if (prop in values) return {
|
|
1056
|
+
enumerable: true,
|
|
1057
|
+
configurable: true,
|
|
1058
|
+
value: values[prop]
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
1061
|
+
});
|
|
1062
|
+
} else {
|
|
1063
|
+
const stateObj = {};
|
|
1064
|
+
let value = initialValue;
|
|
1065
|
+
createReactiveProperty(stateObj, "value", () => value, (v) => {
|
|
1066
|
+
value = v;
|
|
1067
|
+
});
|
|
1068
|
+
return stateObj;
|
|
1069
|
+
}
|
|
1070
|
+
};
|
|
1071
|
+
const component = templateFunction(vars);
|
|
1072
|
+
if (component instanceof Function) adapter.render(component);
|
|
1073
|
+
else adapter.render(component);
|
|
1074
|
+
}
|
|
1075
|
+
if (adapter instanceof GsControlAdapter) adapter.rendered();
|
|
1076
|
+
olMap.render();
|
|
1077
|
+
};
|
|
1078
|
+
olMap.on("rendercomplete", init);
|
|
1079
|
+
});
|
|
1261
1080
|
};
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
const subscriptions = olMap.get(KEY_EVENT_SUBSCRIPTIONS);
|
|
1265
|
-
if (subscriptions) {
|
|
1266
|
-
subscriptions.forEach((token) => unsubscribe(token));
|
|
1267
|
-
olMap.set(KEY_EVENT_SUBSCRIPTIONS, []);
|
|
1268
|
-
}
|
|
1081
|
+
var importOverlaySource = async (olOverlay, src, importer) => {
|
|
1082
|
+
return importSrc(new GsOverlayAdapter(olOverlay), src, importer);
|
|
1269
1083
|
};
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
olMap.set(KEY_ENV, env);
|
|
1273
|
-
olMap.setView(new View({
|
|
1274
|
-
center: gsMap.view.center && gsMap.view.center.length == 2 ? gsMap.view.center : DEFAULT_GSMAP.view.center,
|
|
1275
|
-
zoom: gsMap.view.zoom || DEFAULT_GSMAP.view.zoom,
|
|
1276
|
-
projection: gsMap.view.projection || DEFAULT_GSMAP.view.projection
|
|
1277
|
-
}));
|
|
1278
|
-
for (const layer of gsMap.layers || []) {
|
|
1279
|
-
const olLayer = toOlLayer(layer, env);
|
|
1280
|
-
olMap.addLayer(olLayer);
|
|
1281
|
-
}
|
|
1282
|
-
if (target) {
|
|
1283
|
-
olMap.setTarget(target);
|
|
1284
|
-
}
|
|
1285
|
-
for (const overlay of gsMap.overlays || []) {
|
|
1286
|
-
const olOverlay = toOlOverlay(overlay);
|
|
1287
|
-
olMap.addOverlay(olOverlay);
|
|
1288
|
-
await importOverlaySource(olOverlay, overlay.src, importer);
|
|
1289
|
-
}
|
|
1290
|
-
for (const control of gsMap.controls || []) {
|
|
1291
|
-
const olControl = toOlControl(control);
|
|
1292
|
-
olMap.addControl(olControl);
|
|
1293
|
-
await importControlSource(olControl, control.src, importer);
|
|
1294
|
-
}
|
|
1295
|
-
return olMap;
|
|
1084
|
+
var importControlSource = async (olControl, src, importer) => {
|
|
1085
|
+
return importSrc(new GsControlAdapter(olControl), src, importer);
|
|
1296
1086
|
};
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
case "wmts":
|
|
1305
|
-
case "xyz":
|
|
1306
|
-
return GsLayerType.TILE;
|
|
1307
|
-
case "bm":
|
|
1308
|
-
case "basemap.de":
|
|
1309
|
-
return GsLayerType.GROUP;
|
|
1310
|
-
case "scripted":
|
|
1311
|
-
return GsLayerType.SCRIPTED;
|
|
1312
|
-
default:
|
|
1313
|
-
return GsLayerType.VECTOR;
|
|
1314
|
-
}
|
|
1087
|
+
var DefaultImporter = (src) => import(src);
|
|
1088
|
+
var cleanupEventSubscriptions = (olMap) => {
|
|
1089
|
+
const subscriptions = olMap.get(KEY_EVENT_SUBSCRIPTIONS);
|
|
1090
|
+
if (subscriptions) {
|
|
1091
|
+
subscriptions.forEach((token) => unsubscribe(token));
|
|
1092
|
+
olMap.set(KEY_EVENT_SUBSCRIPTIONS, []);
|
|
1093
|
+
}
|
|
1315
1094
|
};
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1095
|
+
var toOlMap = async (gsMap, options, env, importer, target) => {
|
|
1096
|
+
const olMap = withState(gsMap, new Map$1(options));
|
|
1097
|
+
olMap.set(KEY_ENV, env);
|
|
1098
|
+
olMap.setView(new View({
|
|
1099
|
+
center: gsMap.view.center && gsMap.view.center.length == 2 ? gsMap.view.center : DEFAULT_GSMAP.view.center,
|
|
1100
|
+
zoom: gsMap.view.zoom || DEFAULT_GSMAP.view.zoom,
|
|
1101
|
+
projection: gsMap.view.projection || DEFAULT_GSMAP.view.projection
|
|
1102
|
+
}));
|
|
1103
|
+
for (const layer of gsMap.layers || []) {
|
|
1104
|
+
const olLayer = toOlLayer(layer, env);
|
|
1105
|
+
olMap.addLayer(olLayer);
|
|
1106
|
+
}
|
|
1107
|
+
if (target) olMap.setTarget(target);
|
|
1108
|
+
for (const overlay of gsMap.overlays || []) {
|
|
1109
|
+
const olOverlay = toOlOverlay(overlay);
|
|
1110
|
+
olMap.addOverlay(olOverlay);
|
|
1111
|
+
await importOverlaySource(olOverlay, overlay.src, importer);
|
|
1112
|
+
}
|
|
1113
|
+
for (const control of gsMap.controls || []) {
|
|
1114
|
+
const olControl = toOlControl(control);
|
|
1115
|
+
olMap.addControl(olControl);
|
|
1116
|
+
await importControlSource(olControl, control.src, importer);
|
|
1117
|
+
}
|
|
1118
|
+
return olMap;
|
|
1326
1119
|
};
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1120
|
+
//#endregion
|
|
1121
|
+
//#region src/ol/gs-ol2gs.ts
|
|
1122
|
+
var toGsLayerType = (tag) => {
|
|
1123
|
+
switch (tag?.toLowerCase()) {
|
|
1124
|
+
case "osm":
|
|
1125
|
+
case "bing":
|
|
1126
|
+
case "google":
|
|
1127
|
+
case "geotiff":
|
|
1128
|
+
case "wms":
|
|
1129
|
+
case "wmts":
|
|
1130
|
+
case "xyz": return GsLayerType.TILE;
|
|
1131
|
+
case "bm":
|
|
1132
|
+
case "basemap.de": return GsLayerType.GROUP;
|
|
1133
|
+
case "scripted": return GsLayerType.SCRIPTED;
|
|
1134
|
+
default: return GsLayerType.VECTOR;
|
|
1135
|
+
}
|
|
1333
1136
|
};
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1137
|
+
var toGsSourceType = (tag) => {
|
|
1138
|
+
if (tag) {
|
|
1139
|
+
tag = tag.toLowerCase();
|
|
1140
|
+
const hit = Object.values(GsSourceType).find((t) => tag === t.toLowerCase());
|
|
1141
|
+
if (hit) return hit;
|
|
1142
|
+
}
|
|
1143
|
+
throw new Error("Unsupported source type: " + tag);
|
|
1144
|
+
};
|
|
1145
|
+
var toSourceUrl = (sourceType) => {
|
|
1146
|
+
switch (sourceType) {
|
|
1147
|
+
case GsSourceType.BM: return "https://sgx.geodatenzentrum.de/gdz_basemapworld_vektor/styles/bm_web_wld_col.json";
|
|
1148
|
+
}
|
|
1149
|
+
};
|
|
1150
|
+
var withGsState = (olObj, gsState) => {
|
|
1151
|
+
const state = olObj.get(KEY_STATE);
|
|
1152
|
+
gsState.state = state;
|
|
1153
|
+
if (state?.uuid) gsState.uuid = state.uuid;
|
|
1154
|
+
else {
|
|
1155
|
+
const uuid = olObj.get(KEY_UUID);
|
|
1156
|
+
if (uuid) gsState.uuid = uuid;
|
|
1157
|
+
}
|
|
1158
|
+
return gsState;
|
|
1346
1159
|
};
|
|
1347
1160
|
function toGsGeometry(geometry) {
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1161
|
+
return withGsState(geometry, {
|
|
1162
|
+
type: geometry.getType(),
|
|
1163
|
+
coordinates: geometry.getCoordinates()
|
|
1164
|
+
});
|
|
1352
1165
|
}
|
|
1353
1166
|
function toGsFeature(feature) {
|
|
1354
|
-
|
|
1355
|
-
geometry: toGsGeometry(feature.getGeometry())
|
|
1356
|
-
});
|
|
1167
|
+
return withGsState(feature, { geometry: toGsGeometry(feature.getGeometry()) });
|
|
1357
1168
|
}
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
const target = typeof options.containerSelector === "string" ? document.querySelector(options.containerSelector) : options.containerSelector;
|
|
1377
|
-
const olMap = await toOlMap(options.gsMap, mapOptions, options.env, importer, target);
|
|
1378
|
-
return olMap;
|
|
1169
|
+
//#endregion
|
|
1170
|
+
//#region src/ol/gs-ol-lib.ts
|
|
1171
|
+
var olLib = async (options) => {
|
|
1172
|
+
const mapOptions = {
|
|
1173
|
+
interactions: defaultInteractions({ keyboard: false }),
|
|
1174
|
+
controls: defaultControls(options.mapOptions?.controls)
|
|
1175
|
+
};
|
|
1176
|
+
let importer = options.importer;
|
|
1177
|
+
if (!importer && options.modules) importer = async (src) => {
|
|
1178
|
+
const module = options.modules[src];
|
|
1179
|
+
if (module) {
|
|
1180
|
+
if (typeof module === "string") return import(module);
|
|
1181
|
+
return module;
|
|
1182
|
+
}
|
|
1183
|
+
throw new Error(`Module not found: ${src}`);
|
|
1184
|
+
};
|
|
1185
|
+
const target = typeof options.containerSelector === "string" ? document.querySelector(options.containerSelector) : options.containerSelector;
|
|
1186
|
+
return await toOlMap(options.gsMap, mapOptions, options.env, importer, target);
|
|
1379
1187
|
};
|
|
1188
|
+
//#endregion
|
|
1189
|
+
//#region src/ol/openlayers-map-renderer.ts
|
|
1190
|
+
/**
|
|
1191
|
+
* Lightweight helper to extract minimal GsFeature data for style evaluation
|
|
1192
|
+
* Avoids the overhead of full toGsFeature() conversion
|
|
1193
|
+
*/
|
|
1380
1194
|
function getFeatureStyleData(feature) {
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
state: feature.get(KEY_STATE)
|
|
1389
|
-
});
|
|
1195
|
+
return ensureUuid({
|
|
1196
|
+
geometry: ensureUuid({
|
|
1197
|
+
type: feature.getGeometry().getType(),
|
|
1198
|
+
coordinates: []
|
|
1199
|
+
}),
|
|
1200
|
+
state: feature.get(KEY_STATE)
|
|
1201
|
+
});
|
|
1390
1202
|
}
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
async transform(coord, options) {
|
|
1601
|
-
if (!this.olMap) {
|
|
1602
|
-
throw new Error("Map not available for coordinate transformation");
|
|
1603
|
-
}
|
|
1604
|
-
const view = this.olMap.getView();
|
|
1605
|
-
const mapProj = view.getProjection()?.getCode() || "EPSG:3857";
|
|
1606
|
-
const source2 = options?.sourceProjection ?? mapProj;
|
|
1607
|
-
const target = options?.targetProjection ?? "EPSG:4326";
|
|
1608
|
-
if (source2 === target) {
|
|
1609
|
-
return coord;
|
|
1610
|
-
}
|
|
1611
|
-
const result = proj.transform(coord, source2, target);
|
|
1612
|
-
return result;
|
|
1613
|
-
}
|
|
1614
|
-
}
|
|
1615
|
-
class OpenLayersMapOperations {
|
|
1616
|
-
constructor(olMap, renderer) {
|
|
1617
|
-
this.olMap = olMap;
|
|
1618
|
-
this.renderer = renderer;
|
|
1619
|
-
if (!olMap) {
|
|
1620
|
-
throw new Error("OpenLayers map is required for operations");
|
|
1621
|
-
}
|
|
1622
|
-
this.keyDownListener = (event) => {
|
|
1623
|
-
if (event.key === "Escape") {
|
|
1624
|
-
if (this.drawInteraction) {
|
|
1625
|
-
this.disableDrawing();
|
|
1626
|
-
this.renderer?.triggerSync({ type: "drawingDisabled" });
|
|
1627
|
-
}
|
|
1628
|
-
if (this.selectInteraction) {
|
|
1629
|
-
this.disableSelection();
|
|
1630
|
-
}
|
|
1631
|
-
}
|
|
1632
|
-
};
|
|
1633
|
-
const target = this.olMap.getTargetElement();
|
|
1634
|
-
if (target && target instanceof HTMLElement) {
|
|
1635
|
-
target.setAttribute("tabindex", "-1");
|
|
1636
|
-
target.addEventListener("keydown", this.keyDownListener);
|
|
1637
|
-
}
|
|
1638
|
-
}
|
|
1639
|
-
async setZoom(zoom) {
|
|
1640
|
-
this.olMap.getView().setZoom(zoom);
|
|
1641
|
-
}
|
|
1642
|
-
async setCenter(center) {
|
|
1643
|
-
this.olMap.getView().setCenter(center);
|
|
1644
|
-
}
|
|
1645
|
-
async switchColorMode(mode) {
|
|
1646
|
-
const olMap = this.olMap;
|
|
1647
|
-
let darkMode = olMap.get("darkmode") ?? false;
|
|
1648
|
-
if (mode === "dark") {
|
|
1649
|
-
darkMode = true;
|
|
1650
|
-
} else if (mode === "light") {
|
|
1651
|
-
darkMode = false;
|
|
1652
|
-
} else {
|
|
1653
|
-
darkMode = !darkMode;
|
|
1654
|
-
}
|
|
1655
|
-
olMap.set("darkmode", darkMode);
|
|
1656
|
-
const canvasElements = document.querySelectorAll("canvas");
|
|
1657
|
-
canvasElements.forEach((canvas) => {
|
|
1658
|
-
canvas.style.filter = darkMode ? "invert(100%)" : "";
|
|
1659
|
-
});
|
|
1660
|
-
olMap.render();
|
|
1661
|
-
}
|
|
1662
|
-
async addLayer(layer, isBasemap) {
|
|
1663
|
-
const olLayer = toOlLayer(layer);
|
|
1664
|
-
if (isBasemap) {
|
|
1665
|
-
this.olMap.getLayers().insertAt(0, olLayer);
|
|
1666
|
-
} else {
|
|
1667
|
-
this.olMap.getLayers().push(olLayer);
|
|
1668
|
-
}
|
|
1669
|
-
}
|
|
1670
|
-
async deleteLayer(uuid) {
|
|
1671
|
-
const layers = this.olMap.getLayers();
|
|
1672
|
-
for (let i = 0; i < layers.getLength(); i++) {
|
|
1673
|
-
const layer = layers.item(i);
|
|
1674
|
-
if (layer.get(KEY_UUID) === uuid) {
|
|
1675
|
-
layers.removeAt(i);
|
|
1676
|
-
return;
|
|
1677
|
-
}
|
|
1678
|
-
}
|
|
1679
|
-
}
|
|
1680
|
-
async renameLayer(uuid, newName) {
|
|
1681
|
-
const layers = this.olMap.getLayers();
|
|
1682
|
-
for (let i = 0; i < layers.getLength(); i++) {
|
|
1683
|
-
const layer = layers.item(i);
|
|
1684
|
-
if (layer.get(KEY_UUID) === uuid) {
|
|
1685
|
-
layer.set(KEY_NAME, newName);
|
|
1686
|
-
return;
|
|
1687
|
-
}
|
|
1688
|
-
}
|
|
1689
|
-
}
|
|
1690
|
-
async moveLayer(uuid, targetUuid) {
|
|
1691
|
-
const layers = this.olMap.getLayers();
|
|
1692
|
-
let fromIndex = -1;
|
|
1693
|
-
let toIndex = -1;
|
|
1694
|
-
for (let i = 0; i < layers.getLength(); i++) {
|
|
1695
|
-
const layer = layers.item(i);
|
|
1696
|
-
if (layer.get(KEY_UUID) === uuid) {
|
|
1697
|
-
fromIndex = i;
|
|
1698
|
-
}
|
|
1699
|
-
if (targetUuid && layer.get(KEY_UUID) === targetUuid) {
|
|
1700
|
-
toIndex = i;
|
|
1701
|
-
}
|
|
1702
|
-
}
|
|
1703
|
-
if (fromIndex < 0) return;
|
|
1704
|
-
if (targetUuid) {
|
|
1705
|
-
if (toIndex < 0 || fromIndex === toIndex) return;
|
|
1706
|
-
} else {
|
|
1707
|
-
toIndex = fromIndex > 0 ? fromIndex - 1 : fromIndex + 1;
|
|
1708
|
-
}
|
|
1709
|
-
if (toIndex >= 0 && toIndex < layers.getLength() && fromIndex !== toIndex) {
|
|
1710
|
-
const layer = layers.item(fromIndex);
|
|
1711
|
-
layers.removeAt(fromIndex);
|
|
1712
|
-
layers.insertAt(toIndex, layer);
|
|
1713
|
-
}
|
|
1714
|
-
}
|
|
1715
|
-
async setLayerVisible(uuid, visible) {
|
|
1716
|
-
const layers = this.olMap.getLayers();
|
|
1717
|
-
for (let i = 0; i < layers.getLength(); i++) {
|
|
1718
|
-
const layer = layers.item(i);
|
|
1719
|
-
if (layer.get(KEY_UUID) === uuid) {
|
|
1720
|
-
layer.setVisible(visible);
|
|
1721
|
-
return;
|
|
1722
|
-
}
|
|
1723
|
-
}
|
|
1724
|
-
}
|
|
1725
|
-
async addControlFromModule(_src) {
|
|
1726
|
-
}
|
|
1727
|
-
async removeControl(_uuid) {
|
|
1728
|
-
}
|
|
1729
|
-
async addOverlayFromModule(_src, _position) {
|
|
1730
|
-
}
|
|
1731
|
-
async removeOverlay(_uuid) {
|
|
1732
|
-
}
|
|
1733
|
-
setCursor(cursor) {
|
|
1734
|
-
const viewport = this.olMap.getViewport();
|
|
1735
|
-
if (viewport) {
|
|
1736
|
-
viewport.style.cursor = cursor;
|
|
1737
|
-
}
|
|
1738
|
-
}
|
|
1739
|
-
async enableDrawing(geometryType, layerUuid) {
|
|
1740
|
-
this.disableSelection();
|
|
1741
|
-
if (this.drawInteraction) {
|
|
1742
|
-
this.olMap.removeInteraction(this.drawInteraction);
|
|
1743
|
-
}
|
|
1744
|
-
this.activeDrawingLayerUuid = layerUuid;
|
|
1745
|
-
this.setCursor("crosshair");
|
|
1746
|
-
const layers = this.olMap.getLayers();
|
|
1747
|
-
let layer;
|
|
1748
|
-
for (let i = 0; i < layers.getLength(); i++) {
|
|
1749
|
-
const l = layers.item(i);
|
|
1750
|
-
if (l.get(KEY_UUID) === layerUuid) {
|
|
1751
|
-
layer = l;
|
|
1752
|
-
break;
|
|
1753
|
-
}
|
|
1754
|
-
}
|
|
1755
|
-
if (!layer || !(layer instanceof layerNS.Vector)) {
|
|
1756
|
-
throw new Error("Drawing only supported on vector layers");
|
|
1757
|
-
}
|
|
1758
|
-
const source2 = layer.getSource();
|
|
1759
|
-
if (!source2) {
|
|
1760
|
-
throw new Error("Layer has no source");
|
|
1761
|
-
}
|
|
1762
|
-
const layerSourceType = layer.get("sourceType");
|
|
1763
|
-
if (layerSourceType && layerSourceType !== GsSourceType.Features) {
|
|
1764
|
-
throw new Error("Drawing only supported on layers with in-memory features");
|
|
1765
|
-
}
|
|
1766
|
-
this.drawInteraction = new interactionNS.Draw({
|
|
1767
|
-
source: source2,
|
|
1768
|
-
type: geometryType
|
|
1769
|
-
});
|
|
1770
|
-
const onFeatureAdded = (event) => {
|
|
1771
|
-
const feature = event.feature;
|
|
1772
|
-
if (feature && !feature.get(KEY_UUID)) {
|
|
1773
|
-
const uuid = v4$1();
|
|
1774
|
-
feature.set(KEY_UUID, uuid);
|
|
1775
|
-
const state = feature.get(KEY_STATE) || {};
|
|
1776
|
-
state.uuid = uuid;
|
|
1777
|
-
feature.set(KEY_STATE, state);
|
|
1778
|
-
}
|
|
1779
|
-
if (this.renderer && this.activeDrawingLayerUuid) {
|
|
1780
|
-
this.renderer.syncLayerFeaturesToModel(this.activeDrawingLayerUuid);
|
|
1781
|
-
}
|
|
1782
|
-
this.renderer?.triggerDirty();
|
|
1783
|
-
};
|
|
1784
|
-
source2.on("addfeature", onFeatureAdded);
|
|
1785
|
-
this.drawInteraction._featureAddedListener = onFeatureAdded;
|
|
1786
|
-
this.drawInteraction._sourceRef = source2;
|
|
1787
|
-
this.olMap.addInteraction(this.drawInteraction);
|
|
1788
|
-
}
|
|
1789
|
-
async disableDrawing() {
|
|
1790
|
-
if (this.drawInteraction) {
|
|
1791
|
-
const listener = this.drawInteraction._featureAddedListener;
|
|
1792
|
-
const source2 = this.drawInteraction._sourceRef;
|
|
1793
|
-
if (listener && source2) {
|
|
1794
|
-
source2.un("addfeature", listener);
|
|
1795
|
-
}
|
|
1796
|
-
this.olMap.removeInteraction(this.drawInteraction);
|
|
1797
|
-
this.drawInteraction = void 0;
|
|
1798
|
-
this.setCursor("");
|
|
1799
|
-
}
|
|
1800
|
-
}
|
|
1801
|
-
cleanup() {
|
|
1802
|
-
if (this.keyDownListener) {
|
|
1803
|
-
const target = this.olMap.getTargetElement();
|
|
1804
|
-
if (target && target instanceof HTMLElement) {
|
|
1805
|
-
target.removeEventListener("keydown", this.keyDownListener);
|
|
1806
|
-
}
|
|
1807
|
-
this.keyDownListener = void 0;
|
|
1808
|
-
}
|
|
1809
|
-
}
|
|
1810
|
-
async enableFeatureSelection() {
|
|
1811
|
-
this.disableDrawing();
|
|
1812
|
-
this.disableSelection();
|
|
1813
|
-
const olLayers = this.olMap.getLayers();
|
|
1814
|
-
const vectorLayers = olLayers.getArray().filter((layer) => layer instanceof layerNS.Vector);
|
|
1815
|
-
if (vectorLayers.length === 0) {
|
|
1816
|
-
throw new Error("No vector layers available for selection");
|
|
1817
|
-
}
|
|
1818
|
-
const gsMap = this.renderer?.gsMap;
|
|
1819
|
-
const selectionStyle = gsMap?.styles?.["selection"];
|
|
1820
|
-
const selectOptions = {
|
|
1821
|
-
condition: eventsCondition.click,
|
|
1822
|
-
layers: vectorLayers,
|
|
1823
|
-
hitTolerance: 5,
|
|
1824
|
-
style: selectionStyle ? toOlStyle(selectionStyle) : (_feature) => {
|
|
1825
|
-
const stroke = new style.Stroke({ color: "rgba(255, 255, 0, 1)", width: 3 });
|
|
1826
|
-
const fill = new style.Fill({ color: "rgba(255, 255, 0, 0.3)" });
|
|
1827
|
-
return new style.Style({
|
|
1828
|
-
image: new style.Circle({ radius: 7, fill, stroke }),
|
|
1829
|
-
stroke,
|
|
1830
|
-
fill
|
|
1831
|
-
});
|
|
1832
|
-
}
|
|
1833
|
-
};
|
|
1834
|
-
this.selectInteraction = new interactionNS.Select(selectOptions);
|
|
1835
|
-
this.selectInteraction.on("select", (event) => {
|
|
1836
|
-
if (event.selected.length > 0) {
|
|
1837
|
-
const selectedFeature = event.selected[0];
|
|
1838
|
-
let featureLayerUuid;
|
|
1839
|
-
olLayers.getArray().forEach((layer) => {
|
|
1840
|
-
if (layer instanceof layerNS.Vector) {
|
|
1841
|
-
const source2 = layer.getSource();
|
|
1842
|
-
if (source2 && source2.hasFeature(selectedFeature)) {
|
|
1843
|
-
const uuid = layer.get(KEY_UUID);
|
|
1844
|
-
if (uuid) featureLayerUuid = uuid;
|
|
1845
|
-
}
|
|
1846
|
-
}
|
|
1847
|
-
});
|
|
1848
|
-
if (featureLayerUuid && this.renderer) {
|
|
1849
|
-
const gsFeature = toGsFeature(selectedFeature);
|
|
1850
|
-
const geometry = selectedFeature.getGeometry();
|
|
1851
|
-
const metrics = {};
|
|
1852
|
-
if (geometry) {
|
|
1853
|
-
const geometryType = geometry.getType();
|
|
1854
|
-
try {
|
|
1855
|
-
if (geometryType === "LineString" || geometryType === "MultiLineString") {
|
|
1856
|
-
metrics.length = sphere.getLength(geometry, { projection: this.olMap.getView().getProjection() });
|
|
1857
|
-
} else if (geometryType === "Polygon" || geometryType === "MultiPolygon") {
|
|
1858
|
-
metrics.area = sphere.getArea(geometry, { projection: this.olMap.getView().getProjection() });
|
|
1859
|
-
const coordinates = geometryType === "Polygon" ? geometry.getCoordinates()[0] : geometry.getCoordinates()[0][0];
|
|
1860
|
-
if (coordinates?.length > 0) {
|
|
1861
|
-
const perimeterLine = new olGeom.LineString(coordinates);
|
|
1862
|
-
metrics.length = sphere.getLength(perimeterLine, { projection: this.olMap.getView().getProjection() });
|
|
1863
|
-
}
|
|
1864
|
-
}
|
|
1865
|
-
} catch (error) {
|
|
1866
|
-
console.warn("Error calculating feature metrics:", error);
|
|
1867
|
-
}
|
|
1868
|
-
}
|
|
1869
|
-
this.renderer.triggerSync({
|
|
1870
|
-
type: "featureSelected",
|
|
1871
|
-
layerUuid: featureLayerUuid,
|
|
1872
|
-
feature: gsFeature,
|
|
1873
|
-
metrics
|
|
1874
|
-
});
|
|
1875
|
-
}
|
|
1876
|
-
} else if (event.deselected.length > 0) {
|
|
1877
|
-
this.renderer?.triggerSync({ type: "featureDeselected" });
|
|
1878
|
-
}
|
|
1879
|
-
});
|
|
1880
|
-
this.olMap.addInteraction(this.selectInteraction);
|
|
1881
|
-
this.setCursor("pointer");
|
|
1882
|
-
}
|
|
1883
|
-
async deleteSelectedFeatures() {
|
|
1884
|
-
if (!this.selectInteraction) {
|
|
1885
|
-
throw new Error("No selection interaction active");
|
|
1886
|
-
}
|
|
1887
|
-
const selectedFeatures = this.selectInteraction.getFeatures();
|
|
1888
|
-
if (selectedFeatures.getLength() === 0) {
|
|
1889
|
-
throw new Error("No features selected");
|
|
1890
|
-
}
|
|
1891
|
-
const layersToSync = /* @__PURE__ */ new Set();
|
|
1892
|
-
const olLayers = this.olMap.getLayers();
|
|
1893
|
-
selectedFeatures.forEach((feature) => {
|
|
1894
|
-
for (let i = 0; i < olLayers.getLength(); i++) {
|
|
1895
|
-
const layer = olLayers.item(i);
|
|
1896
|
-
if (layer instanceof layerNS.Vector) {
|
|
1897
|
-
const source2 = layer.getSource();
|
|
1898
|
-
if (source2 && source2.hasFeature(feature)) {
|
|
1899
|
-
source2.removeFeature(feature);
|
|
1900
|
-
const layerUuid = layer.get(KEY_UUID);
|
|
1901
|
-
if (layerUuid) layersToSync.add(layerUuid);
|
|
1902
|
-
break;
|
|
1903
|
-
}
|
|
1904
|
-
}
|
|
1905
|
-
}
|
|
1906
|
-
});
|
|
1907
|
-
selectedFeatures.clear();
|
|
1908
|
-
if (this.renderer && layersToSync.size > 0) {
|
|
1909
|
-
layersToSync.forEach((layerUuid) => {
|
|
1910
|
-
this.renderer.syncLayerFeaturesToModel(layerUuid);
|
|
1911
|
-
});
|
|
1912
|
-
}
|
|
1913
|
-
this.renderer?.triggerDirty();
|
|
1914
|
-
}
|
|
1915
|
-
async disableSelection() {
|
|
1916
|
-
if (this.selectInteraction) {
|
|
1917
|
-
this.olMap.removeInteraction(this.selectInteraction);
|
|
1918
|
-
this.selectInteraction = void 0;
|
|
1919
|
-
this.setCursor("");
|
|
1920
|
-
this.renderer?.triggerSync({ type: "featureDeselected" });
|
|
1921
|
-
}
|
|
1922
|
-
}
|
|
1923
|
-
}
|
|
1924
|
-
const rtUtils = {
|
|
1925
|
-
async resolveUrl(url) {
|
|
1926
|
-
return url;
|
|
1927
|
-
}
|
|
1203
|
+
/**
|
|
1204
|
+
* OpenLayers map renderer that manages OpenLayers maps
|
|
1205
|
+
* Provides complete isolation between the host app and the rendering engine
|
|
1206
|
+
* User modules are handled by the toOlMap() function
|
|
1207
|
+
*/
|
|
1208
|
+
var OpenLayersMapRenderer = class {
|
|
1209
|
+
constructor(gsMap, env) {
|
|
1210
|
+
this.isDestroyed = false;
|
|
1211
|
+
this.styleCache = /* @__PURE__ */ new Map();
|
|
1212
|
+
this.gsMap = gsMap;
|
|
1213
|
+
this.env = env;
|
|
1214
|
+
}
|
|
1215
|
+
async reattached() {}
|
|
1216
|
+
async render(container) {
|
|
1217
|
+
try {
|
|
1218
|
+
this.olMap = await olLib({
|
|
1219
|
+
containerSelector: container,
|
|
1220
|
+
gsMap: this.gsMap,
|
|
1221
|
+
env: this.env,
|
|
1222
|
+
mapOptions: { controls: {
|
|
1223
|
+
zoom: false,
|
|
1224
|
+
attribution: false
|
|
1225
|
+
} }
|
|
1226
|
+
});
|
|
1227
|
+
this.operations = new OpenLayersMapOperations(this.olMap, this);
|
|
1228
|
+
this.applyStylesToLayers();
|
|
1229
|
+
this.olMap.once("rendercomplete", () => {
|
|
1230
|
+
this.setupEventListeners();
|
|
1231
|
+
});
|
|
1232
|
+
} catch (error) {
|
|
1233
|
+
console.error("Failed to render map:", error);
|
|
1234
|
+
throw error;
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
applyStylesToLayers() {
|
|
1238
|
+
if (!this.olMap) return;
|
|
1239
|
+
this.olMap.getLayers().getArray().forEach((layer$1) => {
|
|
1240
|
+
if (layer$1 instanceof layer.Vector) this.applyStyleToVectorLayer(layer$1);
|
|
1241
|
+
});
|
|
1242
|
+
}
|
|
1243
|
+
applyStyleToVectorLayer(layer) {
|
|
1244
|
+
const layerName = layer.get(KEY_NAME);
|
|
1245
|
+
const styleFunction = (feature) => {
|
|
1246
|
+
if (!(feature instanceof gs_olns_exports.Feature)) return;
|
|
1247
|
+
const featureStyleData = getFeatureStyleData(feature);
|
|
1248
|
+
const styleRules = this.gsMap.styleRules;
|
|
1249
|
+
const stylesMap = this.gsMap.styles;
|
|
1250
|
+
if (styleRules && stylesMap) {
|
|
1251
|
+
const gsStyle = getStyleForFeature(featureStyleData, styleRules, stylesMap, layerName);
|
|
1252
|
+
if (gsStyle && gsStyle.id) {
|
|
1253
|
+
let olStyle = this.styleCache.get(gsStyle.id);
|
|
1254
|
+
if (!olStyle) {
|
|
1255
|
+
olStyle = toOlStyle(gsStyle);
|
|
1256
|
+
this.styleCache.set(gsStyle.id, olStyle);
|
|
1257
|
+
}
|
|
1258
|
+
return olStyle;
|
|
1259
|
+
} else if (gsStyle) return toOlStyle(gsStyle);
|
|
1260
|
+
}
|
|
1261
|
+
};
|
|
1262
|
+
layer.setStyle(styleFunction);
|
|
1263
|
+
}
|
|
1264
|
+
clearStyleCache() {
|
|
1265
|
+
this.styleCache.clear();
|
|
1266
|
+
}
|
|
1267
|
+
async modelToUI(updatedGsMap) {
|
|
1268
|
+
if (!this.olMap) throw new Error("Map not initialized");
|
|
1269
|
+
if (updatedGsMap) this.gsMap = updatedGsMap;
|
|
1270
|
+
this.clearStyleCache();
|
|
1271
|
+
const target = this.olMap.getTarget();
|
|
1272
|
+
if (!target || typeof target === "string") throw new Error("Map container not found or invalid");
|
|
1273
|
+
this.destroy();
|
|
1274
|
+
target.innerHTML = "";
|
|
1275
|
+
this.isDestroyed = false;
|
|
1276
|
+
await this.render(target);
|
|
1277
|
+
}
|
|
1278
|
+
getOperations() {
|
|
1279
|
+
if (!this.operations) throw new Error("Operations not available - map not rendered yet");
|
|
1280
|
+
return this.operations;
|
|
1281
|
+
}
|
|
1282
|
+
async getViewExtent() {
|
|
1283
|
+
console.debug("Getting view extent");
|
|
1284
|
+
if (!this.olMap) throw new Error("Map not available for extent calculation");
|
|
1285
|
+
const extent = this.olMap.getView().calculateExtent();
|
|
1286
|
+
console.debug(`View extent: ${extent}`);
|
|
1287
|
+
return extent;
|
|
1288
|
+
}
|
|
1289
|
+
async captureScreenshot() {
|
|
1290
|
+
if (!this.olMap) return {
|
|
1291
|
+
success: false,
|
|
1292
|
+
error: "Map not available"
|
|
1293
|
+
};
|
|
1294
|
+
const olMap = this.olMap;
|
|
1295
|
+
await new Promise((resolve) => {
|
|
1296
|
+
olMap.renderSync();
|
|
1297
|
+
olMap.once("rendercomplete", () => resolve());
|
|
1298
|
+
setTimeout(() => resolve(), 2e3);
|
|
1299
|
+
});
|
|
1300
|
+
const size = olMap.getSize();
|
|
1301
|
+
const width = size ? size[0] : olMap.getViewport().clientWidth;
|
|
1302
|
+
const height = size ? size[1] : olMap.getViewport().clientHeight;
|
|
1303
|
+
try {
|
|
1304
|
+
const canvas = olMap.getViewport().querySelector("canvas");
|
|
1305
|
+
if (!canvas) return {
|
|
1306
|
+
success: false,
|
|
1307
|
+
error: "Map canvas not found"
|
|
1308
|
+
};
|
|
1309
|
+
return {
|
|
1310
|
+
success: true,
|
|
1311
|
+
dataUrl: canvas.toDataURL("image/png"),
|
|
1312
|
+
width,
|
|
1313
|
+
height
|
|
1314
|
+
};
|
|
1315
|
+
} catch (error) {
|
|
1316
|
+
return {
|
|
1317
|
+
success: false,
|
|
1318
|
+
error: `Failed to capture canvas: ${error.message}`
|
|
1319
|
+
};
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
setOnDirty(callback) {
|
|
1323
|
+
this.onDirtyCallback = callback;
|
|
1324
|
+
}
|
|
1325
|
+
setOnSync(callback) {
|
|
1326
|
+
this.onSyncCallback = callback;
|
|
1327
|
+
}
|
|
1328
|
+
triggerDirty() {
|
|
1329
|
+
if (this.isDestroyed || !this.onDirtyCallback) return;
|
|
1330
|
+
this.onDirtyCallback();
|
|
1331
|
+
}
|
|
1332
|
+
triggerSync(event) {
|
|
1333
|
+
if (this.isDestroyed || !this.onSyncCallback) return;
|
|
1334
|
+
this.onSyncCallback(event);
|
|
1335
|
+
}
|
|
1336
|
+
syncViewToModel() {
|
|
1337
|
+
if (!this.olMap) return;
|
|
1338
|
+
const view = this.olMap.getView();
|
|
1339
|
+
const center = view.getCenter();
|
|
1340
|
+
const zoom = view.getZoom();
|
|
1341
|
+
const rotation = view.getRotation();
|
|
1342
|
+
if (center && zoom !== void 0) this.triggerSync({
|
|
1343
|
+
type: "viewChanged",
|
|
1344
|
+
view: {
|
|
1345
|
+
center,
|
|
1346
|
+
zoom,
|
|
1347
|
+
rotation
|
|
1348
|
+
}
|
|
1349
|
+
});
|
|
1350
|
+
}
|
|
1351
|
+
syncLayerFeaturesToModel(layerUuid) {
|
|
1352
|
+
if (!this.olMap) return;
|
|
1353
|
+
const layers = this.olMap.getLayers();
|
|
1354
|
+
let olLayer;
|
|
1355
|
+
for (let i = 0; i < layers.getLength(); i++) {
|
|
1356
|
+
const layer = layers.item(i);
|
|
1357
|
+
if (layer.get("uuid") === layerUuid) {
|
|
1358
|
+
olLayer = layer;
|
|
1359
|
+
break;
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
if (!olLayer || !(olLayer instanceof layer.Vector)) return;
|
|
1363
|
+
const source = olLayer.getSource();
|
|
1364
|
+
if (!source) return;
|
|
1365
|
+
const gsFeatures = source.getFeatures().map((olFeature) => toGsFeature(olFeature));
|
|
1366
|
+
this.triggerSync({
|
|
1367
|
+
type: "featuresChanged",
|
|
1368
|
+
layerUuid,
|
|
1369
|
+
features: gsFeatures
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
setupEventListeners() {
|
|
1373
|
+
if (!this.olMap) return;
|
|
1374
|
+
this.olMap.getView().on("change:center", () => {
|
|
1375
|
+
this.syncViewToModel();
|
|
1376
|
+
this.triggerDirty();
|
|
1377
|
+
});
|
|
1378
|
+
this.olMap.getView().on("change:resolution", () => {
|
|
1379
|
+
this.syncViewToModel();
|
|
1380
|
+
this.triggerDirty();
|
|
1381
|
+
});
|
|
1382
|
+
this.olMap.getView().on("change:rotation", () => {
|
|
1383
|
+
this.syncViewToModel();
|
|
1384
|
+
this.triggerDirty();
|
|
1385
|
+
});
|
|
1386
|
+
this.olMap.getLayers().on("add", () => this.triggerDirty());
|
|
1387
|
+
this.olMap.getLayers().on("remove", () => this.triggerDirty());
|
|
1388
|
+
this.olMap.getControls().on("add", () => this.triggerDirty());
|
|
1389
|
+
this.olMap.getControls().on("remove", () => this.triggerDirty());
|
|
1390
|
+
this.olMap.getOverlays().on("add", () => this.triggerDirty());
|
|
1391
|
+
this.olMap.getOverlays().on("remove", () => this.triggerDirty());
|
|
1392
|
+
}
|
|
1393
|
+
destroy() {
|
|
1394
|
+
this.isDestroyed = true;
|
|
1395
|
+
this.clearStyleCache();
|
|
1396
|
+
if (this.operations) {
|
|
1397
|
+
const ops = this.operations;
|
|
1398
|
+
if (ops.cleanup) ops.cleanup();
|
|
1399
|
+
}
|
|
1400
|
+
if (this.olMap) cleanupEventSubscriptions(this.olMap);
|
|
1401
|
+
this.olMap?.dispose();
|
|
1402
|
+
this.olMap = void 0;
|
|
1403
|
+
}
|
|
1404
|
+
async transform(coord, options) {
|
|
1405
|
+
if (!this.olMap) throw new Error("Map not available for coordinate transformation");
|
|
1406
|
+
const mapProj = this.olMap.getView().getProjection()?.getCode() || "EPSG:3857";
|
|
1407
|
+
const source = options?.sourceProjection ?? mapProj;
|
|
1408
|
+
const target = options?.targetProjection ?? "EPSG:4326";
|
|
1409
|
+
if (source === target) return coord;
|
|
1410
|
+
return proj.transform(coord, source, target);
|
|
1411
|
+
}
|
|
1928
1412
|
};
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
1413
|
+
/**
|
|
1414
|
+
* OpenLayers-specific map operations implementation
|
|
1415
|
+
*/
|
|
1416
|
+
var OpenLayersMapOperations = class {
|
|
1417
|
+
constructor(olMap, renderer) {
|
|
1418
|
+
this.olMap = olMap;
|
|
1419
|
+
this.renderer = renderer;
|
|
1420
|
+
if (!olMap) throw new Error("OpenLayers map is required for operations");
|
|
1421
|
+
this.keyDownListener = (event) => {
|
|
1422
|
+
if (event.key === "Escape") {
|
|
1423
|
+
if (this.drawInteraction) {
|
|
1424
|
+
this.disableDrawing();
|
|
1425
|
+
this.renderer?.triggerSync({ type: "drawingDisabled" });
|
|
1426
|
+
}
|
|
1427
|
+
if (this.selectInteraction) this.disableSelection();
|
|
1428
|
+
}
|
|
1429
|
+
};
|
|
1430
|
+
const target = this.olMap.getTargetElement();
|
|
1431
|
+
if (target && target instanceof HTMLElement) {
|
|
1432
|
+
target.setAttribute("tabindex", "-1");
|
|
1433
|
+
target.addEventListener("keydown", this.keyDownListener);
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
async setZoom(zoom) {
|
|
1437
|
+
this.olMap.getView().setZoom(zoom);
|
|
1438
|
+
}
|
|
1439
|
+
async setCenter(center) {
|
|
1440
|
+
this.olMap.getView().setCenter(center);
|
|
1441
|
+
}
|
|
1442
|
+
async switchColorMode(mode) {
|
|
1443
|
+
const olMap = this.olMap;
|
|
1444
|
+
let darkMode = olMap.get("darkmode") ?? false;
|
|
1445
|
+
if (mode === "dark") darkMode = true;
|
|
1446
|
+
else if (mode === "light") darkMode = false;
|
|
1447
|
+
else darkMode = !darkMode;
|
|
1448
|
+
olMap.set("darkmode", darkMode);
|
|
1449
|
+
document.querySelectorAll("canvas").forEach((canvas) => {
|
|
1450
|
+
canvas.style.filter = darkMode ? "invert(100%)" : "";
|
|
1451
|
+
});
|
|
1452
|
+
olMap.render();
|
|
1453
|
+
}
|
|
1454
|
+
async addLayer(layer, isBasemap) {
|
|
1455
|
+
const olLayer = toOlLayer(layer);
|
|
1456
|
+
if (isBasemap) this.olMap.getLayers().insertAt(0, olLayer);
|
|
1457
|
+
else this.olMap.getLayers().push(olLayer);
|
|
1458
|
+
}
|
|
1459
|
+
async deleteLayer(uuid) {
|
|
1460
|
+
const layers = this.olMap.getLayers();
|
|
1461
|
+
for (let i = 0; i < layers.getLength(); i++) if (layers.item(i).get("uuid") === uuid) {
|
|
1462
|
+
layers.removeAt(i);
|
|
1463
|
+
return;
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
async renameLayer(uuid, newName) {
|
|
1467
|
+
const layers = this.olMap.getLayers();
|
|
1468
|
+
for (let i = 0; i < layers.getLength(); i++) {
|
|
1469
|
+
const layer = layers.item(i);
|
|
1470
|
+
if (layer.get("uuid") === uuid) {
|
|
1471
|
+
layer.set(KEY_NAME, newName);
|
|
1472
|
+
return;
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
async moveLayer(uuid, targetUuid) {
|
|
1477
|
+
const layers = this.olMap.getLayers();
|
|
1478
|
+
let fromIndex = -1;
|
|
1479
|
+
let toIndex = -1;
|
|
1480
|
+
for (let i = 0; i < layers.getLength(); i++) {
|
|
1481
|
+
const layer = layers.item(i);
|
|
1482
|
+
if (layer.get("uuid") === uuid) fromIndex = i;
|
|
1483
|
+
if (targetUuid && layer.get("uuid") === targetUuid) toIndex = i;
|
|
1484
|
+
}
|
|
1485
|
+
if (fromIndex < 0) return;
|
|
1486
|
+
if (targetUuid) {
|
|
1487
|
+
if (toIndex < 0 || fromIndex === toIndex) return;
|
|
1488
|
+
} else toIndex = fromIndex > 0 ? fromIndex - 1 : fromIndex + 1;
|
|
1489
|
+
if (toIndex >= 0 && toIndex < layers.getLength() && fromIndex !== toIndex) {
|
|
1490
|
+
const layer = layers.item(fromIndex);
|
|
1491
|
+
layers.removeAt(fromIndex);
|
|
1492
|
+
layers.insertAt(toIndex, layer);
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
async setLayerVisible(uuid, visible) {
|
|
1496
|
+
const layers = this.olMap.getLayers();
|
|
1497
|
+
for (let i = 0; i < layers.getLength(); i++) {
|
|
1498
|
+
const layer = layers.item(i);
|
|
1499
|
+
if (layer.get("uuid") === uuid) {
|
|
1500
|
+
layer.setVisible(visible);
|
|
1501
|
+
return;
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
async addControlFromModule(_src) {}
|
|
1506
|
+
async removeControl(_uuid) {}
|
|
1507
|
+
async addOverlayFromModule(_src, _position) {}
|
|
1508
|
+
async removeOverlay(_uuid) {}
|
|
1509
|
+
setCursor(cursor) {
|
|
1510
|
+
const viewport = this.olMap.getViewport();
|
|
1511
|
+
if (viewport) viewport.style.cursor = cursor;
|
|
1512
|
+
}
|
|
1513
|
+
async enableDrawing(geometryType, layerUuid) {
|
|
1514
|
+
this.disableSelection();
|
|
1515
|
+
if (this.drawInteraction) this.olMap.removeInteraction(this.drawInteraction);
|
|
1516
|
+
this.activeDrawingLayerUuid = layerUuid;
|
|
1517
|
+
this.setCursor("crosshair");
|
|
1518
|
+
const layers = this.olMap.getLayers();
|
|
1519
|
+
let layer$2;
|
|
1520
|
+
for (let i = 0; i < layers.getLength(); i++) {
|
|
1521
|
+
const l = layers.item(i);
|
|
1522
|
+
if (l.get("uuid") === layerUuid) {
|
|
1523
|
+
layer$2 = l;
|
|
1524
|
+
break;
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
if (!layer$2 || !(layer$2 instanceof layer.Vector)) throw new Error("Drawing only supported on vector layers");
|
|
1528
|
+
const source = layer$2.getSource();
|
|
1529
|
+
if (!source) throw new Error("Layer has no source");
|
|
1530
|
+
const layerSourceType = layer$2.get("sourceType");
|
|
1531
|
+
if (layerSourceType && layerSourceType !== GsSourceType.Features) throw new Error("Drawing only supported on layers with in-memory features");
|
|
1532
|
+
this.drawInteraction = new interaction.Draw({
|
|
1533
|
+
source,
|
|
1534
|
+
type: geometryType
|
|
1535
|
+
});
|
|
1536
|
+
const onFeatureAdded = (event) => {
|
|
1537
|
+
const feature = event.feature;
|
|
1538
|
+
if (feature && !feature.get("uuid")) {
|
|
1539
|
+
const uuid = v4$1();
|
|
1540
|
+
feature.set(KEY_UUID, uuid);
|
|
1541
|
+
const state = feature.get("_state") || {};
|
|
1542
|
+
state.uuid = uuid;
|
|
1543
|
+
feature.set(KEY_STATE, state);
|
|
1544
|
+
}
|
|
1545
|
+
if (this.renderer && this.activeDrawingLayerUuid) this.renderer.syncLayerFeaturesToModel(this.activeDrawingLayerUuid);
|
|
1546
|
+
this.renderer?.triggerDirty();
|
|
1547
|
+
};
|
|
1548
|
+
source.on("addfeature", onFeatureAdded);
|
|
1549
|
+
this.drawInteraction._featureAddedListener = onFeatureAdded;
|
|
1550
|
+
this.drawInteraction._sourceRef = source;
|
|
1551
|
+
this.olMap.addInteraction(this.drawInteraction);
|
|
1552
|
+
}
|
|
1553
|
+
async disableDrawing() {
|
|
1554
|
+
if (this.drawInteraction) {
|
|
1555
|
+
const listener = this.drawInteraction._featureAddedListener;
|
|
1556
|
+
const source = this.drawInteraction._sourceRef;
|
|
1557
|
+
if (listener && source) source.un("addfeature", listener);
|
|
1558
|
+
this.olMap.removeInteraction(this.drawInteraction);
|
|
1559
|
+
this.drawInteraction = void 0;
|
|
1560
|
+
this.setCursor("");
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
cleanup() {
|
|
1564
|
+
if (this.keyDownListener) {
|
|
1565
|
+
const target = this.olMap.getTargetElement();
|
|
1566
|
+
if (target && target instanceof HTMLElement) target.removeEventListener("keydown", this.keyDownListener);
|
|
1567
|
+
this.keyDownListener = void 0;
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
async enableFeatureSelection() {
|
|
1571
|
+
this.disableDrawing();
|
|
1572
|
+
this.disableSelection();
|
|
1573
|
+
const olLayers = this.olMap.getLayers();
|
|
1574
|
+
const vectorLayers = olLayers.getArray().filter((layer$3) => layer$3 instanceof layer.Vector);
|
|
1575
|
+
if (vectorLayers.length === 0) throw new Error("No vector layers available for selection");
|
|
1576
|
+
const selectionStyle = (this.renderer?.gsMap)?.styles?.["selection"];
|
|
1577
|
+
const selectOptions = {
|
|
1578
|
+
condition: eventsCondition.click,
|
|
1579
|
+
layers: vectorLayers,
|
|
1580
|
+
hitTolerance: 5,
|
|
1581
|
+
style: selectionStyle ? toOlStyle(selectionStyle) : (_feature) => {
|
|
1582
|
+
const stroke = new style.Stroke({
|
|
1583
|
+
color: "rgba(255, 255, 0, 1)",
|
|
1584
|
+
width: 3
|
|
1585
|
+
});
|
|
1586
|
+
const fill = new style.Fill({ color: "rgba(255, 255, 0, 0.3)" });
|
|
1587
|
+
return new style.Style({
|
|
1588
|
+
image: new style.Circle({
|
|
1589
|
+
radius: 7,
|
|
1590
|
+
fill,
|
|
1591
|
+
stroke
|
|
1592
|
+
}),
|
|
1593
|
+
stroke,
|
|
1594
|
+
fill
|
|
1595
|
+
});
|
|
1596
|
+
}
|
|
1597
|
+
};
|
|
1598
|
+
this.selectInteraction = new interaction.Select(selectOptions);
|
|
1599
|
+
this.selectInteraction.on("select", (event) => {
|
|
1600
|
+
if (event.selected.length > 0) {
|
|
1601
|
+
const selectedFeature = event.selected[0];
|
|
1602
|
+
let featureLayerUuid;
|
|
1603
|
+
olLayers.getArray().forEach((layer$4) => {
|
|
1604
|
+
if (layer$4 instanceof layer.Vector) {
|
|
1605
|
+
const source = layer$4.getSource();
|
|
1606
|
+
if (source && source.hasFeature(selectedFeature)) {
|
|
1607
|
+
const uuid = layer$4.get(KEY_UUID);
|
|
1608
|
+
if (uuid) featureLayerUuid = uuid;
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
});
|
|
1612
|
+
if (featureLayerUuid && this.renderer) {
|
|
1613
|
+
const gsFeature = toGsFeature(selectedFeature);
|
|
1614
|
+
const geometry = selectedFeature.getGeometry();
|
|
1615
|
+
const metrics = {};
|
|
1616
|
+
if (geometry) {
|
|
1617
|
+
const geometryType = geometry.getType();
|
|
1618
|
+
try {
|
|
1619
|
+
if (geometryType === "LineString" || geometryType === "MultiLineString") metrics.length = sphere.getLength(geometry, { projection: this.olMap.getView().getProjection() });
|
|
1620
|
+
else if (geometryType === "Polygon" || geometryType === "MultiPolygon") {
|
|
1621
|
+
metrics.area = sphere.getArea(geometry, { projection: this.olMap.getView().getProjection() });
|
|
1622
|
+
const coordinates = geometryType === "Polygon" ? geometry.getCoordinates()[0] : geometry.getCoordinates()[0][0];
|
|
1623
|
+
if (coordinates?.length > 0) {
|
|
1624
|
+
const perimeterLine = new geom.LineString(coordinates);
|
|
1625
|
+
metrics.length = sphere.getLength(perimeterLine, { projection: this.olMap.getView().getProjection() });
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
} catch (error) {
|
|
1629
|
+
console.warn("Error calculating feature metrics:", error);
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
this.renderer.triggerSync({
|
|
1633
|
+
type: "featureSelected",
|
|
1634
|
+
layerUuid: featureLayerUuid,
|
|
1635
|
+
feature: gsFeature,
|
|
1636
|
+
metrics
|
|
1637
|
+
});
|
|
1638
|
+
}
|
|
1639
|
+
} else if (event.deselected.length > 0) this.renderer?.triggerSync({ type: "featureDeselected" });
|
|
1640
|
+
});
|
|
1641
|
+
this.olMap.addInteraction(this.selectInteraction);
|
|
1642
|
+
this.setCursor("pointer");
|
|
1643
|
+
}
|
|
1644
|
+
async deleteSelectedFeatures() {
|
|
1645
|
+
if (!this.selectInteraction) throw new Error("No selection interaction active");
|
|
1646
|
+
const selectedFeatures = this.selectInteraction.getFeatures();
|
|
1647
|
+
if (selectedFeatures.getLength() === 0) throw new Error("No features selected");
|
|
1648
|
+
const layersToSync = /* @__PURE__ */ new Set();
|
|
1649
|
+
const olLayers = this.olMap.getLayers();
|
|
1650
|
+
selectedFeatures.forEach((feature) => {
|
|
1651
|
+
for (let i = 0; i < olLayers.getLength(); i++) {
|
|
1652
|
+
const layer$5 = olLayers.item(i);
|
|
1653
|
+
if (layer$5 instanceof layer.Vector) {
|
|
1654
|
+
const source = layer$5.getSource();
|
|
1655
|
+
if (source && source.hasFeature(feature)) {
|
|
1656
|
+
source.removeFeature(feature);
|
|
1657
|
+
const layerUuid = layer$5.get(KEY_UUID);
|
|
1658
|
+
if (layerUuid) layersToSync.add(layerUuid);
|
|
1659
|
+
break;
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
});
|
|
1664
|
+
selectedFeatures.clear();
|
|
1665
|
+
if (this.renderer && layersToSync.size > 0) layersToSync.forEach((layerUuid) => {
|
|
1666
|
+
this.renderer.syncLayerFeaturesToModel(layerUuid);
|
|
1667
|
+
});
|
|
1668
|
+
this.renderer?.triggerDirty();
|
|
1669
|
+
}
|
|
1670
|
+
async disableSelection() {
|
|
1671
|
+
if (this.selectInteraction) {
|
|
1672
|
+
this.olMap.removeInteraction(this.selectInteraction);
|
|
1673
|
+
this.selectInteraction = void 0;
|
|
1674
|
+
this.setCursor("");
|
|
1675
|
+
this.renderer?.triggerSync({ type: "featureDeselected" });
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
2020
1678
|
};
|
|
2021
|
-
//#
|
|
1679
|
+
//#endregion
|
|
1680
|
+
//#region src/ol/index.ts
|
|
1681
|
+
var ol_exports = /* @__PURE__ */ __exportAll({
|
|
1682
|
+
BaseLayer: () => BaseLayer,
|
|
1683
|
+
DEFAULT_GSMAP: () => DEFAULT_GSMAP,
|
|
1684
|
+
DEFAULT_STYLES: () => DEFAULT_STYLES,
|
|
1685
|
+
DEFAULT_STYLE_RULES: () => DEFAULT_STYLE_RULES,
|
|
1686
|
+
DefaultImporter: () => DefaultImporter,
|
|
1687
|
+
GsControlAdapter: () => GsControlAdapter,
|
|
1688
|
+
GsGeometryType: () => GsGeometryType,
|
|
1689
|
+
GsLayerType: () => GsLayerType,
|
|
1690
|
+
GsOlAdapter: () => GsOlAdapter,
|
|
1691
|
+
GsOlControl: () => GsOlControl,
|
|
1692
|
+
GsOlOverlay: () => GsOlOverlay,
|
|
1693
|
+
GsOverlayAdapter: () => GsOverlayAdapter,
|
|
1694
|
+
GsSourceType: () => GsSourceType,
|
|
1695
|
+
KEY_ENV: () => KEY_ENV,
|
|
1696
|
+
KEY_EVENT_SUBSCRIPTIONS: () => KEY_EVENT_SUBSCRIPTIONS,
|
|
1697
|
+
KEY_FORMAT: () => KEY_FORMAT,
|
|
1698
|
+
KEY_GS_MANAGED: () => KEY_GS_MANAGED,
|
|
1699
|
+
KEY_ICON_PATH: () => KEY_ICON_PATH,
|
|
1700
|
+
KEY_LABEL: () => KEY_LABEL,
|
|
1701
|
+
KEY_NAME: () => KEY_NAME,
|
|
1702
|
+
KEY_SETTINGS: () => KEY_SETTINGS,
|
|
1703
|
+
KEY_SOURCETYPE: () => KEY_SOURCETYPE,
|
|
1704
|
+
KEY_SRC: () => "src",
|
|
1705
|
+
KEY_STATE: () => KEY_STATE,
|
|
1706
|
+
KEY_URL: () => "url",
|
|
1707
|
+
KEY_UUID: () => KEY_UUID,
|
|
1708
|
+
LAYER_GEOCODED_MARKERS: () => LAYER_GEOCODED_MARKERS,
|
|
1709
|
+
OL_LAYERS: () => OL_LAYERS,
|
|
1710
|
+
OL_SOURCES: () => OL_SOURCES,
|
|
1711
|
+
OpenLayersMapRenderer: () => OpenLayersMapRenderer,
|
|
1712
|
+
applyMapboxStyle: () => applyMapboxStyle,
|
|
1713
|
+
cleanupEventSubscriptions: () => cleanupEventSubscriptions,
|
|
1714
|
+
createProxy: () => createProxy,
|
|
1715
|
+
defaultControls: () => defaultControls,
|
|
1716
|
+
defaultInteractions: () => defaultInteractions,
|
|
1717
|
+
ensureUuid: () => ensureUuid,
|
|
1718
|
+
ensureUuidsRecursive: () => ensureUuidsRecursive,
|
|
1719
|
+
evaluateStyleRule: () => evaluateStyleRule,
|
|
1720
|
+
events: () => events,
|
|
1721
|
+
eventsCondition: () => eventsCondition,
|
|
1722
|
+
extent: () => extent,
|
|
1723
|
+
findControlByUuid: () => findControlByUuid,
|
|
1724
|
+
findControlIndexByUuid: () => findControlIndexByUuid,
|
|
1725
|
+
findLayerByUuid: () => findLayerByUuid,
|
|
1726
|
+
findLayerIndexByUuid: () => findLayerIndexByUuid,
|
|
1727
|
+
findOverlayByUuid: () => findOverlayByUuid,
|
|
1728
|
+
findOverlayIndexByUuid: () => findOverlayIndexByUuid,
|
|
1729
|
+
format: () => format,
|
|
1730
|
+
geom: () => geom,
|
|
1731
|
+
getStyleForFeature: () => getStyleForFeature,
|
|
1732
|
+
importControlSource: () => importControlSource,
|
|
1733
|
+
importOverlaySource: () => importOverlaySource,
|
|
1734
|
+
interaction: () => interaction,
|
|
1735
|
+
layer: () => layer,
|
|
1736
|
+
olLib: () => olLib,
|
|
1737
|
+
proj: () => proj,
|
|
1738
|
+
resolveScriptLang: () => resolveScriptLang,
|
|
1739
|
+
source: () => source,
|
|
1740
|
+
sphere: () => sphere,
|
|
1741
|
+
style: () => style,
|
|
1742
|
+
toGsFeature: () => toGsFeature,
|
|
1743
|
+
toGsGeometry: () => toGsGeometry,
|
|
1744
|
+
toGsLayerType: () => toGsLayerType,
|
|
1745
|
+
toGsSourceType: () => toGsSourceType,
|
|
1746
|
+
toOLGeometry: () => toOLGeometry,
|
|
1747
|
+
toOlCircleImage: () => toOlCircleImage,
|
|
1748
|
+
toOlControl: () => toOlControl,
|
|
1749
|
+
toOlFeature: () => toOlFeature,
|
|
1750
|
+
toOlFill: () => toOlFill,
|
|
1751
|
+
toOlIconImage: () => toOlIconImage,
|
|
1752
|
+
toOlImage: () => toOlImage,
|
|
1753
|
+
toOlLayer: () => toOlLayer,
|
|
1754
|
+
toOlMap: () => toOlMap,
|
|
1755
|
+
toOlOverlay: () => toOlOverlay,
|
|
1756
|
+
toOlRegularShapeImage: () => toOlRegularShapeImage,
|
|
1757
|
+
toOlResource: () => toOlResource,
|
|
1758
|
+
toOlSource: () => toOlSource,
|
|
1759
|
+
toOlStroke: () => toOlStroke,
|
|
1760
|
+
toOlStyle: () => toOlStyle,
|
|
1761
|
+
toOlText: () => toOlText,
|
|
1762
|
+
toSourceUrl: () => toSourceUrl
|
|
1763
|
+
});
|
|
1764
|
+
__reExport(ol_exports, gs_olns_exports);
|
|
1765
|
+
__reExport(/* @__PURE__ */ __exportAll({
|
|
1766
|
+
BaseLayer: () => BaseLayer,
|
|
1767
|
+
DEFAULT_GSMAP: () => DEFAULT_GSMAP,
|
|
1768
|
+
DEFAULT_STYLES: () => DEFAULT_STYLES,
|
|
1769
|
+
DEFAULT_STYLE_RULES: () => DEFAULT_STYLE_RULES,
|
|
1770
|
+
DefaultImporter: () => DefaultImporter,
|
|
1771
|
+
GsControlAdapter: () => GsControlAdapter,
|
|
1772
|
+
GsGeometryType: () => GsGeometryType,
|
|
1773
|
+
GsLayerType: () => GsLayerType,
|
|
1774
|
+
GsOlAdapter: () => GsOlAdapter,
|
|
1775
|
+
GsOlControl: () => GsOlControl,
|
|
1776
|
+
GsOlOverlay: () => GsOlOverlay,
|
|
1777
|
+
GsOverlayAdapter: () => GsOverlayAdapter,
|
|
1778
|
+
GsSourceType: () => GsSourceType,
|
|
1779
|
+
KEY_ENV: () => KEY_ENV,
|
|
1780
|
+
KEY_EVENT_SUBSCRIPTIONS: () => KEY_EVENT_SUBSCRIPTIONS,
|
|
1781
|
+
KEY_FORMAT: () => KEY_FORMAT,
|
|
1782
|
+
KEY_GS_MANAGED: () => KEY_GS_MANAGED,
|
|
1783
|
+
KEY_ICON_PATH: () => KEY_ICON_PATH,
|
|
1784
|
+
KEY_LABEL: () => KEY_LABEL,
|
|
1785
|
+
KEY_NAME: () => KEY_NAME,
|
|
1786
|
+
KEY_SETTINGS: () => KEY_SETTINGS,
|
|
1787
|
+
KEY_SOURCETYPE: () => KEY_SOURCETYPE,
|
|
1788
|
+
KEY_SRC: () => "src",
|
|
1789
|
+
KEY_STATE: () => KEY_STATE,
|
|
1790
|
+
KEY_URL: () => "url",
|
|
1791
|
+
KEY_UUID: () => KEY_UUID,
|
|
1792
|
+
LAYER_GEOCODED_MARKERS: () => LAYER_GEOCODED_MARKERS,
|
|
1793
|
+
OL_LAYERS: () => OL_LAYERS,
|
|
1794
|
+
OL_SOURCES: () => OL_SOURCES,
|
|
1795
|
+
OpenLayersMapRenderer: () => OpenLayersMapRenderer,
|
|
1796
|
+
applyMapboxStyle: () => applyMapboxStyle,
|
|
1797
|
+
buildMap: () => buildMap,
|
|
1798
|
+
bundleApp: () => bundleApp,
|
|
1799
|
+
cleanupEventSubscriptions: () => cleanupEventSubscriptions,
|
|
1800
|
+
createProxy: () => createProxy,
|
|
1801
|
+
defaultControls: () => defaultControls,
|
|
1802
|
+
defaultInteractions: () => defaultInteractions,
|
|
1803
|
+
ensureUuid: () => ensureUuid,
|
|
1804
|
+
ensureUuidsRecursive: () => ensureUuidsRecursive,
|
|
1805
|
+
evaluateStyleRule: () => evaluateStyleRule,
|
|
1806
|
+
events: () => events,
|
|
1807
|
+
eventsCondition: () => eventsCondition,
|
|
1808
|
+
extent: () => extent,
|
|
1809
|
+
findControlByUuid: () => findControlByUuid,
|
|
1810
|
+
findControlIndexByUuid: () => findControlIndexByUuid,
|
|
1811
|
+
findLayerByUuid: () => findLayerByUuid,
|
|
1812
|
+
findLayerIndexByUuid: () => findLayerIndexByUuid,
|
|
1813
|
+
findOverlayByUuid: () => findOverlayByUuid,
|
|
1814
|
+
findOverlayIndexByUuid: () => findOverlayIndexByUuid,
|
|
1815
|
+
format: () => format,
|
|
1816
|
+
generateAppJs: () => generateAppJs,
|
|
1817
|
+
geom: () => geom,
|
|
1818
|
+
getStyleForFeature: () => getStyleForFeature,
|
|
1819
|
+
gsLib: () => olLib,
|
|
1820
|
+
importControlSource: () => importControlSource,
|
|
1821
|
+
importOverlaySource: () => importOverlaySource,
|
|
1822
|
+
interaction: () => interaction,
|
|
1823
|
+
layer: () => layer,
|
|
1824
|
+
olLib: () => olLib,
|
|
1825
|
+
processHtml: () => processHtml,
|
|
1826
|
+
processManifest: () => processManifest,
|
|
1827
|
+
processServiceWorker: () => processServiceWorker,
|
|
1828
|
+
proj: () => proj,
|
|
1829
|
+
resolveScriptLang: () => resolveScriptLang,
|
|
1830
|
+
rtUtils: () => rtUtils,
|
|
1831
|
+
scriptedRuntimeRegistry: () => scriptedRuntimeRegistry,
|
|
1832
|
+
source: () => source,
|
|
1833
|
+
sphere: () => sphere,
|
|
1834
|
+
style: () => style,
|
|
1835
|
+
toGsFeature: () => toGsFeature,
|
|
1836
|
+
toGsGeometry: () => toGsGeometry,
|
|
1837
|
+
toGsLayerType: () => toGsLayerType,
|
|
1838
|
+
toGsSourceType: () => toGsSourceType,
|
|
1839
|
+
toOLGeometry: () => toOLGeometry,
|
|
1840
|
+
toOlCircleImage: () => toOlCircleImage,
|
|
1841
|
+
toOlControl: () => toOlControl,
|
|
1842
|
+
toOlFeature: () => toOlFeature,
|
|
1843
|
+
toOlFill: () => toOlFill,
|
|
1844
|
+
toOlIconImage: () => toOlIconImage,
|
|
1845
|
+
toOlImage: () => toOlImage,
|
|
1846
|
+
toOlLayer: () => toOlLayer,
|
|
1847
|
+
toOlMap: () => toOlMap,
|
|
1848
|
+
toOlOverlay: () => toOlOverlay,
|
|
1849
|
+
toOlRegularShapeImage: () => toOlRegularShapeImage,
|
|
1850
|
+
toOlResource: () => toOlResource,
|
|
1851
|
+
toOlSource: () => toOlSource,
|
|
1852
|
+
toOlStroke: () => toOlStroke,
|
|
1853
|
+
toOlStyle: () => toOlStyle,
|
|
1854
|
+
toOlText: () => toOlText,
|
|
1855
|
+
toSourceUrl: () => toSourceUrl
|
|
1856
|
+
}), ol_exports);
|
|
1857
|
+
var rtUtils = { async resolveUrl(url) {
|
|
1858
|
+
return url;
|
|
1859
|
+
} };
|
|
1860
|
+
//#endregion
|
|
1861
|
+
export { BaseLayer, DEFAULT_GSMAP, DEFAULT_STYLES, DEFAULT_STYLE_RULES, DefaultImporter, GsControlAdapter, GsGeometryType, GsLayerType, GsOlAdapter, GsOlControl, GsOlOverlay, GsOverlayAdapter, GsSourceType, KEY_ENV, KEY_EVENT_SUBSCRIPTIONS, KEY_FORMAT, KEY_GS_MANAGED, KEY_ICON_PATH, KEY_LABEL, KEY_NAME, KEY_SETTINGS, KEY_SOURCETYPE, KEY_SRC, KEY_STATE, KEY_URL, KEY_UUID, LAYER_GEOCODED_MARKERS, OL_LAYERS, OL_SOURCES, OpenLayersMapRenderer, applyMapboxStyle, buildMap, bundleApp, cleanupEventSubscriptions, createProxy, defaultControls, defaultInteractions, ensureUuid, ensureUuidsRecursive, evaluateStyleRule, events, eventsCondition, extent, findControlByUuid, findControlIndexByUuid, findLayerByUuid, findLayerIndexByUuid, findOverlayByUuid, findOverlayIndexByUuid, format, generateAppJs, geom, getStyleForFeature, olLib as gsLib, olLib, importControlSource, importOverlaySource, interaction, layer, processHtml, processManifest, processServiceWorker, proj, resolveScriptLang, rtUtils, scriptedRuntimeRegistry, source, sphere, style, toGsFeature, toGsGeometry, toGsLayerType, toGsSourceType, toOLGeometry, toOlCircleImage, toOlControl, toOlFeature, toOlFill, toOlIconImage, toOlImage, toOlLayer, toOlMap, toOlOverlay, toOlRegularShapeImage, toOlResource, toOlSource, toOlStroke, toOlStyle, toOlText, toSourceUrl };
|
|
1862
|
+
|
|
1863
|
+
//# sourceMappingURL=index.js.map
|