@sswroom/sswr 1.5.1 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Changelog +34 -0
- package/cesium.d.ts +9 -2
- package/cesium.js +263 -44
- package/data.d.ts +6 -0
- package/data.js +216 -204
- package/geometry.d.ts +5 -0
- package/geometry.js +62 -50
- package/hkoapi.js +10 -10
- package/kml.d.ts +4 -1
- package/kml.js +53 -24
- package/leaflet.js +154 -34
- package/map.js +22 -22
- package/math.js +127 -127
- package/net.d.ts +2 -0
- package/net.js +76 -0
- package/olayer2.d.ts +11 -0
- package/olayer2.js +328 -76
- package/osm.js +21 -22
- package/package.json +1 -1
- package/parser.js +339 -93
- package/text.d.ts +127 -1
- package/text.js +1142 -21
- package/web.d.ts +9 -0
- package/web.js +222 -58
package/leaflet.js
CHANGED
|
@@ -24,7 +24,7 @@ export function fromLatLngBounds(b)
|
|
|
24
24
|
|
|
25
25
|
export function createLayer(layer, options)
|
|
26
26
|
{
|
|
27
|
-
|
|
27
|
+
let lyrOpts;
|
|
28
28
|
if (options == null)
|
|
29
29
|
options = {};
|
|
30
30
|
switch (layer.type)
|
|
@@ -58,8 +58,8 @@ export function createFromKMLFeature(feature, options)
|
|
|
58
58
|
options = data.mergeOptions(options, {noPopup: false});
|
|
59
59
|
if (feature instanceof kml.Container)
|
|
60
60
|
{
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
let i;
|
|
62
|
+
let layers = L.featureGroup();
|
|
63
63
|
for (i in feature.features)
|
|
64
64
|
{
|
|
65
65
|
createFromKMLFeature(feature.features[i], options).addTo(layers);
|
|
@@ -68,12 +68,12 @@ export function createFromKMLFeature(feature, options)
|
|
|
68
68
|
}
|
|
69
69
|
else if (feature instanceof kml.Placemark)
|
|
70
70
|
{
|
|
71
|
-
|
|
71
|
+
let opt = {};
|
|
72
72
|
if (feature.name)
|
|
73
73
|
opt.name = feature.name;
|
|
74
74
|
if (feature.style)
|
|
75
75
|
{
|
|
76
|
-
|
|
76
|
+
let style = feature.style;
|
|
77
77
|
if (style instanceof kml.StyleMap)
|
|
78
78
|
{
|
|
79
79
|
style = style.normalStyle;
|
|
@@ -82,10 +82,10 @@ export function createFromKMLFeature(feature, options)
|
|
|
82
82
|
{
|
|
83
83
|
if (style.iconStyle)
|
|
84
84
|
{
|
|
85
|
-
|
|
85
|
+
let s = style.iconStyle;
|
|
86
86
|
if (s.leafletIcon == null)
|
|
87
87
|
{
|
|
88
|
-
|
|
88
|
+
let icon = {};
|
|
89
89
|
if (s.iconUrl)
|
|
90
90
|
{
|
|
91
91
|
icon.iconUrl = s.iconUrl;
|
|
@@ -100,15 +100,21 @@ export function createFromKMLFeature(feature, options)
|
|
|
100
100
|
}
|
|
101
101
|
if (style.lineStyle)
|
|
102
102
|
{
|
|
103
|
-
|
|
103
|
+
let ls = style.lineStyle;
|
|
104
104
|
if (ls.color)
|
|
105
105
|
opt.lineColor = kml.toCSSColor(ls.color);
|
|
106
106
|
if (ls.width)
|
|
107
107
|
opt.lineWidth = ls.width;
|
|
108
108
|
}
|
|
109
|
+
if (style.polyStyle)
|
|
110
|
+
{
|
|
111
|
+
let ps = style.polyStyle;
|
|
112
|
+
if (ps.color)
|
|
113
|
+
opt.fillColor = kml.toCSSColor(ps.color);
|
|
114
|
+
}
|
|
109
115
|
}
|
|
110
116
|
}
|
|
111
|
-
|
|
117
|
+
let layer = createFromGeometry(feature.vec, opt);
|
|
112
118
|
if (layer && !options.noPopup)
|
|
113
119
|
{
|
|
114
120
|
if (feature.name && feature.description)
|
|
@@ -137,7 +143,7 @@ export function createFromGeometry(geom, options)
|
|
|
137
143
|
{
|
|
138
144
|
if (geom instanceof geometry.Point)
|
|
139
145
|
{
|
|
140
|
-
|
|
146
|
+
let opt = {};
|
|
141
147
|
if (options)
|
|
142
148
|
{
|
|
143
149
|
if (options.name)
|
|
@@ -149,16 +155,16 @@ export function createFromGeometry(geom, options)
|
|
|
149
155
|
}
|
|
150
156
|
else if (geom instanceof geometry.LineString)
|
|
151
157
|
{
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
158
|
+
let opt = {};
|
|
159
|
+
let i;
|
|
160
|
+
let pts = [];
|
|
155
161
|
if (options.lineColor)
|
|
156
162
|
opt.color = options.lineColor;
|
|
157
163
|
if (options.lineWidth)
|
|
158
164
|
opt.weight = options.lineWidth;
|
|
159
165
|
for (i in geom.coordinates)
|
|
160
166
|
{
|
|
161
|
-
|
|
167
|
+
let latLng = L.latLng(geom.coordinates[i][1], geom.coordinates[i][0]);
|
|
162
168
|
if (latLng)
|
|
163
169
|
{
|
|
164
170
|
pts.push(latLng);
|
|
@@ -170,6 +176,120 @@ export function createFromGeometry(geom, options)
|
|
|
170
176
|
}
|
|
171
177
|
return L.polyline(pts, opt);
|
|
172
178
|
}
|
|
179
|
+
else if (geom instanceof geometry.LinearRing)
|
|
180
|
+
{
|
|
181
|
+
let opt = {};
|
|
182
|
+
let k;
|
|
183
|
+
let pts = [];
|
|
184
|
+
if (options.lineColor)
|
|
185
|
+
opt.color = options.lineColor;
|
|
186
|
+
if (options.lineWidth)
|
|
187
|
+
opt.weight = options.lineWidth;
|
|
188
|
+
if (options.fillColor)
|
|
189
|
+
{
|
|
190
|
+
opt.fillColor = options.fillColor;
|
|
191
|
+
opt.fillOpacity = 1.0;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
for (k in geom.coordinates)
|
|
195
|
+
{
|
|
196
|
+
let latLng = L.latLng(geom.coordinates[k][1], geom.coordinates[k][0]);
|
|
197
|
+
if (latLng)
|
|
198
|
+
{
|
|
199
|
+
pts.push(latLng);
|
|
200
|
+
}
|
|
201
|
+
else
|
|
202
|
+
{
|
|
203
|
+
console.log("Error in LinearRing", geom.coordinates[k]);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return L.polygon(pts, opt);
|
|
207
|
+
}
|
|
208
|
+
else if (geom instanceof geometry.Polygon)
|
|
209
|
+
{
|
|
210
|
+
let opt = {};
|
|
211
|
+
let i;
|
|
212
|
+
let j;
|
|
213
|
+
let pts = [];
|
|
214
|
+
let pts2;
|
|
215
|
+
let lr;
|
|
216
|
+
if (options.lineColor)
|
|
217
|
+
opt.color = options.lineColor;
|
|
218
|
+
if (options.lineWidth)
|
|
219
|
+
opt.weight = options.lineWidth;
|
|
220
|
+
if (options.fillColor)
|
|
221
|
+
{
|
|
222
|
+
opt.fillColor = options.fillColor;
|
|
223
|
+
opt.fillOpacity = 1.0;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
for (i in geom.geometries)
|
|
227
|
+
{
|
|
228
|
+
pts2 = [];
|
|
229
|
+
lr = geom.geometries[i];
|
|
230
|
+
for (j in lr.coordinates)
|
|
231
|
+
{
|
|
232
|
+
let latLng = L.latLng(lr.coordinates[j][1], lr.coordinates[j][0]);
|
|
233
|
+
if (latLng)
|
|
234
|
+
{
|
|
235
|
+
pts2.push(latLng);
|
|
236
|
+
}
|
|
237
|
+
else
|
|
238
|
+
{
|
|
239
|
+
console.log("Error in Polygon", lr.coordinates[j]);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
pts.push(pts2);
|
|
243
|
+
}
|
|
244
|
+
return L.polygon(pts, opt);
|
|
245
|
+
}
|
|
246
|
+
else if (geom instanceof geometry.MultiPolygon)
|
|
247
|
+
{
|
|
248
|
+
let opt = {};
|
|
249
|
+
let i;
|
|
250
|
+
let j;
|
|
251
|
+
let k;
|
|
252
|
+
let pts = [];
|
|
253
|
+
let pts2;
|
|
254
|
+
let pts3;
|
|
255
|
+
let pg;
|
|
256
|
+
let lr;
|
|
257
|
+
if (options.lineColor)
|
|
258
|
+
opt.color = options.lineColor;
|
|
259
|
+
if (options.lineWidth)
|
|
260
|
+
opt.weight = options.lineWidth;
|
|
261
|
+
if (options.fillColor)
|
|
262
|
+
{
|
|
263
|
+
opt.fillColor = options.fillColor;
|
|
264
|
+
opt.fillOpacity = 1.0;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
for (i in geom.geometries)
|
|
268
|
+
{
|
|
269
|
+
pts2 = [];
|
|
270
|
+
pg = geom.geometries[i];
|
|
271
|
+
for (j in pg.geometries)
|
|
272
|
+
{
|
|
273
|
+
pts3 = [];
|
|
274
|
+
lr = pg.geometries[j];
|
|
275
|
+
for (k in lr.coordinates)
|
|
276
|
+
{
|
|
277
|
+
let latLng = L.latLng(lr.coordinates[k][1], lr.coordinates[k][0]);
|
|
278
|
+
if (latLng)
|
|
279
|
+
{
|
|
280
|
+
pts3.push(latLng);
|
|
281
|
+
}
|
|
282
|
+
else
|
|
283
|
+
{
|
|
284
|
+
console.log("Error in MultiPolygon", lr.coordinates[k]);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
pts2.push(pts3);
|
|
288
|
+
}
|
|
289
|
+
pts.push(pts2);
|
|
290
|
+
}
|
|
291
|
+
return L.polygon(pts, opt);
|
|
292
|
+
}
|
|
173
293
|
else
|
|
174
294
|
{
|
|
175
295
|
console.log("Unknown geometry type", geom);
|
|
@@ -179,9 +299,9 @@ export function createFromGeometry(geom, options)
|
|
|
179
299
|
|
|
180
300
|
export function createKMLLookAt(map)
|
|
181
301
|
{
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
302
|
+
let center = map.getCenter();
|
|
303
|
+
let zoom = map.getZoom();
|
|
304
|
+
let range = 100000 * Math.pow(2, 11 - zoom);
|
|
185
305
|
return new kml.LookAt(center.lng, center.lat, 0, range);
|
|
186
306
|
}
|
|
187
307
|
|
|
@@ -198,8 +318,8 @@ export function toLineString(layer)
|
|
|
198
318
|
{
|
|
199
319
|
if (layer instanceof L.Polyline)
|
|
200
320
|
{
|
|
201
|
-
|
|
202
|
-
|
|
321
|
+
let coords = [];
|
|
322
|
+
let i;
|
|
203
323
|
for (i in layer._latlngs)
|
|
204
324
|
{
|
|
205
325
|
coords.push([layer._latlngs[i].lng,layer._latlngs[i].lat]);
|
|
@@ -211,7 +331,7 @@ export function toLineString(layer)
|
|
|
211
331
|
|
|
212
332
|
export function toKMLFeature(layer, doc)
|
|
213
333
|
{
|
|
214
|
-
|
|
334
|
+
let feature;
|
|
215
335
|
if (doc == null)
|
|
216
336
|
{
|
|
217
337
|
doc = new kml.Document();
|
|
@@ -225,9 +345,9 @@ export function toKMLFeature(layer, doc)
|
|
|
225
345
|
}
|
|
226
346
|
if (layer instanceof L.FeatureGroup)
|
|
227
347
|
{
|
|
228
|
-
|
|
348
|
+
let featureGroup = new kml.Folder();
|
|
229
349
|
featureGroup.setName("FeatureGroup");
|
|
230
|
-
|
|
350
|
+
let i;
|
|
231
351
|
for (i in layer._layers)
|
|
232
352
|
{
|
|
233
353
|
feature = toKMLFeature(layer._layers[i], doc);
|
|
@@ -247,19 +367,19 @@ export function toKMLFeature(layer, doc)
|
|
|
247
367
|
}
|
|
248
368
|
if (layer.options && layer.options.icon)
|
|
249
369
|
{
|
|
250
|
-
|
|
370
|
+
let opt = layer.options.icon.options;
|
|
251
371
|
if (opt)
|
|
252
372
|
{
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
if (opt.iconSize)
|
|
373
|
+
let iconStyle = new kml.IconStyle();
|
|
374
|
+
if (opt.iconSize && layer._icon)
|
|
256
375
|
{
|
|
376
|
+
let imgW = layer._icon.naturalWidth || layer._icon.offsetWidth;
|
|
257
377
|
iconStyle.setScale(opt.iconSize[0] / imgW);
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
378
|
+
}
|
|
379
|
+
if (opt.iconAnchor)
|
|
380
|
+
{
|
|
381
|
+
iconStyle.setHotSpotX(opt.iconAnchor[0], kml.HotSpotUnit.Pixels);
|
|
382
|
+
iconStyle.setHotSpotY(opt.iconAnchor[1], kml.HotSpotUnit.InsetPixels);
|
|
263
383
|
}
|
|
264
384
|
if (opt.iconUrl)
|
|
265
385
|
{
|
|
@@ -283,10 +403,10 @@ export function toKMLFeature(layer, doc)
|
|
|
283
403
|
feature.setName("Polyline");
|
|
284
404
|
if (layer.options.color || layer.options.weight)
|
|
285
405
|
{
|
|
286
|
-
|
|
406
|
+
let lineStyle = new kml.LineStyle();
|
|
287
407
|
if (layer.options.color)
|
|
288
408
|
{
|
|
289
|
-
|
|
409
|
+
let c = web.parseCSSColor(layer.options.color);
|
|
290
410
|
if (layer.options.opacity)
|
|
291
411
|
{
|
|
292
412
|
c.a = c.a * layer.options.opacity;
|
|
@@ -308,7 +428,7 @@ export function toKMLFeature(layer, doc)
|
|
|
308
428
|
|
|
309
429
|
export function toKMLString(layer)
|
|
310
430
|
{
|
|
311
|
-
|
|
431
|
+
let feature = toKMLFeature(layer);
|
|
312
432
|
if (feature)
|
|
313
433
|
{
|
|
314
434
|
return kml.toString(feature);
|
package/map.js
CHANGED
|
@@ -33,8 +33,8 @@ export const GeometryType = {
|
|
|
33
33
|
|
|
34
34
|
export function calcDistance(srid, geom, x, y)
|
|
35
35
|
{
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
let pt = geom.calBoundaryPoint(new math.Coord2D(x, y));
|
|
37
|
+
let csys = math.CoordinateSystemManager.srCreateCsys(srid);
|
|
38
38
|
return csys.calcSurfaceDistance(x, y, pt.x, pt.y, unit.Distance.Unit.METER);
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -57,9 +57,9 @@ export class GPSTrack
|
|
|
57
57
|
|
|
58
58
|
createLineString()
|
|
59
59
|
{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
let coordinates = new Array();
|
|
61
|
+
let i = 0;
|
|
62
|
+
let j = this.recs.length;
|
|
63
63
|
while (i < j)
|
|
64
64
|
{
|
|
65
65
|
coordinates.push([this.recs[i].lon, this.recs[i].lat, this.recs[i].a]);
|
|
@@ -77,10 +77,10 @@ export class GPSTrack
|
|
|
77
77
|
{
|
|
78
78
|
if (ticks >= this.recs[0].t && ticks <= this.recs[this.recs.length - 1].t)
|
|
79
79
|
{
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
let i = 0;
|
|
81
|
+
let j = this.recs.length - 1;
|
|
82
|
+
let k;
|
|
83
|
+
let l;
|
|
84
84
|
while (i <= j)
|
|
85
85
|
{
|
|
86
86
|
k = (i + j) >> 1;
|
|
@@ -98,9 +98,9 @@ export class GPSTrack
|
|
|
98
98
|
return new math.Vector3(this.recs[k].lon, this.recs[k].lat, this.recs[k].a);
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
let tDiff;
|
|
102
|
+
let rec1 = this.recs[i - 1];
|
|
103
|
+
let rec2 = this.recs[i];
|
|
104
104
|
tDiff = rec2.t - rec1.t;
|
|
105
105
|
return new math.Vector3(
|
|
106
106
|
(rec1.lon * (rec2.t - ticks) + rec2.lon * (ticks - rec1.t)) / tDiff,
|
|
@@ -163,14 +163,14 @@ export class WMS
|
|
|
163
163
|
{
|
|
164
164
|
if (this.version == null)
|
|
165
165
|
{
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
166
|
+
let resp = await fetch(this.url + "?SERVICE=WMS&REQUEST=GetCapabilities");
|
|
167
|
+
let parser = new DOMParser();
|
|
168
|
+
let contentType = resp.headers.get("Content-Type") || "text/xml";
|
|
169
|
+
let doc = parser.parseFromString(await resp.text(), contentType);
|
|
170
|
+
let node = doc.childNodes[0];
|
|
171
171
|
if (node.nodeName == "WMS_Capabilities" || node.nodeName == "WMT_MS_Capabilities")
|
|
172
172
|
{
|
|
173
|
-
|
|
173
|
+
let attr = node.attributes.getNamedItem("version");
|
|
174
174
|
if (attr)
|
|
175
175
|
{
|
|
176
176
|
this.version = attr.value;
|
|
@@ -181,9 +181,9 @@ export class WMS
|
|
|
181
181
|
return null;
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
184
|
+
let x = (mapPos.x - bounds.min.x) * width / bounds.getWidth();
|
|
185
|
+
let y = (bounds.max.y - mapPos.y) * height / bounds.getHeight();
|
|
186
|
+
let url;
|
|
187
187
|
|
|
188
188
|
if (this.version == "1.1.1")
|
|
189
189
|
{
|
|
@@ -204,7 +204,7 @@ export class WMS
|
|
|
204
204
|
console.log("WMS: Unsupported version", this.version);
|
|
205
205
|
return null;
|
|
206
206
|
}
|
|
207
|
-
|
|
207
|
+
let resp = await fetch(url);
|
|
208
208
|
if (resp.ok)
|
|
209
209
|
{
|
|
210
210
|
return await resp.json();
|