From 3b111be4a32d8b46b9f7e328b8a035a05cf0e94d Mon Sep 17 00:00:00 2001 From: mbarto <maurobartolomeoli@gmail.com> Date: Fri, 18 May 2018 09:56:04 +0200 Subject: [PATCH] Include printing fixes from master and fix the color of line vector when printing (#2919) * Fixed color style in pdf print (#2792) * Fixed color style in pdf print * Tinycolor version # Conflicts: # web/client/utils/PrintUtils.js * Fixes #29018: quick fix to printing styles of vector --- package.json | 3 ++- web/client/utils/ColorUtils.js | 2 ++ web/client/utils/PrintUtils.js | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index c9314c3c47..20db588a22 100644 --- a/package.json +++ b/package.json @@ -118,8 +118,8 @@ "leaflet-extra-markers": "1.0.6", "leaflet-minimap": "3.6.0", "leaflet-plugins": "3.0.2", - "leaflet.gridlayer.googlemutant": "0.6.4", "leaflet-simple-graticule": "1.0.2", + "leaflet.gridlayer.googlemutant": "0.6.4", "leaflet.locatecontrol": "0.62.0", "leaflet.nontiledlayer": "1.0.7", "lodash": "4.16.6", @@ -185,6 +185,7 @@ "rxjs": "5.1.1", "screenfull": "3.1.0", "shpjs": "3.4.2", + "tinycolor2": "1.4.1", "turf-bbox": "3.0.10", "turf-buffer": "3.0.10", "turf-intersect": "3.0.10", diff --git a/web/client/utils/ColorUtils.js b/web/client/utils/ColorUtils.js index 2dce2a8026..36e23296ce 100644 --- a/web/client/utils/ColorUtils.js +++ b/web/client/utils/ColorUtils.js @@ -7,6 +7,7 @@ */ const tinycolor = require("tinycolor2"); const {toNumber} = require("lodash"); + /** * Porting of various MapStore(1) utilities for random/color scale generations * @name ColorUtils @@ -157,6 +158,7 @@ const ColorUtils = { return ColorUtils.rgbToHsv(rgb); } }, + colorToHexStr: (color = 'red') => tinycolor(color).toHexString(), /** * Return with position of a character in this.HCHARS string * @private diff --git a/web/client/utils/PrintUtils.js b/web/client/utils/PrintUtils.js index 1baaa5aed2..4bbad262de 100644 --- a/web/client/utils/PrintUtils.js +++ b/web/client/utils/PrintUtils.js @@ -9,6 +9,7 @@ const CoordinatesUtils = require('./CoordinatesUtils'); const MapUtils = require('./MapUtils'); const AnnotationsUtils = require("./AnnotationsUtils"); +const {colorToHexStr} = require("./ColorUtils"); const {isArray} = require('lodash'); @@ -342,14 +343,14 @@ const PrintUtils = { } // commented the available options. return { - "fillColor": PrintUtils.rgbaTorgb(style.fillColor), + "fillColor": colorToHexStr(style.fillColor), "fillOpacity": style.fillOpacity, // "rotation": "30", "externalGraphic": style.iconUrl, // "graphicName": "circle", // "graphicOpacity": 0.4, "pointRadius": style.radius, - "strokeColor": PrintUtils.rgbaTorgb(style.color), + "strokeColor": colorToHexStr(style.color), "strokeOpacity": style.opacity, "strokeWidth": style.weight // "strokeLinecap": "round",