postcodes = {
const pcd = JSON.parse(JSON.stringify(postcodeDistricts))
const {features} = pcd
const properties = ['district', 'borough', 'pc_lower', 'pc_median', 'pc_upper', 'borough_lower', 'borough_median', 'borough_upper', 'london_lower', 'london_median', 'london_upper']
features.forEach(feature => propertiesGeojsonFiles.forEach(json => {
const match = json.features.filter(
property =>
property.properties.district.replace('*', '') === feature.properties.district
)
if (match.length === 1) {
properties.forEach(prop => feature.properties[match[0].properties.category.replace('rooms','').replace('room','')+'-'+prop] = isNumeric(match[0].properties[prop]) ? parseInt(match[0].properties[prop]) : match[0].properties[prop] )
}
Object.keys(feature.properties).forEach(prop => {
if (prop.indexOf('-district') !== -1 ||
( prop.indexOf('-borough') !== -1) &&
( prop.indexOf('-borough_') === -1) ) {
delete feature.properties[prop]
}
})
}))
return pcd
}