Map API

class py123d.api.MapAPI[source]

The base class for all map APIs in 123D.

Public Data Attributes:

map_metadata

The MapMetadata of the map api.

dataset

The dataset name from the map metadata.

location

The location from the map metadata.

map_is_local

Indicates if the map is local (map for each log) or global (map for multiple logs in dataset).

map_has_z

Indicates if the map includes Z (elevation) data.

version

The version of the py123d library used to create this map metadata.

Public Methods:

get_map_metadata()

Returns the MapMetadata of the map api.

get_available_map_layers()

Returns the available MapLayer,

get_map_object(object_id, layer)

Returns a BaseMapObject by its ID

get_map_objects_in_radius(point, radius, layers)

Returns a dictionary of MapLayer to a list of

query(geometry, layers[, predicate, distance])

Queries geometries against the map objects in the specified layers using an optional spatial predicate.

query_object_ids(geometry, layers[, ...])

Queries geometries against the map objects in the specified layers using an optional spatial predicate.


abstractmethod get_map_metadata()[source]

Returns the MapMetadata of the map api.

Return type:

MapMetadata

Returns:

The map metadata, e.g. location, dataset, etc.

abstractmethod get_available_map_layers()[source]
Returns the available MapLayer,

e.g. LANE, LANE_GROUP, etc.

Return type:

List[MapLayer]

Returns:

A list of available map layers.

abstractmethod get_map_object(object_id, layer)[source]
Returns a BaseMapObject by its ID

and MapLayer.

Parameters:
  • object_id (Union[str, int]) – The ID of the map object.

  • layer (MapLayer) – The layer the map object belongs to.

Return type:

Optional[BaseMapObject]

Returns:

The map object if found, None otherwise.

abstractmethod get_map_objects_in_radius(point, radius, layers)[source]
Returns a dictionary of MapLayer to a list of

BaseMapObject within a given radius around a center point.

Parameters:
  • point (Union[Point2D, Point3D]) – The center point to search around.

  • radius (float) – The radius to search within.

  • layers (List[MapLayer]) – The map layers to search in.

Return type:

Dict[MapLayer, List[BaseMapObject]]

Returns:

A dictionary mapping each layer to a list of map objects within the radius.

abstractmethod query(geometry, layers, predicate=None, distance=None)[source]

Queries geometries against the map objects in the specified layers using an optional spatial predicate.

Notes

The syntax is aligned with STRtree implementation of shapely and the corresponding query function [1].

References

Parameters:
  • geometry (Union[BaseGeometry, Iterable[BaseGeometry]]) – A shapely geometry or an iterable of shapely geometries to query against.

  • layers (List[MapLayer]) – The map layers to query against.

  • predicate (Optional[Literal['contains', 'contains_properly', 'covered_by', 'covers', 'crosses', 'intersects', 'overlaps', 'touches', 'within', 'dwithin']]) – An optional spatial predicate to filter the results.

  • distance (Optional[float]) – An optional maximum distance to filter the results, defaults to None.

Return type:

Dict[MapLayer, Union[List[BaseMapObject], Dict[int, List[BaseMapObject]]]]

Returns:

If geometry is a single geometry, a dictionary mapping each layer to a list of map objects.

If geometry is an iterable of geometries, a dictionary mapping each layer to a dictionary of indices (of the input geometries) to lists of map objects (found in map).

abstractmethod query_object_ids(geometry, layers, predicate=None, distance=None)[source]

Queries geometries against the map objects in the specified layers using an optional spatial predicate. Only output the IDs of the matching map objects.

Notes

The syntax is aligned with STRtree implementation of shapely and the corresponding query function [2].

References

Parameters:
  • geometry (Union[BaseGeometry, Iterable[BaseGeometry]]) – A shapely geometry or an iterable of shapely geometries to query against.

  • layers (List[MapLayer]) – The map layers to query against.

  • predicate (Optional[Literal['contains', 'contains_properly', 'covered_by', 'covers', 'crosses', 'intersects', 'overlaps', 'touches', 'within', 'dwithin']]) – An optional spatial predicate to filter the results.

  • distance (Optional[float]) – An optional maximum distance to filter the results, defaults to None.

Return type:

Dict[MapLayer, Union[List[Union[str, int]], Dict[int, List[Union[str, int]]]]]

Returns:

If geometry is a single geometry, a dictionary mapping each layer to a list of map object ids.

If geometry is an iterable of geometries, a dictionary mapping each layer to a dictionary of indices (of the input geometries) to lists of map object ids (found in map).

property map_metadata: MapMetadata

The MapMetadata of the map api.

property dataset: str

The dataset name from the map metadata.

property location: str | None

The location from the map metadata.

property map_is_local: bool

Indicates if the map is local (map for each log) or global (map for multiple logs in dataset).

property map_has_z: bool

Indicates if the map includes Z (elevation) data.

property version: str

The version of the py123d library used to create this map metadata.

class py123d.datatypes.map_objects.MapLayer[source]

Enum for different map layers (i.e. object types) in a map.

Public Data Attributes:

LANE

Lanes (surface).

LANE_GROUP

Lane groups (surface).

INTERSECTION

Intersections (surface).

CROSSWALK

Crosswalks (surface).

WALKWAY

Walkways (surface).

CARPARK

Carparks (surface).

GENERIC_DRIVABLE

Generic drivable (surface).

STOP_ZONE

Stop zones (surface).

ROAD_EDGE

Road edges (lines).

ROAD_LINE

Road lines (lines).

Inherited from Enum

Public Methods:

Inherited from SerialIntEnum

serialize([lower])

Serialize the type when saving.

deserialize(key)

Deserialize the type when loading from a string.

from_int(value)

Get the enum from an int.

from_arbitrary(value)

Get the enum from an int, string, or enum instance.

Private Methods:

_generate_next_value_(start, count, last_values)

Generate the next value when not given.

Inherited from SerialIntEnum

_generate_next_value_(start, count, last_values)

Generate the next value when not given.

Inherited from Enum

_generate_next_value_(start, count, last_values)

Generate the next value when not given.

_missing_(value)

_new_member_(value)

Create and return a new object.


LANE = 0

Lanes (surface).

LANE_GROUP = 1

Lane groups (surface).

INTERSECTION = 2

Intersections (surface).

CROSSWALK = 3

Crosswalks (surface).

WALKWAY = 4

Walkways (surface).

CARPARK = 5

Carparks (surface).

GENERIC_DRIVABLE = 6

Generic drivable (surface).

STOP_ZONE = 7

Stop zones (surface).

ROAD_EDGE = 8

Road edges (lines).

ROAD_LINE = 9

Road lines (lines).