Skip to content

Commit

Permalink
#473 MeasureTool and IdentifierTool Layer Vars (#476)
Browse files Browse the repository at this point in the history
* #473 Layer Specific IdentifierTool vars 1

* #473 MeasureTool and IdentifierTool Layer Vars
  • Loading branch information
tariqksoliman authored Dec 19, 2023
1 parent 5f3d031 commit 05612bd
Show file tree
Hide file tree
Showing 6 changed files with 247 additions and 131 deletions.
24 changes: 24 additions & 0 deletions config/js/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2813,6 +2813,30 @@ function layerPopulateVariable(modalId, layerType) {
"value_in_response_to_replace_with.use.dot.notation.to.traverse.objects",
},
};
currentLayerVars.tools = currentLayerVars.tools
? currentLayerVars.tools
: {
measure: {
layerDems: [
{
name: "(str) example",
url: "(str) path_to_data/data.tif (required)",
},
],
},
identifier: {
data: [
{
url: "(str) path_to_data/data.tif (required)",
bands: "(int) how many bands to query from",
sigfigs: "(int) how many digits after the decimal",
unit: "(str) whatever string unit",
timeFormat:
"(str) for injecting '{starttime}' and '{endtime}' in url. See syntax in https://d3js.org/d3-time-format#locale_format",
},
],
},
};
} else if (layerType == "data") {
currentLayerVars = currentLayerVars.shader
? { shader: currentLayerVars.shader }
Expand Down
23 changes: 22 additions & 1 deletion docs/pages/Configure/Layers/Tile/Tile.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,28 @@ Example:
return:
"value_in_response_to_replace_with.use.dot.notation.to.traverse.objects",
},
}
},
"tools": {
"measure": {
"layerDems": [
{
"name": "(str) example",
"url": "(str) path_to_data/data.tif (required)"
}
]
},
"identifier": {
"data": [
{
"url": "(str) path_to_data/data.tif (required)",
"bands": "(int) how many bands to query from",
"sigfigs": "(int) how many digits after the decimal",
"unit": "(str) whatever string unit",
"timeFormat": "(str) for injecting '{starttime}' and '{endtime}' in url. See syntax in https://d3js.org/d3-time-format#locale_format"
}
]
}
}
}
```

Expand Down
9 changes: 8 additions & 1 deletion src/essence/Ancillary/CursorInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,21 @@ var CursorInfo = {
forceColor,
forceFontColor,
asHTML,
withBorder
withBorder,
withoutPadding
) {
if (position) {
CursorInfo.forcedPos = true
CursorInfo.cursorInfoDiv
.style('left', position.x + 'px')
.style('top', Math.max(40, position.y) + 'px')
}
if (withoutPadding) {
CursorInfo.cursorInfoDiv.style('padding', 0)
} else {
CursorInfo.cursorInfoDiv.style('padding', '5px 9px 4px 9px')
}

$('#cursorInfo').stop()
CursorInfo.cursorInfoDiv.style('display', 'block').style('opacity', 1)
CursorInfo.cursorInfoDiv
Expand Down
14 changes: 12 additions & 2 deletions src/essence/Basics/Layers_/Layers_.js
Original file line number Diff line number Diff line change
Expand Up @@ -1782,16 +1782,26 @@ const L_ = {
}
return false
},
getToolVars: function (toolName, showWarnings) {
getToolVars: function (toolName, withVarsFromLayers, showWarnings) {
let vars = {}
for (var i = 0; i < L_.tools.length; i++) {
if (
L_.tools[i].hasOwnProperty('name') &&
L_.tools[i].name.toLowerCase() == toolName &&
L_.tools[i].hasOwnProperty('variables')
) {
return L_.tools[i].variables
vars = L_.tools[i].variables
}
}
if (withVarsFromLayers) {
vars.__layers = {}
L_.layers.dataFlat.forEach((d) => {
if (d.name != null && d?.variables?.tools?.[toolName] != null) {
vars.__layers[d.name] = d.variables.tools[toolName]
}
})
}
if (Object.keys(vars).length > 0) return vars
if (showWarnings)
console.warn(
`WARNING: Tried to get ${toolName} Tool's config variables and failed.`
Expand Down
Loading

0 comments on commit 05612bd

Please sign in to comment.