Skip to content

Commit

Permalink
Merge branch 'development' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
John Shields authored and John Shields committed Dec 7, 2020
2 parents c6a6c0f + 9902f6b commit da037f1
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion server/models/views/alerts-and-warnings.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ViewModel {
station: station || null,
metaNoIndex: true,
placeName: place ? place.name : '',
placeBbox: place ? place.bbox : [],
placeBbox: place ? place.bbox2k : [],
placeCentre: place ? place.center : [],
timestamp: Date.now(),
error: error ? true : null,
Expand Down
2 changes: 1 addition & 1 deletion server/models/views/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ViewModel {
Object.assign(this, {
q: location,
place,
placeBbox: place ? place.bbox : [],
placeBbox: place ? place.bbox2k : [],
floods,
impacts,
location: title,
Expand Down
2 changes: 1 addition & 1 deletion server/models/views/river-and-sea-levels.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class ViewModel {

this.export = {
countLevels: this.countLevels,
placeBbox: place ? place.bbox : stationsBbox,
placeBbox: place ? place.bbox10k : stationsBbox,
bingMaps: bingKeyMaps
}
}
Expand Down
2 changes: 1 addition & 1 deletion server/models/views/station.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class ViewModel {
const forecastHighestPoint = parseFloat(highestPoint._).toFixed(2)
const forecastHighestPointTime = highestPoint.formattedTimestamp

this.forecastDetails = `The highest level in the forecast is ${forecastHighestPoint}m at ${forecastHighestPointTime}. Forecasts come from a computer model and changes regularly.`
this.forecastDetails = `The highest level in our forecast is ${forecastHighestPoint}m at ${forecastHighestPointTime}. Forecasts come from a computer model and can change.`
}
}

Expand Down
2 changes: 1 addition & 1 deletion server/routes/alerts-and-warnings.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module.exports = [{
return h.view('alerts-and-warnings', { model })
} else {
// Data passed to floods model so the schema is the same as cached floods
const data = await floodService.getFloodsWithin(place.bbox)
const data = await floodService.getFloodsWithin(place.bbox2k)
floods = new Floods(data)
model = new ViewModel({ location, place, floods, station })
return h.view('alerts-and-warnings', { model })
Expand Down
6 changes: 3 additions & 3 deletions server/routes/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ module.exports = {
{ floods },
stations
] = await Promise.all([
floodService.getImpactsWithin(place.bbox),
floodService.getFloodsWithin(place.bbox),
floodService.getStationsWithin(place.bbox)
floodService.getImpactsWithin(place.bbox2k),
floodService.getFloodsWithin(place.bbox2k),
floodService.getStationsWithin(place.bbox10k)
])
const model = new ViewModel({ location, place, floods, stations, impacts })
return h.view('location', { model })
Expand Down
2 changes: 1 addition & 1 deletion server/routes/river-and-sea-levels.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module.exports = [{
return h.view('river-and-sea-levels', { model })
} else {
// Finally show place filtered station list
stations = await floodService.getStationsWithin(place.bbox)
stations = await floodService.getStationsWithin(place.bbox10k)
model = new ViewModel({ location, place, stations })
model.referer = request.headers.referer
return h.view('river-and-sea-levels', { model })
Expand Down
9 changes: 6 additions & 3 deletions server/services/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,16 @@ async function find (location) {

const isEngland = await floodServices.getIsEngland(center[0], center[1])

// add on 2000m buffer to place.bbox for search
bbox = addBufferToBbox(bbox, 2000)
// add on 2000m buffer to place.bbox for warnings and alerts search
const bbox2k = addBufferToBbox(bbox, 2000)
// add on 10000m buffer to place.bbox for stations search
const bbox10k = addBufferToBbox(bbox, 10000)

return {
name,
center,
bbox,
bbox2k,
bbox10k,
address,
isEngland,
isUK,
Expand Down
2 changes: 1 addition & 1 deletion test/routes/station.js
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ lab.experiment('Test - /station/{id}', () => {

Code.expect(response.statusCode).to.equal(200)
Code.expect(response.payload).to.contain('<a href="/target-area/062FWF46Hertford">River Lee at Hertford and Ware</a>')
Code.expect(response.payload).to.contain('The highest level in the forecast is')
Code.expect(response.payload).to.contain('The highest level in our forecast is')
})
lab.test('GET station/5146 with latest value over hour old but < 24 hours ', async () => {
const floodService = require('../../server/services/flood')
Expand Down
4 changes: 3 additions & 1 deletion test/services/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ lab.experiment('location service test', () => {
Code.expect(result.Error).to.be.undefined()
Code.expect(result.address).to.equal('United Kingdom')
// Test that bounding box for location has been given 2km buffer
Code.expect(result.bbox).to.equal(JSON.parse('[-18.297640835711686,49.94624559508356,12.557641064593524,60.79096093998717]'))
Code.expect(result.bbox2k).to.equal(JSON.parse('[-18.297640835711686,49.94624559508356,12.557641064593524,60.79096093998717]'))
// Test that bounding box for location has been given 10km buffer
Code.expect(result.bbox10k).to.equal(JSON.parse('[-18.36950605844125,49.89997768952511,12.629506287323087,60.82601178696]'))
})

lab.test('Check for Bing call returning low confidence and hence no results', async () => {
Expand Down

0 comments on commit da037f1

Please sign in to comment.