diff --git a/lib/layer/format/mvt.mjs b/lib/layer/format/mvt.mjs index fafb24d2d..f869763c8 100644 --- a/lib/layer/format/mvt.mjs +++ b/lib/layer/format/mvt.mjs @@ -201,6 +201,7 @@ function tileUrlFunction(layer) { // Create a set of feature properties for styling. layer.params.fields = [...new Set([ + layer.params.default_fields, Array.isArray(layer.style.theme?.fields) ? layer.style.theme.fields : layer.style.theme?.field, layer.style.theme?.field, @@ -265,10 +266,11 @@ function changeEndLoad(layer) { // Create a set of feature properties for styling. layer.params.fields = [...new Set([ + layer.params.default_fields, Array.isArray(layer.style.theme?.fields) ? layer.style.theme.fields : layer.style.theme?.field, layer.style.theme?.field, - layer.style.label?.field + layer.style.label?.field, ].flat().filter(field => !!field))] const bounds = layer.mapview.getBounds() diff --git a/lib/layer/format/vector.mjs b/lib/layer/format/vector.mjs index 65a42b1aa..420590329 100644 --- a/lib/layer/format/vector.mjs +++ b/lib/layer/format/vector.mjs @@ -78,11 +78,12 @@ export default layer => { // Create a set of feature properties for styling. layer.params.fields = [...new Set([ + layer.params.default_fields, Array.isArray(layer.style.theme?.fields) ? layer.style.theme.fields : layer.style.theme?.field, layer.style.theme?.field, layer.style.label?.field, - layer.cluster?.label + layer.cluster?.label, ].flat().filter(field => !!field))] diff --git a/lib/location/decorate.mjs b/lib/location/decorate.mjs index a3ff23a1c..4716919af 100644 --- a/lib/location/decorate.mjs +++ b/lib/location/decorate.mjs @@ -115,7 +115,7 @@ async function syncFields(fields) { // Return if response is falsy or error. if (!response || response instanceof Error) { - console.warn('No data returned from location_get request.') + console.warn('No data returned from location_get request using ID:', this.id) return } // Check if the response is an array. diff --git a/lib/location/get.mjs b/lib/location/get.mjs index efa2717b9..86b061b2b 100644 --- a/lib/location/get.mjs +++ b/lib/location/get.mjs @@ -87,7 +87,7 @@ export async function getInfoj(location) { // Check if the response is empty. if (!response || response instanceof Error) { - console.warn('No data returned from location_get request.') + console.warn('No data returned from location_get request using ID:', location.id) return } // Check if the response is an array. diff --git a/lib/ui/elements/slider.mjs b/lib/ui/elements/slider.mjs index 4a2d823d9..dfb5ab540 100644 --- a/lib/ui/elements/slider.mjs +++ b/lib/ui/elements/slider.mjs @@ -38,10 +38,13 @@ export default params => { const group = e.target.closest('.input-range') if (val > params.max) { + val = params.max; group.style.setProperty(`--max`, val) group.querySelectorAll('input').forEach(el => el.max = val) } + e.target.value = val; + group.style.setProperty(`--${e.target.dataset.id}`, val) group.querySelectorAll('input') diff --git a/lib/ui/locations/infoj.mjs b/lib/ui/locations/infoj.mjs index af71076a4..678894b0b 100644 --- a/lib/ui/locations/infoj.mjs +++ b/lib/ui/locations/infoj.mjs @@ -141,8 +141,15 @@ export default (location, infoj) => { .xhr(`${entry.host || entry.location?.layer?.mapview?.host || mapp.host}/api/query?${paramString}`) .then(response => { - // Assign query response as entry value. - entry.value = entry.field? response[entry.field] :response; + if (response) { + + // Assign query response as entry value. + entry.value = entry.field ? response[entry.field] : response; + + } else { + + entry.value = entry.nullValue + } // Check whether entry should be skipped. if (skipEntry(entry)) { diff --git a/lib/utils/queryParams.mjs b/lib/utils/queryParams.mjs index 16223bca7..942876836 100644 --- a/lib/utils/queryParams.mjs +++ b/lib/utils/queryParams.mjs @@ -47,6 +47,9 @@ export default _this => { // ID will be taken if a location object is provided with the params. id: _this.queryparams.id ? _this.location?.id : undefined, + // qID will be taken if a location object is provided with the params. + qID: _this.queryparams.qID ? _this.location?.layer?.qID : undefined, + // Email will be taken if a location object is provided with the params. email: _this.queryparams.email ? mapp.user.email : undefined, diff --git a/mod/workspace/templates/_queries.js b/mod/workspace/templates/_queries.js index 19f03a927..e730b4dea 100644 --- a/mod/workspace/templates/_queries.js +++ b/mod/workspace/templates/_queries.js @@ -45,6 +45,15 @@ module.exports = { layer_extent: { template: require('./layer_extent'), }, + st_intersects_ab: { + template: require('./st_intersects_ab'), + }, + st_distance_ab: { + template: require('./st_distance_ab'), + }, + st_distance_ab_multiple: { + template: require('./st_distance_ab_multiple'), + }, location_get: { render: require('./location_get'), }, diff --git a/mod/workspace/templates/st_distance_ab.js b/mod/workspace/templates/st_distance_ab.js new file mode 100644 index 000000000..8b0eea0d2 --- /dev/null +++ b/mod/workspace/templates/st_distance_ab.js @@ -0,0 +1,15 @@ +module.exports = ` +SELECT + ST_DISTANCE(st_transform(a.\${geom},4326)::geography, closest.geom ) AS dist +FROM + \${table} a +LEFT JOIN LATERAL ( + SELECT + st_transform(b.\${geom_b},4326)::geography as geom + FROM \${table_b} b + ORDER BY st_transform(b.\${geom_b},4326)::geography <-> st_transform(a.\${geom},4326)::geography + LIMIT 1 +) closest +on true +WHERE a.\${qID} = %{id} +` \ No newline at end of file diff --git a/mod/workspace/templates/st_distance_ab_multiple.js b/mod/workspace/templates/st_distance_ab_multiple.js new file mode 100644 index 000000000..410e75efd --- /dev/null +++ b/mod/workspace/templates/st_distance_ab_multiple.js @@ -0,0 +1,17 @@ +module.exports = ` +SELECT + closest.field_b AS \${as}, + ST_DISTANCE(st_transform(a.\${geom},4326)::geography, closest.geom ) AS dist +FROM + \${table} a +LEFT JOIN LATERAL ( + SELECT + b.\${field_b} as field_b, + st_transform(b.\${geom_b},4326)::geography as geom + FROM \${table_b} b + ORDER BY st_transform(b.\${geom_b},4326)::geography <-> st_transform(a.\${geom},4326)::geography + LIMIT \${limit} +) closest +on true +WHERE a.\${qID} = %{id} +` \ No newline at end of file diff --git a/mod/workspace/templates/st_intersects_ab.js b/mod/workspace/templates/st_intersects_ab.js new file mode 100644 index 000000000..8de7283c5 --- /dev/null +++ b/mod/workspace/templates/st_intersects_ab.js @@ -0,0 +1,10 @@ +module.exports = ` +SELECT + b.\${field_b} AS \${as} +FROM + \${table} a +LEFT JOIN + \${table_b} b +ON ST_INTERSECTS(a.\${geom}, b.\${geom_b}) +WHERE a.\${qID} = %{id} +` \ No newline at end of file