Skip to content

Commit 3fdc8db

Browse files
fix ut and api
1 parent a87d59f commit 3fdc8db

File tree

4 files changed

+115
-93
lines changed

4 files changed

+115
-93
lines changed

src/mapboxgl/mapping/VideoMap.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,36 +52,36 @@ const MAP_EVENTS = [
5252
/**
5353
* @class VideoMap
5454
* @classdesc 视频地图
55-
* @category Visualization Video
55+
* @category VideoMap
5656
* @version 11.2.0
57-
* @modulecategory Overlay
58-
* @param {string} url - 视频 或 流链接。支持 flv, m3u8, map4 格式。
59-
* @param {string} videoParameters - 视频地图配准参数
60-
* @param {number} videoParameters.pitch - 俯仰角。
61-
* @param {number} videoParameters.roll - 侧偏角。
62-
* @param {number} videoParameters.yaw - 偏航角。
63-
* @param {number} videoParameters.x - 视频 x 坐标。
64-
* @param {number} videoParameters.y - 视频 y 坐标。
65-
* @param {number} videoParameters.z - 视频 z 坐标。
66-
* @param {number} videoParameters.fovX - 水平方向上以像素为单位的焦距。
67-
* @param {number} videoParameters.fovY - 垂直方向上以像素为单位的焦距。
68-
* @param {number} videoParameters.centerX - 相机中心的水平坐标。
69-
* @param {number} videoParameters.centerY - 相机中心的垂直坐标。
57+
* @modulecategory Mapping
7058
* @param {Object} options - 参数
59+
* @param {string} options.url - 视频 或 流链接。支持 flv, m3u8, map4 格式。
60+
* @param {string} options.videoParameters - 视频地图配准参数
61+
* @param {number} options.videoParameters.pitch - 俯仰角。
62+
* @param {number} options.videoParameters.roll - 侧偏角。
63+
* @param {number} options.videoParameters.yaw - 偏航角。
64+
* @param {number} options.videoParameters.x - 视频 x 坐标。
65+
* @param {number} options.videoParameters.y - 视频 y 坐标。
66+
* @param {number} options.videoParameters.z - 视频 z 坐标。
67+
* @param {number} options.videoParameters.fovX - 水平方向上以像素为单位的焦距。
68+
* @param {number} options.videoParameters.fovY - 垂直方向上以像素为单位的焦距。
69+
* @param {number} options.videoParameters.centerX - 相机中心的水平坐标。
70+
* @param {number} options.videoParameters.centerY - 相机中心的垂直坐标。
7171
* @param {string} [options.container='map'] - 地图容器id
7272
* @param {string} [options.opencv] - opencv 实例
73-
* @param {function} [options.videoWidth] - 视频地图宽度
74-
* @param {function} [options.videoHeight] - 视频地图高度
73+
* @param {function} [options.videoWidth] - 视频地图宽度,没设置时默认获取视频宽度
74+
* @param {function} [options.videoHeight] - 视频地图高度,没设置时默认获取视频高度
7575
* @param {Object} [options.styleOptions] - 视频地图风格配置
76-
* @param {string} [options.autoplay = true] - 视频是否自动播放
77-
* @param {string} [options.loop = true] - 视频是否循环播放
76+
* @param {string} [options.autoplay=true] - 视频是否自动播放
77+
* @param {string} [options.loop=true] - 视频是否循环播放
7878
* @extends {mapboxgl.Evented}
7979
*/
8080

8181
export class VideoMap extends mapboxgl.Evented {
82-
constructor(url, videoParameters, options) {
82+
constructor(options) {
8383
super();
84-
const { container, autoplay, loop, videoWidth, videoHeight, opencv, styleOptions } = options;
84+
const { container, url, videoParameters, autoplay, loop, videoWidth, videoHeight, opencv, styleOptions } = options;
8585
this.container = container || 'map';
8686
this.layerCache = {};
8787
this.sourceCache = {};
@@ -108,7 +108,7 @@ export class VideoMap extends mapboxgl.Evented {
108108
* @function VideoMap.prototype.addLayer
109109
* @description 添加图层。
110110
* @param {Object} layer - 图层配置。
111-
* @param {Object} beforeId - 已经存在的图层 ID。
111+
* @param {string} beforeId - 已经存在的图层 ID。
112112
*/
113113
addLayer(layer, beforeId) {
114114
if (!this._mapExisted()) {
@@ -159,7 +159,7 @@ export class VideoMap extends mapboxgl.Evented {
159159
/**
160160
* @function VideoMap.prototype.removeSource
161161
* @description 移除数据源。
162-
* @param {string} id - 数据源 id。
162+
* @param {string} id - source id。
163163
*/
164164
removeSource(id) {
165165
if (!this._mapExisted()) {

src/mapboxgl/overlay/VideoLayer.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,17 @@
1717
* @version 11.2.0
1818
* @param {Object} options - 构造参数。
1919
* @param {string} options.url - 视频 或 流链接。支持 flv, m3u8, map4 格式。
20-
* @param {Object} options.videoParameters - 视频配准参数
20+
* @param {Object} options.videoParameters - 视频配准参数。
21+
* @param {number} options.videoParameters.pitch - 俯仰角。
22+
* @param {number} options.videoParameters.roll - 侧偏角。
23+
* @param {number} options.videoParameters.yaw - 偏航角。
24+
* @param {number} options.videoParameters.x - 视频 x 坐标。
25+
* @param {number} options.videoParameters.y - 视频 y 坐标。
26+
* @param {number} options.videoParameters.z - 视频 z 坐标。
27+
* @param {number} options.videoParameters.fovX - 水平方向上以像素为单位的焦距。
28+
* @param {number} options.videoParameters.fovY - 垂直方向上以像素为单位的焦距。
29+
* @param {number} options.videoParameters.centerX - 相机中心的水平坐标。
30+
* @param {number} options.videoParameters.centerY - 相机中心的垂直坐标。
2131
* @param {Array} options.extent - 视频范围。
2232
* @param {Object} [options.opencv] - opencv.js 实例, 未传入时将去 window.cv 获取。
2333
* @param {string} [options.id] - 视频图层 ID。默认使用 CommonUtil.createUniqueID("VideoLayer_") 创建专题图层 ID。
@@ -53,6 +63,7 @@
5363
/**
5464
* @function VideoLayer.prototype.onAdd
5565
* @description 添加该图层。
66+
* @param {Object} 地图实例。
5667
*/
5768
onAdd(map) {
5869
this.map = map;
@@ -236,6 +247,7 @@
236247
/**
237248
* @function VideoLayer.prototype.moveLayer
238249
* @description 移动图层。
250+
* @param {string} beforeId - 要移动到的图层前的 id。
239251
*/
240252
moveLayer(beforeId) {
241253
this.map.moveLayer(this.layerId, beforeId);

test/mapboxgl/mapping/VideoMapSpec.js

Lines changed: 52 additions & 46 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,22 +61,24 @@ 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;
67-
var videoMap = new VideoMap(url, {
68-
fovX: 84,
69-
fovY: 47,
70-
centerX: 960,
71-
centerY: 540,
72-
pitch: -20,
73-
roll: 0,
74-
yaw: 2,
75-
x: 11587478.810629973,
76-
y: 3570800.195541344,
77-
z: 154.50312
78-
}, {
67+
var videoMap = new VideoMap({
68+
url: url,
7969
opencv: cv,
70+
videoParameters: {
71+
fovX: 84,
72+
fovY: 47,
73+
centerX: 960,
74+
centerY: 540,
75+
pitch: -20,
76+
roll: 0,
77+
yaw: 2,
78+
x: 11587478.810629973,
79+
y: 3570800.195541344,
80+
z: 154.50312
81+
}
8082
});
8183
videoMap.on('load', function () {
8284
expect(videoMap.coordTransfer).not.toBe(null);
@@ -87,19 +89,21 @@ describe('mapboxgl_videoMap', () => {
8789

8890
it('addlayer removelayer', (done) => {
8991
var url = videoUrl;
90-
var videoMap = new VideoMap(url, {
91-
fovX: 84,
92-
fovY: 47,
93-
centerX: 960,
94-
centerY: 540,
95-
pitch: -20,
96-
roll: 0,
97-
yaw: 2,
98-
x: 11587478.810629973,
99-
y: 3570800.195541344,
100-
z: 154.50312
101-
}, {
92+
var videoMap = new VideoMap({
93+
url: url,
10294
opencv: cv,
95+
videoParameters: {
96+
fovX: 84,
97+
fovY: 47,
98+
centerX: 960,
99+
centerY: 540,
100+
pitch: -20,
101+
roll: 0,
102+
yaw: 2,
103+
x: 11587478.810629973,
104+
y: 3570800.195541344,
105+
z: 154.50312
106+
}
103107
});
104108
videoMap.on('load', function () {
105109
videoMap.addLayer({
@@ -150,19 +154,21 @@ describe('mapboxgl_videoMap', () => {
150154

151155
it('addSource removeSource', (done) => {
152156
var url = videoUrl;
153-
var videoMap = new VideoMap(url, {
154-
fovX: 84,
155-
fovY: 47,
156-
centerX: 960,
157-
centerY: 540,
158-
pitch: -20,
159-
roll: 0,
160-
yaw: 2,
161-
x: 11587478.810629973,
162-
y: 3570800.195541344,
163-
z: 154.50312
164-
}, {
157+
var videoMap = new VideoMap({
158+
url: url,
165159
opencv: cv,
160+
videoParameters: {
161+
fovX: 84,
162+
fovY: 47,
163+
centerX: 960,
164+
centerY: 540,
165+
pitch: -20,
166+
roll: 0,
167+
yaw: 2,
168+
x: 11587478.810629973,
169+
y: 3570800.195541344,
170+
z: 154.50312
171+
}
166172
});
167173
videoMap.on('load', function () {
168174
videoMap.addSource('test111', {

test/mapboxgl/overlay/VideoLayerSpec.js

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -127,25 +127,27 @@ describe('mapboxgl_VideoLayer', () => {
127127
var url = videoUrl;
128128
spyOn(cv, 'Size');
129129
spyOn(cv, 'warpPerspective');
130-
var videoLayer = new VideoLayer(url, {
131-
fovX: 84,
132-
fovY: 47,
133-
centerX: 960,
134-
centerY: 540,
135-
pitch: -20,
136-
roll: 0,
137-
yaw: 2,
138-
x: 11587478.810629973,
139-
y: 3570800.195541344,
140-
z: 154.50312
141-
}, {
130+
var videoLayer = new VideoLayer({
131+
url: url,
142132
opencv: cv,
143133
clipRegion: [
144134
[0, 0],
145135
[1920, 0],
146136
[1920, 900],
147137
[0, 900]
148138
],
139+
videoParameters: {
140+
fovX: 84,
141+
fovY: 47,
142+
centerX: 960,
143+
centerY: 540,
144+
pitch: -20,
145+
roll: 0,
146+
yaw: 2,
147+
x: 11587478.810629973,
148+
y: 3570800.195541344,
149+
z: 154.50312
150+
},
149151
extent: [
150152
[116.14394400766855, 28.249134537249257],
151153
[116.143464581289, 28.252977295834056],
@@ -167,25 +169,27 @@ describe('mapboxgl_VideoLayer', () => {
167169

168170
it('render moveLayer onRemove setVisibility', (done) => {
169171
var url = videoUrl;
170-
var videoLayer = new VideoLayer(url, {
171-
fovX: 84,
172-
fovY: 47,
173-
centerX: 960,
174-
centerY: 540,
175-
pitch: -20,
176-
roll: 0,
177-
yaw: 2,
178-
x: 11587478.810629973,
179-
y: 3570800.195541344,
180-
z: 154.50312
181-
}, {
172+
var videoLayer = new VideoLayer({
173+
url: url,
182174
opencv: cv,
183175
clipRegion: [
184176
[0, 0],
185177
[1920, 0],
186178
[1920, 900],
187179
[0, 900]
188180
],
181+
videoParameters: {
182+
fovX: 84,
183+
fovY: 47,
184+
centerX: 960,
185+
centerY: 540,
186+
pitch: -20,
187+
roll: 0,
188+
yaw: 2,
189+
x: 11587478.810629973,
190+
y: 3570800.195541344,
191+
z: 154.50312
192+
},
189193
extent: [
190194
[116.14394400766855, 28.249134537249257],
191195
[116.143464581289, 28.252977295834056],

0 commit comments

Comments
 (0)