Skip to content

Commit e401536

Browse files
fix ut
1 parent 5af098a commit e401536

File tree

5 files changed

+155
-22
lines changed

5 files changed

+155
-22
lines changed

src/common/iServer/VideoFeature.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ export class VideoFeature {
6363
destroy() {
6464
if (this.geometry && this.geometry.destroy) {
6565
this.geometry.destroy();
66-
this.geometry = null;
6766
}
67+
this.geometry = null;
6868
this.name = null;
6969
this.videoParameters = null;
7070
this.cameraLocation = null;

src/mapboxgl/mapping/utils/VideoMapUtil.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,6 @@ export const transformCoordReverse = ({
2222
return [(coord[0] - originCoordsLeftTop.lng) / perWidth, (originCoordsLeftTop.lat - coord[1]) / perHeight];
2323
};
2424

25-
export const validLnglat = (lnglat) => {
26-
if (!lnglat) {
27-
return false;
28-
}
29-
if (lnglat[0] < -90 || lnglat[1] > 90 || lnglat[0] > 90 || lnglat[1] < -90) {
30-
return false;
31-
}
32-
return true;
33-
};
34-
3525
export const fovXToFx = (fovX, videoWidth) => {
3626
return videoWidth / (2 * Math.tan(fovX / 2 * Math.PI / 180));
3727
}

test/common/util/GeometryAnalysisSpec.js

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,64 @@ describe('GeometryAnalysis', () => {
5858
expect(result).toBeTruthy();
5959
});
6060

61+
62+
it('isIdentical multilinestring', () => {
63+
const line1 = {
64+
"type": "Feature",
65+
"properties": {},
66+
"geometry": {
67+
"coordinates": [[
68+
[
69+
67.99609375000006,
70+
67.69489448648969
71+
],
72+
[
73+
89.26562499999926,
74+
63.72666005814014
75+
]
76+
], [
77+
[
78+
57.80078124999906,
79+
65.82307382870485
80+
],
81+
[
82+
93.1328124999992,
83+
59.201303359951794
84+
]
85+
]],
86+
"type": "MultiLineString"
87+
}
88+
};
89+
const line2 = {
90+
"type": "Feature",
91+
"properties": {},
92+
"geometry": {
93+
"coordinates": [[
94+
[
95+
67.99609375000006,
96+
67.69489448648969
97+
],
98+
[
99+
89.26562499999926,
100+
63.72666005814014
101+
]
102+
], [
103+
[
104+
57.80078124999906,
105+
65.82307382870485
106+
],
107+
[
108+
93.1328124999992,
109+
59.201303359951794
110+
]
111+
]],
112+
"type": "MultiLineString"
113+
}
114+
};
115+
const result = instance.isIdentical(line1, line2);
116+
expect(result).toBeTruthy();
117+
});
118+
61119
it('hasTouch', () => {
62120
const polygon1 = {
63121
type: 'Feature',
@@ -346,7 +404,7 @@ describe('GeometryAnalysis', () => {
346404
const result = instance.computeGeodesicArea(polygon, 4326);
347405
expect(result).toBe(6.578677712850164);
348406
});
349-
407+
350408
it('computeGeodesicDistance', () => {
351409
var xArray = [120, 125];
352410
var yArray = [30, 30];

test/leaflet/services/EditVideoFeatureSpec.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,65 @@ describe('leaflet_EditVideoFeature', () => {
6060
done();
6161
});
6262
})
63+
64+
it('toGeoJSONFeature', done => {
65+
const geometry1 = {
66+
type: 'Feature',
67+
geometry: {
68+
type: 'Polygon',
69+
coordinates: [
70+
[
71+
[116.75, 39.75],
72+
[117.25, 39.75],
73+
[117.25, 40.75],
74+
[116.75, 40.75],
75+
[116.75, 39.75]
76+
]
77+
]
78+
}
79+
};
80+
81+
var videoFeature = new VideoFeature({
82+
id: 1,
83+
name: 'newTest.mp4',
84+
geometry: geometry1,
85+
address: 'http://localhost:9876/iserver/services/video/restjsr/hls/stream/test/index.m3u8'
86+
});
87+
88+
var transFeature = videoFeature.toGeoJSONFeature();
89+
expect(transFeature.type).toBe('Feature');
90+
expect(transFeature.id).toBe(1);
91+
expect(transFeature.geometry).toEqual(geometry1);
92+
done();
93+
})
94+
95+
it('destroy', done => {
96+
const geometry = {
97+
type: 'Feature',
98+
geometry: {
99+
type: 'Polygon',
100+
coordinates: [
101+
[
102+
[116.75, 39.75],
103+
[117.25, 39.75],
104+
[117.25, 40.75],
105+
[116.75, 40.75],
106+
[116.75, 39.75]
107+
]
108+
]
109+
}
110+
};
111+
112+
var videoFeature = new VideoFeature({
113+
id: 1,
114+
name: 'newTest.mp4',
115+
geometry: geometry,
116+
address: 'http://localhost:9876/iserver/services/video/restjsr/hls/stream/test/index.m3u8'
117+
});
118+
expect(videoFeature.geometry).toEqual(geometry);
119+
videoFeature.destroy();
120+
expect(videoFeature.name).toBeNull();
121+
expect(videoFeature.geometry).toBeNull();
122+
done();
123+
})
63124
});

test/mapboxgl/mapping/VideoMapSpec.js

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('mapboxgl_videoMap', () => {
1717
CV_64FC1: 'CV_64FC1',
1818
matFromImageData: function () {
1919
return {
20-
delete: function () {}
20+
delete: function () { }
2121
};
2222
},
2323
Size: function () {
@@ -26,22 +26,22 @@ describe('mapboxgl_videoMap', () => {
2626
height: 690
2727
};
2828
},
29-
matFromArray: function () {},
29+
matFromArray: function () { },
3030
Mat: function () {
3131
return {
32-
inv: function () {},
33-
delete: function () {},
32+
inv: function () { },
33+
delete: function () { },
3434
data64F: [200, 100],
3535
cols: 2,
3636
rows: 2,
3737
data: [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]
3838
};
3939
},
40-
gemm: function () {},
41-
Rodrigues: function () {},
42-
projectPoints: function () {},
43-
multiply: function () {},
44-
subtract: function () {}
40+
gemm: function () { },
41+
Rodrigues: function () { },
42+
projectPoints: function () { },
43+
multiply: function () { },
44+
subtract: function () { }
4545
};
4646
});
4747
afterEach(() => {
@@ -61,7 +61,7 @@ describe('mapboxgl_videoMap', () => {
6161
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
6262
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000;
6363
});
64-
64+
6565
it('init videoMap', (done) => {
6666
var url = videoUrl;
6767
var videoMap = new VideoMap({
@@ -201,4 +201,28 @@ describe('mapboxgl_videoMap', () => {
201201
done();
202202
});
203203
});
204+
205+
it('destroy', (done) => {
206+
var videoMap = new VideoMap({
207+
opencv: cv,
208+
videoParameters: {
209+
fovX: 84,
210+
fovY: 47,
211+
centerX: 960,
212+
centerY: 540,
213+
pitch: -20,
214+
roll: 0,
215+
yaw: 2,
216+
x: 11587478.810629973,
217+
y: 3570800.195541344,
218+
z: 154.50312
219+
}
220+
});
221+
setTimeout(() => {
222+
videoMap.videoMapLayer = null;
223+
videoMap.destroy();
224+
expect(videoMap.map).toBeNull();
225+
done();
226+
}, 2000);
227+
});
204228
});

0 commit comments

Comments
 (0)