diff --git a/configure/src/core/utils.js b/configure/src/core/utils.js index 5fad6be4..a53b2bd7 100644 --- a/configure/src/core/utils.js +++ b/configure/src/core/utils.js @@ -1,5 +1,9 @@ import { saveAs } from "file-saver"; +// Positive ints only +export const isNumeric = (value) => { + return /^\d+$/.test(value); +}; /** * Traverses an object with an array of keys * @param {*} obj @@ -19,11 +23,15 @@ export const getIn = (obj, keyArray, notSetValue) => { return object; }; export const setIn = (obj, keyArray, value, force) => { + console.log("setIn", obj, keyArray, value, force); if (keyArray == null || keyArray.length === 0) return null; let object = obj; for (let i = 0; i < keyArray.length - 1; i++) { + console.log(obj, keyArray, keyArray[i], value, force); if (force) { - if (!object.hasOwnProperty(keyArray[i])) object[keyArray[i]] = {}; + if (!object.hasOwnProperty(keyArray[i])) + object[keyArray[i]] = + i === keyArray.length - 2 && isNumeric(keyArray[i + 1]) ? [] : {}; object = object[keyArray[i]]; } else { if (object.hasOwnProperty(keyArray[i])) object = object[keyArray[i]]; @@ -32,6 +40,7 @@ export const setIn = (obj, keyArray, value, force) => { } object[keyArray[keyArray.length - 1]] = value; }; + export const traverseLayers = (layers, onLayer) => { depthTraversal(layers, 0, []); function depthTraversal(node, depth, path) { diff --git a/configure/src/metaconfigs/layer-data-config.json b/configure/src/metaconfigs/layer-data-config.json index 7122f68b..f230cc72 100644 --- a/configure/src/metaconfigs/layer-data-config.json +++ b/configure/src/metaconfigs/layer-data-config.json @@ -384,46 +384,45 @@ { "name": "Information", "subname": "Layer Tags", - "subdescription": "Assign tags to this layer so that they may be searched upon through the LayersTool.", + "subdescription": "Assign tags to this layer so that they may be searched upon through the LayersTool. A category may be specified with the following pattern: 'category:tag'", "components": [ { - "new": true, - "field": "variables.tags.0", + "field": "tags.0", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.1", + "field": "tags.1", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.2", + "field": "tags.2", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.3", + "field": "tags.3", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.4", + "field": "tags.4", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.5", + "field": "tags.5", "name": "Tag", "description": "", "type": "text", @@ -434,42 +433,42 @@ { "components": [ { - "field": "variables.tags.6", + "field": "tags.6", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.7", + "field": "tags.7", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.8", + "field": "tags.8", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.9", + "field": "tags.9", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.10", + "field": "tags.10", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.11", + "field": "tags.11", "name": "Tag", "description": "", "type": "text", diff --git a/configure/src/metaconfigs/layer-header-config.json b/configure/src/metaconfigs/layer-header-config.json index 466eb2c3..fbc54a42 100644 --- a/configure/src/metaconfigs/layer-header-config.json +++ b/configure/src/metaconfigs/layer-header-config.json @@ -39,46 +39,45 @@ { "name": "Information", "subname": "Layer Tags", - "subdescription": "Assign tags to this layer so that they may be searched upon through the LayersTool.", + "subdescription": "Assign tags to this layer so that they may be searched upon through the LayersTool. A category may be specified with the following pattern: 'category:tag'", "components": [ { - "new": true, - "field": "variables.tags.0", + "field": "tags.0", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.1", + "field": "tags.1", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.2", + "field": "tags.2", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.3", + "field": "tags.3", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.4", + "field": "tags.4", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.5", + "field": "tags.5", "name": "Tag", "description": "", "type": "text", @@ -89,42 +88,42 @@ { "components": [ { - "field": "variables.tags.6", + "field": "tags.6", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.7", + "field": "tags.7", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.8", + "field": "tags.8", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.9", + "field": "tags.9", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.10", + "field": "tags.10", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.11", + "field": "tags.11", "name": "Tag", "description": "", "type": "text", diff --git a/configure/src/metaconfigs/layer-model-config.json b/configure/src/metaconfigs/layer-model-config.json index 00f95758..51c16969 100644 --- a/configure/src/metaconfigs/layer-model-config.json +++ b/configure/src/metaconfigs/layer-model-config.json @@ -686,46 +686,45 @@ { "name": "Information", "subname": "Layer Tags", - "subdescription": "Assign tags to this layer so that they may be searched upon through the LayersTool.", + "subdescription": "Assign tags to this layer so that they may be searched upon through the LayersTool. A category may be specified with the following pattern: 'category:tag'", "components": [ { - "new": true, - "field": "variables.tags.0", + "field": "tags.0", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.1", + "field": "tags.1", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.2", + "field": "tags.2", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.3", + "field": "tags.3", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.4", + "field": "tags.4", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.5", + "field": "tags.5", "name": "Tag", "description": "", "type": "text", @@ -736,42 +735,42 @@ { "components": [ { - "field": "variables.tags.6", + "field": "tags.6", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.7", + "field": "tags.7", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.8", + "field": "tags.8", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.9", + "field": "tags.9", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.10", + "field": "tags.10", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.11", + "field": "tags.11", "name": "Tag", "description": "", "type": "text", diff --git a/configure/src/metaconfigs/layer-query-config.json b/configure/src/metaconfigs/layer-query-config.json index 0fcb3cce..b17e4e84 100644 --- a/configure/src/metaconfigs/layer-query-config.json +++ b/configure/src/metaconfigs/layer-query-config.json @@ -808,46 +808,45 @@ { "name": "Information", "subname": "Layer Tags", - "subdescription": "Assign tags to this layer so that they may be searched upon through the LayersTool.", + "subdescription": "Assign tags to this layer so that they may be searched upon through the LayersTool. A category may be specified with the following pattern: 'category:tag'", "components": [ { - "new": true, - "field": "variables.tags.0", + "field": "tags.0", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.1", + "field": "tags.1", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.2", + "field": "tags.2", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.3", + "field": "tags.3", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.4", + "field": "tags.4", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.5", + "field": "tags.5", "name": "Tag", "description": "", "type": "text", @@ -858,42 +857,42 @@ { "components": [ { - "field": "variables.tags.6", + "field": "tags.6", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.7", + "field": "tags.7", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.8", + "field": "tags.8", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.9", + "field": "tags.9", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.10", + "field": "tags.10", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.11", + "field": "tags.11", "name": "Tag", "description": "", "type": "text", diff --git a/configure/src/metaconfigs/layer-tile-config.json b/configure/src/metaconfigs/layer-tile-config.json index 4aedd115..e8f7c1b0 100644 --- a/configure/src/metaconfigs/layer-tile-config.json +++ b/configure/src/metaconfigs/layer-tile-config.json @@ -268,46 +268,45 @@ { "name": "Information", "subname": "Layer Tags", - "subdescription": "Assign tags to this layer so that they may be searched upon through the LayersTool.", + "subdescription": "Assign tags to this layer so that they may be searched upon through the LayersTool. A category may be specified with the following pattern: 'category:tag'", "components": [ { - "new": true, - "field": "variables.tags.0", + "field": "tags.0", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.1", + "field": "tags.1", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.2", + "field": "tags.2", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.3", + "field": "tags.3", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.4", + "field": "tags.4", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.5", + "field": "tags.5", "name": "Tag", "description": "", "type": "text", @@ -318,42 +317,42 @@ { "components": [ { - "field": "variables.tags.6", + "field": "tags.6", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.7", + "field": "tags.7", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.8", + "field": "tags.8", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.9", + "field": "tags.9", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.10", + "field": "tags.10", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.11", + "field": "tags.11", "name": "Tag", "description": "", "type": "text", diff --git a/configure/src/metaconfigs/layer-vector-config.json b/configure/src/metaconfigs/layer-vector-config.json index 51b42ceb..509c8605 100644 --- a/configure/src/metaconfigs/layer-vector-config.json +++ b/configure/src/metaconfigs/layer-vector-config.json @@ -683,46 +683,45 @@ { "name": "Information", "subname": "Layer Tags", - "subdescription": "Assign tags to this layer so that they may be searched upon through the LayersTool.", + "subdescription": "Assign tags to this layer so that they may be searched upon through the LayersTool. A category may be specified with the following pattern: 'category:tag'", "components": [ { - "new": true, - "field": "variables.tags.0", + "field": "tags.0", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.1", + "field": "tags.1", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.2", + "field": "tags.2", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.3", + "field": "tags.3", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.4", + "field": "tags.4", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.5", + "field": "tags.5", "name": "Tag", "description": "", "type": "text", @@ -733,42 +732,42 @@ { "components": [ { - "field": "variables.tags.6", + "field": "tags.6", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.7", + "field": "tags.7", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.8", + "field": "tags.8", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.9", + "field": "tags.9", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.10", + "field": "tags.10", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.11", + "field": "tags.11", "name": "Tag", "description": "", "type": "text", diff --git a/configure/src/metaconfigs/layer-vectortile-config.json b/configure/src/metaconfigs/layer-vectortile-config.json index 073035b9..695f9d49 100644 --- a/configure/src/metaconfigs/layer-vectortile-config.json +++ b/configure/src/metaconfigs/layer-vectortile-config.json @@ -703,46 +703,45 @@ { "name": "Information", "subname": "Layer Tags", - "subdescription": "Assign tags to this layer so that they may be searched upon through the LayersTool.", + "subdescription": "Assign tags to this layer so that they may be searched upon through the LayersTool. A category may be specified with the following pattern: 'category:tag'", "components": [ { - "new": true, - "field": "variables.tags.0", + "field": "tags.0", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.1", + "field": "tags.1", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.2", + "field": "tags.2", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.3", + "field": "tags.3", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.4", + "field": "tags.4", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.5", + "field": "tags.5", "name": "Tag", "description": "", "type": "text", @@ -753,42 +752,42 @@ { "components": [ { - "field": "variables.tags.6", + "field": "tags.6", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.7", + "field": "tags.7", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.8", + "field": "tags.8", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.9", + "field": "tags.9", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.10", + "field": "tags.10", "name": "Tag", "description": "", "type": "text", "width": 2 }, { - "field": "variables.tags.11", + "field": "tags.11", "name": "Tag", "description": "", "type": "text", diff --git a/src/essence/Basics/Layers_/LayerConstructors.js b/src/essence/Basics/Layers_/LayerConstructors.js index c9c7af3b..5ee5a8b1 100644 --- a/src/essence/Basics/Layers_/LayerConstructors.js +++ b/src/essence/Basics/Layers_/LayerConstructors.js @@ -243,7 +243,10 @@ export const constructVectorLayer = ( layerObj, 'variables.markerAttachments.bearing' ) - if (bearingVar) { + if ( + bearingVar && + (bearingVar.enabled === true || bearingVar.enabled == null) + ) { const unit = bearingVar.angleUnit || 'deg' const bearingProp = bearingVar.angleProp || false @@ -581,7 +584,10 @@ const labels = (geojson, layerObj, leafletLayerObject, layer, sublayers) => { //LABELS const labelsVar = F_.getIn(layerObj, 'variables.layerAttachments.labels') - if (labelsVar) { + if ( + labelsVar && + (labelsVar.enabled === true || labelsVar.enabled == null) + ) { let theme = ['solid'].includes(labelsVar.theme) ? labelsVar.theme : 'default' @@ -816,7 +822,10 @@ const pairings = (geojson, layerObj, leafletLayerObject) => { 'variables.layerAttachments.pairings' ) - if (pairingsVar) { + if ( + pairingsVar && + (pairingsVar.enabled === true || pairingsVar.enabled == null) + ) { const layers = (pairingsVar.layers || []).map((l) => L_.asLayerUUID(l)) const pairProp = pairingsVar.pairProp @@ -997,7 +1006,10 @@ const uncertaintyEllipses = (geojson, layerObj, leafletLayerObject) => { let clampedUncertaintyOptions let leafletLayerObjectUncertaintyEllipse - if (uncertaintyVar) { + if ( + uncertaintyVar && + (uncertaintyVar.enabled === true || uncertaintyVar.enabled == null) + ) { let existingOn = null let existingOpacity = uncertaintyVar.initialOpacity != null @@ -1164,7 +1176,7 @@ const imageOverlays = (geojson, layerObj, leafletLayerObject) => { // IMAGE const imageVar = F_.getIn(layerObj, 'variables.markerAttachments.image') - if (imageVar) { + if (imageVar && (imageVar.enabled === true || imageVar.enabled == null)) { const imageShow = F_.getIn( layerObj, 'variables.markerAttachments.image.show', @@ -1334,7 +1346,7 @@ const models = (geojson, layerObj, leafletLayerObject) => { // MODEL const modelVar = F_.getIn(layerObj, 'variables.markerAttachments.model') - if (modelVar) { + if (modelVar && (modelVar.enabled === true || modelVar.enabled == null)) { const modelShow = F_.getIn(modelVar, 'show', 'click') const modelPaths = [] const modelMtlPaths = [] @@ -1508,7 +1520,10 @@ const coordinateMarkers = (geojson, layerObj, leafletLayerObject) => { 'variables.coordinateAttachments.marker' ) - if (coordMarkerVar) { + if ( + coordMarkerVar && + (coordMarkerVar.enabled === true || coordMarkerVar.enabled == null) + ) { const coordMarkerSettings = { initialVisibility: F_.getIn( coordMarkerVar, @@ -1564,7 +1579,11 @@ const pathGradient = (geojson, layerObj, leafletLayerObject) => { layerObj, 'variables.pathAttachments.gradient' ) - if (pathGradientVar) { + if ( + pathGradientVar && + (pathGradientVar.enabled === true || + pathGradientVar.enabled == null) + ) { const pathGradientSettings = { initialVisibility: F_.getIn( pathGradientVar, diff --git a/src/essence/Basics/Layers_/Layers_.js b/src/essence/Basics/Layers_/Layers_.js index 0fc818da..4ee999db 100644 --- a/src/essence/Basics/Layers_/Layers_.js +++ b/src/essence/Basics/Layers_/Layers_.js @@ -536,11 +536,17 @@ const L_ = { weight: s.style.weight, radius: s.radius, }, - bearing: s.variables?.markerAttachments - ?.bearing - ? s.variables.markerAttachments - .bearing - : null, + bearing: + (s.variables?.markerAttachments + ?.bearing && + s.variables?.markerAttachments + ?.bearing.enabled == + null) || + s.variables?.markerAttachments + ?.bearing?.enabled === true + ? s.variables.markerAttachments + .bearing + : null, }, opacity: L_.layers.opacity[s.name], minZoom: @@ -892,10 +898,16 @@ const L_ = { weight: s.style.weight, radius: s.radius, }, - bearing: s.variables?.markerAttachments - ?.bearing - ? s.variables.markerAttachments.bearing - : null, + bearing: + (s.variables?.markerAttachments + ?.bearing && + s.variables?.markerAttachments + ?.bearing.enabled == null) || + s.variables?.markerAttachments?.bearing + ?.enabled === true + ? s.variables.markerAttachments + .bearing + : null, }, opacity: L_.layers.opacity[s.name], minZoom: diff --git a/src/essence/Tools/Kinds/Kinds.js b/src/essence/Tools/Kinds/Kinds.js index b15afc22..f322ce34 100644 --- a/src/essence/Tools/Kinds/Kinds.js +++ b/src/essence/Tools/Kinds/Kinds.js @@ -33,7 +33,15 @@ var Kinds = { break case 'waypoint': // Add image overlay - if (F_.getIn(layerVar, 'markerAttachments.image', false)) { + const imageVar = F_.getIn( + layerVar, + 'markerAttachments.image', + false + ) + if ( + imageVar && + (imageVar.enabled === true || imageVar.enabled == null) + ) { const path = F_.getIn( layerVar, 'markerAttachments.image.path', @@ -154,7 +162,15 @@ var Kinds = { } // Add model to globe - if (F_.getIn(layerVar, 'markerAttachments.model', false)) { + const modelVar = F_.getIn( + layerVar, + 'markerAttachments.model', + false + ) + if ( + modelVar && + (modelVar.enabled === true || modelVar.enabled == null) + ) { const path = F_.getIn( layerVar, 'markerAttachments.model.path', diff --git a/src/essence/Tools/Layers/LayerInfoModal/LayerInfoModal.js b/src/essence/Tools/Layers/LayerInfoModal/LayerInfoModal.js index dd25857c..4f18e389 100644 --- a/src/essence/Tools/Layers/LayerInfoModal/LayerInfoModal.js +++ b/src/essence/Tools/Layers/LayerInfoModal/LayerInfoModal.js @@ -42,17 +42,19 @@ const LayerInfo = { `