Map API¶
- class py123d.api.MapAPI[source]¶
The base class for all map APIs in 123D.
Public Data Attributes:
map_metadataThe
MapMetadataof the map api.datasetThe dataset name from the map metadata.
locationThe location from the map metadata.
map_is_localIndicates if the map is local (map for each log) or global (map for multiple logs in dataset).
map_has_zIndicates if the map includes Z (elevation) data.
versionThe version of the py123d library used to create this map metadata.
Public Methods:
get_map_metadata()Returns the
MapMetadataof the map api.get_available_map_layers()Returns the available
MapLayer,get_map_object(object_id, layer)Returns a
BaseMapObjectby its IDget_map_objects_in_radius(point, radius, layers)Returns a dictionary of
MapLayerto a list ofquery(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
MapMetadataof the map api.- Return type:
- 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.
- Returns the available
- abstractmethod get_map_object(object_id, layer)[source]¶
- Returns a
BaseMapObjectby its ID and
MapLayer.
- Parameters:
- Return type:
- Returns:
The map object if found, None otherwise.
- Returns a
- abstractmethod get_map_objects_in_radius(point, radius, layers)[source]¶
- Returns a dictionary of
MapLayerto a list of BaseMapObjectwithin a given radius around a center point.
- Parameters:
- Return type:
- Returns:
A dictionary mapping each layer to a list of map objects within the radius.
- Returns a dictionary of
- 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
queryfunction [1].References
- Parameters:
geometry (
Union[BaseGeometry,Iterable[BaseGeometry]]) – A shapely geometry or an iterable of shapely geometries 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
queryfunction [2].References
[2] https://shapely.readthedocs.io/en/latest/strtree.html#shapely.STRtree.query
- Parameters:
geometry (
Union[BaseGeometry,Iterable[BaseGeometry]]) – A shapely geometry or an iterable of shapely geometries 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
MapMetadataof the map api.
- class py123d.datatypes.map_objects.MapLayer[source]¶
Enum for different map layers (i.e. object types) in a map.
Public Data Attributes:
LANELanes (surface).
LANE_GROUPLane groups (surface).
INTERSECTIONIntersections (surface).
CROSSWALKCrosswalks (surface).
WALKWAYWalkways (surface).
CARPARKCarparks (surface).
GENERIC_DRIVABLEGeneric drivable (surface).
STOP_ZONEStop zones (surface).
ROAD_EDGERoad edges (lines).
ROAD_LINERoad lines (lines).
Inherited from
EnumPublic Methods:
Inherited from
SerialIntEnumserialize([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).