From 0644f5e8cdf85531c880f05e6cd635e9c44f40e4 Mon Sep 17 00:00:00 2001 From: Jared Parnell Date: Wed, 16 Nov 2022 13:01:48 +0000 Subject: [PATCH] maps: Add more features to the colour coding This adds logic and fields that can be selected for colour coding. The fields will take the pretty field name and attach either the field value or if the field does not exist --- cove_ofds/process.py | 36 +++++++++------- cove_ofds/templates/cove_ofds/explore.html | 49 +++++++++++++++++++--- 2 files changed, 65 insertions(+), 20 deletions(-) diff --git a/cove_ofds/process.py b/cove_ofds/process.py index 77d8393..419022e 100644 --- a/cove_ofds/process.py +++ b/cove_ofds/process.py @@ -239,11 +239,11 @@ class ConvertJSONIntoGeoJSON(ProcessDataTask): "/features/properties/phase/name": "Phase", "/features/properties/physicalInfrastructureProvider/name": "Physical Infrastructure Provider", "/features/properties/networkProvider/name": "Network Provider", - # "/features/properties/technologies": "Technologies", - # "/features/properties/status": "Status", - # "/features/properties/type": "Type", - # "/features/properties/accessPoint": "accessPoint", - # "/features/properties/power": "Power", + "/features/properties/technologies": "Technologies", + "/features/properties/status": "Status", + "/features/properties/type": "Type", + "/features/properties/accessPoint": "accessPoint", + "/features/properties/power": "Power", } spanFields = { @@ -253,13 +253,13 @@ class ConvertJSONIntoGeoJSON(ProcessDataTask): "/features/properties/physicalInfrastructureProvider/name": "Physical Infrastructure Provider", "/features/properties/networkProvider/name": "Network Provider", "/features/properties/supplier/name": "Supplier", - # "/features/properties/transmissionMedium": "Transmission Medium", - # "/features/properties/deployment": "Deployment", - # "/features/properties/darkFibre": "Dark Fibre", - # "/features/properties/fibreType": "Fibre Type", - # "/features/properties/fibreCount": "Fibre Count", - # "/features/properties/technologies": "Technologies", - # "/features/properties/capacity": "Capacity", + "/features/properties/transmissionMedium": "Transmission Medium", + "/features/properties/deployment": "Deployment", + "/features/properties/darkFibre": "Dark Fibre", + "/features/properties/fibreType": "Fibre Type", + "/features/properties/fibreCount": "Fibre Count", + "/features/properties/technologies": "Technologies", + "/features/properties/capacity": "Capacity", } def __init__(self, supplied_data): @@ -329,8 +329,16 @@ def get_context(self): data = json.load(fp) context["any_nodes_with_geometry"] = data["any_nodes_with_geometry"] context["any_spans_with_geometry"] = data["any_spans_with_geometry"] - context["nodes_fields"] = {field.split("/")[3]: label for field, label in self.nodeFields.items() if field in data["nodes_output_field_coverage"]} - context["spans_fields"] = {field.split("/")[3]: label for field, label in self.spanFields.items() if field in data["spans_output_field_coverage"]} + context["nodes_fields"] = { + field.split("/")[3]: label + for field, label in self.nodeFields.items() + if field in data["nodes_output_field_coverage"] + } + context["spans_fields"] = { + field.split("/")[3]: label + for field, label in self.spanFields.items() + if field in data["spans_output_field_coverage"] + } else: context["can_download_geojson"] = False # done! diff --git a/cove_ofds/templates/cove_ofds/explore.html b/cove_ofds/templates/cove_ofds/explore.html index a01622a..265a3b9 100644 --- a/cove_ofds/templates/cove_ofds/explore.html +++ b/cove_ofds/templates/cove_ofds/explore.html @@ -313,6 +313,8 @@

{% block extrafooterscript %} {{ block.super }} {% if can_download_geojson %}{% if any_nodes_with_geometry or any_spans_with_geometry %} + {{ nodes_fields|json_script:"node-fields" }} + {{ spans_fields|json_script:"span-fields" }}