simworld.citygen.road package

Submodules

simworld.citygen.road.road_generator module

Road network generation module for the city simulation.

This module handles the procedural generation of road networks, including the creation of road segments, intersections, and the overall structure of the city’s transportation system.

class simworld.citygen.road.road_generator.RoadGenerator(config, num_segments: int | None = None)

Bases: object

Handles procedural road network generation.

create_segment(start: Point, angle: float, length: float, is_highway: bool, t: float = 0) Segment

Create a new road segment with specified parameters.

Args:

start: Starting point of the segment. angle: Direction angle in degrees. length: Length of the segment. is_highway: Whether this is a highway segment. t: Time parameter for generation sequencing.

Returns:

A new road segment.

find_intersections() None

Find all road intersections in the network.

generate_initial_segments() None

Generate the initial road segments at the city center.

generate_next_segments(segment: Segment)

Generate potential next segments from the current segment.

Args:

segment: The current segment to generate branches from.

generate_roads_from_file(input_path: str) None

Generate roads from a JSON file.

Args:

input_path: Path to the JSON file containing road data.

generate_step() bool

Process one step of road network generation.

Returns:

True when generation should stop, False otherwise.

simworld.citygen.road.road_manager module

Road network management module for the city simulation.

This module provides functionality for managing road segments, including spatial indexing, conflict detection, and intersection identification.

class simworld.citygen.road.road_manager.RoadManager(config)

Bases: object

Manages road segments and their spatial relationships.

add_segment(segment: Segment) None

Add a road segment to the network.

can_place_segment(segment: Segment) bool

Check if a segment can be placed without conflicts.

get_nearby_segments(bounds: Bounds) List[Segment]

Get segments within the specified bounds.

get_segment_by_id(id: int) Segment

Get a road segment by its ID.

rebuild_quadtree()

Rebuild the quadtree.

remove_segment(segment: Segment) None

Remove a road segment from the network.

update_segment(old_segment: Segment, new_segment: Segment) None

Update a road segment’s position in the spatial index.

Module contents

Road generation module for creating road networks in the simulation.

This module provides functionality to generate road networks based on various parameters and constraints, including road density, width, and connectivity.