Skip to content

Commit

Permalink
style: Reformat with tox
Browse files Browse the repository at this point in the history
  • Loading branch information
annehaley committed Aug 2, 2024
1 parent 0bb90a4 commit 0f985c9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion sample_data/use_cases/new_york_energy/contexts.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"default_map_zoom": 8,
"datasets": [
"National Grid CompanyBoundary",
"National Grid Network",
"National Grid County Networks",
"National Grid Substations",
"County Boundaries"
]
Expand Down
48 changes: 26 additions & 22 deletions uvdat/core/tasks/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 0f985c9

Please sign in to comment.