Build Your Simulation
Build Map
RoadNet Data Preparation
Two ways to get RoadNet data
- Prepare your own RoadNet in GeoJSON format
- 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
proj_str (str)
: projection string, e.g. 'epsg:3857'max_longitude, min_longitude, max_latitude, min_latitude (float)
: boundary of the target area, in WGS84.wikipedia_name (str)
: wikipedia name of the area in OSM.proxies (dict)
: proxies for requests
AOI Data Preparation
Two ways to get AOI data
- Prepare your own AOIs in GeoJSON format
- 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
proj_str (str)
: projection string, e.g. 'epsg:3857'max_longitude, min_longitude, max_latitude, min_latitude (float)
: boundary of the target area, in WGS84.wikipedia_name (str)
: wikipedia name of the area in OSM.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
net (FeatureCollection | Map)
: road network. if input is inMap
format, the program extracts lanes, roads and junctions from theMap
, mainly for generated map to add AOIsproj_str (str)
: projection stringaois (FeatureCollection)
: area of interestpois (FeatureCollection)
: point of interestpublic_transport (Dict[str, List])
: public transports in json formatpop_tif_path (str)
: path to population tif filelanduse_shp_path (str)
: path to landuse shape filetraffic_light_min_direction_group (int)
: minimum number of lane directions for traffic-light generationdefault_lane_width (float)
: default lane widthmin_sidewalk_speed_limit (float)
: speed limit to generate sidewalk (m/s)expand_roads (bool)
: expand roads according to junction typeroad_expand_mode (str)
: road expand modegreen_time (float)
: traffic light green time in fixed programstrict_mode (bool)
: when enabled, causes the program to exit whenever a warning occursyellow_time (float)
: traffic light yellow time in fixed programworkers (int)
: number of workers