Skip to content

Commit 91727b4

Browse files
VT截图算法增加偏移量参数,修改对应VT。
1 parent 6799804 commit 91727b4

File tree

6 files changed

+17
-15
lines changed

6 files changed

+17
-15
lines changed

examples-test/base/commonTools.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ var commonTools = ({
3333
* exampleName(String) - eg:'01_tiledMapLayer3857' etc.
3434
* standardTilePrams(offsetX, offsetY, width, height).
3535
* */
36-
getStdTile: function (browser, type, exampleName, width, height) {
36+
getStdTile: function (browser, type, exampleName, offsetX, offsetY, width, height) {
3737
var screenShotPath = './examples-test/temp/' + exampleName + '.png';
3838
var tileTestPath = './examples-test/' + type + '/resources/' + exampleName + '.png';
3939
browser.pause(5000);
4040
browser.saveScreenshot(screenShotPath, function () {
4141
console.log('Screenshot has been saved , now start to get StdTile from Screenshot');
4242
var totalWidth = images(screenShotPath).width();
4343
var totalHeight = images(screenShotPath).height();
44-
var offsetX = (totalWidth - width) / 2;
45-
var offsetY = (totalHeight - height) / 2;
46-
commonTools.getTileFromScreenshot(screenShotPath, offsetX, offsetY, width, height, tileTestPath);
44+
var offX = (totalWidth - width) / 2 + offsetX;
45+
var offY = (totalHeight - height) / 2 - offsetY;
46+
commonTools.getTileFromScreenshot(screenShotPath, offX, offY, width, height, tileTestPath);
4747
console.log('get StdTile completed');
4848
});
4949
browser.pause(2000, function () {
@@ -58,10 +58,11 @@ var commonTools = ({
5858
* params: broswer ;
5959
* type(String) - serviceType, eg:'leaflet'、'openlayers'、'3dwebgl'、'mapboxgl' etc.
6060
* exampleName(String) - eg:'01_tiledMapLayer3857' etc.
61-
* testTilePrams(width, height) - should be equal with Corresponding standard tile params.
61+
* testTilePrams(offsetX, offsetY, width, height) - should be equal with Corresponding standard tile params.
62+
* offsetX, offsetY: Offset relative to the center point
6263
* return : boolean
6364
* */
64-
cmpTestTileWithStdTile: function (browser, type, exampleName, width, height) {
65+
cmpTestTileWithStdTile: function (browser, type, exampleName, offsetX, offsetY, width, height) {
6566
var screenShotPath, tileTestPath, tileStandardPath;
6667
if (typeof type !== 'string' || typeof exampleName !== 'string') {
6768
console.log('invalid input : type or exampleName is not a string');
@@ -75,9 +76,9 @@ var commonTools = ({
7576
console.log('start to get the tile');
7677
var totalWidth = images(screenShotPath).width();
7778
var totalHeight = images(screenShotPath).height();
78-
var offsetX = (totalWidth - width) / 2;
79-
var offsetY = (totalHeight - height) / 2;
80-
commonTools.getTileFromScreenshot(screenShotPath, offsetX, offsetY, width, height, tileTestPath);
79+
var offX = (totalWidth - width) / 2 + offsetX;
80+
var offY = (totalHeight - height) / 2 - offsetY;
81+
commonTools.getTileFromScreenshot(screenShotPath, offX, offY, width, height, tileTestPath);
8182
console.log('get the tile completed');
8283
});
8384
browser.pause(5000, function () {
@@ -89,9 +90,10 @@ var commonTools = ({
8990

9091
/*
9192
* function: get a tile with certain range from the screenshot
93+
* offX, offY: Offset relative to the top-left corner
9294
* */
93-
getTileFromScreenshot: function (sourceImagePath, offsetX, offsetY, width, height, tilePath) {
94-
images(images(sourceImagePath), offsetX, offsetY, width, height)
95+
getTileFromScreenshot: function (sourceImagePath, offX, offY, width, height, tilePath) {
96+
images(images(sourceImagePath), offX, offY, width, height)
9597
.save(tilePath);
9698
},
9799

examples-test/leaflet/01_overlayTiledMapLayerIT.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = {
55
var exampleName = '01_overlayTiledMapLayer';
66
commonTools.openExampleAndLoadMap(browser, type, exampleName);
77
//测试过程中截取地图瓦片, 和已有的标准瓦片进行对比
8-
commonTools.cmpTestTileWithStdTile(browser, type, exampleName, 256, 256);
8+
commonTools.cmpTestTileWithStdTile(browser, type, exampleName, 128, 128, 256, 256);
99
browser.end();
1010
}
1111
};

examples-test/leaflet/01_tiledMapLayer3857IT.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = {
55
var exampleName = '01_tiledMapLayer3857';
66
commonTools.openExampleAndLoadMap(browser, type, exampleName);
77
//测试过程中截取地图瓦片, 和已有的标准瓦片进行对比
8-
commonTools.cmpTestTileWithStdTile(browser, type, exampleName, 256, 256);
8+
commonTools.cmpTestTileWithStdTile(browser, type, exampleName, 0, 0, 256, 256);
99
browser.end();
1010
}
1111
};

examples-test/leaflet/01_tiledMapLayer4326IT.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = {
55
var exampleName = '01_tiledMapLayer4326';
66
commonTools.openExampleAndLoadMap(browser, type, exampleName);
77
//测试过程中截取地图瓦片, 和已有的标准瓦片进行对比
8-
commonTools.cmpTestTileWithStdTile(browser, type, exampleName, 256, 256);
8+
commonTools.cmpTestTileWithStdTile(browser, type, exampleName, 0, 0, 256, 256);
99
browser.end();
1010
}
1111
};

examples-test/leaflet/01_tiledMapLayerNonEarthIT.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = {
55
var exampleName = '01_tiledMapLayerNonEarth';
66
commonTools.openExampleAndLoadMap(browser, type, exampleName);
77
//测试过程中截取地图瓦片, 和已有的标准瓦片进行对比
8-
commonTools.cmpTestTileWithStdTile(browser, type, exampleName, 256, 256);
8+
commonTools.cmpTestTileWithStdTile(browser, type, exampleName, 0, 0, 256, 256);
99
browser.end();
1010
}
1111
};
-26 KB
Loading

0 commit comments

Comments
 (0)