@@ -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
0 commit comments