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

FCRM-4460 - fixed searches for Brighton, Newcastle and Stockton #379

Merged
merged 2 commits into from
Oct 27, 2023
Merged
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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fmfp",
"version": "2.7.0-pre.2",
"version": "2.7.0-pre.3",
"dataVersion": "2.5.1",
"description": "Flood map for planning",
"main": "index.js",
Expand Down
13 changes: 13 additions & 0 deletions server/services/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,24 @@ const config = require('../../config')
const { osNamesUrl, osSearchKey } = config.ordnanceSurvey
const fqFilter = 'LOCAL_TYPE:City%20LOCAL_TYPE:Hamlet%20LOCAL_TYPE:Other_Settlement%20LOCAL_TYPE:Suburban_Area%20LOCAL_TYPE:Town%20LOCAL_TYPE:PostCode%20LOCAL_TYPE:Village'

// FCRM-4460 was to fix searches for large towns and cities with Proper Names that differ from their common names.
// The first attempt was to try and make a match on the data returned from OS Names, but this only worked for Brighton,
// as it is a place in it's own right (although the OS Place Names returns a village in Cornwall as the top result).
// This is a less than ideal workaround, that hard codes specific results, if any more are found they need to be added to this list.
const shortNames = {
Brighton: 'Brighton and Hove',
Newcastle: 'Newcastle upon Tyne',
Stockton: 'Stockton-on-Tees'
}

const replaceCommonSearchTerms = place => shortNames[place] || place

module.exports = {
findByPlace: async (place) => {
const uri = `${osNamesUrl}${place}&key=${osSearchKey}&fq=${fqFilter}`.replace('maxresults=1&', 'maxresults=10&')
const payload = await util.getJson(uri)

place = replaceCommonSearchTerms(place) // FCRM-4460 - see comment above
if (!payload || !payload.results || !payload.results.length) {
return []
}
Expand Down
2 changes: 1 addition & 1 deletion server/views/confirm-location.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h1 class="govuk-heading-xl">
<div class="govuk-grid-column-two-thirds">
<div class="hide" data-journey="{{analyticsPageEvent}}"></div>
{% if locationDetails %}
<p class="govuk-body">Your search for '{{placeOrPostcodeUnencoded}}' has been placed in {{locationDetails}}.</p>
<p class="govuk-body your-search-details">Your search for '{{placeOrPostcodeUnencoded}}' has been placed in {{locationDetails}}.</p>
{% endif %}
{% if polygonMissing %}
{{ govukErrorSummary({
Expand Down
Loading