Skip to content

Commit

Permalink
Remove unused isScotlandOrNorthernIsland flag
Browse files Browse the repository at this point in the history
Also hard coded the isEngland flag as bing results are filtered to
exclude non-english results. This flag can also probably be removed next.
  • Loading branch information
neilbmclaughlin committed Dec 12, 2024
1 parent 7dc0122 commit 04d3908
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 46 deletions.
9 changes: 3 additions & 6 deletions server/services/lib/bing-results-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const englishCeremonialCounties =
'worcestershire'
]

async function bingResultsParser (bingData, getIsEngland) {
async function bingResultsParser (bingData) {
const set = bingData.resourceSets[0]
if (set.estimatedTotal === 0) {
return []
Expand Down Expand Up @@ -112,10 +112,8 @@ async function bingResultsParser (bingData, getIsEngland) {
center.reverse()

const isUK = data.address.countryRegionIso2 === 'GB'
const isScotlandOrNorthernIreland = isUK &&
(data.address.adminDistrict === 'Northern Ireland' || data.address.adminDistrict === 'Scotland')

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

const distanceInMetres = {
'2k': 2000,
Expand All @@ -132,8 +130,7 @@ async function bingResultsParser (bingData, getIsEngland) {
bbox2k,
bbox10k,
isUK,
isScotlandOrNorthernIreland,
isEngland
isEngland: { is_england: true }
}]
}

Expand Down
5 changes: 2 additions & 3 deletions test/data/riverAndSeaLevelData.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"isEngland": {
"is_england": true
},
"isUK": true,
"isScotlandOrNorthernIreland": false
"isUK": true
},
"stations": [
{
Expand Down Expand Up @@ -2223,4 +2222,4 @@
}
]
}


3 changes: 1 addition & 2 deletions test/data/riverAndSeaLevelDataUnordered.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"isEngland": {
"is_england": true
},
"isUK": true,
"isScotlandOrNorthernIreland": false
"isUK": true
},
"stations": [
{
Expand Down
3 changes: 1 addition & 2 deletions test/data/scottishPlaceData.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@
"isEngland":{
"is_england":false
},
"isUK":true,
"isScotlandOrNorthernIreland":true
"isUK":true
}
9 changes: 3 additions & 6 deletions test/models/outlook-polys.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ const liverpool = {
bbox10k: [-3.2625314463031407, 53.2213132254306, -2.6220408212292075, 53.640518437630426],
address: 'Liverpool, Merseyside',
isEngland: { is_england: true },
isUK: true,
isScotlandOrNorthernIreland: false
isUK: true
}
const london = {
name: 'London',
Expand All @@ -34,8 +33,7 @@ const london = {
],
address: 'London, Greater London',
isEngland: { is_england: true },
isUK: true,
isScotlandOrNorthernIreland: false
isUK: true
}

const newcastle = {
Expand All @@ -55,8 +53,7 @@ const newcastle = {
],
address: 'Newcastle Upon Tyne, Tyne And Wear',
isEngland: { is_england: true },
isUK: true,
isScotlandOrNorthernIreland: false
isUK: true
}

experiment('OutlookPolys test', () => {
Expand Down
27 changes: 10 additions & 17 deletions test/models/outlook-tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ lab.experiment('outlookTabs model test', () => {
lab.test('Test OutlookTabsModel', async () => {
const outlook = data.fgs

const place = { name: 'Manchester, Greater Manchester', center: [-2.2343759536743164, 53.480712890625], bbox2k: [-3.216968300327545, 53.11623436652925, -1.2803249596532866, 53.840428045393054], bbox10k: [-3.322971089502337, 53.05355679509522, -1.1735137703389709, 53.903467893179474], address: 'Manchester, Greater Manchester', isEngland: { is_england: true }, isUK: true, isScotlandOrNorthernIreland: false }
const place = { name: 'Manchester, Greater Manchester', center: [-2.2343759536743164, 53.480712890625], bbox2k: [-3.216968300327545, 53.11623436652925, -1.2803249596532866, 53.840428045393054], bbox10k: [-3.322971089502337, 53.05355679509522, -1.1735137703389709, 53.903467893179474], address: 'Manchester, Greater Manchester', isEngland: { is_england: true }, isUK: true }

const expectedOutlookTab1 = '{"3-i3-l4":["overflowing rivers"],"1-i2-l2":["runoff from rainfall or blocked drains"]}'
const expectedOutlookTab2 = '{"3-i3-l4":["overflowing rivers"],"1-i2-l2":["runoff from rainfall or blocked drains"]}'
Expand All @@ -27,7 +27,7 @@ lab.experiment('outlookTabs model test', () => {
lab.test('Test Coastal poly isnt failing in turf', async () => {
const outlook = data.fgsCoastal

const place = { name: 'Manchester, Greater Manchester', center: [-2.2343759536743164, 53.480712890625], bbox2k: [-3.216968300327545, 53.11623436652925, -1.2803249596532866, 53.840428045393054], bbox10k: [-3.322971089502337, 53.05355679509522, -1.1735137703389709, 53.903467893179474], address: 'Manchester, Greater Manchester', isEngland: { is_england: true }, isUK: true, isScotlandOrNorthernIreland: false }
const place = { name: 'Manchester, Greater Manchester', center: [-2.2343759536743164, 53.480712890625], bbox2k: [-3.216968300327545, 53.11623436652925, -1.2803249596532866, 53.840428045393054], bbox10k: [-3.322971089502337, 53.05355679509522, -1.1735137703389709, 53.903467893179474], address: 'Manchester, Greater Manchester', isEngland: { is_england: true }, isUK: true }

const expectedOutlookTab1 = '{"2-i2-l4":"runoff from rainfall or blocked drains and overflowing rivers","1-i2-l2":["high tides or large waves"]}'
const expectedOutlookTab2 = '{"1-i2-l2":"runoff from rainfall or blocked drains, overflowing rivers and high tides or large waves"}'
Expand All @@ -46,7 +46,7 @@ lab.experiment('outlookTabs model test', () => {

const formattedIssueDate = formatDate(outlook.issued_at, 'h:mma') + ' on ' + formatDate(outlook.issued_at, 'D MMMM YYYY')

const place = { name: 'Manchester, Greater Manchester', center: [-2.2343759536743164, 53.480712890625], bbox2k: [-3.216968300327545, 53.11623436652925, -1.2803249596532866, 53.840428045393054], bbox10k: [-3.322971089502337, 53.05355679509522, -1.1735137703389709, 53.903467893179474], address: 'Manchester, Greater Manchester', isEngland: { is_england: true }, isUK: true, isScotlandOrNorthernIreland: false }
const place = { name: 'Manchester, Greater Manchester', center: [-2.2343759536743164, 53.480712890625], bbox2k: [-3.216968300327545, 53.11623436652925, -1.2803249596532866, 53.840428045393054], bbox10k: [-3.322971089502337, 53.05355679509522, -1.1735137703389709, 53.903467893179474], address: 'Manchester, Greater Manchester', isEngland: { is_england: true }, isUK: true }

const viewModel = new OutlookTabsModel(outlook, place)

Expand All @@ -72,8 +72,7 @@ lab.experiment('outlookTabs model test', () => {
],
address: 'Leeds, West Yorkshire',
isEngland: { is_england: true },
isUK: true,
isScotlandOrNorthernIreland: false
isUK: true
}

const expectedOutlookTab1 = '{}'
Expand Down Expand Up @@ -109,8 +108,7 @@ lab.experiment('outlookTabs model test', () => {
],
address: 'Oxford, Oxfordshire',
isEngland: { is_england: true },
isUK: true,
isScotlandOrNorthernIreland: false
isUK: true
}

const viewModel = new OutlookTabsModel(outlook, place)
Expand Down Expand Up @@ -140,8 +138,7 @@ lab.experiment('outlookTabs model test', () => {
],
address: 'Oxford, Oxfordshire',
isEngland: { is_england: true },
isUK: true,
isScotlandOrNorthernIreland: false
isUK: true
}

const viewModel = new OutlookTabsModel(outlook, place)
Expand Down Expand Up @@ -267,8 +264,7 @@ lab.experiment('outlookTabs model test', () => {
],
address: 'Leeds, West Yorkshire',
isEngland: { is_england: true },
isUK: true,
isScotlandOrNorthernIreland: false
isUK: true
}

const viewModel = new OutlookTabsModel(outlook, place)
Expand Down Expand Up @@ -299,8 +295,7 @@ lab.experiment('outlookTabs model test', () => {
],
address: 'Derby, Derby City',
isEngland: { is_england: true },
isUK: true,
isScotlandOrNorthernIreland: false
isUK: true
}

const viewModel = new OutlookTabsModel(outlook, place)
Expand Down Expand Up @@ -332,8 +327,7 @@ lab.experiment('outlookTabs model test', () => {
],
address: 'Derby, Derby City',
isEngland: { is_england: true },
isUK: true,
isScotlandOrNorthernIreland: false
isUK: true
}

const viewModel = new OutlookTabsModel(outlook, place)
Expand Down Expand Up @@ -362,8 +356,7 @@ lab.experiment('outlookTabs model test', () => {
],
address: 'Dover, Kent',
isEngland: { is_england: true },
isUK: true,
isScotlandOrNorthernIreland: false
isUK: true
}

const expectedOutlookTab1 = '{"3-i4-l2":"Runoff from rainfall or blocked drains and overflowing rivers"}'
Expand Down
2 changes: 0 additions & 2 deletions test/routes/national.js
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,6 @@ lab.experiment('Routes test - national view', () => {
51.267098001671634
],
isUK: true,
isScotlandOrNorthernIreland: false,
isEngland: { is_england: true }
}
]
Expand Down Expand Up @@ -686,7 +685,6 @@ lab.experiment('Routes test - national view', () => {
51.267098001671634
],
isUK: true,
isScotlandOrNorthernIreland: true,
isEngland: { is_england: false }
}
]
Expand Down
7 changes: 0 additions & 7 deletions test/services/lib/bing-results-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ experiment('bingResultsParser', () => {
54.12413077805586
],
isUK: true,
isScotlandOrNorthernIreland: false,
isEngland: { is_england: true }
}
]
Expand Down Expand Up @@ -244,7 +243,6 @@ experiment('bingResultsParser', () => {
55.901603977656706
],
isUK: true,
isScotlandOrNorthernIreland: false,
isEngland: { is_england: true }
}
]
Expand Down Expand Up @@ -313,7 +311,6 @@ experiment('bingResultsParser', () => {
55.278917707262806
],
isUK: true,
isScotlandOrNorthernIreland: false,
isEngland: { is_england: true }
}
]
Expand Down Expand Up @@ -386,7 +383,6 @@ experiment('bingResultsParser', () => {
54.10335056978173
],
isUK: true,
isScotlandOrNorthernIreland: false,
isEngland: { is_england: true }
}
]
Expand Down Expand Up @@ -460,7 +456,6 @@ experiment('bingResultsParser', () => {
54.16625259905653
],
isUK: true,
isScotlandOrNorthernIreland: false,
isEngland: { is_england: true }
}
]
Expand Down Expand Up @@ -596,7 +591,6 @@ experiment('bingResultsParser', () => {
54.12413077805586
],
isUK: true,
isScotlandOrNorthernIreland: false,
isEngland: { is_england: true }
}
]
Expand Down Expand Up @@ -851,7 +845,6 @@ experiment('bingResultsParser', () => {
51.267098001671634
],
isUK: true,
isScotlandOrNorthernIreland: false,
isEngland: { is_england: true }
}
]
Expand Down
1 change: 0 additions & 1 deletion test/services/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ describe('location service', () => {
51.267098001671634
],
isUK: true,
isScotlandOrNorthernIreland: false,
isEngland: { is_england: true }
})
})
Expand Down

0 comments on commit 04d3908

Please sign in to comment.