* @function StyleUtils.getPathway 获取铁路样式 * @param {Object} style - 样式参数 * @param {Object} outlineStyle - 轮廓样式参数 * @returns {Object} style对象
(style, outlineStyle)
| 1214 | * @returns {Object} style对象 |
| 1215 | */ |
| 1216 | static getPathway(style, outlineStyle) { |
| 1217 | let { strokeWidth=ZERO, strokeColor, strokeOpacity } = style; |
| 1218 | // 道路线都是solid, lineCap都是直角 |
| 1219 | const lineDash = (w => [w, w + strokeWidth * 2])(4 * strokeWidth), lineCap= 'square'; |
| 1220 | let strokeColorArray = this.hexToRgb(strokeColor); |
| 1221 | strokeColorArray && strokeColorArray.push(strokeOpacity); |
| 1222 | var stroke = new Style({ |
| 1223 | stroke: new StrokeStyle({ |
| 1224 | width: strokeWidth*0.5 || ZERO, |
| 1225 | color: strokeColorArray, |
| 1226 | lineCap, |
| 1227 | lineDash |
| 1228 | }) |
| 1229 | }); |
| 1230 | |
| 1231 | const { strokeColor: outlineColor } = outlineStyle; |
| 1232 | let outlineColorArray = this.hexToRgb(outlineColor); |
| 1233 | // opacity使用style的透明度。保持两根线透明度一致 |
| 1234 | outlineColorArray && outlineColorArray.push(strokeOpacity); |
| 1235 | var outlineStroke = new Style({ |
| 1236 | stroke: new StrokeStyle({ |
| 1237 | width: strokeWidth || ZERO, |
| 1238 | color: outlineColorArray, |
| 1239 | lineCap |
| 1240 | }) |
| 1241 | }); |
| 1242 | return [outlineStroke, stroke]; |
| 1243 | } |
| 1244 | } |
no test coverage detected