Skip to content

Commit 6a847b0

Browse files
committed
优化测试写法 修改出图url被多次编码
1 parent e5e0296 commit 6a847b0

File tree

5 files changed

+80
-80
lines changed

5 files changed

+80
-80
lines changed

dist/iclient9-openlayers.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57086,7 +57086,7 @@ var ImageSuperMapRest = exports.ImageSuperMapRest = function (_ol$source$Image)
5708657086
//为url添加请求参数
5708757087
url = _openlayers2.default.uri.appendParams(url, params);
5708857088
//为url添加请求图片大小以及显示范围参数
57089-
return encodeURI(url + "&width=" + size[0] + "&height=" + size[1] + "&viewBounds=" + "{\"leftBottom\" : {\"x\":" + extent[0] + ",\"y\":" + extent[1] + "},\"rightTop\" : {\"x\":" + extent[2] + ",\"y\":" + extent[3] + "}}");
57089+
return url + encodeURI("&width=" + size[0] + "&height=" + size[1] + "&viewBounds=" + "{\"leftBottom\" : {\"x\":" + extent[0] + ",\"y\":" + extent[1] + "},\"rightTop\" : {\"x\":" + extent[2] + ",\"y\":" + extent[3] + "}}");
5709057090
}
5709157091

5709257092
/**
@@ -57443,7 +57443,7 @@ var TileSuperMapRest = exports.TileSuperMapRest = function (_ol$source$TileImage
5744357443
var scale = _Util.Util.resolutionToScale(resolution, dpi, unit);
5744457444
var tileSize = _openlayers2.default.size.toSize(me.tileGrid.getTileSize(z, me.tmpSize));
5744557445
var layerUrl = getFullRequestUrl.call(me);
57446-
return encodeURI(layerUrl + "&x=" + x + "&y=" + y + "&width=" + tileSize[0] + "&height=" + tileSize[1] + "&scale=" + scale);
57446+
return layerUrl + encodeURI("&x=" + x + "&y=" + y + "&width=" + tileSize[0] + "&height=" + tileSize[1] + "&scale=" + scale);
5744757447
}
5744857448

5744957449
return _this;
@@ -65199,7 +65199,7 @@ var DataFlowService = exports.DataFlowService = function (_CommonServiceBase) {
6519965199
}, {
6520065200
key: 'broadcast',
6520165201
value: function broadcast(geoJSONFeature) {
65202-
if (!this.broadcastWebSocket.isOpen) {
65202+
if (!this.broadcastWebSocket || !this.broadcastWebSocket.isOpen) {
6520365203
this.events.triggerEvent('broadcastFailed');
6520465204
return;
6520565205
}

dist/iclient9-openlayers.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/openlayers/mapping/TileSuperMapRest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ export class TileSuperMapRest extends ol.source.TileImage {
213213
var scale = Util.resolutionToScale(resolution, dpi, unit);
214214
var tileSize = ol.size.toSize(me.tileGrid.getTileSize(z, me.tmpSize));
215215
var layerUrl = getFullRequestUrl.call(me);
216-
return encodeURI(layerUrl + "&x=" + x + "&y=" + y + "&width=" + tileSize[0] + "&height=" + tileSize[1] + "&scale=" + scale);
216+
return layerUrl +encodeURI( "&x=" + x + "&y=" + y + "&width=" + tileSize[0] + "&height=" + tileSize[1] + "&scale=" + scale);
217217
}
218218

219219
}

test/openlayers/overlay/GraphSpec.js

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -140,53 +140,53 @@ describe('openlayers_Graph', function () {
140140
});
141141

142142
it('addFeatures, redraw, getFeatures, removeFeatures', function (done) {
143+
var graphThemeSource = new ol.source.Graph("BarThemeLayer", "Bar", {
144+
map: map
145+
});
146+
graphThemeSource.themeFields = ["CON2009", "CON2010", "CON2011", "CON2012", "CON2013"];
147+
graphThemeSource.chartsSetting = {
148+
width: 240,
149+
height: 100,
150+
codomain: [0, 40000],
151+
barStyle: {fillOpacity: 0.7},
152+
barHoverStyle: {fillOpacity: 1},
153+
xShapeBlank: [10, 10, 10],
154+
axisYTick: 4,
155+
axisYLabels: ["4万", "3万", "2万", "1万", "0"],
156+
axisXLabels: ["09年", "10年", "11年", "12年", "13年"],
157+
backgroundStyle: {fillColor: "#CCE8CF"},
158+
backgroundRadius: [5, 5, 5, 5],
159+
showShadow: true,
160+
barShadowStyle: {
161+
shadowBlur: 8,
162+
shadowOffsetX: 2,
163+
shadowOffsetY: 2,
164+
shadowColor: "rgba(100,100,100,0.8)"
165+
},
166+
barLinearGradient: [["#00FF00", "#00CD00"], ["#00CCFF", "#5E87A2"], ["#00FF66", "#669985"], ["#CCFF00", "#94A25E"], ["#FF9900", "#A2945E"]]
167+
};
168+
var layer = new ol.layer.Image({
169+
source: graphThemeSource
170+
});
171+
map.addLayer(layer);
172+
expect(graphThemeSource.features.length).toEqual(0);
173+
var features = [];
174+
for (var i = 0, len = chinaConsumptionLevel.length; i < len; i++) {
175+
var provinceInfo = chinaConsumptionLevel[i];
176+
var geometry = new ol.geom.Point([provinceInfo[1], provinceInfo[2]]);
177+
var atrributes = {};
178+
atrributes.NAME = provinceInfo[0];
179+
atrributes.CON2009 = provinceInfo[3];
180+
atrributes.CON2010 = provinceInfo[4];
181+
atrributes.CON2011 = provinceInfo[5];
182+
atrributes.CON2012 = provinceInfo[6];
183+
atrributes.CON2013 = provinceInfo[7];
184+
var fea = new ol.supermap.ThemeFeature(geometry, atrributes);
185+
features.push(fea);
186+
}
187+
//addFeatures
188+
graphThemeSource.addFeatures(features);
143189
setTimeout(function () {
144-
var graphThemeSource = new ol.source.Graph("BarThemeLayer", "Bar", {
145-
map: map
146-
});
147-
graphThemeSource.themeFields = ["CON2009", "CON2010", "CON2011", "CON2012", "CON2013"];
148-
graphThemeSource.chartsSetting = {
149-
width: 240,
150-
height: 100,
151-
codomain: [0, 40000],
152-
barStyle: {fillOpacity: 0.7},
153-
barHoverStyle: {fillOpacity: 1},
154-
xShapeBlank: [10, 10, 10],
155-
axisYTick: 4,
156-
axisYLabels: ["4万", "3万", "2万", "1万", "0"],
157-
axisXLabels: ["09年", "10年", "11年", "12年", "13年"],
158-
backgroundStyle: {fillColor: "#CCE8CF"},
159-
backgroundRadius: [5, 5, 5, 5],
160-
showShadow: true,
161-
barShadowStyle: {
162-
shadowBlur: 8,
163-
shadowOffsetX: 2,
164-
shadowOffsetY: 2,
165-
shadowColor: "rgba(100,100,100,0.8)"
166-
},
167-
barLinearGradient: [["#00FF00", "#00CD00"], ["#00CCFF", "#5E87A2"], ["#00FF66", "#669985"], ["#CCFF00", "#94A25E"], ["#FF9900", "#A2945E"]]
168-
};
169-
var layer = new ol.layer.Image({
170-
source: graphThemeSource
171-
});
172-
map.addLayer(layer);
173-
expect(graphThemeSource.features.length).toEqual(0);
174-
var features = [];
175-
for (var i = 0, len = chinaConsumptionLevel.length; i < len; i++) {
176-
var provinceInfo = chinaConsumptionLevel[i];
177-
var geometry = new ol.geom.Point([provinceInfo[1], provinceInfo[2]]);
178-
var atrributes = {};
179-
atrributes.NAME = provinceInfo[0];
180-
atrributes.CON2009 = provinceInfo[3];
181-
atrributes.CON2010 = provinceInfo[4];
182-
atrributes.CON2011 = provinceInfo[5];
183-
atrributes.CON2012 = provinceInfo[6];
184-
atrributes.CON2013 = provinceInfo[7];
185-
var fea = new ol.supermap.ThemeFeature(geometry, atrributes);
186-
features.push(fea);
187-
}
188-
//addFeatures
189-
graphThemeSource.addFeatures(features);
190190
var LayerFeatures = graphThemeSource.features;
191191
expect(LayerFeatures.length).toBeGreaterThan(0);
192192
for (var j = 0; j < LayerFeatures.length; j++) {

test/openlayers/overlay/LabelSpec.js

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ describe('openlayers_Label', function () {
142142

143143
//创建专题要素
144144
it('createThematicFeature', function (done) {
145+
addFeatures();
145146
setTimeout(function () {
146-
addFeatures();
147147
var feature = themeSource.labelFeatures[0];
148148
var thematicFeature = themeSource.createThematicFeature(feature);
149149
expect(themeSource.features.length).toBeGreaterThan(0);
@@ -158,8 +158,8 @@ describe('openlayers_Label', function () {
158158

159159
//重绘所有专题要素
160160
it('redrawThematicFeatures', function (done) {
161+
addFeatures();
161162
setTimeout(function () {
162-
addFeatures();
163163
var bounds = [-180, -90, 90, 180];
164164
themeSource.redrawThematicFeatures(bounds);
165165
expect(themeSource).not.toBeNull();
@@ -174,31 +174,31 @@ describe('openlayers_Label', function () {
174174

175175
//获取经(压盖)处理后将要绘制在图层上的标签要素
176176
it('getDrawnLabels', function (done) {
177+
addFeatures();
177178
setTimeout(function () {
178-
addFeatures();
179-
var labelFeatures = themeSource.labelFeatures;
180-
labelFeatures[0].style.minZoomLevel = 4;
181-
var feas = themeSource.getDrawnLabels(labelFeatures);
182-
expect(feas).not.toBeNull();
183-
expect(feas.length).toBeGreaterThan(0);
184-
for (var i = 0; i < feas.length; i++) {
185-
expect(feas[i].CLASS_NAME).toEqual("SuperMap.Feature.Vector");
186-
expect(feas[i].attributes).not.toBeNull();
187-
expect(feas[i].geometry).not.toBeNull();
188-
expect(feas[i].geometry.CLASS_NAME).toEqual("SuperMap.Geometry.GeoText");
189-
expect(feas[i].geometry.bounds).not.toBeNull();
190-
expect(feas[i].geometry.id).not.toBeNull();
191-
expect(feas[i].style).not.toBeNull();
192-
expect(feas[i].id).toContain("SuperMap.Feature_");
193-
done();
194-
}
195-
}, 1500)
179+
var labelFeatures = themeSource.labelFeatures;
180+
labelFeatures[0].style.minZoomLevel = 4;
181+
var feas = themeSource.getDrawnLabels(labelFeatures);
182+
expect(feas).not.toBeNull();
183+
expect(feas.length).toBeGreaterThan(0);
184+
for (var i = 0; i < feas.length; i++) {
185+
expect(feas[i].CLASS_NAME).toEqual("SuperMap.Feature.Vector");
186+
expect(feas[i].attributes).not.toBeNull();
187+
expect(feas[i].geometry).not.toBeNull();
188+
expect(feas[i].geometry.CLASS_NAME).toEqual("SuperMap.Geometry.GeoText");
189+
expect(feas[i].geometry.bounds).not.toBeNull();
190+
expect(feas[i].geometry.id).not.toBeNull();
191+
expect(feas[i].style).not.toBeNull();
192+
expect(feas[i].id).toContain("SuperMap.Feature_");
193+
done();
194+
}
195+
}, 2000)
196196
});
197197

198198
//根据用户数据(feature)设置专题要素的 Style
199199
it('getStyleByData', function (done) {
200+
addFeatures();
200201
setTimeout(function () {
201-
addFeatures();
202202
var feat = themeSource.labelFeatures[0];
203203
var featStyle = themeSource.getStyleByData(feat);
204204
expect(featStyle).not.toBeNull();
@@ -212,8 +212,8 @@ describe('openlayers_Label', function () {
212212

213213
//设置标签要素的Style
214214
it('setLabelsStyle', function (done) {
215+
addFeatures();
215216
setTimeout(function () {
216-
addFeatures();
217217
var labelFeatures = themeSource.labelFeatures;
218218
var labelFeas = themeSource.setLabelsStyle(labelFeatures);
219219
expect(labelFeas).not.toBeNull();
@@ -233,8 +233,8 @@ describe('openlayers_Label', function () {
233233

234234
//设置标签要素的Style
235235
it('setStyle', function (done) {
236+
addFeatures();
236237
setTimeout(function () {
237-
addFeatures();
238238
var feat = themeSource.labelFeatures[0];
239239
var feature = themeSource.setStyle(feat);
240240
expect(feature).not.toBeNull();
@@ -251,8 +251,8 @@ describe('openlayers_Label', function () {
251251

252252
//获取标签要素的像素坐标
253253
it('getLabelPxLocation', function (done) {
254+
addFeatures();
254255
setTimeout(function () {
255-
addFeatures();
256256
var feature = themeSource.labelFeatures[0];
257257
feature.style.labelXOffset = 1;
258258
feature.style.labelYOffset = 1;
@@ -266,8 +266,8 @@ describe('openlayers_Label', function () {
266266

267267
//获得标签要素的最终范围 默认getPxBoundsMode = 0
268268
it('calculateLabelBounds_getPxBoundsMode = 0', function (done) {
269+
addFeatures();
269270
setTimeout(function () {
270-
addFeatures();
271271
var feature = themeSource.labelFeatures[0];
272272
var location = themeSource.getLabelPxLocation(feature);
273273
var boundsQuad = themeSource.calculateLabelBounds(feature, location);
@@ -284,8 +284,8 @@ describe('openlayers_Label', function () {
284284

285285
//获得标签要素的最终范围 getPxBoundsMode = 1
286286
it('calculateLabelBounds_getPxBoundsMode = 1', function (done) {
287+
addFeatures();
287288
setTimeout(function () {
288-
addFeatures();
289289
themeSource.getPxBoundsMode = 1;
290290
var feature = themeSource.labelFeatures[0];
291291
feature.style.labelXOffset = 1;
@@ -304,8 +304,8 @@ describe('openlayers_Label', function () {
304304

305305
//获得标签要素的最终范围的另一种算法
306306
it('calculateLabelBounds2', function (done) {
307+
addFeatures();
307308
setTimeout(function () {
308-
addFeatures();
309309
var feature = themeSource.labelFeatures[0];
310310
var location = themeSource.getLabelPxLocation(feature);
311311
feature.style.fontStyle = "italic";
@@ -379,8 +379,8 @@ describe('openlayers_Label', function () {
379379

380380
//根据当前位置获取绘制后的标签信息,包括标签的宽,高和行数等
381381
it('getLabelInfo', function (done) {
382+
addFeatures();
382383
setTimeout(function () {
383-
addFeatures();
384384
var feature = themeSource.labelFeatures[0];
385385
var location = feature.geometry.getCentroid();
386386
var style = feature.style;
@@ -396,8 +396,8 @@ describe('openlayers_Label', function () {
396396

397397
//旋转bounds
398398
it('rotationBounds', function (done) {
399+
addFeatures();
399400
setTimeout(function () {
400-
addFeatures();
401401
var feature = themeSource.labelFeatures[0];
402402
var bounds = new SuperMap.Bounds(50, 30, 30, 50);
403403
var rotationCenterPoi = themeSource.getLabelPxLocation(feature);

0 commit comments

Comments
 (0)