Skip to content

Commit

Permalink
add dominant tillage dailyerosion#13
Browse files Browse the repository at this point in the history
  • Loading branch information
akrherz committed Jul 20, 2022
1 parent 5f91555 commit f4b26b5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
8 changes: 7 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ <h4>To Date:</h4>
</div>
</div>

<h4>View:</h4>
<h4>View Outputs:</h4>
<ul class="list-unstyled deplist">
<li><input type="radio" id="precip-in2_opt" name="whichlayer" value="qc_precip" checked="checked">
<label for="precip-in2_opt">Precipitation</label></li>
Expand All @@ -235,6 +235,12 @@ <h4>View:</h4>
<label for="delivery2_opt">Hillslope Soil Loss</label></li>
</ul>

<h4>View Metadata:</h4>
<ul class="list-unstyled deplist">
<li><input type="radio" id="dt_opt" name="whichlayer" value="dt">
<label for="dt_opt">Dominant Tillage Practice</label></li>
</ul>

<p><span id="variable_desc"></span></p>

<h4>Imagery:</h4>
Expand Down
34 changes: 24 additions & 10 deletions src/js/nextgen.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,24 @@ var defaultCenter = ol.proj.transform([-94.5, 42.1], 'EPSG:4326', 'EPSG:3857');
var defaultZoom = 6;
var popup;

// Those provided by the data service.
var varnames = ['qc_precip', 'avg_runoff', 'avg_loss', 'avg_delivery'];
// How to get english units to metric, when appstate.metric == 1
// multipliers[appstate.varname][appstate.metric]
var multipliers = {
'qc_precip': [1, 25.4],
'avg_runoff': [1, 25.4],
'avg_loss': [1, 2.2417],
'avg_delivery': [1, 2.2417]
'avg_delivery': [1, 2.2417],
'dt': [1, 1],
};
// english ramp, metric ramp, english max, metric max
var levels = {
'qc_precip': [[], [], 0, 0],
'avg_runoff': [[], [], 0, 0],
'avg_loss': [[], [], 0, 0],
'avg_delivery': [[], [], 0, 0]
'avg_delivery': [[], [], 0, 0],
'dt': [[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], 6, 6]
};
var colors = {
'qc_precip': ['#FFFF80', '#98F046', '#3BD923', '#3FC453',
Expand All @@ -38,7 +41,8 @@ var colors = {
'avg_loss': ['#FFEBAF', '#E0A870', '#BF8347', '#DDFA00', '#21DE00', '#16B568',
'#1A818F', '#003075'],
'avg_delivery': ['#FFEBAF', '#E0A870', '#BF8347', '#DDFA00', '#21DE00', '#16B568',
'#1A818F', '#003075']
'#1A818F', '#003075'],
'dt': ['#FFEBAF', '#E0A870', '#BF8347', '#DDFA00', '#21DE00', '#16B568']
};


Expand All @@ -47,19 +51,22 @@ var vardesc = {
avg_loss: 'Soil Detachment is the average amount of soil disturbed on the modelled hillslopes.',
qc_precip: 'Precipitation is the average amount of rainfall and melted snow received on the hillslopes.',
avg_delivery: 'Hillslope Soil Loss is the average amount of soil transported to the bottom of the modelled hillslopes.',
dt: "Dominant Tillage Code is an index value with increasing values indicating increasing tillage intensity."
}

var varunits = {
avg_runoff: ['inches', 'mm'],
avg_loss: ['tons per acre', 'tonnes per ha'],
qc_precip: ['inches', 'mm'],
avg_delivery: ['tons per acre', 'tonnes per ha']
avg_delivery: ['tons per acre', 'tonnes per ha'],
dt: [' ', ' '],
};
var vartitle = {
avg_runoff: 'Water Runoff',
avg_loss: 'Soil Detachment',
qc_precip: 'Precipitation',
avg_delivery: 'Hillslope Soil Loss'
avg_delivery: 'Hillslope Soil Loss',
dt: 'Dominant Tillage'
};

function handleSideBarClick() {
Expand Down Expand Up @@ -503,15 +510,22 @@ function drawColorbar() {

ctx.font = 'bold 12pt Calibri';
ctx.fillStyle = 'black';
var leveltxt = level.toFixed((level < 100) ? 2 : 0);
var precision = (level < 100) ? 2 : 0;
if (appstate.ltype == "dt"){
precision = 0;
}
var leveltxt = level.toFixed(precision);
if (level == 0.001) {
leveltxt = 0.001;
}
metrics = ctx.measureText(leveltxt);
ctx.fillText(
leveltxt, 45 - (metrics.width / 2),
canvas.height - (pos + 10) - 4);

if (appstate.ltype == "dt"){
ctx.fillText(leveltxt, 10, canvas.height - (pos + 26));
} else {
ctx.fillText(
leveltxt, 45 - (metrics.width / 2),
canvas.height - (pos + 10) - 4);
}
pos = pos + 20;
});

Expand Down

0 comments on commit f4b26b5

Please sign in to comment.