Skip to content

Commit 8971b81

Browse files
修复测试
1 parent 7f6c11e commit 8971b81

File tree

2 files changed

+65
-61
lines changed

2 files changed

+65
-61
lines changed

test/openlayers/core/StyleUtilsSpec.js

Lines changed: 3 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ describe('openlayers_StyleUtils', () => {
122122
var request = requestFeature(tileFeatureUrl);
123123
request.then((features) => {
124124
try {
125-
var layerName = "District_pt@POI_Other#2";
125+
var layerName = "District_pt@China#6";
126126
var layerInfo = getLayerInfo(layerName);
127127
var feature = getFeature(layerName, features);
128128
var style = StyleUtils.getValidStyleFromLayerInfo(layerInfo, feature, mapUrl);
@@ -145,34 +145,6 @@ describe('openlayers_StyleUtils', () => {
145145
});
146146
});
147147

148-
//测试从图层信息中获取style
149-
it('getValidStyleFromLayerInfo_text2', (done) => {
150-
var tileFeatureUrl = mapUrl + "/tileFeature.json?returnAttributes=true&x=28&y=13&width=256&height=256&scale=5.408523429128511e-8";
151-
var request = requestFeature(tileFeatureUrl);
152-
request.then((features) => {
153-
try {
154-
var layerName = "World_Ocean_txt@China";
155-
var layerInfo = getLayerInfo(layerName);
156-
var feature = getFeature(layerName, features);
157-
var style = StyleUtils.getValidStyleFromLayerInfo(layerInfo, feature, mapUrl);
158-
expect(style).not.toBeNull();
159-
var textStyle = style.getText();
160-
expect(textStyle).not.toBeNull();
161-
expect(textStyle.getText()).toBe("太平洋");
162-
expect(textStyle.getStroke()).not.toBeNull();
163-
expect(textStyle.getStroke().getColor()).toBe("rgba(236,233,216,1)");
164-
expect(textStyle.getFill()).not.toBeNull();
165-
expect(textStyle.getFill().getColor()).toBe("rgba(95,155,211,1)");
166-
expect(textStyle.getTextAlign()).toBe("center");
167-
expect(textStyle.getTextBaseline()).toBe("alphabetic");
168-
done();
169-
} catch (exception) {
170-
console.error("openlayers_StyleUtils': getValidStyleFromLayerInfo_text2'案例失败:" + exception.name + ":" + exception.message);
171-
expect(false).toBeTruthy();
172-
done();
173-
}
174-
});
175-
});
176148

177149
//测试从CartoCSS中获取style
178150
it('getStyleFromCarto_point1', (done) => {
@@ -201,35 +173,6 @@ describe('openlayers_StyleUtils', () => {
201173
}
202174
});
203175
});
204-
205-
//测试从CartoCSS中获取style
206-
it('getStyleFromCarto_point2', (done) => {
207-
var tileFeatureUrl = mapUrl + "/tileFeature.json?returnAttributes=true&x=1687&y=774&width=256&height=256&scale=0.00000346145499464224";
208-
var request = requestFeature(tileFeatureUrl);
209-
request.then((features) => {
210-
try {
211-
var layerName = "Airport_pt@POI_Other";
212-
var feature = getFeature(layerName, features);
213-
var shader = getShader(layerName);
214-
var style = StyleUtils.getStyleFromCarto(10, 0.00000346145499464224, shader, feature, true, mapUrl);
215-
expect(style).not.toBeNull();
216-
expect(style.getStroke()).toBeNull();
217-
expect(style.getText()).toBeNull();
218-
expect(style.getFill()).toBeNull();
219-
var imageStyle = style.getImage();
220-
expect(imageStyle).not.toBeNull();
221-
expect(imageStyle.getOpacity()).toBe(1);
222-
expect(imageStyle.getSrc()).not.toBeNull();
223-
expect(imageStyle.getImage(imageStyle.getSrc())).not.toBeNull();
224-
done();
225-
} catch (exception) {
226-
console.error("openlayers_StyleUtils': getStyleFromCarto_point2'案例失败:" + exception.name + ":" + exception.message);
227-
expect(false).toBeTruthy();
228-
done();
229-
}
230-
});
231-
});
232-
233176
//测试从CartoCSS中获取style
234177
it('getStyleFromCarto_polyLine', (done) => {
235178
var tileFeatureUrl = mapUrl + "/tileFeature.json?returnAttributes=true&x=420&y=193&width=256&height=256&scale=8.653637486605572e-7";
@@ -295,9 +238,9 @@ describe('openlayers_StyleUtils', () => {
295238
var request = requestFeature(tileFeatureUrl);
296239
request.then((features) => {
297240
try {
298-
var layerName = "District_pt@POI_Other#2";
241+
var layerName = "District_pt@China#6";
299242
var feature = getFeature(layerName, features);
300-
var shader = getShader(layerName);
243+
var shader = getShader("District_pt@China");
301244
var style = StyleUtils.getStyleFromCarto(10, 0.00000346145499464224, shader, feature, true, mapUrl);
302245
expect(style).not.toBeNull();
303246
expect(style.getStroke()).toBeNull();

test/resources/china_layers.js

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2252,7 +2252,68 @@ var ChinaLayersInfo = {
22522252
"symbolScale": 0,
22532253
"minScale": 0,
22542254
"representationField": ""
2255-
}, {
2255+
},
2256+
{
2257+
"joinItems": null,
2258+
"completeLineSymbolDisplayed": false,
2259+
"themeElementPosition": null,
2260+
"ugcLayerType": "THEME",
2261+
"displayFilter": "Length(District_pt.NAME)>7",
2262+
"visible": true,
2263+
"maxScale": 1.3845819978568952E-5,
2264+
"fieldValuesDisplayFilter": {"fieldName": "", "values": [], "fieldValuesDisplayMode": "DISABLE"},
2265+
"caption": "District_pt@China#6",
2266+
"description": "",
2267+
"symbolScalable": false,
2268+
"subLayers": {},
2269+
"type": "UGC",
2270+
"datasetInfo": {"charset": null, "isReadOnly": false, "encodeType": null, "recordCount": 0, "name": "District_pt", "bounds": {"top": 6977562.192132358, "left": 8374114.080529345, "bottom": 2097120.9982587001, "leftBottom": {"x": 8374114.080529345, "y": 2097120.9982587001}, "right": 1.4948875797724146E7, "rightTop": {"x": 1.4948875797724146E7, "y": 6977562.192132358}}, "isFileCache": false, "description": null, "prjCoordSys": null, "type": "POINT", "dataSourceName": "China", "tableName": null},
2271+
"queryable": false,
2272+
"opaqueRate": 100,
2273+
"minVisibleGeometrySize": 0.4,
2274+
"name": "District_pt@China#6",
2275+
"bounds": {"top": 6977562.192132358, "left": 8374114.080529345, "bottom": 2097120.9982587001, "leftBottom": {"x": 8374114.080529345, "y": 2097120.9982587001}, "right": 1.4948875797724146E7, "rightTop": {"x": 1.4948875797724146E7, "y": 6977562.192132358}},
2276+
"theme": {
2277+
"memoryData": null,
2278+
"overlapAvoided": true,
2279+
"minTextWidth": 0,
2280+
"maxLabelLength": -1,
2281+
"repeatIntervalFixed": false,
2282+
"flowEnabled": false,
2283+
"alongLineDirection": "LEFT_TOP_TO_RIGHT_BOTTOM",
2284+
"maxTextWidth": 0,
2285+
"offsetFixed": true,
2286+
"type": "LABEL",
2287+
"labelExpression": "NAME",
2288+
"offsetX": "0",
2289+
"leaderLineStyle": {"fillGradientOffsetRatioX": 0, "markerSize": 2.4, "fillForeColor": {"red": 189, "green": 235, "blue": 255, "alpha": 255}, "fillGradientOffsetRatioY": 0, "markerWidth": 0, "markerAngle": 0, "fillSymbolID": 0, "lineColor": {"red": 0, "green": 0, "blue": 0, "alpha": 255}, "markerSymbolID": 0, "lineWidth": 0.1, "markerHeight": 0, "fillOpaqueRate": 100, "fillBackOpaque": true, "fillBackColor": {"red": 255, "green": 255, "blue": 255, "alpha": 255}, "fillGradientMode": "NONE", "lineSymbolID": 39, "fillGradientAngle": 0},
2290+
"offsetY": "0",
2291+
"leaderLineDisplayed": false,
2292+
"uniformStyle": {"italicAngle": 0, "shadow": false, "sizeFixed": true, "underline": false, "rotation": 0, "backOpaque": false, "bold": false, "align": "MIDDLECENTER", "foreColor": {"red": 255, "green": 255, "blue": 255, "alpha": 255}, "italic": false, "strikeout": false, "fontName": "微软雅黑", "outline": false, "borderSpacingWidth": 3, "backColor": {"red": 255, "green": 255, "blue": 255, "alpha": 255}, "outlineWidth": 1, "fontHeight": 3.8800705467372136, "fontWidth": 0, "opaqueRate": 0, "stringAlignment": "LEFT", "fontScale": 1, "fontWeight": 400},
2293+
"maxTextHeight": 0,
2294+
"smallGeometryLabeled": true,
2295+
"matrixCells": null,
2296+
"labelBackShape": "ROUNDRECT",
2297+
"labelOverLengthMode": "NONE",
2298+
"numericPrecision": 1,
2299+
"backStyle": {"fillGradientOffsetRatioX": 0, "markerSize": 2.4, "fillForeColor": {"red": 78, "green": 153, "blue": 221, "alpha": 255}, "fillGradientOffsetRatioY": 0, "markerWidth": 0, "markerAngle": 0, "fillSymbolID": 0, "lineColor": {"red": 0, "green": 0, "blue": 0, "alpha": 255}, "markerSymbolID": 0, "lineWidth": 0.1, "markerHeight": 0, "fillOpaqueRate": 90, "fillBackOpaque": false, "fillBackColor": {"red": 255, "green": 255, "blue": 255, "alpha": 255}, "fillGradientMode": "NONE", "lineSymbolID": 5, "fillGradientAngle": 0},
2300+
"minTextHeight": 0,
2301+
"uniqueExpression": "",
2302+
"alongLine": false,
2303+
"uniqueItems": null,
2304+
"rangeExpression": "",
2305+
"angleFixed": false,
2306+
"uniformMixedStyle": null,
2307+
"repeatedLabelAvoided": false,
2308+
"items": null,
2309+
"labelRepeatInterval": 0
2310+
},
2311+
"displayOrderBy": null,
2312+
"symbolScale": 0,
2313+
"minScale": 1.7307274973211203E-6,
2314+
"representationField": ""
2315+
},
2316+
{
22562317
"joinItems": null,
22572318
"completeLineSymbolDisplayed": false,
22582319
"ugcLayerType": "VECTOR",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy