Skip to content

Commit

Permalink
Fix/improve the location of labels derived from proportional symbol l…
Browse files Browse the repository at this point in the history
…ayer, fix #108
  • Loading branch information
mthh committed Mar 24, 2023
1 parent 7f358df commit 8edbcf0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changes
=======

Unreleased
----------

- Fix the location of labels derived from a dorling/demers (proportional symbol) layer (Fix #108). Also works on symbols that were manually moved.

0.14.0 (2023-03-24)
-------------------

Expand Down
15 changes: 13 additions & 2 deletions client/js/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -4945,12 +4945,23 @@ export const render_label = function render_label(layer, rendering_params, optio
let i_id = 0;
nb_ft = ref_selection.length;
for (let i = 0; i < nb_ft; i++) {
const ft = ref_selection[i].__data__;
const ref_elem = ref_selection[i];
const ft = ref_elem.__data__;
if (!filter_test(ft.properties)) continue;
let coords;
if (!ft.geometry) {
warn_empty_features.push([i, ft]);
continue;
}
let coords;
// Use the geometry of the circle/square if label are rendered on a symbol
// layer because the symbol might have been moved (either manually by the user or
// by using the dorling/demers algorithm).
// Otherwise, use our custom 'coordsPointOnFeature' function.
if (type_ft_ref === 'circle') {
coords = proj.invert([ref_elem.cx.baseVal.value, ref_elem.cy.baseVal.value]);
} else if (type_ft_ref === 'rect') {
const size = ref_elem.width.baseVal.value;
coords = proj.invert([ref_elem.x.baseVal.value + size / 2, ref_elem.y.baseVal.value + size / 2]);
} else {
coords = coordsPointOnFeature(ft.geometry);
}
Expand Down
4 changes: 4 additions & 0 deletions documentation/src/changelog_fr.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Historique des versions et des changements effectués

#### Unreleased

- Correction de l'emplacement des étiquettes dérivées d'une couche de symboles proportionnels déplacés pour éviter les chevauchements (dorling/demers) (<a href="https://github.com/riatelab/magrit/issues/108">cf. issue #108</a>). Fonctionne également sur les symboles qui ont été déplacés manuellement.

#### 0.14.0 (2023-03-24)

- Nouveau : Ajout d'une fonctionnalité permettant le filtrage d'une ou plusieurs catégories lors de la création d'une couche de pictogrammes (merci à @robLittiere et à @ArmelVidali pour la contribution <a href="https://github.com/riatelab/magrit/pull/106">contribution #106</a>).
Expand Down

0 comments on commit 8edbcf0

Please sign in to comment.