Skip to content

Commit

Permalink
Redlining: print labels w/ given size
Browse files Browse the repository at this point in the history
Note: rotation does not work. Is it a QGIS bug?
  • Loading branch information
nboisteault committed Sep 12, 2023
1 parent c0a28e1 commit 9ec97d9
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion assets/src/components/Print.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,13 @@ export default class Print extends HTMLElement {
const formatWKT = new WKT();
const highlightGeom = [];
const highlightSymbol = [];
const highlightLabelString = [];
const highlightLabelSize = [];
const highlightLabelBufferColor = [];
const highlightLabelBufferSize = [];
const highlightLabelRotation = [];

mainLizmap.digitizing.featureDrawn?.map((featureDrawn, index) => {
mainLizmap.digitizing.featureDrawn?.forEach((featureDrawn, index) => {

// Translate circle coords to WKT
if (featureDrawn.getGeometry().getType() === 'Circle') {
Expand All @@ -303,13 +308,36 @@ export default class Print extends HTMLElement {
}

highlightSymbol.push(mainLizmap.digitizing.getFeatureDrawnSLD(index));

// Labels
const label = featureDrawn.get('text') ? featureDrawn.get('text') : ' ';
highlightLabelString.push(label);
// Font size is 10px by default (https://github.com/openlayers/openlayers/blob/v8.1.0/src/ol/style/Text.js#L30)
let scale = featureDrawn.get('scale');
if (scale) {
scale = scale * 10;
}
highlightLabelSize.push(scale);

highlightLabelBufferColor.push('#FFFFFF');
highlightLabelBufferSize.push(1.5);

highlightLabelRotation.push(featureDrawn.get('rotation'));
});

if (highlightGeom.length && highlightSymbol.length) {
wmsParams[this._mainMapID + ':HIGHLIGHT_GEOM'] = highlightGeom.join(';');
wmsParams[this._mainMapID + ':HIGHLIGHT_SYMBOL'] = highlightSymbol.join(';');
}

if (!highlightLabelString.every(label => label === ' ')){
wmsParams[this._mainMapID + ':HIGHLIGHT_LABELSTRING'] = highlightLabelString.join(';');
wmsParams[this._mainMapID + ':HIGHLIGHT_LABELSIZE'] = highlightLabelSize.join(';');
wmsParams[this._mainMapID + ':HIGHLIGHT_LABELBUFFERCOLOR'] = highlightLabelBufferColor.join(';');
wmsParams[this._mainMapID + ':HIGHLIGHT_LABELBUFFERSIZE'] = highlightLabelBufferSize.join(';');
wmsParams[this._mainMapID + ':HIGHLIGHT_LABEL_ROTATION'] = highlightLabelRotation.join(';');
}

// Grid
if(this._gridX){
wmsParams[this._mainMapID + ':GRID_INTERVAL_X'] = this._gridX;
Expand Down

0 comments on commit 9ec97d9

Please sign in to comment.