RDG-Networks 0.2.3__py3-none-any.whl → 0.2.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {RDG_Networks-0.2.3.dist-info → RDG_Networks-0.2.4.dist-info}/METADATA +1 -1
- {RDG_Networks-0.2.3.dist-info → RDG_Networks-0.2.4.dist-info}/RECORD +7 -7
- RDG_networks/generate_line_segments_dynamic.py +17 -14
- {RDG_Networks-0.2.3.dist-info → RDG_Networks-0.2.4.dist-info}/LICENSE.txt +0 -0
- {RDG_Networks-0.2.3.dist-info → RDG_Networks-0.2.4.dist-info}/WHEEL +0 -0
- {RDG_Networks-0.2.3.dist-info → RDG_Networks-0.2.4.dist-info}/entry_points.txt +0 -0
- {RDG_Networks-0.2.3.dist-info → RDG_Networks-0.2.4.dist-info}/top_level.txt +0 -0
@@ -3,12 +3,12 @@ RDG_networks/__init__.py,sha256=aCfGs87cJn0Tp5GqTpFXPOEfJPpR4Tnnz819Kk_0t84,661
|
|
3
3
|
RDG_networks/draw_segments.py,sha256=U53N5GXmQHWKdM1Q1faP_EGKjc6enOu2mcsunzSFpP0,984
|
4
4
|
RDG_networks/generate_line_network.py,sha256=lJ4rhObim3WcEQoebomewRQKWNJC5phFyFYRW7qjXIg,1127
|
5
5
|
RDG_networks/generate_line_segments.py,sha256=QV8_k7q6TD5c7Hcb2Ms_apEdWYw4XdLr7rdJgh49v4Q,9004
|
6
|
-
RDG_networks/generate_line_segments_dynamic.py,sha256=
|
6
|
+
RDG_networks/generate_line_segments_dynamic.py,sha256=GoIhGXYbcvjqR5BJCnkvAGp8QBpzsE1ZSbl2k9XAOGI,7531
|
7
7
|
RDG_networks/get_intersection_segments.py,sha256=mXB5qCy1oOps4Vu1mX6flW6v_4Xxc71YK41yOWjJX8o,2797
|
8
8
|
RDG_networks/sample_in_polygon.py,sha256=qpPpW-Da1vK8ZkVWMJ0zBsE8IgyMB619gCdybSkzKSQ,1605
|
9
|
-
RDG_Networks-0.2.
|
10
|
-
RDG_Networks-0.2.
|
11
|
-
RDG_Networks-0.2.
|
12
|
-
RDG_Networks-0.2.
|
13
|
-
RDG_Networks-0.2.
|
14
|
-
RDG_Networks-0.2.
|
9
|
+
RDG_Networks-0.2.4.dist-info/LICENSE.txt,sha256=BHUkX2GsdTr30sKmVZ1MLGR1njnx17EX_oUuuSVZZPE,598
|
10
|
+
RDG_Networks-0.2.4.dist-info/METADATA,sha256=UAxR8eK6DyBT3B1C1O9chrCUnYpWfhh7YcytLETtYMc,2422
|
11
|
+
RDG_Networks-0.2.4.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
|
12
|
+
RDG_Networks-0.2.4.dist-info/entry_points.txt,sha256=Htsh9jRabMCGHwXayUwZoSy-9IFGFrMB1X9hgyyr3_8,350
|
13
|
+
RDG_Networks-0.2.4.dist-info/top_level.txt,sha256=4gUUYafD5Al9V8ZSiViVGYHpRMMCsCBcGgCNodk9Syg,13
|
14
|
+
RDG_Networks-0.2.4.dist-info/RECORD,,
|
@@ -2,6 +2,7 @@ import numpy as np
|
|
2
2
|
import random
|
3
3
|
from shapely.geometry import LineString
|
4
4
|
from typing import List, Dict, Any, Tuple
|
5
|
+
import matplotlib.pyplot as plt
|
5
6
|
|
6
7
|
from .Classes import LineSegment
|
7
8
|
|
@@ -88,7 +89,7 @@ def update_for_border_intersections(lines: List[Dict[str, Any]]) -> List[Dict[st
|
|
88
89
|
|
89
90
|
return lines
|
90
91
|
|
91
|
-
def check_and_update_when_intersect(lines: List[Dict[str, Any]], epsilon: float) -> List[Dict[str, Any]]:
|
92
|
+
def check_and_update_when_intersect(lines: List[Dict[str, Any]], epsilon: float, dt: float) -> List[Dict[str, Any]]:
|
92
93
|
"""
|
93
94
|
Check for intersections between lines and update their properties accordingly.
|
94
95
|
|
@@ -99,36 +100,37 @@ def check_and_update_when_intersect(lines: List[Dict[str, Any]], epsilon: float)
|
|
99
100
|
Returns:
|
100
101
|
List[Dict[str, Any]]: The updated list of lines after handling intersections.
|
101
102
|
"""
|
103
|
+
|
102
104
|
for index1, j1 in enumerate(lines):
|
103
105
|
for index2, j2 in enumerate(lines):
|
104
106
|
if j1['id'][:-2] == j2['id'][:-2] or index2 < index1:
|
105
107
|
continue
|
106
|
-
|
108
|
+
|
107
109
|
if j1['growth_status'] == False and j2['growth_status'] == False:
|
108
110
|
continue
|
109
|
-
|
111
|
+
|
110
112
|
line1 = LineString([j1['start'], j1['end']])
|
111
113
|
line2 = LineString([j2['start'], j2['end']])
|
112
|
-
|
114
|
+
|
113
115
|
intersection_pt = line1.intersection(line2)
|
114
116
|
|
115
117
|
if not intersection_pt.is_empty:
|
116
118
|
d1 = np.linalg.norm(np.array(j1['start']) - np.array([intersection_pt.x, intersection_pt.y]))
|
117
119
|
d2 = np.linalg.norm(np.array(j2['start']) - np.array([intersection_pt.x, intersection_pt.y]))
|
118
120
|
|
119
|
-
arrival_1 = j1['introduction_time'] + d1 / epsilon
|
120
|
-
arrival_2 = j2['introduction_time'] + d2 / epsilon
|
121
|
+
arrival_1 = j1['introduction_time'] + d1 / epsilon * dt
|
122
|
+
arrival_2 = j2['introduction_time'] + d2 / epsilon * dt
|
121
123
|
|
122
124
|
if arrival_1 > arrival_2:
|
123
125
|
lines[index1]['end'] = (intersection_pt.x, intersection_pt.y)
|
124
126
|
lines[index1]['neighbors_initial'] = lines[index1]['neighbors_initial'] + [j2['id'][:-2]]
|
125
|
-
lines[index1]['growth_status'] = False
|
127
|
+
lines[index1]['growth_status'] = False
|
126
128
|
|
127
129
|
else:
|
128
130
|
lines[index2]['end'] = (intersection_pt.x, intersection_pt.y)
|
129
131
|
lines[index2]['neighbors_initial'] = lines[index2]['neighbors_initial'] + [j1['id'][:-2]]
|
130
132
|
lines[index2]['growth_status'] = False
|
131
|
-
|
133
|
+
|
132
134
|
return lines
|
133
135
|
|
134
136
|
def transform_to_standard_lines(lines: List[Dict[str, Any]]) -> List[LineSegment]:
|
@@ -173,7 +175,7 @@ def generate_line_segments_dynamic(size: int, dt: float, epsilon: float, time: f
|
|
173
175
|
"""
|
174
176
|
lines = []
|
175
177
|
line_id, t, t_total = 1, 0, 0
|
176
|
-
|
178
|
+
|
177
179
|
# Stop loop whenever we have enough lines and all lines have stopped growing
|
178
180
|
while len(lines) / 2 < size or np.any([item['growth_status'] for item in lines]):
|
179
181
|
|
@@ -185,17 +187,18 @@ def generate_line_segments_dynamic(size: int, dt: float, epsilon: float, time: f
|
|
185
187
|
if time == 0:
|
186
188
|
number_of_lines_to_add = size
|
187
189
|
else:
|
188
|
-
number_of_lines_to_add = int(t
|
190
|
+
number_of_lines_to_add = int(t / time)
|
191
|
+
|
189
192
|
for _ in range(number_of_lines_to_add):
|
190
193
|
lines = add_new_line(lines, line_id, t_total, angles=angles)
|
191
194
|
line_id += 1
|
192
|
-
|
193
|
-
|
195
|
+
|
196
|
+
t = 0
|
194
197
|
|
195
198
|
lines = grow_lines(lines, epsilon)
|
196
199
|
lines = update_for_border_intersections(lines)
|
197
|
-
lines = check_and_update_when_intersect(lines, epsilon)
|
198
|
-
|
200
|
+
lines = check_and_update_when_intersect(lines, epsilon, dt)
|
201
|
+
|
199
202
|
lines = transform_to_standard_lines(lines)
|
200
203
|
|
201
204
|
return lines
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|