Fix naming convention
This commit is contained in:
3
networks/roads/intersections/Intersection.py
Normal file
3
networks/roads/intersections/Intersection.py
Normal file
@@ -0,0 +1,3 @@
|
||||
class Intersection:
|
||||
def __init__(self, Roads):
|
||||
self.Roads = Roads
|
||||
37
networks/roads/lanes/Lane.py
Normal file
37
networks/roads/lanes/Lane.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import networks.geometry.curve as curve
|
||||
import networks.geometry.CurveSurface as CurveSurface
|
||||
import networks.geometry.segment as segment
|
||||
import random
|
||||
|
||||
|
||||
class Lane:
|
||||
def __init__(self, coordinates, lane_materials, width):
|
||||
self.coordinates = coordinates
|
||||
self.width = width
|
||||
self.lane_materials = lane_materials
|
||||
self.surface = []
|
||||
|
||||
def get_surface(self):
|
||||
resolution, distance = curve.resolution_distance(self.coordinates, 6)
|
||||
|
||||
curve_points = curve.curve(self.coordinates, resolution)
|
||||
curve_surface = CurveSurface.CurveSurface(self.coordinates)
|
||||
curve_surface.compute_curvature()
|
||||
|
||||
# Set the road to be flat
|
||||
normals = []
|
||||
for i in range(len(curve_surface.curvature)):
|
||||
normals.append((0, 1, 0))
|
||||
|
||||
# Compute each line
|
||||
for distance in range(self.width):
|
||||
offset = curve.offset(curve_surface.curve, distance, normals)
|
||||
for i in range(len(offset)-1):
|
||||
line = segment.discrete_segment(offset[i], offset[i+1])
|
||||
for coordinate in line:
|
||||
self.surface.append((coordinate, random.choices(
|
||||
list(self.lane_materials.keys()),
|
||||
weights=self.lane_materials.values(),
|
||||
k=1,)))
|
||||
|
||||
return self.surface
|
||||
7
networks/roads/lanes/lanes.json
Normal file
7
networks/roads/lanes/lanes.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"classic_lane": {"stone": 3, "andesite": 1},
|
||||
"modern_lane": {"black_concrete": 3, "black_concrete_powder": 1},
|
||||
|
||||
"bike_lane_green": {"green_concrete": 3, "green_concrete_powder": 1},
|
||||
"bike_lane_red": {"red_concrete": 3, "red_concrete_powder": 1}
|
||||
}
|
||||
42
networks/roads/lines/Line.py
Normal file
42
networks/roads/lines/Line.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import networks.geometry.curve as curve
|
||||
import networks.geometry.segment as segment
|
||||
import random
|
||||
|
||||
|
||||
class Line:
|
||||
def __init__(self, coordinates, line_materials):
|
||||
self.coordinates = coordinates
|
||||
self.line_materials = line_materials
|
||||
self.surface = []
|
||||
|
||||
def get_surface(self):
|
||||
resolution, distance = curve.resolution_distance(self.coordinates, 6)
|
||||
|
||||
curve_points = curve.curve(self.coordinates, resolution)
|
||||
|
||||
# Compute the line
|
||||
|
||||
pattern_length = 0
|
||||
pattern_materials = []
|
||||
|
||||
for pattern in self.line_materials:
|
||||
pattern_length += pattern[1]
|
||||
for _ in range(pattern[1]):
|
||||
pattern_materials.append(pattern[0])
|
||||
|
||||
pattern_iteration = 0
|
||||
for i in range(len(curve_points)-1):
|
||||
line = segment.discrete_segment(curve_points[i], curve_points[i+1])
|
||||
for coordinate in line:
|
||||
block = random.choices(
|
||||
list(pattern_materials[pattern_iteration].keys()),
|
||||
weights=pattern_materials[pattern_iteration].values(),
|
||||
k=1)[0]
|
||||
if block != 'None':
|
||||
self.surface.append((coordinate, block))
|
||||
|
||||
pattern_iteration += 1
|
||||
if pattern_iteration >= pattern_length:
|
||||
pattern_iteration = 0
|
||||
|
||||
return self.surface
|
||||
10
networks/roads/lines/lines.json
Normal file
10
networks/roads/lines/lines.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"solid_white": [
|
||||
[{"white_concrete": 3, "white_concrete_powder": 1}, 1]
|
||||
],
|
||||
|
||||
"broken_white": [
|
||||
[{"white_concrete": 3, "white_concrete_powder": 1}, 3],
|
||||
[{"None": 1}, 1]
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user