From cb84013f3afdde7cc441386811d51c4d83d49d25 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 12 Jan 2023 16:21:57 +0000 Subject: [PATCH] maps: networkProvider -> networkProviders https://github.com/Open-Telecoms-Data/cove-ofds/issues/79 --- cove_ofds/process.py | 4 +-- cove_ofds/templates/cove_ofds/explore.html | 33 ++++++++++++++++++++-- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/cove_ofds/process.py b/cove_ofds/process.py index 81d1902..53db6e2 100644 --- a/cove_ofds/process.py +++ b/cove_ofds/process.py @@ -238,7 +238,7 @@ class ConvertJSONIntoGeoJSON(ProcessDataTask): "/features/properties/network/name": "Network", "/features/properties/phase/name": "Phase", "/features/properties/physicalInfrastructureProvider/name": "Physical Infrastructure Provider", - "/features/properties/networkProvider/name": "Network Provider", + "/features/properties/networkProviders/name": "Network Providers", "/features/properties/technologies": "Technologies", "/features/properties/status": "Status", "/features/properties/type": "Type", @@ -250,7 +250,7 @@ class ConvertJSONIntoGeoJSON(ProcessDataTask): "/features/properties/network/name": "Network", "/features/properties/phase/name": "Phase", "/features/properties/physicalInfrastructureProvider/name": "Physical Infrastructure Provider", - "/features/properties/networkProvider/name": "Network Provider", + "/features/properties/networkProviders/name": "Network Providers", "/features/properties/supplier/name": "Supplier", "/features/properties/transmissionMedium": "Transmission Medium", "/features/properties/status": "Status", diff --git a/cove_ofds/templates/cove_ofds/explore.html b/cove_ofds/templates/cove_ofds/explore.html index b7d6dd4..c15be79 100644 --- a/cove_ofds/templates/cove_ofds/explore.html +++ b/cove_ofds/templates/cove_ofds/explore.html @@ -386,10 +386,19 @@

}; function generatePopup(layer) { + let networkProvidersNames = [] + if (layer?.feature?.properties?.networkProviders) { + for(np of layer.feature.properties.networkProviders) { + if (np?.name) { + networkProvidersNames.push(np.name) + } + } + } + networkProvidersNames.sort() return `

Name: ${layer?.feature?.properties?.name || 'Unknown'}

Network: ${layer?.feature?.properties?.network?.name || 'Unknown'}

-

Network provider: ${layer?.feature?.properties?.networkProvider?.name || 'Unknown'}

+

Network provider: ${networkProvidersNames.join(", ") || 'Unknown'}

Physical infrastructure provider: ${layer?.feature?.properties?.physicalInfrastructureProvider?.name || 'Unknown'}

Phase: ${layer?.feature?.properties?.phase?.name || 'Unknown'}

`; @@ -454,7 +463,16 @@

function getFeatureName(feature, field) { let fieldOptions = getJsonFromDict(feature); - if (feature?.properties[field]?.name !== undefined) { + if (field == 'networkProviders' && feature?.properties[field]) { + let names = [] + for(np of feature.properties[field]) { + if (np?.name) { + names.push(np.name) + } + } + names.sort() + return names.join(', ') + } else if (feature?.properties[field]?.name !== undefined) { return feature.properties[field].name } else if ((feature?.properties[field] !== undefined)) { return `${fieldOptions[field]}: ${feature?.properties[field] || 'no data'}` @@ -471,7 +489,16 @@

let spanLegend = {} function getFeatureID(feature, field) { - if (feature?.properties[field]?.id !== undefined) { + if (field == 'networkProviders' && feature?.properties[field]) { + let names = [] + for(np of feature.properties[field]) { + if (np?.name) { + names.push(np.name) + } + } + names.sort() + return names.join(', ') + } else if (feature?.properties[field]?.id !== undefined) { return feature.properties[field].id } else if ((feature?.properties[field] !== undefined)) { return feature.properties[field]