Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mapp.layer.styleParser() method #1132

Merged
merged 139 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
d541479
mapp.layer.themeStyle() method
dbauszus-glx Feb 13, 2024
8afb188
remove commented code
dbauszus-glx Feb 13, 2024
f354a14
don't use structural clone in cat.style assignment.
dbauszus-glx Feb 13, 2024
afc47a7
fix unsafe usage of optional chaining
dbauszus-glx Feb 13, 2024
44b0b53
move cat dcelaration out of for loop binding
dbauszus-glx Feb 13, 2024
d9b54f9
styleParser
dbauszus-glx Feb 14, 2024
d8bbf18
Merge branch 'main' into layer-themestyle
dbauszus-glx Feb 15, 2024
e2f8358
Merge branch 'main' into layer-themestyle
dbauszus-glx Mar 1, 2024
323bd64
mapview mask style expression
dbauszus-glx Mar 1, 2024
fb353a6
style parser in layer formats
dbauszus-glx Mar 4, 2024
506682f
Merge branch 'main' into layer-themestyle
dbauszus-glx Mar 4, 2024
6c1dfbd
styleparser location
dbauszus-glx Mar 4, 2024
70f7217
params.fields check and structured style clone
dbauszus-glx Mar 4, 2024
508d0ba
fields length fix for distributed themes
dbauszus-glx Mar 4, 2024
a2c1c7d
warnings method
dbauszus-glx Mar 4, 2024
7a7a9a6
fix for distributed theme switch
dbauszus-glx Mar 4, 2024
6e207dc
move setLabel & setHover to style panel
dbauszus-glx Mar 4, 2024
d92763b
parse style objects and assign defaults
dbauszus-glx Mar 4, 2024
d8a5e70
remove structured clone from theme
dbauszus-glx Mar 4, 2024
cf427c5
assign layer zIndex in addLayer
dbauszus-glx Mar 4, 2024
55ef101
Merge branch 'main' into layer-themestyle
dbauszus-glx Mar 4, 2024
f633d2f
move cluster style into pointStyle
dbauszus-glx Mar 5, 2024
9e3ae75
ammend cluster assignment and style clone
dbauszus-glx Mar 5, 2024
5fdc2bd
fix distributed style assignment
dbauszus-glx Mar 5, 2024
b149041
type icon fillColor assignment
dbauszus-glx Mar 5, 2024
3718932
fix mvt_clone label issue
dbauszus-glx Mar 5, 2024
b47e6be
remove geometry type lookup
dbauszus-glx Mar 7, 2024
8e897ce
fix for cluster scale
dbauszus-glx Mar 7, 2024
e4e0d48
fix for label style
dbauszus-glx Mar 7, 2024
974ebb7
fix for nullish label
dbauszus-glx Mar 7, 2024
8d56856
spread wkt/geojson properties
dbauszus-glx Mar 7, 2024
c7430a8
spread geojson / wkt properties
dbauszus-glx Mar 7, 2024
4667984
merge graduated theme fix
dbauszus-glx Mar 7, 2024
bb4799e
remove property warning
dbauszus-glx Mar 7, 2024
0c29bda
Update console warning to be expliit on how to fix
simon-leech Mar 12, 2024
d0be087
For testing purposes - added console log
simon-leech Mar 12, 2024
4bc8828
cluster icon style
dbauszus-glx Mar 12, 2024
7dd6eb4
cat style icons
dbauszus-glx Mar 12, 2024
15bb207
Merge branch 'main' into layer-themestyle
dbauszus-glx Mar 12, 2024
ed0f311
add chk for graduated
dbauszus-glx Mar 12, 2024
83eeedf
Graduated Theme docs
RobAndrewHurst Mar 13, 2024
a2d6e01
Vector docs
RobAndrewHurst Mar 13, 2024
427314b
Docs
RobAndrewHurst Mar 13, 2024
4de9962
Feature Style
RobAndrewHurst Mar 14, 2024
304bca9
Layer featureFilter docs
RobAndrewHurst Mar 14, 2024
6237672
Layer styleParse docs
RobAndrewHurst Mar 14, 2024
19f8db4
do not merge selected style
dbauszus-glx Mar 15, 2024
a49a530
Merge branch 'main' into pr/dbauszus-glx/1132
RobAndrewHurst Mar 18, 2024
c36485f
theme categories array
dbauszus-glx Mar 18, 2024
93d320c
theme categories array
dbauszus-glx Mar 18, 2024
8108b48
styleParser from entry methods
dbauszus-glx Mar 18, 2024
b446c03
Merge branch 'main' into layer-themestyle
dbauszus-glx Mar 19, 2024
f21c786
Merge branch 'main' into layer-themestyle
dbauszus-glx Mar 20, 2024
8ae68a4
Merge branch 'main' into layer-themestyle
dbauszus-glx Mar 21, 2024
21b89ae
Merge branch 'main' into layer-themestyle
dbauszus-glx Mar 21, 2024
3a5e606
Merge branch 'main' into layer-themestyle
dbauszus-glx Mar 21, 2024
5135380
Merge branch 'main' into pr/dbauszus-glx/1132
RobAndrewHurst Mar 22, 2024
5df8a0b
Merge branch 'main' into pr/dbauszus-glx/1132
RobAndrewHurst Mar 22, 2024
53804b9
remove structured clone from default and cluster assignment.
dbauszus-glx Mar 25, 2024
46e43da
add locations.selected condition
dbauszus-glx Mar 25, 2024
5e103d9
Merge branch 'main' into layer-themestyle
dbauszus-glx Mar 26, 2024
c2346ba
Merge branch 'main' into pr/dbauszus-glx/1132
RobAndrewHurst Mar 26, 2024
3b0c59f
undefined distributed style; spread selected style
dbauszus-glx Mar 26, 2024
ef7672a
format url for legendIcon inlineStyle
dbauszus-glx Mar 26, 2024
2ef2e98
format inline style legendicon
dbauszus-glx Mar 26, 2024
19ee81d
assign default style before theme style
dbauszus-glx Mar 26, 2024
98b42e1
graduated breaks
dbauszus-glx Mar 27, 2024
e72e697
remove locations.selected check
dbauszus-glx Mar 27, 2024
9657187
Merge branch 'main' into layer-themestyle
dbauszus-glx Mar 27, 2024
493a919
change utils.style.mjs to olStyle.mjs
dbauszus-glx Mar 28, 2024
aa18487
warning for re using an svg, 'union' on sets is not widely supported
AlexanderGeere Apr 9, 2024
5b9f0e6
Sonar cloud intentionality fix
AlexanderGeere Apr 9, 2024
56ef435
remove the warning for now
AlexanderGeere Apr 9, 2024
7709b67
Merge branch 'main' into pr/1132
simon-leech Apr 9, 2024
8e08d06
Testing Legend Issue
simon-leech Apr 9, 2024
53588dd
Revert "Testing Legend Issue"
simon-leech Apr 11, 2024
105691d
Merge branch 'main' into pr/1132
simon-leech Apr 11, 2024
58f1eab
Merge branch 'main' into pr/dbauszus-glx/1132
RobAndrewHurst Apr 15, 2024
790eea3
Initial tests
RobAndrewHurst Apr 15, 2024
c8f379d
Update styleParse Tests
RobAndrewHurst Apr 15, 2024
b71d2ea
Update actions
RobAndrewHurst Apr 15, 2024
0c19940
Graduated theme with greater than breaks test
RobAndrewHurst Apr 15, 2024
483e0b1
Depricated hover method handling
RobAndrewHurst Apr 15, 2024
f37df5d
Deprecated style hover test
RobAndrewHurst Apr 16, 2024
55550e4
Remove test
RobAndrewHurst Apr 16, 2024
32f377d
Update styleParser.mjs
simon-leech Apr 16, 2024
0f69eb1
add evalIconObject
dbauszus-glx Apr 17, 2024
e2a929b
Add layer key to the warning for easier debugging
simon-leech Apr 18, 2024
20fa5eb
MVT Clone and Vector Layers need a key or the warning shows undefined
simon-leech Apr 18, 2024
c672f6b
Merge branch 'main' into layer-themestyle
dbauszus-glx Apr 18, 2024
adda4c7
fix for mvt_clone and vector_layer zindex
dbauszus-glx Apr 18, 2024
7cfac2b
Remove styling in decorate module
RobAndrewHurst Apr 19, 2024
f302588
Fix for icon object in style parser.
dbauszus-glx Apr 19, 2024
04bdf9a
clusterScale assignment
dbauszus-glx Apr 19, 2024
ec0ba9c
Merge branch 'main' into layer-themestyle
dbauszus-glx Apr 22, 2024
a1da549
Merge branch 'main' into layer-themestyle
dbauszus-glx Apr 24, 2024
9689fbb
Merge branch 'main' into layer-themestyle
dbauszus-glx Apr 24, 2024
d7a59d0
basic theme
dbauszus-glx Apr 26, 2024
b0a6dff
use spread for basic theme legendicon
dbauszus-glx Apr 26, 2024
431065f
style default.style
dbauszus-glx Apr 29, 2024
a38503b
image load state
dbauszus-glx Apr 29, 2024
f6509e7
remove image load
dbauszus-glx Apr 29, 2024
2181ac4
style width and height default assignment in legendicon
dbauszus-glx Apr 30, 2024
8ccc82b
check on icon object
dbauszus-glx Apr 30, 2024
bb51571
cluster icon
dbauszus-glx Apr 30, 2024
942d16e
Merge branch 'main' into layer-themestyle
dbauszus-glx Apr 30, 2024
7f5b8bf
Minor Tweaks
simon-leech May 1, 2024
ea38657
Sonarcloud fix
simon-leech May 1, 2024
e2b0176
Update styleParser.mjs
simon-leech May 1, 2024
396557d
Fix Check
simon-leech May 1, 2024
519fad1
Update warning to be explicit on what can be provided
simon-leech May 1, 2024
02c2502
Remove cluster distance check as going into a different PR
simon-leech May 1, 2024
f2af842
cluster default icon
dbauszus-glx May 1, 2024
b73c08f
Merge branch 'main' into layer-themestyle
dbauszus-glx May 1, 2024
0dc9d39
cluster style count
dbauszus-glx May 1, 2024
3340e1d
maplibre z-index
dbauszus-glx May 1, 2024
8beddef
fix for loader image loader
dbauszus-glx May 2, 2024
a2d0908
docs logs
dbauszus-glx May 2, 2024
e42a3a1
legendIcon node
dbauszus-glx May 2, 2024
8bdeebe
Merge branch 'main' into layer-themestyle
dbauszus-glx May 3, 2024
65aa9c7
Merge branch 'main' into layer-themestyle
dbauszus-glx May 7, 2024
42292ca
Merge branch 'main' into layer-themestyle
dbauszus-glx May 8, 2024
fc16673
inputfilter
dbauszus-glx May 8, 2024
aec2fdc
icon objects in default styles
dbauszus-glx May 10, 2024
23f1aaf
create clusterChecks method from warnings.
dbauszus-glx May 10, 2024
7a92ad0
Merge branch 'main' into pr/1132
simon-leech May 15, 2024
da536ea
mapp.layer.Style warning
dbauszus-glx May 16, 2024
348fd3c
Merge branch 'main' into pr/dbauszus-glx/1132
RobAndrewHurst May 20, 2024
63e6994
default icon
dbauszus-glx May 21, 2024
fecf875
defaultStyle.icon assignment
dbauszus-glx May 21, 2024
a4d432b
comment and remove return
dbauszus-glx May 21, 2024
9565b3e
create a mergeStyle from valid styleKeys
dbauszus-glx May 23, 2024
4bed91d
Assign default style to the theme.style
dbauszus-glx May 24, 2024
0c97447
Merge branch 'main' into layer-themestyle
dbauszus-glx Jun 6, 2024
621f73e
remove layer key from vector_layer
dbauszus-glx Jun 6, 2024
09640bd
Merge branch 'main' into layer-themestyle
simon-leech Jun 8, 2024
76c3a21
If cluster.label is id - remove it
simon-leech Jun 12, 2024
e70c3db
Revert "If cluster.label is id - remove it"
simon-leech Jun 12, 2024
aef0479
Merge branch 'main' into layer-themestyle
dbauszus-glx Jun 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: '18'

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
**v4.8.8**

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
![example workflow](https://github.com/GEOLYTIX/xyz/actions/workflows/unit_tests.yml/badge.svg)
![Codi Unit Tests](https://github.com/GEOLYTIX/xyz/actions/workflows/unit_tests.yml/badge.svg)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=GEOLYTIX_xyz&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=GEOLYTIX_xyz)

**Open source presentation, controller, domain and service layers for cloud native spatial data and application interfaces.**
Expand Down
207 changes: 0 additions & 207 deletions lib/layer/Style.mjs

This file was deleted.

53 changes: 39 additions & 14 deletions lib/layer/_layer.mjs
Original file line number Diff line number Diff line change
@@ -1,23 +1,45 @@
/**
## mapp.layer{}
The module export methods to decorate layer objects.

This module exports methods to decorate layer objects.
@module /layer
*/
*/

import decorate from './decorate.mjs'
import decorate from './decorate.mjs';
import formats from './format/_format.mjs';
import fade from './fade.mjs'
import fade from './fade.mjs';
import changeEnd from './changeEnd.mjs'
import featureHover from './featureHover.mjs'
import featureFilter from './featureFilter.mjs'
import * as featureFormats from './featureFormats.mjs'
import * as featureFields from './featureFields.mjs'
import Style from './Style.mjs'
import categorized from './themes/categorized.mjs'
import distributed from './themes/distributed.mjs'
import graduated from './themes/graduated.mjs'
import featureHover from './featureHover.mjs';
import featureFilter from './featureFilter.mjs';
import * as featureFormats from './featureFormats.mjs';
import * as featureFields from './featureFields.mjs';
import featureStyle from './featureStyle.mjs';
import styleParser from './styleParser.mjs';
const Style = layer => {
console.warn(`The mapp.layer.Style() method has been superseeded by the mapp.layer.featureStyle() method.`)
return featureStyle(layer)
}
import basic from './themes/basic.mjs';
import categorized from './themes/categorized.mjs';
import distributed from './themes/distributed.mjs';
import graduated from './themes/graduated.mjs';

/**
@function layer
@property {function} decorate - A function to decorate layer objects.
@property {function} changeEnd - A function to add the changeEnd event.
@property {Object} formats - An object containing layer format modules.
@property {Object} featureFormats - An object containing feature format modules.
@property {Object} featureFields - An object containing feature field modules.
@property {function} featureHover - A function to handle feature hover interactions.
@property {function} featureFilter - A function to filter features.
@property {function} featureStyle - A function to style features.
@property {function} fade - A function to apply fade effects to layers.
@property {function} styleParser - A function to parse layer styles.
@property {Object} themes - An object containing theme modules.
@property {function} themes.categorized - A function to apply a categorized theme to features.
@property {function} themes.distributed - A function to apply a distributed theme to features.
@property {function} themes.graduated - A function to apply a graduated theme to features.
*/
export default {
decorate,
changeEnd,
Expand All @@ -26,11 +48,14 @@ export default {
featureFields,
featureHover,
featureFilter,
featureStyle,
fade,
styleParser,
Style,
themes: {
basic,
categorized,
distributed,
graduated
}
}
};
55 changes: 0 additions & 55 deletions lib/layer/decorate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -125,61 +125,6 @@ export default async function decorate(layer) {
// Set layer opacity from style.
layer.L.setOpacity(layer.style?.opacity || 1);

// Handle deprecated layer.style.hover and layer.style.hovers.
if (layer.style?.hovers && layer.style?.hover) {
console.warn(`Layer: ${layer.key}, cannot use both layer.style.hover and layer.style.hovers. Layer.style.hover has been deleted.`);
delete layer.style.hover;
}

// Handle deprecated layer.style.label and layer.style.labels.
if (layer.style?.labels && layer.style?.label) {
console.warn(`Layer: ${layer.key}, cannot use both layer.style.label and layer.style.labels. Layer.style.label has been deleted.`);
delete layer.style.label;
}

// Handle multiple themes in layer style.
if (layer.style?.themes) {
Object.keys(layer.style.themes).forEach(key => {
layer.style.themes[key].title ??= key;
if (layer.style.themes[key].skip) delete layer.style.themes[key];
});
layer.style.theme = typeof layer.style.theme === 'object'
? layer.style.theme
: layer.style.themes[layer.style.theme || Object.keys(layer.style.themes)[0]];
}

// Handle setLabel and labels in layer style.
if (layer.style?.theme?.setLabel && layer.style?.labels) {
layer.style.label = layer.style.labels[layer.style.theme.setLabel];
}

// Handle deprecated layer.hover configuration.
if (layer.hover) {
console.warn(`Layer: ${layer.key}, layer.hover{} should be defined within layer.style{}.`);
layer.style.hover = layer.hover;
delete layer.hover;
}

// Handle setHover and hovers in layer style.
if (layer.style?.theme?.setHover && layer.style?.hovers) {
layer.style.hover = layer.style.hovers[layer.style.theme.setHover];
}

// Handle multiple hovers in layer style.
if (layer.style?.hovers) {
layer.style.hover = typeof layer.style.hover === 'object' ? layer.style.hover : layer.style.hovers[layer.style.hover || Object.keys(layer.style.hovers)[0]];
}

// Set default featureHover method if not provided.
if (layer.style?.hover) {
layer.style.hover.method ??= mapp.layer.featureHover;
}

// Handle multiple labels in layer style.
if (layer.style?.labels) {
layer.style.label = typeof layer.style.label === 'object' ? layer.style.label : layer.style.labels[layer.style.label || Object.keys(layer.style.labels)[0]];
}

// Call layer and/or plugin methods.
Object.keys(layer).forEach((key) => {
typeof mapp.layer[key] === 'function' && mapp.layer[key]?.(layer);
Expand Down
6 changes: 3 additions & 3 deletions lib/layer/featureFields.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ featureFields.process(layer) will process the fields required for a theme and re
export function process(layer) {

// Check if the distribution method is defined in the distribution object.
if (Object.hasOwnProperty(distribution, layer.style?.theme?.distribution)) {
if (Object.hasOwn(distribution, layer.style?.theme?.distribution)) {

// Call the corresponding distribution function.
distribution[layer.style.theme.distribution](layer);
Expand Down Expand Up @@ -71,7 +71,7 @@ The cat values will be updated to represented the natural breaks before the laye
function jenks(layer) {
let theme = layer.style.theme;

let n = Math.min(layer.featureFields[theme.field].values.length, theme.cat_arr.length);
let n = Math.min(layer.featureFields[theme.field].values.length, theme.categories.length);

// Parse array values as float.
layer.featureFields[theme.field].values = layer.featureFields[theme.field].values.map(parseFloat);
Expand All @@ -82,7 +82,7 @@ function jenks(layer) {

let val;

theme.cat_arr.forEach((cat, i) => {
theme.categories.forEach((cat, i) => {
val = val === layer.featureFields[theme.field].jenks[i] ? undefined : layer.featureFields[theme.field].jenks[i];
cat.value = val;
});
Expand Down
Loading
Loading