From 0f985c96452d0fa834b371f990b045af85e4d29c Mon Sep 17 00:00:00 2001 From: Anne Haley Date: Mon, 29 Jul 2024 18:34:48 +0000 Subject: [PATCH] style: Reformat with tox --- .../use_cases/new_york_energy/contexts.json | 2 +- uvdat/core/tasks/networks.py | 48 ++++++++++--------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/sample_data/use_cases/new_york_energy/contexts.json b/sample_data/use_cases/new_york_energy/contexts.json index 23d4550f..d58f67e5 100644 --- a/sample_data/use_cases/new_york_energy/contexts.json +++ b/sample_data/use_cases/new_york_energy/contexts.json @@ -8,7 +8,7 @@ "default_map_zoom": 8, "datasets": [ "National Grid CompanyBoundary", - "National Grid Network", + "National Grid County Networks", "National Grid Substations", "County Boundaries" ] diff --git a/uvdat/core/tasks/networks.py b/uvdat/core/tasks/networks.py index ec34f97d..2c2ec9e4 100644 --- a/uvdat/core/tasks/networks.py +++ b/uvdat/core/tasks/networks.py @@ -6,7 +6,7 @@ import numpy import shapely -from uvdat.core.models import Network, NetworkEdge, NetworkNode, VectorMapLayer, VectorFeature +from uvdat.core.models import Network, NetworkEdge, NetworkNode, VectorFeature, VectorMapLayer NODE_RECOVERY_MODES = [ 'random', @@ -216,27 +216,31 @@ def geojson_from_network(dataset): def vector_features_from_network(network): VectorMapLayer.objects.filter(dataset=network.dataset).delete() map_layer, created = VectorMapLayer.objects.get_or_create(dataset=network.dataset, index=0) - VectorFeature.objects.bulk_create([ - VectorFeature( - map_layer=map_layer, - geometry=node.location, - properties=dict(node_id=node.id, **node.metadata), - ) - for node in network.nodes.all() - ]) - VectorFeature.objects.bulk_create([ - VectorFeature( - map_layer=map_layer, - geometry=edge.line_geometry, - properties=dict( - edge_id=edge.id, - from_node_id=edge.from_node.id, - to_node_id=edge.to_node.id, - **edge.metadata, - ), - ) - for edge in network.edges.all() - ]) + VectorFeature.objects.bulk_create( + [ + VectorFeature( + map_layer=map_layer, + geometry=node.location, + properties=dict(node_id=node.id, **node.metadata), + ) + for node in network.nodes.all() + ] + ) + VectorFeature.objects.bulk_create( + [ + VectorFeature( + map_layer=map_layer, + geometry=edge.line_geometry, + properties=dict( + edge_id=edge.id, + from_node_id=edge.from_node.id, + to_node_id=edge.to_node.id, + **edge.metadata, + ), + ) + for edge in network.edges.all() + ] + ) def get_network_graph(network):