moss.export

Module Contents

Classes

StringIteratorIO

_CopyWriter

DBRecorder

DBRecorder is for web visualization and writes to Postgres Database

Data

API

moss.export.__all__

[‘DBRecorder’]

class moss.export.StringIteratorIO(iter: Iterator[str])

Bases: io.TextIOBase

readable() bool
_read1(n: Optional[int] = None) str
read(n: Optional[int] = None) str
class moss.export._CopyWriter(dsn: str, proj_str: str, carid2model: Dict[int, str], pedid2model: Dict[int, str])

Initialization

async awrite(table_name: str, step, persons, tls, roads)
class moss.export.DBRecorder(eng: moss.engine.Engine, db_url: str, mongo_map: str, output_name: str, total_steps: int = 86400, use_tqdm: bool = False, max_unwaited: int = 16)

DBRecorder is for web visualization and writes to Postgres Database

The table schema is as follows:

  • meta_simple: The metadata of the simulation.

    • name: The name of the simulation.

    • start: The start step of the simulation.

    • steps: The total steps of the simulation.

    • time: The time of the simulation.

    • total_agents: The total agents of the simulation.

    • map: The map of the simulation.

    • min_lng: The minimum longitude of the simulation.

    • min_lat: The minimum latitude of the simulation.

    • max_lng: The maximum longitude of the simulation.

    • max_lat: The maximum latitude of the simulation.

    • road_status_v_min: The minimum speed of the road status.

    • road_status_interval: The interval of the road status.

    • version: The version of the simulation result schema (now is 2).

  • {output_name}_s_cars: The vehicles of the simulation.

    • step: The step of the simulation.

    • id: The id of the vehicle.

    • parent_id: The parent id of the vehicle.

    • direction: The direction of the vehicle.

    • lng: The longitude of the vehicle.

    • lat: The latitude of the vehicle.

    • model: The model of the vehicle.

    • z: The z of the vehicle.

    • pitch: The pitch of the vehicle.

    • v: The speed of the vehicle.

  • {output_name}_s_people: The people of the simulation.

    • step: The step of the simulation.

    • id: The id of the people.

    • parent_id: The parent id of the people.

    • direction: The direction of the people.

    • lng: The longitude of the people.

    • lat: The latitude of the people.

    • z: The z of the people.

    • v: The speed of the people.

    • model: The model of the people.

  • {output_name}_s_traffic_light: The traffic lights of the simulation.

    • step: The step of the simulation.

    • id: The id of the traffic light.

    • state: The state of the traffic light.

    • lng: The longitude of the traffic light.

    • lat: The latitude of the traffic light.

  • {output_name}_s_road: The road status of the simulation.

    • step: The step of the simulation.

    • id: The id of the road.

    • level: The level of the road.

    • v: The speed of the road.

    • in_vehicle_cnt: The in vehicle count of the road.

    • out_vehicle_cnt: The out vehicle count of the road.

    • cnt: The count of the road.

  • {output_name}_s_aoi: The number of people in AOI (no content, only for compatibility)

    • step: The step of the simulation.

    • id: The id of the AOI.

    • cnt: The count of the people in the AOI.

The index of the table is as follows:

  • {output_name}_s_cars: (step, lng, lat)

  • {output_name}_s_people: (step, lng, lat)

  • {output_name}_s_traffic_light: (step, lng, lat)

  • {output_name}_s_road: (step)

  • {output_name}_s_aoi: (step)

Initialization

Args:

  • eng: The engine to be recorded.

  • db_url: The URL of the database.

  • mongo_map: The map of the simulation.

  • output_name: The name of the output.

  • total_steps: The total steps of the simulation.

  • max_unwaited: The maximum number of unwaited tasks.

__del__()
_init_table()
record()

Record the data of the engine.

flush()

Flush the data to the database.