Skip to content

Commit 5b905a5

Browse files
committed
Enabled scalefactor and improved text readout for Identifier tool
Resolves: - Consistent text alignment in Identifier Tool readouts #555 - Apply scale factor to Identifier Tool source data readouts #556
1 parent d2d049f commit 5b905a5

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

docs/pages/Tools/Identifier/Identifier.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ The following is an example of the Sites Tool's Tool Tab configuration:
1919
"url": "(str) path_to_data/data.tif",
2020
"bands": "(int) how many bands to query from",
2121
"sigfigs": "(int) how many digits after the decimal",
22+
"scalefactor": "(float) number to multiply value",
2223
"unit": "(str) whatever string unit",
2324
"timeFormat": "(str) for formatting injected '{starttime}' and '{endtime}' in url."
2425
},
@@ -30,5 +31,6 @@ The following is an example of the Sites Tool's Tool Tab configuration:
3031
- `url`: This can be a relative path to a file under the Mission name or a full url path. The former is preferred is the file is large. Can use '{starttime}' and '{endtime}' if the layer is time enabled.
3132
- `bands`: Allows you to specify how many bands to return data from. Default is 1.
3233
- `sigfigs`: Sets the decimal precision.
34+
- `scalefactor`: A float number that will multiply the value to scale.
3335
- `unit`: A string that is appended to your returned value. e.g. " m" would be appended on a raw value ("41") and show "41 m". If it was "m", it would return "41m", without a space.
3436
- `timeFormat`: A string for formatting the injected '{starttime}' and '{endtime}' in the url. See syntax in https://d3js.org/d3-time-format#locale_format

src/essence/Tools/Identifier/IdentifierTool.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ var IdentifierTool = {
3434
//Get tool variables and UI adjustments
3535
this.justification = L_.getToolVars('identifier')['justification']
3636
var toolContent = d3.select('#toolSeparated_Identifier')
37+
toolContent.style('bottom', '2px')
3738

3839
if (this.justification == 'right') {
3940
var toolController = d3.select('#toolcontroller_sepdiv')
@@ -351,17 +352,25 @@ var IdentifierTool = {
351352
var valueParsed =
352353
parseValue(
353354
value[v][1],
354-
d2.sigfigs
355+
d2.sigfigs,
356+
d2.scalefactor
355357
) +
356358
'' +
357359
unit
358360

359-
htmlValues +=
360-
'<div style="display: flex; justify-content: space-between;"><div style="margin-right: 15px; color: var(--color-a5); font-size: 12px;">' +
361-
value[v][0] +
362-
'</div><div style="color: var(--color-a6); font-size: 14px;">' +
363-
valueParsed +
364-
'</div></div>'
361+
if (value.length > 1) {
362+
htmlValues +=
363+
'<div style="display: flex; justify-content: space-between;"><div style="margin-right: 15px; color: var(--color-a5); font-size: 12px;">' +
364+
value[v][0] +
365+
'</div><div style="color: var(--color-a6); font-size: 14px;">' +
366+
valueParsed +
367+
'</div></div>'
368+
} else {
369+
htmlValues +=
370+
'<div style="display: flex; justify-content: space-between;"><div style="color: var(--color-a6); font-size: 16px;">' +
371+
valueParsed +
372+
'</div></div>'
373+
}
365374
cnt++
366375
}
367376
$(
@@ -441,7 +450,7 @@ var IdentifierTool = {
441450
}, 150)
442451
}
443452

444-
function parseValue(v, sigfigs) {
453+
function parseValue(v, sigfigs, scalefactor) {
445454
var ed = 10
446455
if (typeof v === 'string') {
447456
return v
@@ -450,13 +459,15 @@ var IdentifierTool = {
450459
return v
451460
} else if (v.toString().indexOf('e') != -1) {
452461
if (sigfigs != undefined) ed = sigfigs
462+
if (scalefactor != undefined) v = v * parseFloat(scalefactor)
453463
v = parseFloat(v)
454464
return v.toExponential(ed)
455465
} else {
456466
var decSplit = v.toString().split('.')
457467
var decPlacesBefore = decSplit[0] ? decSplit[0].length : 0
458468
var decPlacesAfter = decSplit[1] ? decSplit[1].length : 0
459469
if (decPlacesBefore <= 5) {
470+
if (scalefactor != undefined) v = v * parseFloat(scalefactor)
460471
if (sigfigs != undefined) v = v.toFixed(sigfigs)
461472
}
462473
v = parseFloat(v)

0 commit comments

Comments
 (0)