Skip to content

Commit

Permalink
Fix #9651 better handling of geometry transformation in annotation st…
Browse files Browse the repository at this point in the history
…yler (#9661)
  • Loading branch information
MV88 authored Oct 27, 2023
1 parent 40b2c88 commit 6096213
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions web/client/plugins/Annotations/components/FeaturesEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,15 @@ const historyCollectionReducer = undoable(reducer, {

const DEFAULT_VALUE = {};

function parseBlocks({ symbolizerBlock, ruleBlock }) {

/**
* it overrides default styler config in order to customize certain blocks
* that in turn will make UI to change accordingly
* @param {object} symbolizerBlock the symbolyzer block
* @param {object} ruleBlock the rule block
* @param {object} selected the features annotation selected
*/
function parseBlocks({ symbolizerBlock, ruleBlock}, selected) {
return {
symbolizerBlock: Object.keys(symbolizerBlock)
.reduce((config, kind) => ({
Expand All @@ -69,15 +77,19 @@ function parseBlocks({ symbolizerBlock, ruleBlock }) {
params: Object.keys(symbolizerBlock[kind].params)
.reduce((acc, key) => {
const value = symbolizerBlock[kind].params[key];
if (['Circle'].includes(kind) && ['geodesic', 'radius', 'msClampToGround'].includes(key)) {
if (['Circle'].includes(kind) && ['geodesic', 'radius', 'msClampToGround', "msGeometry"].includes(key)) {
return acc;
}
if (['Text'].includes(kind) && ['label'].includes(key)) {
if (['Text'].includes(kind) && ['label', "msGeometry"].includes(key)) {
return acc;
}
if (['Line', 'Fill'].includes(kind) && ['msGeometry'].includes(key)) {
return acc;
}
// check selected annotation type
if (['Point', "Circle"].includes(selected?.properties?.annotationType) && ['msGeometry'].includes(key)) {
return acc;
}
return {
...acc,
[key]: value
Expand Down Expand Up @@ -129,10 +141,13 @@ export function FeaturesEditor({
const [collectionHistory, dispatch] = useReducer(historyCollectionReducer, { present: value, past: [], future: [] });
const collection = collectionHistory?.present || collectionHistory || DEFAULT_VALUE;
const selected = (collection?.features || []).find((feature) => feature?.id === selectedId);
const { symbolizerBlock, ruleBlock } = parseBlocks(getBlocks({
exactMatchGeometrySymbol: true,
enable3dStyleOptions
}));
const { symbolizerBlock, ruleBlock } = parseBlocks(
getBlocks({
exactMatchGeometrySymbol: true,
enable3dStyleOptions
}),
selected
);

const MapInteractionsSupport = mapInteractionsSupport;

Expand Down

0 comments on commit 6096213

Please sign in to comment.