@sswroom/sswr 1.3.1 → 1.4.1
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 +13 -0
- package/geometry.d.ts +4 -0
- package/geometry.js +21 -0
- package/kml.d.ts +11 -1
- package/kml.js +78 -28
- package/leaflet.d.ts +3 -1
- package/leaflet.js +21 -3
- package/map.d.ts +93 -7
- package/map.js +70 -0
- package/olayer2.d.ts +54 -0
- package/olayer2.js +492 -0
- package/package.json +1 -1
- package/sswr.js +1 -0
- package/web.d.ts +1 -0
- package/web.js +363 -20
package/Changelog
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
1.4.1
|
|
2
|
+
-Fixed problems in Chrome
|
|
3
|
+
|
|
4
|
+
1.4.0
|
|
5
|
+
-Added LinearRing.createFromCircle
|
|
6
|
+
-Full support kml.IconStyle
|
|
7
|
+
-Added LinearRing.toPolygon
|
|
8
|
+
-Added map.MapControl
|
|
9
|
+
-Added OpenLayers2 supporting (olayer2.js)
|
|
10
|
+
-Added web.handleFileDrop
|
|
11
|
+
-Added map.WMS
|
|
12
|
+
-Added leaflet.fromLatLngBounds
|
|
13
|
+
|
|
1
14
|
1.3.1
|
|
2
15
|
-Added leaflet.createLayer
|
|
3
16
|
-Added web.buildTable
|
package/geometry.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export enum VectorType
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export class Vector2D {
|
|
39
|
+
srid: number;
|
|
39
40
|
type: VectorType;
|
|
40
41
|
constructor(srid: number);
|
|
41
42
|
insideOrTouch(coord: math.Coord2D): boolean;
|
|
@@ -63,6 +64,9 @@ export class LinearRing extends LineString
|
|
|
63
64
|
insideOrTouch(coord: math.Coord2D): boolean;
|
|
64
65
|
isOpen(): boolean;
|
|
65
66
|
isClose(): boolean;
|
|
67
|
+
toPolygon(): Polygon;
|
|
68
|
+
|
|
69
|
+
static createFromCircle(srid: number, center: math.Coord2D, radiusX: number, radiusY: number, nPoints: number): LinearRing;
|
|
66
70
|
}
|
|
67
71
|
|
|
68
72
|
export class MultiGeometry<VecType> extends Vector2D
|
package/geometry.js
CHANGED
|
@@ -305,6 +305,27 @@ export class LinearRing extends LineString
|
|
|
305
305
|
var lastPoint = this.coordinates[this.coordinates.length - 1];
|
|
306
306
|
return firstPoint[0] == lastPoint[0] && firstPoint[1] == lastPoint[1];
|
|
307
307
|
}
|
|
308
|
+
|
|
309
|
+
toPolygon()
|
|
310
|
+
{
|
|
311
|
+
return new Polygon(this.srid, [this.coordinates]);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
static createFromCircle(srid, center, radiusX, radiusY, nPoints)
|
|
315
|
+
{
|
|
316
|
+
var pos = [];
|
|
317
|
+
var ratio = 2 * Math.PI / nPoints;
|
|
318
|
+
var i = 0;
|
|
319
|
+
var angle;
|
|
320
|
+
i = 0;
|
|
321
|
+
while (i <= nPoints)
|
|
322
|
+
{
|
|
323
|
+
angle = i * ratio;
|
|
324
|
+
pos.push([center.x + radiusX * Math.cos(angle), center.y + radiusY * Math.sin(angle)]);
|
|
325
|
+
i++;
|
|
326
|
+
}
|
|
327
|
+
return new LinearRing(srid, pos);
|
|
328
|
+
}
|
|
308
329
|
}
|
|
309
330
|
|
|
310
331
|
export class MultiGeometry extends Vector2D
|
package/kml.d.ts
CHANGED
|
@@ -86,8 +86,18 @@ export class ColorStyle extends Element
|
|
|
86
86
|
|
|
87
87
|
export class IconStyle extends ColorStyle
|
|
88
88
|
{
|
|
89
|
-
|
|
89
|
+
scale: number;
|
|
90
|
+
heading: number;
|
|
91
|
+
iconUrl: string;
|
|
92
|
+
hotSpotX: number;
|
|
93
|
+
hotSpotY: number;
|
|
94
|
+
|
|
90
95
|
constructor();
|
|
96
|
+
setScale(scale: number);
|
|
97
|
+
setHeading(heading: number);
|
|
98
|
+
setIconUrl(iconUrl: string);
|
|
99
|
+
setHotSpotX(hotSpotX: number);
|
|
100
|
+
setHotSpotY(hotSpotY: number);
|
|
91
101
|
appendOuterXML(strs: string[], level: number): void;
|
|
92
102
|
equals(o: IconStyle): boolean;
|
|
93
103
|
};
|
package/kml.js
CHANGED
|
@@ -142,10 +142,47 @@ export class IconStyle extends ColorStyle
|
|
|
142
142
|
super();
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
setScale(scale)
|
|
146
|
+
{
|
|
147
|
+
this.scale = scale;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
setHeading(heading)
|
|
151
|
+
{
|
|
152
|
+
this.heading = heading;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
setIconUrl(iconUrl)
|
|
156
|
+
{
|
|
157
|
+
this.iconUrl = iconUrl;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
setHotSpotX(hotSpotX)
|
|
161
|
+
{
|
|
162
|
+
this.hotSpotX = hotSpotX;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
setHotSpotY(hotSpotY)
|
|
166
|
+
{
|
|
167
|
+
this.hotSpotY = hotSpotY;
|
|
168
|
+
}
|
|
169
|
+
|
|
145
170
|
appendOuterXML(strs, level)
|
|
146
171
|
{
|
|
147
172
|
strs.push("\t".repeat(level)+"<IconStyle>");
|
|
148
173
|
this.appendInnerXML(strs, level + 1);
|
|
174
|
+
if (this.scale)
|
|
175
|
+
strs.push("\t".repeat(level + 1)+"<scale>"+this.scale+"</scale>");
|
|
176
|
+
if (this.heading != null)
|
|
177
|
+
strs.push("\t".repeat(level + 1)+"<heading>"+this.heading+"</heading>");
|
|
178
|
+
if (this.iconUrl)
|
|
179
|
+
{
|
|
180
|
+
strs.push("\t".repeat(level + 1)+"<Icon>");
|
|
181
|
+
strs.push("\t".repeat(level + 2)+"<href>"+text.toXMLText(this.iconUrl)+"</href>");
|
|
182
|
+
strs.push("\t".repeat(level + 1)+"</Icon>");
|
|
183
|
+
}
|
|
184
|
+
if (this.hotSpotX != null && this.hotSpotY != null)
|
|
185
|
+
strs.push("\t".repeat(level + 1)+"<hotSpot x="+text.toAttrText(""+this.hotSpotX)+" y="+text.toAttrText(""+this.hotSpotY)+" xunits=\"fraction\" yunits=\"fraction\"/>");
|
|
149
186
|
strs.push("\t".repeat(level)+"</IconStyle>");
|
|
150
187
|
}
|
|
151
188
|
|
|
@@ -155,6 +192,16 @@ export class IconStyle extends ColorStyle
|
|
|
155
192
|
return false;
|
|
156
193
|
if (!this.sameColor(o))
|
|
157
194
|
return false;
|
|
195
|
+
if (this.scale != o.scale)
|
|
196
|
+
return false;
|
|
197
|
+
if (this.heading != o.heading)
|
|
198
|
+
return false;
|
|
199
|
+
if (this.iconUrl != o.iconUrl)
|
|
200
|
+
return false;
|
|
201
|
+
if (this.hotSpotX != o.hotSpotX)
|
|
202
|
+
return false;
|
|
203
|
+
if (this.hotSpotY != o.hotSpotY)
|
|
204
|
+
return false;
|
|
158
205
|
return true;
|
|
159
206
|
}
|
|
160
207
|
}
|
|
@@ -379,7 +426,6 @@ export class Style extends Element
|
|
|
379
426
|
{
|
|
380
427
|
return false;
|
|
381
428
|
}
|
|
382
|
-
|
|
383
429
|
if (labelStyle == null)
|
|
384
430
|
{
|
|
385
431
|
if (this.labelStyle != null)
|
|
@@ -393,7 +439,6 @@ export class Style extends Element
|
|
|
393
439
|
{
|
|
394
440
|
return false;
|
|
395
441
|
}
|
|
396
|
-
|
|
397
442
|
if (lineStyle == null)
|
|
398
443
|
{
|
|
399
444
|
if (this.lineStyle != null)
|
|
@@ -407,7 +452,6 @@ export class Style extends Element
|
|
|
407
452
|
{
|
|
408
453
|
return false;
|
|
409
454
|
}
|
|
410
|
-
|
|
411
455
|
if (polyStyle == null)
|
|
412
456
|
{
|
|
413
457
|
if (this.polyStyle != null)
|
|
@@ -421,7 +465,6 @@ export class Style extends Element
|
|
|
421
465
|
{
|
|
422
466
|
return false;
|
|
423
467
|
}
|
|
424
|
-
|
|
425
468
|
if (balloonStyle == null)
|
|
426
469
|
{
|
|
427
470
|
if (this.balloonStyle != null)
|
|
@@ -435,7 +478,6 @@ export class Style extends Element
|
|
|
435
478
|
{
|
|
436
479
|
return false;
|
|
437
480
|
}
|
|
438
|
-
|
|
439
481
|
if (listStyle == null)
|
|
440
482
|
{
|
|
441
483
|
if (this.listStyle != null)
|
|
@@ -583,7 +625,7 @@ export class Document extends Container
|
|
|
583
625
|
var i;
|
|
584
626
|
for (i in this.styleList)
|
|
585
627
|
{
|
|
586
|
-
if (this.styleList[i].isStyle(iconStyle, labelStyle, lineStyle, polyStyle, balloonStyle,
|
|
628
|
+
if (this.styleList[i].isStyle(iconStyle, labelStyle, lineStyle, polyStyle, balloonStyle, listStyle))
|
|
587
629
|
return this.styleList[i];
|
|
588
630
|
}
|
|
589
631
|
var style = new Style("style"+(this.styleList.length + 1));
|
|
@@ -659,38 +701,46 @@ export class Placemark extends Feature
|
|
|
659
701
|
}
|
|
660
702
|
strs.push("\t".repeat(level)+"</Point>");
|
|
661
703
|
}
|
|
662
|
-
else if (vec instanceof geometry.
|
|
704
|
+
else if (vec instanceof geometry.LinearRing)
|
|
663
705
|
{
|
|
664
|
-
|
|
665
|
-
strs.push("\t".repeat(level)+"<LineString>");
|
|
666
|
-
if (vec.coordinates[0].length >= 3)
|
|
706
|
+
if (subGeom)
|
|
667
707
|
{
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
for (i in vec.coordinates)
|
|
708
|
+
var i;
|
|
709
|
+
strs.push("\t".repeat(level)+"<LinearRing>");
|
|
710
|
+
if (vec.coordinates[0].length >= 3)
|
|
672
711
|
{
|
|
673
|
-
|
|
712
|
+
if (subGeom != true)
|
|
713
|
+
strs.push("\t".repeat(level + 1)+"<altitudeMode>absolute</altitudeMode>");
|
|
714
|
+
strs.push("\t".repeat(level + 1)+"<coordinates>");
|
|
715
|
+
for (i in vec.coordinates)
|
|
716
|
+
{
|
|
717
|
+
strs.push("\t".repeat(level + 2)+vec.coordinates[i][0]+","+vec.coordinates[i][1]+","+vec.coordinates[i][2]+" ");
|
|
718
|
+
}
|
|
719
|
+
strs.push("\t".repeat(level + 1)+"</coordinates>");
|
|
674
720
|
}
|
|
675
|
-
|
|
721
|
+
else
|
|
722
|
+
{
|
|
723
|
+
if (subGeom != true)
|
|
724
|
+
strs.push("\t".repeat(level + 1)+"<tessellate>1</tessellate>");
|
|
725
|
+
strs.push("\t".repeat(level + 1)+"<coordinates>");
|
|
726
|
+
for (i in vec.coordinates)
|
|
727
|
+
{
|
|
728
|
+
strs.push("\t".repeat(level + 2)+vec.coordinates[i][0]+","+vec.coordinates[i][1]+" ");
|
|
729
|
+
}
|
|
730
|
+
strs.push("\t".repeat(level + 1)+"</coordinates>");
|
|
731
|
+
}
|
|
732
|
+
strs.push("\t".repeat(level)+"</LinearRing>");
|
|
676
733
|
}
|
|
677
734
|
else
|
|
678
735
|
{
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
strs.push("\t".repeat(level + 1)+"<coordinates>");
|
|
682
|
-
for (i in vec.coordinates)
|
|
683
|
-
{
|
|
684
|
-
strs.push("\t".repeat(level + 2)+vec.coordinates[i][0]+","+vec.coordinates[i][1]+" ");
|
|
685
|
-
}
|
|
686
|
-
strs.push("\t".repeat(level + 1)+"</coordinates>");
|
|
736
|
+
var pg = vec.toPolygon();
|
|
737
|
+
this.appendGeometry(strs, level, pg, subGeom);
|
|
687
738
|
}
|
|
688
|
-
strs.push("\t".repeat(level)+"</LineString>");
|
|
689
739
|
}
|
|
690
|
-
else if (vec instanceof geometry.
|
|
740
|
+
else if (vec instanceof geometry.LineString)
|
|
691
741
|
{
|
|
692
742
|
var i;
|
|
693
|
-
strs.push("\t".repeat(level)+"<
|
|
743
|
+
strs.push("\t".repeat(level)+"<LineString>");
|
|
694
744
|
if (vec.coordinates[0].length >= 3)
|
|
695
745
|
{
|
|
696
746
|
if (subGeom != true)
|
|
@@ -713,7 +763,7 @@ export class Placemark extends Feature
|
|
|
713
763
|
}
|
|
714
764
|
strs.push("\t".repeat(level + 1)+"</coordinates>");
|
|
715
765
|
}
|
|
716
|
-
strs.push("\t".repeat(level)+"</
|
|
766
|
+
strs.push("\t".repeat(level)+"</LineString>");
|
|
717
767
|
}
|
|
718
768
|
else if (vec instanceof geometry.Polygon)
|
|
719
769
|
{
|
package/leaflet.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as L from "./node_modules/leaflet/src/Leaflet";
|
|
2
2
|
import * as kml from "./kml";
|
|
3
|
-
import { Coord2D } from "./math";
|
|
3
|
+
import { Coord2D, RectArea } from "./math";
|
|
4
4
|
import { LayerInfo } from "./map";
|
|
5
5
|
|
|
6
6
|
export function fromLatLon(latLon: L.LatLng): Coord2D;
|
|
7
|
+
export function fromLatLng(latLng: L.LatLng): Coord2D;
|
|
8
|
+
export function fromLatLngBounds(b: L.LatLngBounds): RectArea;
|
|
7
9
|
export function createLayer(layer: LayerInfo, options: object): L.Layer;
|
|
8
10
|
export function createKMLLookAt(map: L.Map): kml.LookAt;
|
|
9
11
|
export function toKMLFeature(layer: L.Layer, doc?: kml.Document): kml.Feature | null;
|
package/leaflet.js
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import * as data from "./data.js";
|
|
2
2
|
import * as geometry from "./geometry.js";
|
|
3
3
|
import * as kml from "./kml.js";
|
|
4
|
-
import
|
|
4
|
+
import * as math from "./math.js";
|
|
5
5
|
import * as map from "./map.js";
|
|
6
|
+
import * as web from "./web.js";
|
|
6
7
|
|
|
7
8
|
export function fromLatLon(latLon)
|
|
8
9
|
{
|
|
9
|
-
return new Coord2D(latLon.lng, latLon.lat);
|
|
10
|
+
return new math.Coord2D(latLon.lng, latLon.lat);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function fromLatLng(latLng)
|
|
14
|
+
{
|
|
15
|
+
return new math.Coord2D(latLng.lng, latLng.lat);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function fromLatLngBounds(b)
|
|
19
|
+
{
|
|
20
|
+
return new math.RectArea(b.getWest(), b.getSouth(), b.getEast(), b.getNorth());
|
|
10
21
|
}
|
|
11
22
|
|
|
12
23
|
export function createLayer(layer, options)
|
|
@@ -118,7 +129,14 @@ export function toKMLFeature(layer, doc)
|
|
|
118
129
|
{
|
|
119
130
|
var lineStyle = new kml.LineStyle();
|
|
120
131
|
if (layer.options.color)
|
|
121
|
-
|
|
132
|
+
{
|
|
133
|
+
var c = web.parseCSSColor(layer.options.color);
|
|
134
|
+
if (layer.options.opacity)
|
|
135
|
+
{
|
|
136
|
+
c.a = c.a * layer.options.opacity;
|
|
137
|
+
}
|
|
138
|
+
lineStyle.fromARGB(c.a, c.r, c.g, c.b);
|
|
139
|
+
}
|
|
122
140
|
if (layer.options.weight)
|
|
123
141
|
lineStyle.setWidth(layer.options.weight);
|
|
124
142
|
feature.setStyle(doc.getOrNewStyle(null, null, lineStyle, null, null, null));
|
package/map.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { CoordinateSystem, Vector3 } from "./math";
|
|
2
|
-
import { LineString, Vector2D } from "./geometry";
|
|
3
1
|
import { Timestamp } from "./data";
|
|
2
|
+
import * as geometry from "./geometry";
|
|
3
|
+
import * as map from "./map";
|
|
4
|
+
import * as math from "./math";
|
|
4
5
|
|
|
5
6
|
export enum DataFormat
|
|
6
7
|
{
|
|
@@ -70,7 +71,7 @@ declare class GeoJSONFeatureCollection extends GeoJSON
|
|
|
70
71
|
features: GeoJSONFeature[];
|
|
71
72
|
};
|
|
72
73
|
|
|
73
|
-
export function calcDistance(srid: number, geom: Vector2D, x: number, y: number): number;
|
|
74
|
+
export function calcDistance(srid: number, geom: geometry.Vector2D, x: number, y: number): number;
|
|
74
75
|
export function getLayers(svcUrl: string, onResultFunc: Function): void;
|
|
75
76
|
export function getLayerData(svcUrl: string, onResultFunc: Function, layerName: string, dataFormat: DataFormat): void;
|
|
76
77
|
|
|
@@ -90,18 +91,103 @@ export class GPSTrack
|
|
|
90
91
|
{
|
|
91
92
|
recs: GPSRecord[];
|
|
92
93
|
constructor(recs: GPSRecord[]);
|
|
93
|
-
createLineString(): LineString;
|
|
94
|
-
getPosByTime(ts: Timestamp): Vector3;
|
|
95
|
-
getPosByTicks(ticks: number): Vector3;
|
|
94
|
+
createLineString(): geometry.LineString;
|
|
95
|
+
getPosByTime(ts: Timestamp): math.Vector3;
|
|
96
|
+
getPosByTicks(ticks: number): math.Vector3;
|
|
96
97
|
};
|
|
97
98
|
|
|
98
99
|
export class GeolocationFilter
|
|
99
100
|
{
|
|
100
101
|
lastPos?: GeolocationPosition;
|
|
101
|
-
csys: CoordinateSystem;
|
|
102
|
+
csys: math.CoordinateSystem;
|
|
102
103
|
minSecs: number;
|
|
103
104
|
minDistMeter: number;
|
|
104
105
|
|
|
105
106
|
constructor(minSecs: number, minDistMeter: number);
|
|
106
107
|
isValid(pos: GeolocationPosition): boolean;
|
|
107
108
|
};
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
declare class LayerOptions
|
|
112
|
+
{
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
declare class MarkerOptions
|
|
116
|
+
{
|
|
117
|
+
zIndex?: number;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
declare class GeometryOptions
|
|
121
|
+
{
|
|
122
|
+
lineColor?: string;
|
|
123
|
+
lineWidth?: number;
|
|
124
|
+
fillColor?: string;
|
|
125
|
+
fillOpacity?: number;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export class MapControl
|
|
129
|
+
{
|
|
130
|
+
constructor();
|
|
131
|
+
createLayer(layer: map.LayerInfo, options?: LayerOptions): any;
|
|
132
|
+
createMarkerLayer(name: string, options?: LayerOptions): any;
|
|
133
|
+
createGeometryLayer(name: string, options?: LayerOptions): any;
|
|
134
|
+
addLayer(layer: any);
|
|
135
|
+
uninit(): void;
|
|
136
|
+
zoomIn(): void;
|
|
137
|
+
zoomOut(): void;
|
|
138
|
+
zoomScale(scale: number): void;
|
|
139
|
+
panTo(pos: math.Coord2D): void;
|
|
140
|
+
panZoomScale(pos: math.Coord2D, scale: number): void;
|
|
141
|
+
zoomToExtent(extent: math.RectArea): void;
|
|
142
|
+
handleMouseLClick(clickFunc: (mapPos: math.Coord2D, scnPos: math.Coord2D)=>void): void;
|
|
143
|
+
handleMouseMove(moveFunc: (mapPos: math.Coord2D)=>void): void;
|
|
144
|
+
handlePosChange(posFunc: (mapPos: math.Coord2D)=>void): void;
|
|
145
|
+
map2ScnPos(mapPos: math.Coord2D): math.Coord2D;
|
|
146
|
+
scn2MapPos(scnPos: math.Coord2D): math.Coord2D;
|
|
147
|
+
|
|
148
|
+
createMarker(mapPos: math.Coord2D, imgURL: string, imgWidth: number, imgHeight: number, options?: MarkerOptions): any;
|
|
149
|
+
layerAddMarker(markerLayer: any, marker: any): void;
|
|
150
|
+
layerRemoveMarker(markerLayer: any, marker: any): void;
|
|
151
|
+
layerClearMarkers(markerLayer: any): void;
|
|
152
|
+
markerIsOver(marker: any, scnPos: math.Coord2D): boolean;
|
|
153
|
+
|
|
154
|
+
createGeometry(geom: geometry.Vector2D, options: GeometryOptions): any;
|
|
155
|
+
layerAddGeometry(geometryLayer: any, geom: any): void;
|
|
156
|
+
layerRemoveGeometry(geometryLayer: any, geom: any): void;
|
|
157
|
+
layerClearGeometries(geometryLayer: any): void;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
declare class OWSSpatialReference
|
|
161
|
+
{
|
|
162
|
+
type: string;
|
|
163
|
+
properties: string;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
declare class OWSFeature
|
|
167
|
+
{
|
|
168
|
+
type: string;
|
|
169
|
+
id: string;
|
|
170
|
+
geometry_name?: string;
|
|
171
|
+
geometry: Geometry;
|
|
172
|
+
properties: object;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
declare class OWSFeatureCollection
|
|
176
|
+
{
|
|
177
|
+
crs: OWSSpatialReference;
|
|
178
|
+
features: OWSFeature[];
|
|
179
|
+
numberReturned: number;
|
|
180
|
+
timeStamp: string;
|
|
181
|
+
totalFeatures: number | string;
|
|
182
|
+
type: string;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export class WMS
|
|
186
|
+
{
|
|
187
|
+
url: string;
|
|
188
|
+
layer: string;
|
|
189
|
+
version: string;
|
|
190
|
+
|
|
191
|
+
constructor(url: string, layer: string, version?: string);
|
|
192
|
+
queryInfos(mapPos: math.Coord2D, bounds: math.RectArea, width: number, height: number): Promise<OWSFeatureCollection | null>;
|
|
193
|
+
}
|
package/map.js
CHANGED
|
@@ -142,3 +142,73 @@ export class GeolocationFilter
|
|
|
142
142
|
return true;
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
+
|
|
146
|
+
export class MapControl
|
|
147
|
+
{
|
|
148
|
+
constructor()
|
|
149
|
+
{
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export class WMS
|
|
154
|
+
{
|
|
155
|
+
constructor(url, layer, version)
|
|
156
|
+
{
|
|
157
|
+
this.url = url;
|
|
158
|
+
this.layer = layer;
|
|
159
|
+
this.version = version;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async queryInfos(mapPos, bounds, width, height)
|
|
163
|
+
{
|
|
164
|
+
if (this.version == null)
|
|
165
|
+
{
|
|
166
|
+
var resp = await fetch(this.url + "?SERVICE=WMS&REQUEST=GetCapabilities");
|
|
167
|
+
var parser = new DOMParser();
|
|
168
|
+
var contentType = resp.headers.get("Content-Type") || "text/xml";
|
|
169
|
+
var doc = parser.parseFromString(await resp.text(), contentType);
|
|
170
|
+
var node = doc.childNodes[0];
|
|
171
|
+
if (node.nodeName == "WMS_Capabilities" || node.nodeName == "WMT_MS_Capabilities")
|
|
172
|
+
{
|
|
173
|
+
var attr = node.attributes.getNamedItem("version");
|
|
174
|
+
if (attr)
|
|
175
|
+
{
|
|
176
|
+
this.version = attr.value;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (this.version == null)
|
|
180
|
+
{
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
var x = (mapPos.x - bounds.min.x) * width / bounds.getWidth();
|
|
185
|
+
var y = (bounds.max.y - mapPos.y) * height / bounds.getHeight();
|
|
186
|
+
var url;
|
|
187
|
+
|
|
188
|
+
if (this.version == "1.1.1")
|
|
189
|
+
{
|
|
190
|
+
url = this.url + "?service=WMS&version=1.1.1&request=GetFeatureInfo&layers="+encodeURIComponent(this.layer);
|
|
191
|
+
url = url + "&bbox="+bounds.min.y+"%2C"+bounds.min.x+"%2C"+bounds.max.y+"%2C"+bounds.max.x+"&width="+width+"&height="+height;
|
|
192
|
+
url = url + "&srs=EPSG%3A4326&styles=&format=image%2Fpng&QUERY_LAYERS="+encodeURIComponent(this.layer)+"&INFO_FORMAT=application%2Fjson&FEATURE_COUNT=5";
|
|
193
|
+
url = url + "&X="+Math.round(x)+"&Y="+Math.round(y);
|
|
194
|
+
}
|
|
195
|
+
else if (this.version == "1.3.0")
|
|
196
|
+
{
|
|
197
|
+
url = this.url + "?service=WMS&version=1.3.0&request=GetFeatureInfo&layers="+encodeURIComponent(this.layer);
|
|
198
|
+
url = url + "&bbox="+bounds.min.y+"%2C"+bounds.min.x+"%2C"+bounds.max.y+"%2C"+bounds.max.x+"&width="+width+"&height="+height;
|
|
199
|
+
url = url + "&CRS=EPSG%3A4326&styles=&format=image%2Fpng&QUERY_LAYERS="+encodeURIComponent(this.layer)+"&INFO_FORMAT=application%2Fjson&FEATURE_COUNT=5";
|
|
200
|
+
url = url + "&I="+Math.round(x)+"&J="+Math.round(y);
|
|
201
|
+
}
|
|
202
|
+
else
|
|
203
|
+
{
|
|
204
|
+
console.log("WMS: Unsupported version", this.version);
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
var resp = await fetch(url);
|
|
208
|
+
if (resp.ok)
|
|
209
|
+
{
|
|
210
|
+
return await resp.json();
|
|
211
|
+
}
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
}
|
package/olayer2.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as geometry from "./geometry";
|
|
2
|
+
import * as kml from "./kml";
|
|
3
|
+
import * as map from "./map";
|
|
4
|
+
import * as math from "./math";
|
|
5
|
+
|
|
6
|
+
export class Olayer2Map extends map.MapControl
|
|
7
|
+
{
|
|
8
|
+
inited: boolean;
|
|
9
|
+
mapId: string;
|
|
10
|
+
mapProjection: OpenLayers.Projection;
|
|
11
|
+
map: OpenLayers.Map;
|
|
12
|
+
Click: OpenLayers.Control;
|
|
13
|
+
mouseCtrl: Olayer2Map.Click;
|
|
14
|
+
currMarkerPopup: any;
|
|
15
|
+
currMarkerPopupObj: any;
|
|
16
|
+
lclickFunc: (lat: number, lon: number, scnX: number, scnY: number)=>void;
|
|
17
|
+
moveFunc: (lat: number, lon: number)=>void;
|
|
18
|
+
posFunc: (lat: number, lon: number)=>void;
|
|
19
|
+
|
|
20
|
+
constructor(mapId: string);
|
|
21
|
+
createLayer(layer: map.LayerInfo, options?: LayerOptions): any;
|
|
22
|
+
createMarkerLayer(name: string, options?: LayerOptions): any;
|
|
23
|
+
createGeometryLayer(name: string, options?: LayerOptions): any;
|
|
24
|
+
addLayer(layer: any);
|
|
25
|
+
uninit(): void;
|
|
26
|
+
zoomIn(): void;
|
|
27
|
+
zoomOut(): void;
|
|
28
|
+
zoomScale(scale: number): void;
|
|
29
|
+
panTo(pos: math.Coord2D): void;
|
|
30
|
+
panZoomScale(pos: math.Coord2D, scale: number): void;
|
|
31
|
+
zoomToExtent(extent: math.RectArea): void;
|
|
32
|
+
handleMouseLClick(clickFunc: (mapPos: math.Coord2D, scnPos: math.Coord2D)=>void): void;
|
|
33
|
+
handleMouseMove(moveFunc: (mapPos: math.Coord2D)=>void): void;
|
|
34
|
+
handlePosChange(posFunc: (mapPos: math.Coord2D)=>void): void;
|
|
35
|
+
map2ScnPos(mapPos: math.Coord2D): math.Coord2D;
|
|
36
|
+
scn2MapPos(scnPos: math.Coord2D): math.Coord2D;
|
|
37
|
+
|
|
38
|
+
createMarker(mapPos: math.Coord2D, imgURL: string, imgWidth: number, imgHeight: number, options?: MarkerOptions): any;
|
|
39
|
+
layerAddMarker(markerLayer: any, marker: any): void;
|
|
40
|
+
layerRemoveMarker(markerLayer: any, marker: any): void;
|
|
41
|
+
layerClearMarkers(markerLayer: any): void;
|
|
42
|
+
markerIsOver(marker: any, scnPos: math.Coord2D): boolean;
|
|
43
|
+
|
|
44
|
+
createGeometry(geom: geometry.Vector2D, lineColor: string, fillColor: string, fillOpacity: string): any;
|
|
45
|
+
layerAddGeometry(geometryLayer: any, geom: any): void;
|
|
46
|
+
layerRemoveGeometry(geometryLayer: any, geom: any): void;
|
|
47
|
+
layerClearGeometries(goemetryLayer: any): void;
|
|
48
|
+
|
|
49
|
+
toKMLFeature(layer: any, doc?: kml.Document): kml.Feature | null;
|
|
50
|
+
|
|
51
|
+
private eventLClicked(e: any): void;
|
|
52
|
+
private eventMoved(): void;
|
|
53
|
+
private eventMouseMoved(event: any): void;
|
|
54
|
+
}
|