@supermapgis/iclient-ol 11.1.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/README.md +56 -0
- package/control/ChangeTileVersion.js +438 -0
- package/control/Logo.js +99 -0
- package/control/ScaleLine.js +164 -0
- package/control/index.js +6 -0
- package/core/MapExtend.js +49 -0
- package/core/StyleUtils.js +1253 -0
- package/core/Util.js +478 -0
- package/core/index.js +6 -0
- package/css/ChangeTileVersion.css +347 -0
- package/css/index.js +5 -0
- package/dist/iclient-openlayers-es6.js +121806 -0
- package/dist/iclient-openlayers-es6.min.js +8 -0
- package/dist/iclient-openlayers.css +668 -0
- package/dist/iclient-openlayers.js +132335 -0
- package/dist/iclient-openlayers.min.css +8 -0
- package/dist/iclient-openlayers.min.js +8 -0
- package/index.js +9 -0
- package/mapping/BaiduMap.js +121 -0
- package/mapping/ImageSuperMapRest.js +252 -0
- package/mapping/ImageTileSuperMapRest.js +99 -0
- package/mapping/InitMap.js +125 -0
- package/mapping/SuperMapCloud.js +56 -0
- package/mapping/Tianditu.js +152 -0
- package/mapping/TileSuperMapRest.js +358 -0
- package/mapping/WebMap.js +5185 -0
- package/mapping/index.js +11 -0
- package/mapping/webmap/Util.js +176 -0
- package/mapping/webmap/config/MunicipalCenter.json +1 -0
- package/mapping/webmap/config/ProvinceCenter.json +1 -0
- package/mapping/webmap/config/SampleDataInfo.json +55 -0
- package/namespace.js +150 -0
- package/overlay/DataFlow.js +114 -0
- package/overlay/FGB.js +97 -0
- package/overlay/Graph.js +436 -0
- package/overlay/GraphMap.js +91 -0
- package/overlay/Graphic.js +587 -0
- package/overlay/HeatMap.js +444 -0
- package/overlay/Label.js +964 -0
- package/overlay/Mapv.js +146 -0
- package/overlay/Range.js +127 -0
- package/overlay/RankSymbol.js +94 -0
- package/overlay/Turf.js +298 -0
- package/overlay/Unique.js +123 -0
- package/overlay/VectorTileSuperMapRest.js +466 -0
- package/overlay/graphic/CanvasRenderer.js +177 -0
- package/overlay/graphic/CloverShape.js +133 -0
- package/overlay/graphic/Graphic.js +174 -0
- package/overlay/graphic/HitCloverShape.js +63 -0
- package/overlay/graphic/WebGLRenderer.js +356 -0
- package/overlay/graphic/index.js +9 -0
- package/overlay/index.js +21 -0
- package/overlay/mapv/MapvCanvasLayer.js +104 -0
- package/overlay/mapv/MapvLayer.js +410 -0
- package/overlay/mapv/index.js +5 -0
- package/overlay/theme/GeoFeature.js +275 -0
- package/overlay/theme/Theme.js +585 -0
- package/overlay/theme/ThemeFeature.js +46 -0
- package/overlay/theme/index.js +6 -0
- package/overlay/vectortile/DeafultCanvasStyle.js +125 -0
- package/overlay/vectortile/MapboxStyles.js +375 -0
- package/overlay/vectortile/StyleMap.js +252 -0
- package/overlay/vectortile/VectorTileStyles.js +554 -0
- package/overlay/vectortile/index.js +7 -0
- package/overlay/vectortile/olExtends.js +382 -0
- package/package.json +29 -0
- package/services/AddressMatchService.js +60 -0
- package/services/ChartService.js +74 -0
- package/services/DataFlowService.js +118 -0
- package/services/DatasetService.js +104 -0
- package/services/DatasourceService.js +76 -0
- package/services/FeatureService.js +196 -0
- package/services/FieldService.js +53 -0
- package/services/GeoprocessingService.js +156 -0
- package/services/GridCellInfosService.js +53 -0
- package/services/ImageCollectionService.js +92 -0
- package/services/ImageService.js +69 -0
- package/services/KnowledgeGraphService.js +82 -0
- package/services/LayerInfoService.js +85 -0
- package/services/MapService.js +85 -0
- package/services/MeasureService.js +77 -0
- package/services/NetworkAnalyst3DService.js +88 -0
- package/services/NetworkAnalystService.js +252 -0
- package/services/ProcessingService.js +478 -0
- package/services/QueryService.js +116 -0
- package/services/ServiceBase.js +26 -0
- package/services/SpatialAnalystService.js +432 -0
- package/services/ThemeService.js +50 -0
- package/services/TrafficTransferAnalystService.js +88 -0
- package/services/WebPrintingJobService.js +112 -0
- package/services/index.js +27 -0
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
/* Copyright© 2000 - 2024 SuperMap Software Co.Ltd. All rights reserved.
|
|
2
|
+
* This program are made available under the terms of the Apache License, Version 2.0
|
|
3
|
+
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
|
|
4
|
+
import { Util } from '../../core/Util';
|
|
5
|
+
import LineString from 'ol/geom/LineString';
|
|
6
|
+
|
|
7
|
+
export var olExtends = function(targetMap) {
|
|
8
|
+
//解决olms.js插件,在使用ol.js时沿线标注不显示的问题,因为ol.geom.LineString.getFlatMidpoint未非公开方法
|
|
9
|
+
if (!LineString.prototype.getFlatMidpoint) {
|
|
10
|
+
LineString.prototype.getFlatMidpoint = function() {
|
|
11
|
+
return this.getCoordinateAt(0.5);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (Util.getOlVersion() === '4' && window && window.ol && window.ol.geom.flat) {
|
|
16
|
+
// for ol4-debug
|
|
17
|
+
window.targetMapCache = targetMap;
|
|
18
|
+
let ol = window.ol;
|
|
19
|
+
//解决 new ol.format.MVT({featureClass: ol.Feature})时,非3857显示异常的问题。ol即将发布的5.0版本已解决。
|
|
20
|
+
// eslint-disable-next-line no-unused-vars
|
|
21
|
+
ol.format.MVT.prototype.readProjection = function(source) {
|
|
22
|
+
return new ol.proj.Projection({
|
|
23
|
+
code: '',
|
|
24
|
+
units: ol.proj.Units.TILE_PIXELS
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
//解决 new ol.format.MVT({featureClass: ol.Feature})时,非3857显示异常的问题。ol即将发布的5.0版本已解决。
|
|
28
|
+
// eslint-disable-next-line no-unused-vars
|
|
29
|
+
ol.format.MVT.prototype.readProjection = function(source) {
|
|
30
|
+
return new ol.proj.Projection({
|
|
31
|
+
code: '',
|
|
32
|
+
units: ol.proj.Units.TILE_PIXELS
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
//解决面填充时不能整版填充的问题。ol即将发布的5.0版本已解决。
|
|
36
|
+
// eslint-disable-next-line no-unused-vars
|
|
37
|
+
ol.render.canvas.Replay.prototype.applyFill = function(state, geometry) {
|
|
38
|
+
var fillStyle = state.fillStyle;
|
|
39
|
+
var fillInstruction = [ol.render.canvas.Instruction.SET_FILL_STYLE, fillStyle];
|
|
40
|
+
if (typeof fillStyle !== 'string') {
|
|
41
|
+
var viewExtent = window.targetMapCache
|
|
42
|
+
.getView()
|
|
43
|
+
.getProjection()
|
|
44
|
+
.getExtent();
|
|
45
|
+
fillInstruction.push([viewExtent[0], viewExtent[3]]);
|
|
46
|
+
}
|
|
47
|
+
this.instructions.push(fillInstruction);
|
|
48
|
+
};
|
|
49
|
+
//解决面填充时不能整版填充的问题。ol即将发布的5.0版本已解决。
|
|
50
|
+
// eslint-disable-next-line no-unused-vars
|
|
51
|
+
ol.render.canvas.Replay.prototype.applyFill = function(state, geometry) {
|
|
52
|
+
var fillStyle = state.fillStyle;
|
|
53
|
+
var fillInstruction = [ol.render.canvas.Instruction.SET_FILL_STYLE, fillStyle];
|
|
54
|
+
if (typeof fillStyle !== 'string') {
|
|
55
|
+
var viewExtent = window.targetMapCache
|
|
56
|
+
.getView()
|
|
57
|
+
.getProjection()
|
|
58
|
+
.getExtent();
|
|
59
|
+
fillInstruction.push([viewExtent[0], viewExtent[3]]);
|
|
60
|
+
}
|
|
61
|
+
this.instructions.push(fillInstruction);
|
|
62
|
+
};
|
|
63
|
+
//解决在多面时,第一个面是逆时针时无法显示的问题。该问题由组件修复。
|
|
64
|
+
ol.format.MVT.prototype.createFeature_ = function(pbf, rawFeature, opt_options) {
|
|
65
|
+
var type = rawFeature.type;
|
|
66
|
+
if (type === 0) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
var feature;
|
|
71
|
+
var id = rawFeature.id;
|
|
72
|
+
var values = rawFeature.properties;
|
|
73
|
+
values[this.layerName_] = rawFeature.layer.name;
|
|
74
|
+
|
|
75
|
+
var flatCoordinates = [];
|
|
76
|
+
var ends = [];
|
|
77
|
+
ol.format.MVT.readRawGeometry_(pbf, rawFeature, flatCoordinates, ends);
|
|
78
|
+
|
|
79
|
+
var geometryType = ol.format.MVT.getGeometryType_(type, ends.length);
|
|
80
|
+
|
|
81
|
+
if (this.featureClass_ === ol.render.Feature) {
|
|
82
|
+
feature = new this.featureClass_(geometryType, flatCoordinates, ends, values, id);
|
|
83
|
+
} else {
|
|
84
|
+
var geom;
|
|
85
|
+
if (geometryType == ol.geom.GeometryType.POLYGON) {
|
|
86
|
+
var endss = [];
|
|
87
|
+
var offset = 0;
|
|
88
|
+
var prevEndIndex = 0;
|
|
89
|
+
for (var i = 0, ii = ends.length; i < ii; ++i) {
|
|
90
|
+
var end = ends[i];
|
|
91
|
+
if (!ol.geom.flat.orient.linearRingIsClockwise(flatCoordinates, offset, end, 2)) {
|
|
92
|
+
endss.push(ends.slice(prevEndIndex, i + 1));
|
|
93
|
+
prevEndIndex = i + 1;
|
|
94
|
+
}
|
|
95
|
+
offset = end;
|
|
96
|
+
}
|
|
97
|
+
if (endss.length > 1) {
|
|
98
|
+
ends = endss;
|
|
99
|
+
geom = new ol.geom.MultiPolygon(null);
|
|
100
|
+
} else {
|
|
101
|
+
geom = new ol.geom.Polygon(null);
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
geom =
|
|
105
|
+
geometryType === ol.geom.GeometryType.POINT
|
|
106
|
+
? new ol.geom.Point(null)
|
|
107
|
+
: geometryType === ol.geom.GeometryType.LINE_STRING
|
|
108
|
+
? new ol.geom.LineString(null)
|
|
109
|
+
: geometryType === ol.geom.GeometryType.POLYGON
|
|
110
|
+
? new ol.geom.Polygon(null)
|
|
111
|
+
: geometryType === ol.geom.GeometryType.MULTI_POINT
|
|
112
|
+
? new ol.geom.MultiPoint(null)
|
|
113
|
+
: geometryType === ol.geom.GeometryType.MULTI_LINE_STRING
|
|
114
|
+
? new ol.geom.MultiLineString(null)
|
|
115
|
+
: null;
|
|
116
|
+
}
|
|
117
|
+
if (geom) {
|
|
118
|
+
geom.setFlatCoordinates(ol.geom.GeometryLayout.XY, flatCoordinates, ends);
|
|
119
|
+
feature = new this.featureClass_();
|
|
120
|
+
if (this.geometryName_) {
|
|
121
|
+
feature.setGeometryName(this.geometryName_);
|
|
122
|
+
}
|
|
123
|
+
var geometry = ol.format.Feature.transformWithOptions(geom, false, this.adaptOptions(opt_options));
|
|
124
|
+
feature.setGeometry(geometry);
|
|
125
|
+
feature.setId(id);
|
|
126
|
+
feature.setProperties(values);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return feature;
|
|
131
|
+
};
|
|
132
|
+
//解决中文沿线表述显示不符合中文阅读习惯的问题
|
|
133
|
+
ol.geom.flat.textpath.lineString = function(
|
|
134
|
+
flatCoordinates,
|
|
135
|
+
offset,
|
|
136
|
+
end,
|
|
137
|
+
stride,
|
|
138
|
+
text,
|
|
139
|
+
measure,
|
|
140
|
+
startM,
|
|
141
|
+
maxAngle
|
|
142
|
+
) {
|
|
143
|
+
var result = [];
|
|
144
|
+
|
|
145
|
+
// Keep text upright
|
|
146
|
+
var anglereverse = Math.atan2(
|
|
147
|
+
flatCoordinates[end - stride + 1] - flatCoordinates[offset + 1],
|
|
148
|
+
flatCoordinates[end - stride] - flatCoordinates[offset]
|
|
149
|
+
);
|
|
150
|
+
var reverse = anglereverse < -0.785 || anglereverse > 2.356; //0.785//2.356
|
|
151
|
+
var isRotateUp =
|
|
152
|
+
(anglereverse < -0.785 && anglereverse > -2.356) || (anglereverse > 0.785 && anglereverse < 2.356);
|
|
153
|
+
|
|
154
|
+
var numChars = text.length;
|
|
155
|
+
|
|
156
|
+
var x1 = flatCoordinates[offset];
|
|
157
|
+
var y1 = flatCoordinates[offset + 1];
|
|
158
|
+
offset += stride;
|
|
159
|
+
var x2 = flatCoordinates[offset];
|
|
160
|
+
var y2 = flatCoordinates[offset + 1];
|
|
161
|
+
var segmentM = 0;
|
|
162
|
+
var segmentLength = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
|
|
163
|
+
|
|
164
|
+
while (offset < end - stride && segmentM + segmentLength < startM) {
|
|
165
|
+
x1 = x2;
|
|
166
|
+
y1 = y2;
|
|
167
|
+
offset += stride;
|
|
168
|
+
x2 = flatCoordinates[offset];
|
|
169
|
+
y2 = flatCoordinates[offset + 1];
|
|
170
|
+
segmentM += segmentLength;
|
|
171
|
+
segmentLength = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
|
|
172
|
+
}
|
|
173
|
+
var interpolate = (startM - segmentM) / segmentLength;
|
|
174
|
+
var x0 = ol.math.lerp(x1, x2, interpolate); //起始点
|
|
175
|
+
var y0 = ol.math.lerp(y1, y2, interpolate); //起始点
|
|
176
|
+
|
|
177
|
+
var chunk = '';
|
|
178
|
+
var chunkLength = 0;
|
|
179
|
+
var data, index, previousAngle, previousLang;
|
|
180
|
+
for (var i = 0; i < numChars; ++i) {
|
|
181
|
+
index = reverse ? numChars - i - 1 : i;
|
|
182
|
+
var char = text.charAt(index);
|
|
183
|
+
var charcode = char.charCodeAt(0);
|
|
184
|
+
var ischinese = charcode >= 19968 && charcode <= 40907;
|
|
185
|
+
chunk = reverse ? char + chunk : chunk + char;
|
|
186
|
+
var charLength = measure(chunk) - chunkLength;
|
|
187
|
+
chunkLength += charLength;
|
|
188
|
+
//var charM = startM + charLength / 2;
|
|
189
|
+
while (
|
|
190
|
+
offset < end - stride &&
|
|
191
|
+
Math.sqrt(Math.pow(x2 - x0, 2) + Math.pow(y2 - y0, 2)) < charLength / 2
|
|
192
|
+
) {
|
|
193
|
+
x1 = x2;
|
|
194
|
+
y1 = y2;
|
|
195
|
+
offset += stride;
|
|
196
|
+
x2 = flatCoordinates[offset];
|
|
197
|
+
y2 = flatCoordinates[offset + 1];
|
|
198
|
+
}
|
|
199
|
+
var a = Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2);
|
|
200
|
+
var b = 2 * (x2 - x1) * (x1 - x0) + 2 * (y2 - y1) * (y1 - y0);
|
|
201
|
+
var c = Math.pow(x1 - x0, 2) + Math.pow(y1 - y0, 2) - Math.pow(charLength / 2, 2);
|
|
202
|
+
var scale1 = (-b + Math.sqrt(b * b - 4 * a * c)) / (2 * a);
|
|
203
|
+
var scale2 = (-b - Math.sqrt(b * b - 4 * a * c)) / (2 * a);
|
|
204
|
+
interpolate =
|
|
205
|
+
scale1 < 0 || scale1 > 1
|
|
206
|
+
? scale2
|
|
207
|
+
: scale2 < 0 || scale2 > 1
|
|
208
|
+
? scale1
|
|
209
|
+
: scale1 < scale2
|
|
210
|
+
? scale2
|
|
211
|
+
: scale1;
|
|
212
|
+
var x = ol.math.lerp(x1, x2, interpolate);
|
|
213
|
+
var y = ol.math.lerp(y1, y2, interpolate);
|
|
214
|
+
|
|
215
|
+
while (offset < end - stride && Math.sqrt(Math.pow(x2 - x, 2) + Math.pow(y2 - y, 2)) < charLength / 2) {
|
|
216
|
+
x1 = x2;
|
|
217
|
+
y1 = y2;
|
|
218
|
+
offset += stride;
|
|
219
|
+
x2 = flatCoordinates[offset];
|
|
220
|
+
y2 = flatCoordinates[offset + 1];
|
|
221
|
+
}
|
|
222
|
+
a = Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2);
|
|
223
|
+
b = 2 * (x2 - x1) * (x1 - x) + 2 * (y2 - y1) * (y1 - y);
|
|
224
|
+
c = Math.pow(x1 - x, 2) + Math.pow(y1 - y, 2) - Math.pow(charLength / 2, 2);
|
|
225
|
+
scale1 = (-b + Math.sqrt(b * b - 4 * a * c)) / (2 * a);
|
|
226
|
+
scale2 = (-b - Math.sqrt(b * b - 4 * a * c)) / (2 * a);
|
|
227
|
+
interpolate =
|
|
228
|
+
scale1 < 0 || scale1 > 1
|
|
229
|
+
? scale2
|
|
230
|
+
: scale2 < 0 || scale2 > 1
|
|
231
|
+
? scale1
|
|
232
|
+
: scale1 < scale2
|
|
233
|
+
? scale2
|
|
234
|
+
: scale1;
|
|
235
|
+
var x3 = ol.math.lerp(x1, x2, interpolate);
|
|
236
|
+
var y3 = ol.math.lerp(y1, y2, interpolate);
|
|
237
|
+
var angle = Math.atan2(y3 - y0, x3 - x0);
|
|
238
|
+
|
|
239
|
+
if (reverse) {
|
|
240
|
+
angle += angle > 0 ? -Math.PI : Math.PI;
|
|
241
|
+
}
|
|
242
|
+
if (ischinese && isRotateUp) {
|
|
243
|
+
angle += angle > 0 ? -Math.PI / 2 : Math.PI / 2;
|
|
244
|
+
}
|
|
245
|
+
if (previousAngle !== undefined) {
|
|
246
|
+
var delta = angle - previousAngle;
|
|
247
|
+
delta += delta > Math.PI ? -2 * Math.PI : delta < -Math.PI ? 2 * Math.PI : 0;
|
|
248
|
+
if (
|
|
249
|
+
ischinese === previousLang
|
|
250
|
+
? Math.abs(delta) > maxAngle
|
|
251
|
+
: Math.abs(delta) > maxAngle + Math.PI / 2
|
|
252
|
+
) {
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (previousAngle == angle && !isRotateUp) {
|
|
258
|
+
if (reverse) {
|
|
259
|
+
data[0] = x;
|
|
260
|
+
data[1] = y;
|
|
261
|
+
data[2] = charLength / 2;
|
|
262
|
+
}
|
|
263
|
+
data[4] = chunk;
|
|
264
|
+
} else {
|
|
265
|
+
chunk = char;
|
|
266
|
+
chunkLength = charLength;
|
|
267
|
+
data = [x, y, charLength / 2, angle, chunk];
|
|
268
|
+
if (reverse) {
|
|
269
|
+
result.unshift(data);
|
|
270
|
+
} else {
|
|
271
|
+
result.push(data);
|
|
272
|
+
}
|
|
273
|
+
previousAngle = angle;
|
|
274
|
+
previousLang = ischinese;
|
|
275
|
+
}
|
|
276
|
+
x0 = x3;
|
|
277
|
+
y0 = y3;
|
|
278
|
+
startM += charLength;
|
|
279
|
+
}
|
|
280
|
+
return result;
|
|
281
|
+
};
|
|
282
|
+
//以下两个方法解决在大数据量图斑时,内存疯长的问题。该改法引发新问题:无法点选要素
|
|
283
|
+
ol.layer.VectorTile.prototype.setFastRender = function(fastRender) {
|
|
284
|
+
return (this.fastRender = fastRender);
|
|
285
|
+
};
|
|
286
|
+
ol.renderer.canvas.VectorTileLayer.prototype.postCompose = function(context, frameState, layerState) {
|
|
287
|
+
var layer = this.getLayer();
|
|
288
|
+
var declutterReplays = layer.getDeclutter() ? {} : null;
|
|
289
|
+
var source = /** @type {ol.source.VectorTile} */ (layer.getSource());
|
|
290
|
+
var renderMode = layer.getRenderMode();
|
|
291
|
+
var replayTypes = ol.renderer.canvas.VectorTileLayer.VECTOR_REPLAYS[renderMode];
|
|
292
|
+
var pixelRatio = frameState.pixelRatio;
|
|
293
|
+
var rotation = frameState.viewState.rotation;
|
|
294
|
+
var size = frameState.size;
|
|
295
|
+
var offsetX, offsetY;
|
|
296
|
+
if (rotation) {
|
|
297
|
+
offsetX = Math.round((pixelRatio * size[0]) / 2);
|
|
298
|
+
offsetY = Math.round((pixelRatio * size[1]) / 2);
|
|
299
|
+
ol.render.canvas.rotateAtOffset(context, -rotation, offsetX, offsetY);
|
|
300
|
+
}
|
|
301
|
+
if (declutterReplays) {
|
|
302
|
+
this.declutterTree_.clear();
|
|
303
|
+
}
|
|
304
|
+
var tiles = this.renderedTiles;
|
|
305
|
+
var tileGrid = source.getTileGridForProjection(frameState.viewState.projection);
|
|
306
|
+
var clips = [];
|
|
307
|
+
var zs = [];
|
|
308
|
+
for (var i = tiles.length - 1; i >= 0; --i) {
|
|
309
|
+
var tile = /** @type {ol.VectorImageTile} */ (tiles[i]);
|
|
310
|
+
if (tile.getState() == ol.TileState.ABORT) {
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
var tileCoord = tile.tileCoord;
|
|
314
|
+
var worldOffset =
|
|
315
|
+
tileGrid.getTileCoordExtent(tileCoord)[0] - tileGrid.getTileCoordExtent(tile.wrappedTileCoord)[0];
|
|
316
|
+
var transform = undefined;
|
|
317
|
+
for (var t = 0, tt = tile.tileKeys.length; t < tt; ++t) {
|
|
318
|
+
var sourceTile = tile.getTile(tile.tileKeys[t]);
|
|
319
|
+
if (sourceTile.getState() == ol.TileState.ERROR) {
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
var replayGroup = sourceTile.getReplayGroup(layer, tileCoord.toString());
|
|
323
|
+
if (
|
|
324
|
+
renderMode != ol.layer.VectorTileRenderType.VECTOR &&
|
|
325
|
+
(!replayGroup || !replayGroup.hasReplays(replayTypes))
|
|
326
|
+
) {
|
|
327
|
+
if (layer.fastRender === true) {
|
|
328
|
+
sourceTile.replayGroups_ = {};
|
|
329
|
+
sourceTile.features_ = [];
|
|
330
|
+
}
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
if (!transform) {
|
|
334
|
+
transform = this.getTransform(frameState, worldOffset);
|
|
335
|
+
}
|
|
336
|
+
var currentZ = sourceTile.tileCoord[0];
|
|
337
|
+
var currentClip = replayGroup.getClipCoords(transform);
|
|
338
|
+
context.save();
|
|
339
|
+
context.globalAlpha = layerState.opacity;
|
|
340
|
+
// Create a clip mask for regions in this low resolution tile that are
|
|
341
|
+
// already filled by a higher resolution tile
|
|
342
|
+
for (var j = 0, jj = clips.length; j < jj; ++j) {
|
|
343
|
+
var clip = clips[j];
|
|
344
|
+
if (currentZ < zs[j]) {
|
|
345
|
+
context.beginPath();
|
|
346
|
+
// counter-clockwise (outer ring) for current tile
|
|
347
|
+
context.moveTo(currentClip[0], currentClip[1]);
|
|
348
|
+
context.lineTo(currentClip[2], currentClip[3]);
|
|
349
|
+
context.lineTo(currentClip[4], currentClip[5]);
|
|
350
|
+
context.lineTo(currentClip[6], currentClip[7]);
|
|
351
|
+
// clockwise (inner ring) for higher resolution tile
|
|
352
|
+
context.moveTo(clip[6], clip[7]);
|
|
353
|
+
context.lineTo(clip[4], clip[5]);
|
|
354
|
+
context.lineTo(clip[2], clip[3]);
|
|
355
|
+
context.lineTo(clip[0], clip[1]);
|
|
356
|
+
context.clip();
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
replayGroup.replay(context, transform, rotation, {}, replayTypes, declutterReplays);
|
|
360
|
+
context.restore();
|
|
361
|
+
clips.push(currentClip);
|
|
362
|
+
zs.push(currentZ);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
if (declutterReplays) {
|
|
366
|
+
ol.render.canvas.ReplayGroup.replayDeclutter(declutterReplays, context, rotation);
|
|
367
|
+
}
|
|
368
|
+
if (rotation) {
|
|
369
|
+
ol.render.canvas.rotateAtOffset(
|
|
370
|
+
context,
|
|
371
|
+
rotation,
|
|
372
|
+
/** @type {number} */
|
|
373
|
+
(offsetX),
|
|
374
|
+
/** @type {number} */ (offsetY)
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
ol.renderer.canvas.TileLayer.prototype.postCompose.apply(this, arguments);
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
window.olExtends = olExtends;
|
|
382
|
+
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@supermapgis/iclient-ol",
|
|
3
|
+
"description": "",
|
|
4
|
+
"version": "11.1.2",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"SuperMap",
|
|
7
|
+
"OpenLayers"
|
|
8
|
+
],
|
|
9
|
+
"main": "namespace.js",
|
|
10
|
+
"homepage": "https://iclient.supermap.io",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/SuperMap/iClient-JavaScript.git"
|
|
14
|
+
},
|
|
15
|
+
"author": "SuperMap",
|
|
16
|
+
"license": "Apache-2.0",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@turf/turf": "6.5.0",
|
|
19
|
+
"mapv": "2.0.62",
|
|
20
|
+
"ol": "6.14.1",
|
|
21
|
+
"@supermapgis/iclient-common": "11.1.2",
|
|
22
|
+
"proj4": "2.9.0",
|
|
23
|
+
"canvg": "3.0.10",
|
|
24
|
+
"lodash.remove": "^4.7.0",
|
|
25
|
+
"lodash.difference": "^4.5.0",
|
|
26
|
+
"flatgeobuf": "3.31.1",
|
|
27
|
+
"rbush": "^2.0.2"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* Copyright© 2000 - 2024 SuperMap Software Co.Ltd. All rights reserved.
|
|
2
|
+
* This program are made available under the terms of the Apache License, Version 2.0
|
|
3
|
+
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
|
|
4
|
+
import {ServiceBase} from './ServiceBase';
|
|
5
|
+
import { AddressMatchService as CommonAddressMatchService } from '@supermapgis/iclient-common/iServer/AddressMatchService';
|
|
6
|
+
import { Util as CommonUtil } from '@supermapgis/iclient-common/commontypes/Util';
|
|
7
|
+
/**
|
|
8
|
+
* @class AddressMatchService
|
|
9
|
+
* @category iServer AddressMatch
|
|
10
|
+
* @classdesc 地址匹配服务。
|
|
11
|
+
* @modulecategory Services
|
|
12
|
+
* @example
|
|
13
|
+
* new AddressMatchService(url,options)
|
|
14
|
+
* .code(function(result){
|
|
15
|
+
* //doSomething
|
|
16
|
+
* })
|
|
17
|
+
* @param {string} url - 服务地址。
|
|
18
|
+
* @param {Object} options - 参数。
|
|
19
|
+
* @param {string} [options.proxy] - 服务代理地址。
|
|
20
|
+
* @param {boolean} [options.withCredentials=false] - 请求是否携带 cookie。
|
|
21
|
+
* @param {boolean} [options.crossOrigin] - 是否允许跨域请求。
|
|
22
|
+
* @param {Object} [options.headers] - 请求头。
|
|
23
|
+
* @extends {ServiceBase}
|
|
24
|
+
* @usage
|
|
25
|
+
*/
|
|
26
|
+
export class AddressMatchService extends ServiceBase {
|
|
27
|
+
|
|
28
|
+
constructor(url, options) {
|
|
29
|
+
super(url, options);
|
|
30
|
+
this._addressMatchService = new CommonAddressMatchService(this.url, {
|
|
31
|
+
proxy: this.options.proxy,
|
|
32
|
+
withCredentials: this.options.withCredentials,
|
|
33
|
+
crossOrigin: this.options.crossOrigin,
|
|
34
|
+
headers: this.options.headers
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @function AddressMatchService.prototype.code
|
|
40
|
+
* @description 获取正向地址匹配结果。
|
|
41
|
+
* @param {GeoCodingParameter} params - 正向匹配参数。
|
|
42
|
+
* @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的promise 获取结果。
|
|
43
|
+
* @returns {Promise} Promise 对象。
|
|
44
|
+
*/
|
|
45
|
+
code(params, callback) {
|
|
46
|
+
return this._addressMatchService.code(CommonUtil.urlPathAppend(this.url, 'geocoding'), params, callback);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @function AddressMatchService.prototype.decode
|
|
51
|
+
* @description 获取反向地址匹配结果。
|
|
52
|
+
* @param {GeoDecodingParameter} params - 反向匹配参数。
|
|
53
|
+
* @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的promise 获取结果。
|
|
54
|
+
* @returns {Promise} Promise 对象。
|
|
55
|
+
*/
|
|
56
|
+
decode(params, callback) {
|
|
57
|
+
return this._addressMatchService.decode(CommonUtil.urlPathAppend(this.url, 'geodecoding'), params, callback);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/* Copyright© 2000 - 2024 SuperMap Software Co.Ltd. All rights reserved.
|
|
2
|
+
* This program are made available under the terms of the Apache License, Version 2.0
|
|
3
|
+
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
|
|
4
|
+
import {Util} from '../core/Util';
|
|
5
|
+
import { Bounds } from '@supermapgis/iclient-common/commontypes/Bounds';
|
|
6
|
+
import {ServiceBase} from './ServiceBase';
|
|
7
|
+
import { ChartService as CommonChartService } from '@supermapgis/iclient-common/iServer/ChartService';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @class ChartService
|
|
11
|
+
* @category iServer Map Chart
|
|
12
|
+
* @classdesc 海图服务。
|
|
13
|
+
* @modulecategory Services
|
|
14
|
+
* @extends {ServiceBase}
|
|
15
|
+
* @example
|
|
16
|
+
* new ChartService(url).queryChart(param,function(result){
|
|
17
|
+
* //doSomething
|
|
18
|
+
* })
|
|
19
|
+
* @param {string} url - 服务地址。
|
|
20
|
+
* @param {Object} options - 参数。
|
|
21
|
+
* @param {string} [options.proxy] - 服务代理地址。
|
|
22
|
+
* @param {boolean} [options.withCredentials=false] - 请求是否携带 cookie。
|
|
23
|
+
* @param {boolean} [options.crossOrigin] - 是否允许跨域请求。
|
|
24
|
+
* @param {Object} [options.headers] - 请求头。
|
|
25
|
+
* @usage
|
|
26
|
+
*/
|
|
27
|
+
export class ChartService extends ServiceBase {
|
|
28
|
+
|
|
29
|
+
constructor(url, options) {
|
|
30
|
+
super(url, options);
|
|
31
|
+
this._chartService = new CommonChartService(url, options);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @function ChartService.prototype.queryChart
|
|
36
|
+
* @description 查询海图服务。
|
|
37
|
+
* @param {ChartQueryParameters} params - 海图查询所需参数类。
|
|
38
|
+
* @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的promise 获取结果。
|
|
39
|
+
* @param {DataFormat} resultFormat - 返回结果类型。
|
|
40
|
+
* @returns {Promise} Promise 对象。
|
|
41
|
+
*/
|
|
42
|
+
queryChart(params, callback, resultFormat) {
|
|
43
|
+
params = this._processParams(params);
|
|
44
|
+
return this._chartService.queryChart(params, callback, resultFormat);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @function ChartService.prototype.getChartFeatureInfo
|
|
49
|
+
* @description 获取海图物标信息服务。
|
|
50
|
+
* @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的promise 获取结果。
|
|
51
|
+
* @returns {Promise} Promise 对象。
|
|
52
|
+
*/
|
|
53
|
+
getChartFeatureInfo(callback) {
|
|
54
|
+
return this._chartService.getChartFeatureInfo(callback);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
_processParams(params) {
|
|
58
|
+
if (!params) {
|
|
59
|
+
return {};
|
|
60
|
+
}
|
|
61
|
+
params.returnContent = (params.returnContent == null) ? true : params.returnContent;
|
|
62
|
+
if (params.filter) {
|
|
63
|
+
params.chartQueryFilterParameters = Util.isArray(params.filter) ? params.filter : [params.filter];
|
|
64
|
+
}
|
|
65
|
+
if (params.bounds) {
|
|
66
|
+
params.bounds = new Bounds(
|
|
67
|
+
params.bounds[0],
|
|
68
|
+
params.bounds[1],
|
|
69
|
+
params.bounds[2],
|
|
70
|
+
params.bounds[3]
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/* Copyright© 2000 - 2024 SuperMap Software Co.Ltd. All rights reserved.
|
|
2
|
+
* This program are made available under the terms of the Apache License, Version 2.0
|
|
3
|
+
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
|
|
4
|
+
import {ServiceBase} from './ServiceBase';
|
|
5
|
+
import { DataFlowService as DataFlow } from '@supermapgis/iclient-common/iServer/DataFlowService';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @class DataFlowService
|
|
9
|
+
* @category iServer DataFlow
|
|
10
|
+
* @classdesc 数据流服务。
|
|
11
|
+
* @modulecategory Services
|
|
12
|
+
* @extends {ServiceBase}
|
|
13
|
+
* @example
|
|
14
|
+
* new DataFlowService(url).queryChart(param,function(result){
|
|
15
|
+
* //doSomething
|
|
16
|
+
* })
|
|
17
|
+
* @param {string} url - 服务地址。
|
|
18
|
+
* @param {Object} options - 参数。
|
|
19
|
+
* @param {string} [options.proxy] - 服务代理地址。
|
|
20
|
+
* @param {boolean} [options.withCredentials=false] - 请求是否携带 cookie。
|
|
21
|
+
* @param {boolean} [options.crossOrigin] - 是否允许跨域请求。
|
|
22
|
+
* @param {Object} [options.headers] - 请求头。
|
|
23
|
+
* @param {GeoJSONObject} [options.geometry] - 指定几何范围,该范围内的要素才能被订阅。
|
|
24
|
+
* @param {Object} [options.excludeField] - 排除字段。
|
|
25
|
+
* @usage
|
|
26
|
+
*/
|
|
27
|
+
export class DataFlowService extends ServiceBase {
|
|
28
|
+
|
|
29
|
+
constructor(url, options) {
|
|
30
|
+
options = options || {};
|
|
31
|
+
if (options.projection) {
|
|
32
|
+
options.prjCoordSys = options.projection;
|
|
33
|
+
}
|
|
34
|
+
super(url, options);
|
|
35
|
+
this.dataFlow = new DataFlow(url, options);
|
|
36
|
+
this.dataFlow.events.on({
|
|
37
|
+
"broadcastSocketConnected": this._defaultEvent,
|
|
38
|
+
"broadcastSocketError": this._defaultEvent,
|
|
39
|
+
"broadcastFailed": this._defaultEvent,
|
|
40
|
+
"broadcastSucceeded": this._defaultEvent,
|
|
41
|
+
"subscribeSocketConnected": this._defaultEvent,
|
|
42
|
+
"subscribeSocketError": this._defaultEvent,
|
|
43
|
+
"messageSucceeded": this._defaultEvent,
|
|
44
|
+
"setFilterParamSucceeded": this._defaultEvent,
|
|
45
|
+
scope: this
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @function DataFlowService.prototype.initBroadcast
|
|
51
|
+
* @description 初始化广播。
|
|
52
|
+
* @returns {DataFlowService}
|
|
53
|
+
*/
|
|
54
|
+
initBroadcast() {
|
|
55
|
+
this.dataFlow.initBroadcast();
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @function DataFlowService.prototype.broadcast
|
|
61
|
+
* @description 加载广播数据。
|
|
62
|
+
* @param {JSONObject} obj - JSON 格式的要素数据。
|
|
63
|
+
*/
|
|
64
|
+
broadcast(obj) {
|
|
65
|
+
this.dataFlow.broadcast(obj);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @function DataFlowService.prototype.initSubscribe
|
|
70
|
+
* @description 初始化订阅数据。
|
|
71
|
+
*/
|
|
72
|
+
initSubscribe() {
|
|
73
|
+
this.dataFlow.initSubscribe();
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @function DataFlowService.prototype.setExcludeField
|
|
79
|
+
* @description 设置排除字段。
|
|
80
|
+
* @param {Object} excludeField - 排除字段。
|
|
81
|
+
*/
|
|
82
|
+
setExcludeField(excludeField) {
|
|
83
|
+
this.dataFlow.setExcludeField(excludeField);
|
|
84
|
+
this.options.excludeField = excludeField;
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @function DataFlowService.prototype.setGeometry
|
|
90
|
+
* @description 设置添加的几何要素数据。
|
|
91
|
+
* @param {GeoJSONObject} geometry - 指定几何范围,该范围内的要素才能被订阅。
|
|
92
|
+
*/
|
|
93
|
+
setGeometry(geometry) {
|
|
94
|
+
this.dataFlow.setGeometry(geometry);
|
|
95
|
+
this.options.geometry = geometry;
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @function DataFlowService.prototype.unSubscribe
|
|
101
|
+
* @description 结束订阅数据。
|
|
102
|
+
*/
|
|
103
|
+
unSubscribe() {
|
|
104
|
+
this.dataFlow.unSubscribe();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @function DataFlowService.prototype.unBroadcast
|
|
109
|
+
* @description 结束加载广播。
|
|
110
|
+
*/
|
|
111
|
+
unBroadcast() {
|
|
112
|
+
this.dataFlow.unBroadcast();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
_defaultEvent(e) {
|
|
116
|
+
this.dispatchEvent({type: e.eventType || e.type, value: e});
|
|
117
|
+
}
|
|
118
|
+
}
|