From 88e98cbc6b53b148eec2dc379a101d100d6a84a9 Mon Sep 17 00:00:00 2001 From: jansule Date: Mon, 6 Aug 2018 08:55:06 +0200 Subject: [PATCH 1/3] add-lineDashOffset-type --- types/openlayers/index.d.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/types/openlayers/index.d.ts b/types/openlayers/index.d.ts index a6122c8477..01d7e120f5 100644 --- a/types/openlayers/index.d.ts +++ b/types/openlayers/index.d.ts @@ -9,6 +9,7 @@ // Yair Tawil // Pierre Marchand // Hauke Stieler +// Jan Suleiman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Definitions partially generated using tsd-jsdoc (https://github.com/englercj/tsd-jsdoc) @@ -10135,6 +10136,13 @@ export namespace style { */ getLineDash(): number[]; + /** + * Get the line dash offset style for the stroke. + * @return Line dash offset + * @api + */ + getLineDashOffset(): number; + /** * Get the line join type for the stroke. * @return Line join. @@ -10186,6 +10194,14 @@ export namespace style { */ setLineDash(lineDash: number[]): void; + /** + * Set the line dash offset. + * + * @param lineDashOffset Line dash offset. + * @api + */ + setLineDashOffset(lineDashOffset: number): void; + /** * Set the line join. * @@ -12347,6 +12363,7 @@ export namespace olx { lineCap?: string; lineJoin?: string; lineDash?: number[]; + lineDashOffset?: number; miterLimit?: number; width?: number; } From bbf5ad55bb874bffbf9ae6b39c48b5defbc0d130 Mon Sep 17 00:00:00 2001 From: jansule Date: Mon, 6 Aug 2018 11:56:51 +0200 Subject: [PATCH 2/3] add unit tests for ol.style.Stroke --- types/openlayers/openlayers-tests.ts | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/types/openlayers/openlayers-tests.ts b/types/openlayers/openlayers-tests.ts index fcf925886d..240f77d033 100644 --- a/types/openlayers/openlayers-tests.ts +++ b/types/openlayers/openlayers-tests.ts @@ -74,6 +74,7 @@ const style = new ol.style.Style(); const styleArray: ol.style.Style[] = []; const styleFunction: ol.StyleFunction = (feature, resolution) => style; let styleRegularShape: ol.style.RegularShape; +let styleStroke: ol.style.Stroke; const tilegrid = new ol.tilegrid.TileGrid({resolutions: numberArray}); const transformFn: ol.TransformFunction = (array, out, dimension) => numberArray; let units: ol.proj.Units; @@ -1111,6 +1112,35 @@ styleRegularShape = new ol.style.RegularShape({ points: 4, }); +// +// ol.style.Stroke +// + +styleStroke = new ol.style.Stroke(); +styleStroke.setColor('#FF0000'); +styleStroke.setColor('red'); +styleStroke.setColor('#CCC'); +styleStroke.setColor('rgb(255, 255, 255)'); +styleStroke.setColor('rgb(255, 255, 255, 0.7)'); +styleStroke.setLineCap('butt'); +styleStroke.setLineCap('round'); +styleStroke.setLineCap('square'); +styleStroke.setLineJoin('bevel'); +styleStroke.setLineJoin('round'); +styleStroke.setLineJoin('miter'); +styleStroke.setLineDash([10, 5]); +styleStroke.setLineDashOffset(10); +styleStroke.setMiterLimit(20); +styleStroke.setWidth(5); + +styleStroke.getColor(); +styleStroke.getLineCap(); +styleStroke.getLineJoin(); +styleStroke.getLineDash(); +styleStroke.getLineDashOffset(); +styleStroke.getMiterLimit(); +styleStroke.getWidth(); + // // ol.proj // From 44db229c6eda231ebb6f54752b6d6ca17f68b952 Mon Sep 17 00:00:00 2001 From: jansule Date: Tue, 7 Aug 2018 11:08:30 +0200 Subject: [PATCH 3/3] Affect returned value to typed variables in getters Also, remove name from contributors list --- types/openlayers/index.d.ts | 1 - types/openlayers/openlayers-tests.ts | 14 +++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/types/openlayers/index.d.ts b/types/openlayers/index.d.ts index 01d7e120f5..37cac7e65d 100644 --- a/types/openlayers/index.d.ts +++ b/types/openlayers/index.d.ts @@ -9,7 +9,6 @@ // Yair Tawil // Pierre Marchand // Hauke Stieler -// Jan Suleiman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Definitions partially generated using tsd-jsdoc (https://github.com/englercj/tsd-jsdoc) diff --git a/types/openlayers/openlayers-tests.ts b/types/openlayers/openlayers-tests.ts index 240f77d033..6e28ad4cd2 100644 --- a/types/openlayers/openlayers-tests.ts +++ b/types/openlayers/openlayers-tests.ts @@ -1133,13 +1133,13 @@ styleStroke.setLineDashOffset(10); styleStroke.setMiterLimit(20); styleStroke.setWidth(5); -styleStroke.getColor(); -styleStroke.getLineCap(); -styleStroke.getLineJoin(); -styleStroke.getLineDash(); -styleStroke.getLineDashOffset(); -styleStroke.getMiterLimit(); -styleStroke.getWidth(); +const strokeColor: ol.Color|ol.ColorLike = styleStroke.getColor(); +const strokeLineCap: string = styleStroke.getLineCap(); +const strokeLineJoin: string = styleStroke.getLineJoin(); +const strokeLineDash: number[] = styleStroke.getLineDash(); +const strokeLineDashOffset: number = styleStroke.getLineDashOffset(); +const strokeMiterLimit: number = styleStroke.getMiterLimit(); +const strokeWidth: number = styleStroke.getWidth(); // // ol.proj