Skip to content

Commit

Permalink
Merge pull request #3 from theodm/feature/Update_To_Newer_Libary_Vers…
Browse files Browse the repository at this point in the history
…ions

Updated library versions
  • Loading branch information
gabrielspadon authored Jun 23, 2024
2 parents 77c81e0 + 338dfac commit 4f875f5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,8 @@ notebooks/.ipynb_checkpoints/*
notebooks/cache/*
cache/*

# Files created by installing via pip
/StreetContinuity.egg-info

# Used for local tests
/local_test
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
license='GLP-3.0',
packages=['street_continuity'],
install_requires=[
'numpy>=1.15.4',
'osmnx>=0.8.1',
'networkx>= 2.1',
'numpy>=1.26.2',
'osmnx>=1.7.1',
'networkx>=3.2.1',
],
include_package_data=True,
zip_safe=False)
18 changes: 9 additions & 9 deletions street_continuity/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def from_osmnx(oxg: nx.MultiDiGraph, use_label: bool):
oxg = nx.Graph(oxg)

# removing self-loops from the resulting graph
oxg.remove_edges_from(oxg.selfloop_edges())
oxg.remove_edges_from(nx.selfloop_edges(oxg))

# latitude (y-axis) and longitude (x-axis)
node_dictionary = {nid: (data['y'], data['x']) for nid, data in oxg.nodes(data=True)}
Expand Down Expand Up @@ -162,14 +162,14 @@ def write_graphml(graph: DualGraph, filename: str = 'file.graphml', directory: s
# inserting new node and related attributes
nxg.add_node(nid)
# GraphML does not support lists and dictionaries as objects, so we must add attributes one by one
nxg.node[nid]['names'] = str(data.names)
nxg.node[nid]['nodes'] = str(data.nodes)
nxg.node[nid]['edges'] = str(data.edges)
nxg.node[nid]['source'] = data.source
nxg.node[nid]['target'] = data.target
nxg.node[nid]['length'] = data.length
nxg.node[nid]['src_edge'] = data.src_edge
nxg.node[nid]['tgt_edge'] = data.tgt_edge
nxg.nodes[nid]['names'] = str(data.names)
nxg.nodes[nid]['nodes'] = str(data.nodes)
nxg.nodes[nid]['edges'] = str(data.edges)
nxg.nodes[nid]['source'] = data.source
nxg.nodes[nid]['target'] = data.target
nxg.nodes[nid]['length'] = data.length
nxg.nodes[nid]['src_edge'] = data.src_edge
nxg.nodes[nid]['tgt_edge'] = data.tgt_edge

# creating edges that connect nodes whenever we have two edges (PrimalEdge) crossings each other
for eid, (source, target) in graph.edge_dictionary.items():
Expand Down
3 changes: 2 additions & 1 deletion street_continuity/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import warnings
import osmnx as ox
import numpy as np
import osmnx.distance as oxd


def compute_distance(source_coordinates: tuple, target_coordinates: tuple):
Expand All @@ -25,7 +26,7 @@ def compute_distance(source_coordinates: tuple, target_coordinates: tuple):
target_longitude, target_latitude = target_coordinates

# calculating the length of the edge
return np.round(ox.great_circle_vec(source_latitude, source_longitude, target_latitude, target_longitude), 2)
return np.round(oxd.great_circle(source_latitude, source_longitude, target_latitude, target_longitude), 2)


def compute_angle(neighbor, source, target):
Expand Down

0 comments on commit 4f875f5

Please sign in to comment.