diff --git a/app/api/formulas.py b/app/api/formulas.py index 62577459..e399fb93 100644 --- a/app/api/formulas.py +++ b/app/api/formulas.py @@ -9,23 +9,28 @@ from django.utils.translation import gettext_lazy as _ algos = { 'NDVI': { 'expr': '(N - R) / (N + R)', - 'help': _('Normalized Difference Vegetation Index shows the amount of green vegetation.') + 'help': _('Normalized Difference Vegetation Index shows the amount of green vegetation.'), + 'range': (-1, 1) }, 'NDYI': { 'expr': '(G - B) / (G + B)', - 'help': _('Normalized difference yellowness index (NDYI), best model variability in relative yield potential in Canola.') + 'help': _('Normalized difference yellowness index (NDYI), best model variability in relative yield potential in Canola.'), + 'range': (-1, 1) }, 'NDRE': { 'expr': '(N - Re) / (N + Re)', - 'help': _('Normalized Difference Red Edge Index shows the amount of green vegetation of permanent or later stage crops.') + 'help': _('Normalized Difference Red Edge Index shows the amount of green vegetation of permanent or later stage crops.'), + 'range': (-1, 1) }, 'NDWI': { 'expr': '(G - N) / (G + N)', - 'help': _('Normalized Difference Water Index shows the amount of water content in water bodies.') + 'help': _('Normalized Difference Water Index shows the amount of water content in water bodies.'), + 'range': (-1, 1) }, 'NDVI (Blue)': { 'expr': '(N - B) / (N + B)', - 'help': _('Normalized Difference Vegetation Index shows the amount of green vegetation.') + 'help': _('Normalized Difference Vegetation Index shows the amount of green vegetation.'), + 'range': (-1, 1) }, 'ENDVI':{ 'expr': '((N + G) - (2 * B)) / ((N + G) + (2 * B))', @@ -59,7 +64,8 @@ algos = { }, 'GNDVI':{ 'expr': '(N - G) / (N + G)', - 'help': _('Green Normalized Difference Vegetation Index is similar to NDVI, but measures the green spectrum instead of red.') + 'help': _('Green Normalized Difference Vegetation Index is similar to NDVI, but measures the green spectrum instead of red.'), + 'range': (-1, 1) }, 'GRVI':{ 'expr': 'N / G', @@ -153,7 +159,7 @@ def lookup_formula(algo, band_order = 'RGB'): raise ValueError("Cannot find algorithm " + algo) input_bands = tuple(b for b in re.split(r"([A-Z][a-z]*)", band_order) if b != "") - + def repl(matches): b = matches.group(1) try: diff --git a/app/static/app/js/components/Histogram.jsx b/app/static/app/js/components/Histogram.jsx index 217d23cb..9779b34e 100644 --- a/app/static/app/js/components/Histogram.jsx +++ b/app/static/app/js/components/Histogram.jsx @@ -55,7 +55,9 @@ export default class Histogram extends React.Component { const st = { min: minX.toFixed(3), - max: maxX.toFixed(3) + max: maxX.toFixed(3), + minInput: minX.toFixed(3), + maxInput: maxX.toFixed(3) }; if (!this.state){ @@ -235,6 +237,9 @@ export default class Histogram extends React.Component { } componentDidUpdate(prevProps, prevState){ + if (prevState.min !== this.state.min) this.state.minInput = this.state.min; + if (prevState.max !== this.state.max) this.state.maxInput = this.state.max; + if (prevState.min !== this.state.min || prevState.max !== this.state.max || prevProps.colorMap !== this.props.colorMap || @@ -271,6 +276,7 @@ export default class Histogram extends React.Component { } handleChangeMax = (e) => { + this.setState({maxInput: e.target.value}); const val = parseFloat(e.target.value); if (val >= this.state.min && val <= this.rangeX[1]){ @@ -279,6 +285,7 @@ export default class Histogram extends React.Component { } handleChangeMin = (e) => { + this.setState({minInput: e.target.value}); const val = parseFloat(e.target.value); if (val <= this.state.max && val >= this.rangeX[0]){ @@ -290,8 +297,8 @@ export default class Histogram extends React.Component { return (
{ this.hgContainer = domNode; }}>
- - + +
); } }