Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

remove unit conversion from vector metadata

Jason Kent92356fe5df3b
diff --git a/web/js/components/vector-metadata/table.js b/web/js/components/vector-metadata/table.js
index 21b5d59de..8195abd34 100644
--- a/web/js/components/vector-metadata/table.js
+++ b/web/js/components/vector-metadata/table.js
@@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
import { Table } from 'reactstrap';
import VectorMetaTooltip from './tooltip';
import util from '../../util/util';
-import { checkTemperatureUnitConversion, convertPaletteValue, getAbbrevFromTemperatureUnit } from '../../modules/global-unit/util';
export default class VectorMetaTable extends React.Component {
shouldComponentUpdate(nextProps) {
@@ -15,7 +14,7 @@ export default class VectorMetaTable extends React.Component {
}
render() {
- const { metaArray, globalTemperatureUnit } = this.props;
+ const { metaArray } = this.props;
return (
<div>
@@ -33,46 +32,32 @@ export default class VectorMetaTable extends React.Component {
</thead>
<tbody>
{metaLegend.map((properties, index) => {
- const featureId = properties.Identifier;
- const isIntegerToStyle = properties.Function !== 'Identify' && (properties.DataType === 'int');
- let value = properties.ValueMap
- ? properties.ValueMap[metaFeatures[featureId]]
- : isIntegerToStyle ? metaFeatures[featureId].toLocaleString('en')
- : metaFeatures[featureId];
- const id = util.cleanId(String(`${title}-${metaIndex + index}`));
+ const {
+ Function, ValueMap, DataType, Title, Identifier, Units, Description,
+ } = properties;
- let description = properties.Description;
- let unit = properties.Units;
- if (value && unit) {
- const { disableUnitConversion } = obj;
- const initialUnit = unit;
- unit = getAbbrevFromTemperatureUnit(unit) || unit;
- if (!disableUnitConversion) {
- const { needsConversion, legendTempUnit } = checkTemperatureUnitConversion(unit, globalTemperatureUnit);
- if (needsConversion) {
- value = `${convertPaletteValue(`${value}`, legendTempUnit, globalTemperatureUnit)}`;
- description = description.replace(initialUnit, globalTemperatureUnit);
- unit = '';
- }
- }
- }
+ const isIntegerToStyle = Function !== 'Identify' && (DataType === 'int');
+ const value = ValueMap
+ ? ValueMap[metaFeatures[Identifier]]
+ : isIntegerToStyle ? metaFeatures[Identifier].toLocaleString('en')
+ : metaFeatures[Identifier];
+ const id = util.cleanId(String(`${title}-${metaIndex + index}`));
if (!value) return undefined;
return (
<tr key={`vector-row-${id}`}>
<td>
- {description ? (
- <VectorMetaTooltip id={id} index={index} description={description} />
+ {Description ? (
+ <VectorMetaTooltip id={id} index={index} description={Description} />
) : undefined}
- <div className="vector-feature-name-cell">{properties.Title ? properties.Title : featureId}</div>
+ <div className="vector-feature-name-cell">{Title || Identifier}</div>
</td>
<td>
<span>{value}</span>
- {unit
- && (
+ {Units && (
<span>
{' '}
- {unit}
+ {Units}
</span>
)}
</td>
@@ -90,7 +75,6 @@ export default class VectorMetaTable extends React.Component {
}
VectorMetaTable.propTypes = {
id: PropTypes.number,
- globalTemperatureUnit: PropTypes.string,
metaArray: PropTypes.array,
title: PropTypes.string,
};
diff --git a/web/js/containers/vector-dialog.js b/web/js/containers/vector-dialog.js
index 86245ee6f..2d553549b 100644
--- a/web/js/containers/vector-dialog.js
+++ b/web/js/containers/vector-dialog.js
@@ -23,7 +23,7 @@ class VectorDialog extends React.Component {
render() {
const {
- toggleWithClose, globalTemperatureUnit, vectorMetaObject, modalHeight, dialogKey,
+ toggleWithClose, vectorMetaObject, modalHeight, dialogKey,
} = this.props;
const { activeIndex } = this.state;
const navArray = [];
@@ -63,7 +63,6 @@ class VectorDialog extends React.Component {
<ModalBody>
<Scrollbars style={{ maxHeight: `${modalHeight - 70}px` }}>
<VectorMetaTable
- globalTemperatureUnit={globalTemperatureUnit}
id={dialogKey}
metaArray={activeMetaArray}
title={keyArray[activeIndex]}
@@ -76,11 +75,7 @@ class VectorDialog extends React.Component {
}
function mapStateToProps(state) {
- const {
- globalUnit,
- } = state;
- const { globalTemperatureUnit } = globalUnit;
- return { globalTemperatureUnit };
+ return {};
}
export default connect(
mapStateToProps,
@@ -88,7 +83,6 @@ export default connect(
)(VectorDialog);
VectorDialog.propTypes = {
dialogKey: PropTypes.number,
- globalTemperatureUnit: PropTypes.string,
modalHeight: PropTypes.number,
toggleWithClose: PropTypes.func,
vectorMetaObject: PropTypes.object,