Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/fsr 1295 default station chart threshold #862

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion server/models/views/lib/process-imtd-thresholds.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,6 @@ function calculateAlertThreshold (imtdThresholds, stationStageDatum, stationSubt
}

module.exports = {
processImtdThresholds
processImtdThresholds,
processThreshold
}
10 changes: 5 additions & 5 deletions server/models/views/station.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ const Station = require('./station-data')
const Forecast = require('./station-forecast')
const util = require('../../util')
const tz = 'Europe/London'
const { processImtdThresholds } = require('./lib/process-imtd-thresholds')
const processWarningThresholds = require('./lib/process-warning-thresholds')
const { processImtdThresholds, processThreshold } = require('./lib/process-imtd-thresholds')
const filterImtdThresholds = require('./lib/find-min-threshold')

const bannerIconId3 = 3
Expand Down Expand Up @@ -289,7 +288,7 @@ class ViewModel {
}

// Retrieve the applicable threshold for chartThreshold
const chartThreshold = [getThresholdByThresholdId(tid, imtdThresholds, thresholds)].filter(Boolean)
const chartThreshold = [getThresholdByThresholdId(tid, imtdThresholds, thresholds, this.station.stageDatum, this.station.subtract, this.station.post_process)].filter(Boolean)

// Set chartThreshold property
this.chartThreshold = chartThreshold
Expand Down Expand Up @@ -450,13 +449,14 @@ function telemetryForecastBuilder (telemetryRawData, forecastRawData, stationTyp
}

// Function to retrieve a threshold by tid or fall back to 'pc5' or 'alertThreshold'
const getThresholdByThresholdId = (tid, imtdThresholds, thresholds) => {
const getThresholdByThresholdId = (tid, imtdThresholds, thresholds, stationStageDatum, stationSubtract, postProcess) => {
// Check if a threshold exists based on tid
const tidThreshold = tid && imtdThresholds?.find(thresh => thresh.station_threshold_id === tid)
if (tidThreshold) {
const thresholdValue = processThreshold(tidThreshold.value, stationStageDatum, stationSubtract, postProcess)
return {
id: tidThreshold.station_threshold_id,
value: Number(tidThreshold.value).toFixed(2),
value: thresholdValue,
description: `${tidThreshold.value}m ${tidThreshold.ta_name || ''}`,
shortname: tidThreshold.ta_name || 'Target Area Threshold'
}
Expand Down
Loading