Skip to main content

Build Your Simulation

Build Map

RoadNet Data Preparation

Two ways to get RoadNet data
  1. Prepare your own RoadNet in GeoJSON format
  2. Fetch RoadNet from OpenStreetMap with mosstool
    • Example are as follows
from mosstool.map.osm import RoadNet
rn = RoadNet(
proj_str="+proj=tmerc +lat_0=39.90611 +lon_0=116.3911",
max_latitude=39.92,
min_latitude=39.78,
max_longitude=116.32,
min_longitude=116.40,
)
roadnet = rn.create_road_net()
Args of RoadNet
  1. proj_str (str): projection string, e.g. 'epsg:3857'
  2. max_longitude, min_longitude, max_latitude, min_latitude (float): boundary of the target area, in WGS84.
  3. wikipedia_name (str): wikipedia name of the area in OSM.
  4. proxies (dict): proxies for requests

AOI Data Preparation

Two ways to get AOI data
  1. Prepare your own AOIs in GeoJSON format
  2. Fetch AOI from OpenStreetMap with mosstool
    • Example are as follows
from mosstool.map.osm import Building
building = Building(
proj_str="+proj=tmerc +lat_0=39.90611 +lon_0=116.3911",
max_latitude=39.92,
min_latitude=39.78,
max_longitude=116.32,
min_longitude=116.40,
)
aois = building.create_building()
Args of Building
  1. proj_str (str): projection string, e.g. 'epsg:3857'
  2. max_longitude, min_longitude, max_latitude, min_latitude (float): boundary of the target area, in WGS84.
  3. wikipedia_name (str): wikipedia name of the area in OSM.
  4. proxies (dict): proxies for requests

Generate Map with AOI and RoadNet

With prepared RoadNet roadnet and AOIs aois, we can build our own Map now.

Example is as follows.

from mosstool.map.builder import Builder
builder = Builder(
net=roadnet,
aois=aois,
proj_str="+proj=tmerc +lat_0=33.9 +lon_0=116.4",
)
m = builder.build("example")
Args of Builder
  1. net (FeatureCollection | Map): road network. if input is in Map format, the program extracts lanes, roads and junctions from the Map, mainly for generated map to add AOIs
  2. proj_str (str): projection string
  3. aois (FeatureCollection): area of interest
  4. pois (FeatureCollection): point of interest
  5. public_transport (Dict[str, List]): public transports in json format
  6. pop_tif_path (str): path to population tif file
  7. landuse_shp_path (str): path to landuse shape file
  8. traffic_light_min_direction_group (int): minimum number of lane directions for traffic-light generation
  9. default_lane_width (float): default lane width
  10. min_sidewalk_speed_limit (float): speed limit to generate sidewalk (m/s)
  11. expand_roads (bool): expand roads according to junction type
  12. road_expand_mode (str): road expand mode
  13. green_time (float): traffic light green time in fixed program
  14. strict_mode (bool): when enabled, causes the program to exit whenever a warning occurs
  15. yellow_time (float): traffic light yellow time in fixed program
  16. workers (int): number of workers