Skip to content

Commit

Permalink
Merge branch 'main' into mvt-query
Browse files Browse the repository at this point in the history
  • Loading branch information
dbauszus-glx committed Nov 22, 2023
2 parents e4346a1 + dc22e27 commit f435b4a
Show file tree
Hide file tree
Showing 16 changed files with 321 additions and 236 deletions.
41 changes: 40 additions & 1 deletion lib/layer/decorate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,35 @@ export default async layer => {
layer.draw?.defaults || {}))
})

// Check whether feature is loaded on MVT update.
if (layer.format === 'mvt') {

layer.features = []

// Concat layer.features array with features from tileloadend
layer.source.on('tileloadend', concatFeatures);

function concatFeatures(e) {

layer.features = layer.features.concat(e.tile.getFeatures())
}

setTimeout(checkFeature, 1000)

function checkFeature() {

let found = layer.features?.find(F => F.properties?.id === location.id)

if (found) {

layer.source.un('tileloadend', concatFeatures);
} else {

layer.reload()
}
}
}

// Layer must be reloaded to reflect geometry changes.
layer.reload()

Expand Down Expand Up @@ -92,8 +121,18 @@ export default async layer => {
// Layer style has multiple themes.
if (layer.style?.themes) {

Object.keys(layer.style.themes).forEach(key => {

// Assign theme key as title if undefined.
layer.style.themes[key].title ??= key

if (layer.style.themes[key].skip) delete layer.style.themes[key]
})

// Keep object theme.
layer.style.theme = typeof layer.style.theme === 'object' ? layer.style.theme
layer.style.theme = typeof layer.style.theme === 'object'

? layer.style.theme

// Assign theme from key [string], or first theme.
: layer.style.themes[layer.style.theme || Object.keys(layer.style.themes)[0]];
Expand Down
2 changes: 1 addition & 1 deletion lib/layer/format/mvt.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default layer => {

layer.reload = () => {

//layer.source.clear()
layer.source.clear()
layer.source.refresh()
layer.tilesLoaded = []
layer.featureSource.refresh()
Expand Down
1 change: 1 addition & 0 deletions lib/ui/layers/panels/style.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ export default layer => {

// Add theme control
if (Object.keys(layer.style.themes || 0).length > 1) {

content.push(mapp.utils.html`
<div>${mapp.dictionary.layer_style_select_theme}</div>
${mapp.ui.elements.dropdown({
Expand Down
7 changes: 3 additions & 4 deletions mod/utils/merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,20 @@ module.exports = function mergeDeep(target, ...sources) {
// Call recursive merge for target key object.
Object.hasOwn(target, key) && mergeDeep(target[key], source[key]);

// Target and Source are both arrays.
// Target and Source are both arrays.
} else if (Array.isArray(source[key]) && Array.isArray(target[key])) {


// Target and Source arrays are equal.
if (source[key].every(item => target[key].includes(item))) {

// Do not merge.
target[key] = source[key]

} else {

// Merge unequal arrays.

target[key] = [...target[key]||[], ...source[key]]
target[key] = [...target[key] || [], ...source[key]]
}

} else {
Expand Down
32 changes: 17 additions & 15 deletions mod/workspace/getLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ module.exports = async (params) => {

const locale = await getLocale(params)

if (locale instanceof Error) {

return locale
}
if (locale instanceof Error) return locale

const roles = params.user?.roles || []

Expand All @@ -35,31 +32,36 @@ module.exports = async (params) => {

let layer = locale.layers[params.layer]

// Return already merged layer.
if (layer.merged) return layer

// Assign key value as key on layer object.
layer.key ??= params.layer

// Merge layer --> template
if (Object.hasOwn(workspace.templates, layer.template || layer.key)) {

// Merge the workspace template into the layer.
layer = merge(await getTemplate(workspace.templates[layer.template || layer.key]), layer)
}
let template = structuredClone(await getTemplate(workspace.templates[layer.template || layer.key]))

if (Array.isArray(layer.templates)) for (const key of layer.templates){

let template = Object.hasOwn(workspace.templates, key) && await getTemplate(workspace.templates[key])

// Merge the workspace template into the layer.
layer = merge(template, layer)
layer = merge(template, layer)
}

// Check for layer geom[s].
if ((layer.table || layer.tables) && (!layer.geom && !layer.geoms)) {
// Merge templates --> layer
for (const key of layer.templates || []){

if (!Object.hasOwn(workspace.templates, key)) continue;

console.warn(`Layer: ${layer.key},has a table or tables defined, but no geom or geoms.`)
let template = structuredClone(await getTemplate(workspace.templates[key]))

// Merge the workspace template into the layer.
layer = merge(layer, template)
}

// Assign layer key as name with no existing name on layer object.
layer.name ??= layer.key

layer.merged = true

return layer
}
4 changes: 3 additions & 1 deletion mod/workspace/getLocale.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ module.exports = async (params) => {
// A template exists for the locale key.
if (Object.hasOwn(workspace.templates, params.locale)) {

let template = structuredClone(await getTemplate(workspace.templates[params.locale]))

// Merge the workspace template into workspace.
locale = merge(await getTemplate(workspace.templates[params.locale]), locale)
locale = merge(template, locale)
}

return locale
Expand Down
8 changes: 4 additions & 4 deletions public/css/_button.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ button {

&.flat {
border-radius: 3px;
border-bottom: 1px solid var(--color-lighter);
border-bottom: 1px solid var(--color-light-secondary);
padding: 0.3em;

&.active {
Expand All @@ -44,8 +44,8 @@ button {

&.raised {
border-radius: 3px;
border: 1px solid var(--color-lighter);
box-shadow: 1px 1px 2px var(--color-lighter);
border: 1px solid var(--color-light-secondary);
box-shadow: 1px 1px 2px var(--color-light-secondary);
padding: 0.3em;

&.active {
Expand Down Expand Up @@ -92,7 +92,7 @@ button {
width: 100%;
padding: 0.3em 0.5em;
background-color: white;
border: 1px solid var(--color-lighter);
border: 1px solid var(--color-light-secondary);
border-radius: 3px;
box-shadow: 1px 1px 3px var(--color-primary-light);

Expand Down
8 changes: 6 additions & 2 deletions public/css/_colours.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@

--color-primary-light: #939faa;

--color-light: #E9E3DD;
--color-light: #ffffff;

--color-lighter: #D5E1E6;
--color-light-secondary: #f2f2f2;

--color-light-tertiary: #fafafa;

--color-mid: #e3e3e3;

--color-on: #E18335;

Expand Down
6 changes: 3 additions & 3 deletions public/css/_drawer.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

.drawer {
padding: 5px;
background-color: white;
background-color: var(--color-light-tertiary);

&.expandable:not(.empty)>.header:hover {
cursor: pointer;
Expand Down Expand Up @@ -70,13 +70,13 @@

&.flat {
border-radius: 2px;
border: 1px solid var(--color-lighter);
border: 1px solid var(--color-light-secondary);
}

&.raised {
border-radius: 2px;
box-shadow: 1px 1px 3px var(--color-primary-light);
border: 1px solid var(--color-lighter);
border: 1px solid var(--color-light-secondary);
}

&.raised.empty {
Expand Down
2 changes: 1 addition & 1 deletion public/css/_inputs.css
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ label.checkbox {
}

&>li.selected {
background-color: var(--color-lighter);
background-color: var(--color-light-secondary);
}

& .label {
Expand Down
17 changes: 17 additions & 0 deletions public/css/_layerview.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,21 @@
padding-left: 4px;
padding-right: 4px;
}
}

#layers>.drawer.layer-group .drawer.layer-view {
background: var(--color-light);
border: none;
box-shadow: none;
border-top: 2px solid var(--color-light-secondary);
}

#layers>.layer-view>.drawer,
#layers .drawer.layer-view .drawer {
border: none;
box-shadow: none;
}

#layers>.layer-view>.drawer {
background: var(--color-light);
}
6 changes: 4 additions & 2 deletions public/css/_locationview.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
grid-template-columns: 1fr 1fr;

& pre {
background-color: var(--color-lighter);
background-color: var(--color-light-secondary);
}

& .contents {
Expand Down Expand Up @@ -67,7 +67,9 @@
cursor: help;
border-radius: 2px;
font-weight: bold;
background-color: var(--color-light);
font-size: 0.8em;
color: black;
background-color: var(--color-mid);
}
}

Expand Down
2 changes: 1 addition & 1 deletion public/css/_tabview.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
height: 50px;
overflow-x: auto;
display: flex;
background-color: var(--color-light);
background-color: var(--color-light-secondary);

& > .tab > .header {
height: 100%;
Expand Down
2 changes: 1 addition & 1 deletion public/css/_ui.css
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
}

.lighter-background {
background-color: var(--color-lighter);
background-color: var(--color-light-secondary);
}

.off-black {
Expand Down
5 changes: 3 additions & 2 deletions public/css/mapp.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
--color-off-black: #3f3f3f;
--color-primary: #003D57;
--color-primary-light: #939faa;
--color-light: #E9E3DD;
--color-lighter: #D5E1E6;
--color-light: #ffffff;
--color-light-secondary: #f2f2f2;
--color-light-tertiary: #fafafa;
--color-on: #E18335;
--color-no: #A21309;
}
Expand Down
Loading

0 comments on commit f435b4a

Please sign in to comment.