Skip to content

Commit

Permalink
maps: Provide 7 colours for network styles
Browse files Browse the repository at this point in the history
This provides 7 colours which are used in sequence for unique networks. These colours are repeated once the number exceeds 7.
And adds a legend
  • Loading branch information
Jared Parnell committed Nov 11, 2022
1 parent d1599a5 commit 405afdb
Show file tree
Hide file tree
Showing 7 changed files with 618 additions and 35 deletions.
30 changes: 30 additions & 0 deletions cove_ofds/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,34 @@ def get_context(self):
class ConvertJSONIntoGeoJSON(ProcessDataTask):
"""Convert primary format (JSON) to GeoJSON"""

nodeFields = {
"/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/technologies": "Technologies",
# "/features/properties/status": "Status",
# "/features/properties/type": "Type",
# "/features/properties/accessPoint": "accessPoint",
# "/features/properties/power": "Power",
}

spanFields = {
"/features/properties/network/name": "Network",
"/features/properties/phase/name": "Phase",
"/features/properties/status/name": "Status",
"/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",
}

def __init__(self, supplied_data):
super().__init__(supplied_data)
self.nodes_file_name = os.path.join(
Expand Down Expand Up @@ -298,6 +326,8 @@ 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"]}
else:
context["can_download_geojson"] = False
# done!
Expand Down
8 changes: 8 additions & 0 deletions cove_ofds/sass/_custom-ofds.sass
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,11 @@
.popupCustom .leaflet-popup-tip
border-right: 15px solid #CCC
border-top: 15px solid #CCC

.popupCustom p
margin: 0

.leaflet-legend-item span
display: inline
font-size: 16px
margin-left: 10px
2 changes: 1 addition & 1 deletion cove_ofds/static/dataexplore/css/bootstrap-ofds.css

Large diffs are not rendered by default.

83 changes: 83 additions & 0 deletions cove_ofds/static/dataexplore/css/leaflet.legend.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
.leaflet-legend {
background-color: white;
}

.leaflet-legend-title {
margin: 3px;
padding-bottom: 5px;
}

.leaflet-legend-column {
float: left;
margin-left: 10px;
}


.leaflet-legend-item {
display: table;
margin: 2px 0;
}

.leaflet-legend-item span {
vertical-align: middle;
display: table-cell;
word-break: keep-all;
white-space: nowrap;
background-color: transparent;
text-align: left;
}

.leaflet-legend-item-clickable {
cursor: pointer;
}

.leaflet-legend-item-inactive span {
color: #cccccc;
}

.leaflet-legend-item-inactive i img, .leaflet-legend-item-inactive i canvas {
opacity: 0.3;
/*
color: #000000;
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-ms-filter: grayscale(100%);
-o-filter: grayscale(100%);
filter: grayscale(100%);
filter: gray;
*/
}

.leaflet-legend-item i {
display: inline-block;
padding: 0px 3px 0px 4px;
position: relative;
vertical-align: middle;
}

.leaflet-legend-toggle {
background-image: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNTk5MDE0Mjk2NTEwIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjE3Nzk4IiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0Ij48ZGVmcz48c3R5bGUgdHlwZT0idGV4dC9jc3MiPjwvc3R5bGU+PC9kZWZzPjxwYXRoIGQ9Ik05MzQuNCA0NzguNzJINzM3LjI4Yy0xNS44NzItMTEwLjA4LTExMS4xMDQtMTk0LjU2LTIyNS4yOC0xOTQuNTZTMzAyLjU5MiAzNjguNjQgMjg2LjcyIDQ3OC43Mkg4OS42djY2LjU2SDI4Ni43MmMxNS44NzIgMTEwLjA4IDExMS4xMDQgMTk0LjU2IDIyNS4yOCAxOTQuNTZzMjA5LjQwOC04NC40OCAyMjUuMjgtMTk0LjU2aDE5Ny4xMnYtNjYuNTZ6IiBmaWxsPSIjNzA3MDcwIiBwLWlkPSIxNzc5OSI+PC9wYXRoPjwvc3ZnPg==");
background-repeat: no-repeat;
background-position: 50% 50%;
box-shadow: none;
border-radius: 4px;
}

.leaflet-legend-contents {
display: none;
}

.leaflet-legend-expanded .leaflet-legend-contents {
display: block;
padding: 6px 15px 6px 6px;
}

.leaflet-legend-contents img {
position: absolute;
}

.leaflet-legend-contents:after {
content: "";
display: block;
clear: both;
}
Loading

0 comments on commit 405afdb

Please sign in to comment.