agentsociety.environment.mapdata

Module Contents

Classes

MapConfig

Map configuration class.

MapData

地图API Map API

Data

API

agentsociety.environment.mapdata.__all__

[‘MapData’, ‘MapConfig’]

class agentsociety.environment.mapdata.MapConfig

Bases: pydantic.BaseModel

Map configuration class.

file_path: str

‘Field(…)’

Path to the map file. If s3 is enabled, the file will be downloaded from S3

class agentsociety.environment.mapdata.MapData(config: agentsociety.environment.mapdata.MapConfig, s3config: agentsociety.s3.S3Config)

地图API Map API

Initialization

Args:

  • config (MapConfig): Map config, Defaults to None. Map config.

header: dict

None

地图元数据,包含如下属性: Map metadata, including the following attributes:

  • name (string): 城市道路名称,供标识数据集合的语义。Map name, to identify the semantics of data collections.

  • date (string): 城市道路数据的创建时间。Map data creation time.

  • north (float): 道路数据的北边界坐标。The coordinate of the northern boundary of the Map data.

  • south (float): 道路数据的南边界坐标。The coordinate of the southern boundary of the Map data.

  • east (float): 道路数据的东边界坐标。The coordinate of the eastern boundary of the Map data.

  • west (float): 道路数据的西边界坐标。The coordinate of the western boundary of the Map data.

  • projection (string): PROJ.4 投影字符串,用以支持xy坐标到其他坐标系的转换。PROJ.4 projection string to support the conversion of xy coordinates to other coordinate systems.

aois: Dict[int, dict]

None

地图中的AOI集合(aoi),字典的值包含如下属性: AOI collection (aoi) in the map, the value of the dictionary contains the following attributes:

  • id (int): AOI编号。AOI ID.

  • positions (list[XYPosition]): 多边形空间范围。Shape of polygon.

  • area (float): 面积(单位: m2)。Area.

  • driving_positions (list[LanePosition]): 和道路网中行车道的连接点。Connection points to driving lanes.

  • walking_positions (list[LanePosition]): 和道路网中人行道的连接点。Connection points to pedestrian lanes.

  • driving_gates (list[XYPosition]): 和道路网中行车道的连接点对应的AOI边界上的位置。Position on the AOI boundary corresponding to the connection point to driving lanes.

  • walking_gates (list[XYPosition]): 和道路网中人行道的连接点对应的AOI边界上的位置。Position on the AOI boundary corresponding to the connection point to pedestrian lanes.

  • urban_land_use (Optional[str]): 城市建设用地分类,参照执行标准GB 50137-2011(https://www.planning.org.cn/law/uploads/2013/1383993139.pdf) Urban Land use type, refer to the national standard GB 50137-2011.

  • poi_ids (list[int]): 包含的POI列表。Contained POI IDs.

  • shapely_xy (shapely.geometry.Polygon): AOI的形状(xy坐标系)。Shape of polygon (in xy coordinates).

  • shapely_lnglat (shapely.geometry.Polygon): AOI的形状(经纬度坐标系)。Shape of polygon (in latitude and longitude).

pois: Dict[int, dict]

None

地图中的POI集合(poi),字典的值包含如下属性: POI collection (poi) in the map, the value of the dictionary contains the following attributes:

  • id (int): POI编号。POI ID.

  • name (string): POI名称。POI name.

  • category (string): POI类别编码。POI category code.

  • position (XYPosition): POI位置。POI position.

  • aoi_id (int): POI所属的AOI编号。AOI ID to which the POI belongs.

get_all_aois()
get_aoi(aoi_id: int)
get_all_pois()
get_poi(poi_id: int)
_parse_map(m: List[Any]) Dict[str, Any]
_build_geo_index()
query_pois(center: Union[Tuple[float, float], shapely.geometry.Point], radius: Optional[float] = None, category_prefix: Optional[str] = None, limit: Optional[int] = None, return_distance: bool = True) Union[List[Tuple[Any, float]], List[Any]]

查询center点指定半径内类别满足前缀的poi(按距离排序)。Query the POIs whose categories satisfy the prefix within the specified radius of the center point (sorted by distance).

Args:

  • center (x, y): 中心点(xy坐标系)。Center point (xy coordinate system).

  • radius (float, optional): 半径(单位:m)。如果不提供则返回所有的poi。Radius (unit: m).If not provided, all pois within the map will be returned.

  • category_prefix (str, optional): 类别前缀,如实际类别为100000,那么匹配的前缀可以为10、1000等。Category prefix, if the actual category is 100000, then the matching prefix can be 10, 1000, etc.

  • limit (int, optional): 最多返回的poi数量,按距离排序,近的优先(默认None). The maximum number of POIs returned, sorted by distance, closest ones first (default to None).

  • return_distance (bool): 是否返回距离。Return the distance or not.

Returns:

  • Union[List[Tuple[Any, float]],List[Any]]: poi列表,每个元素为(poi, 距离)或者poi。poi list, each element is (poi, distance) or poi.

get_poi_cate()
get_map_header()
get_projector()
query_aois(center: Union[Tuple[float, float], shapely.geometry.Point], radius: float, urban_land_uses: Optional[List[str]] = None, limit: Optional[int] = None) List[Tuple[Any, float]]

查询center点指定半径内城市用地满足条件的aoi(按距离排序)。Query the AOIs whose urban land use within the specified radius of the center point meets the conditions (sorted by distance).

Args:

  • center (x, y): 中心点(xy坐标系)。Center point (xy coordinate system).

  • radius (float): 半径(单位:m)。Radius (unit: m).

  • urban_land_uses (List[str], optional): 城市用地分类列表,参照执行标准GB 50137-2011(https://www.planning.org.cn/law/uploads/2013/1383993139.pdf). Urban land use classification list, refer to the national standard GB 50137-2011.

  • limit (int, optional): 最多返回的aoi数量,按距离排序,近的优先(默认None). The maximum number of AOIs returned, sorted by distance, closest ones first (default to None).

Returns:

  • List[Tuple[Any, float]]: aoi列表,每个元素为(aoi, 距离)。aoi list, each element is (aoi, distance).