Skip to content

Commit e81d45d

Browse files
committed
补充leaflet下的UT。review by chenmy
1 parent e00d0af commit e81d45d

12 files changed

Lines changed: 732 additions & 0 deletions
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
require('../../../src/leaflet/services/spatialAnalystService');
2+
3+
var spatialAnalystURL = GlobeParameter.spatialAnalystURL_Changchun;
4+
var options = {
5+
serverType: 'iServer'
6+
};
7+
describe('leaflet_SpatialAnalystService_bufferAnalysis', function () {
8+
var serviceResult;
9+
var originalTimeout;
10+
beforeEach(function () {
11+
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
12+
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000;
13+
serviceResult = null;
14+
});
15+
afterEach(function () {
16+
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
17+
});
18+
it('bufferAnalysis_test', function (done) {
19+
var pointsList = [
20+
[-4690.000, 2823.940],
21+
[-4690.301, 3448.940],
22+
[-3810.125, 3816.561],
23+
[-3609.158, 3917.383],
24+
[-3490.291, 3976.983],
25+
[-4377.027, 4020.004],
26+
[-4382.939, 4076.265],
27+
[-4382.333, 4215.049],
28+
[-4382.285, 4428.156],
29+
[-4383.017, 4647.579],
30+
[-4382.898, 4679.707],
31+
[-4382.635, 4917.462],
32+
[-4381.833, 5074.019],
33+
[-4381.031, 5257.042],
34+
[-4380.717, 5363.785],
35+
[-4378.794, 5671.717],
36+
[-4377.970, 5847.521],
37+
[-4303.528, 5990.637],
38+
[-4270.072, 6055.343],
39+
[-4382.389, 6168.913],
40+
[-4209.927, 6214.183],
41+
[-4209.142, 6377.789],
42+
[-4210.142, 6393.692],
43+
[-4207.450, 6693.989],
44+
[-4208.450, 6788.392],
45+
[-4207.210, 6984.304],
46+
[-4208.296, 7189.183],
47+
[-4208.296, 7300.505],
48+
[-4208.803, 7573.056],
49+
[-4208.804, 7680.977],
50+
[-4208.393, 7850.593],
51+
[-4210.533, 8182.656],
52+
[-4261.485, 8554.893]
53+
];
54+
var roadLine = L.polyline(pointsList, {color: 'red'});
55+
var geoBufferAnalystParams = new SuperMap.GeometryBufferAnalystParameters({
56+
sourceGeometry: roadLine,
57+
bufferSetting: new SuperMap.BufferSetting({
58+
endType: SuperMap.BufferEndType.ROUND,
59+
leftDistance: new SuperMap.BufferDistance({value: 250}),
60+
rightDistance: new SuperMap.BufferDistance({value: 250}),
61+
semicircleLineSegment: 10
62+
})
63+
});
64+
var bufferAnalystService = L.supermap.spatialAnalystService(spatialAnalystURL, options);
65+
bufferAnalystService.bufferAnalysis(geoBufferAnalystParams, function (result) {
66+
serviceResult = result;
67+
});
68+
setTimeout(function () {
69+
try {
70+
expect(bufferAnalystService).not.toBeNull();
71+
expect(serviceResult).not.toBeNull();
72+
expect(serviceResult.type).toBe("processCompleted");
73+
expect(serviceResult.result).not.toBeNull();
74+
expect(serviceResult.result.succeed).toBe(true);
75+
var resultGeometry = serviceResult.result.resultGeometry;
76+
expect(resultGeometry.type).toBe("Feature");
77+
expect(resultGeometry.geometry).not.toBeNull();
78+
expect(resultGeometry.geometry.type).toEqual("MultiPolygon");
79+
var coordinates = resultGeometry.geometry.coordinates;
80+
expect(coordinates).not.toBeNull();
81+
expect(coordinates.length).toBeGreaterThan(0);
82+
for (var i = 0; i < coordinates[0][0].length; i++) {
83+
expect(coordinates[0][0][i].length).toEqual(2);
84+
}
85+
bufferAnalystService.destroy();
86+
done();
87+
} catch (exception) {
88+
console.log("'bufferAnalysis_test'案例失败" + exception.name + ":" + exception.message);
89+
bufferAnalystService.destroy();
90+
expect(false).toBeTruthy();
91+
done();
92+
}
93+
}, 5000);
94+
});
95+
});
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
require('../../../src/leaflet/services/spatialAnalystService');
2+
3+
var spatialAnalystURL = GlobeParameter.spatialAnalystURL_Changchun;
4+
var options = {
5+
serverType: 'iServer'
6+
};
7+
8+
describe('leaflet_SpatialAnalystService_densityAnalysis', function () {
9+
var serviceResult;
10+
var originalTimeout;
11+
beforeEach(function () {
12+
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
13+
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000;
14+
serviceResult = null;
15+
});
16+
afterEach(function () {
17+
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
18+
});
19+
//点密度分析
20+
it('densityAnalysis_test', function (done) {
21+
22+
var densityAnalystParameters = new SuperMap.DensityKernelAnalystParameters({
23+
//指定数据集
24+
dataset: "Railway@Changchun",
25+
//指定范围
26+
bounds: L.bounds([3800, -3800], [8200, -2200]),
27+
//指定数据集中用于核密度分析的字段
28+
fieldName: "SmLength",
29+
searchRadius: 50, //Railway@Changchun的单位是米
30+
// 结果数据集名称
31+
resultGridName: "KernelDensity_Result",
32+
deleteExistResultDataset: true
33+
});
34+
var densityAnalystService = L.supermap.spatialAnalystService(spatialAnalystURL, options);
35+
densityAnalystService.densityAnalysis(densityAnalystParameters, function (densityServiceResult) {
36+
serviceResult = densityServiceResult;
37+
});
38+
setTimeout(function () {
39+
try {
40+
expect(densityAnalystService).not.toBeNull();
41+
expect(serviceResult).not.toBeNull();
42+
expect(serviceResult.type).toBe("processCompleted");
43+
var result = serviceResult.result;
44+
expect(result).not.toBeNull();
45+
expect(result.dataset).toEqual("KernelDensity_Result@Changchun");
46+
expect(result.succeed).toBe(true);
47+
densityAnalystService.destroy();
48+
done();
49+
50+
} catch (exception) {
51+
console.log("'densityAnalysis_test'案例失败" + exception.name + ":" + exception.message);
52+
densityAnalystService.destroy();
53+
expect(false).toBeTruthy();
54+
done();
55+
}
56+
}, 5000);
57+
});
58+
});
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
require('../../../src/leaflet/services/spatialAnalystService');
2+
3+
var spatialAnalystURL = GlobeParameter.spatialAnalystURL_Changchun;
4+
var options = {
5+
serverType: 'iServer'
6+
};
7+
describe('leaflet_SpatialAnalystService_generateSpatialData', function () {
8+
var serviceResult;
9+
var originalTimeout;
10+
beforeEach(function () {
11+
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
12+
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000;
13+
serviceResult = null;
14+
});
15+
afterEach(function () {
16+
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
17+
});
18+
it('generateSpatialData_test', function (done) {
19+
var generateSpatialDataParameters = new SuperMap.GenerateSpatialDataParameters({
20+
routeTable: "RouteDT_road@Changchun",
21+
routeIDField: "RouteID",
22+
eventTable: "LinearEventTabDT@Changchun",
23+
eventRouteIDField: "RouteID",
24+
measureField: "",
25+
measureStartField: "LineMeasureFrom",
26+
measureEndField: "LineMeasureTo",
27+
measureOffsetField: "",
28+
errorInfoField: "",
29+
dataReturnOption: new SuperMap.DataReturnOption({
30+
expectCount: 1000,
31+
dataset: "generateSpatialData@Changchun",
32+
deleteExistResultDataset: true,
33+
dataReturnMode: SuperMap.DataReturnMode.DATASET_ONLY
34+
})
35+
});
36+
var generateSpatialDataService = L.supermap.spatialAnalystService(spatialAnalystURL, options);
37+
generateSpatialDataService.generateSpatialData(generateSpatialDataParameters, function (result) {
38+
serviceResult = result;
39+
40+
});
41+
setTimeout(function () {
42+
try {
43+
expect(generateSpatialDataService).not.toBeNull();
44+
expect(generateSpatialDataService.options.serverType).toBe('iServer');
45+
expect(serviceResult).not.toBeNull();
46+
expect(serviceResult.type).toEqual("processCompleted");
47+
expect(serviceResult.result).not.toBeNull();
48+
expect(serviceResult.result.succeed).toBe(true);
49+
expect(serviceResult.result.dataset).toEqual("generateSpatialData@Changchun");
50+
generateSpatialDataService.destroy();
51+
done();
52+
53+
} catch (exception) {
54+
console.log("'generateSpatialData_test'案例失败" + exception.name + ":" + exception.message);
55+
generateSpatialDataService.destroy();
56+
expect(false).toBeTruthy();
57+
done();
58+
}
59+
}, 5000);
60+
});
61+
});
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
require('../../../src/leaflet/services/spatialAnalystService');
2+
var spatialAnalystURL = GlobeParameter.spatialAnalystURL;
3+
var options = {
4+
serverType: 'iServer'
5+
};
6+
describe('leaflet_SpatialAnalystService_interpolationAnalysis', function () {
7+
var serviceResult;
8+
var originalTimeout;
9+
beforeEach(function () {
10+
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
11+
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000;
12+
serviceResult = null;
13+
});
14+
afterEach(function () {
15+
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
16+
});
17+
it('interpolationAnalysis_test', function (done) {
18+
var interpolationAnalystParameters = new SuperMap.InterpolationKrigingAnalystParameters({
19+
// 用于做插值分析的数据源中数据集的名称
20+
dataset: "SamplesP@Interpolation",
21+
// 插值分析结果数据集的名称
22+
outputDatasetName: "UniversalKriging_Result",
23+
// 插值分析结果数据源的名称
24+
outputDatasourceName: "Interpolation",
25+
// 结果栅格数据集存储的像素格式
26+
pixelFormat: SuperMap.PixelFormat.DOUBLE,
27+
// 属性过滤条件
28+
filterQueryParameter: {
29+
attributeFilter: ""
30+
},
31+
//存储用于进行插值分析的字段名称
32+
zValueFieldName: "AVG_TMP",
33+
searchRadius: "0",
34+
//克吕金插值的类型
35+
type: "UniversalKriging",
36+
//克吕金类型中旋转角度值
37+
angle: 0,
38+
//克吕金类型中块金效应值
39+
nugget: 0,
40+
//克吕金类型中自相关阈值,单位与原数据集单位相同
41+
range: 0,
42+
//克吕金类型中基台值
43+
sill: 0,
44+
//克吕金插值时的半变函数类型
45+
variogramMode: "SPHERICAL",
46+
searchMode: "KDTREE_FIXED_COUNT",
47+
bounds: L.bounds([-2640403.63, 1873792.1], [3247669.39, 5921501.4])
48+
});
49+
var interpolationAnalystService = L.supermap.spatialAnalystService(spatialAnalystURL, options);
50+
interpolationAnalystService.interpolationAnalysis(interpolationAnalystParameters, function (result) {
51+
serviceResult = result;
52+
});
53+
setTimeout(function () {
54+
try {
55+
expect(interpolationAnalystService).not.toBeNull();
56+
expect(serviceResult).not.toBeNull();
57+
expect(serviceResult.type).toEqual("processCompleted");
58+
expect(serviceResult.result).not.toBeNull();
59+
expect(serviceResult.result.dataset).toContain("UniversalKriging_Result");
60+
expect(serviceResult.result.succeed).toBe(true);
61+
interpolationAnalystService.destroy();
62+
done();
63+
} catch (exception) {
64+
console.log("'interpolationAnalystService_test'案例失败" + exception.name + ":" + exception.message);
65+
interpolationAnalystService.destroy();
66+
expect(false).toBeTruthy();
67+
done();
68+
}
69+
}, 15000);
70+
71+
});
72+
});
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
require('../../../src/leaflet/services/spatialAnalystService');
2+
3+
var spatialAnalystURL = GlobeParameter.spatialAnalystURL;
4+
var options = {
5+
serverType: 'iServer'
6+
};
7+
describe('leaflet_SpatialAnalystService_mathExpressionAnalysis', function () {
8+
var serviceResult;
9+
var originalTimeout;
10+
beforeEach(function () {
11+
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
12+
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000;
13+
serviceResult = null;
14+
});
15+
afterEach(function () {
16+
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
17+
});
18+
it('mathExpressionAnalysis_test', function (done) {
19+
var mathExpressionAnalysisParameters = new SuperMap.MathExpressionAnalysisParameters({
20+
//指定数据集,必设
21+
dataset: "JingjinTerrain@Jingjin",
22+
//要执行的栅格运算代数表达式,必设
23+
expression: "[Jingjin.JingjinTerrain] + 600",
24+
//存储结果数据集的数据源,必设
25+
targetDatasource: "Jingjin",
26+
//结果数据集名称,必设
27+
resultGridName: "MathExpressionAnalysis_Result",
28+
deleteExistResultDataset: true
29+
});
30+
var mathExpressionAnalystService = L.supermap.spatialAnalystService(spatialAnalystURL, options);
31+
mathExpressionAnalystService.densityAnalysis(mathExpressionAnalysisParameters, function (result) {
32+
serviceResult = result;
33+
});
34+
setTimeout(function () {
35+
try {
36+
expect(mathExpressionAnalystService).not.toBeNull();
37+
expect(mathExpressionAnalystService.options.serverType).toBe('iServer');
38+
expect(serviceResult).not.toBeNull();
39+
expect(serviceResult.type).toEqual("processCompleted");
40+
expect(serviceResult.result).not.toBeNull();
41+
expect(serviceResult.result.succeed).toBe(true);
42+
mathExpressionAnalystService.destroy();
43+
done();
44+
45+
} catch (exception) {
46+
console.log("'mathExpressionAnalysis_test'案例失败" + exception.name + ":" + exception.message);
47+
mathExpressionAnalystService.destroy();
48+
expect(false).toBeTruthy();
49+
done();
50+
}
51+
}, 5000);
52+
});
53+
});

0 commit comments

Comments
 (0)