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, sort, ...])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.
query_nearest(geometry, layers[, ...])Return the nearest map objects in a spatial tree for each input geometry in
- 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, sort=False, distance=None)[source]¶
Queries geometries against the map objects in the specified layers using an optional spatial predicate.
Notes
The implementation is aligned with the geopandas spatial index query method [1]_, used in the
GPKGMapAPI. It is likely this method will be removed or improved in future versions of 123D.References
[1] https://geopandas.org/en/stable/docs/reference/api/geopandas.sindex.SpatialIndex.query.html
- Parameters:
geometry (
Union[Geometry,Iterable[Geometry]]) – 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.sort (
bool) – Whether to sort the results by distance, defaults to False.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:
A dictionary mapping each layer to a list of map objects or a dictionary of indices to lists of map objects.
- abstractmethod query_object_ids(geometry, layers, predicate=None, sort=False, distance=None)[source]¶
Queries geometries against the map objects in the specified layers using an optional spatial predicate. Instead of returning the map objects, it returns their IDs only.
Notes
The implementation is aligned with the geopandas spatial index query method [1]_, used in the
GPKGMapAPI. It is likely this method will be removed or improved in future versions of 123D.References
[1] https://geopandas.org/en/stable/docs/reference/api/geopandas.sindex.SpatialIndex.query.html
- Parameters:
geometry (
Union[Geometry,Iterable[Geometry]]) – A shapely geometry or an iterable of shapely geometries to query against.predicate (
Optional[str]) – An optional spatial predicate to filter the results.sort (
bool) – Whether to sort the results by distance, defaults to False.distance (
Optional[float]) – An optional maximum distance to filter the results, defaults to None.
- Return type:
- Returns:
A dictionary mapping each layer to a list of map object IDs or a dictionary of indices to lists of map object IDs.
- abstractmethod query_nearest(geometry, layers, return_all=True, max_distance=None, return_distance=False, exclusive=False)[source]¶
Return the nearest map objects in a spatial tree for each input geometry in
Notes
The implementation is aligned with the geopandas spatial index nearest method [1]_, used in the
GPKGMapAPI. It is likely this method will be removed or improved in future versions of 123D.References
[1] https://geopandas.org/en/stable/docs/reference/api/geopandas.sindex.SpatialIndex.nearest.html
- Parameters:
geometry (
Union[Geometry,Iterable[Geometry]]) – A shapely geometry or an iterable of shapely geometries to query against.return_all (
bool) – Whether to return all matching objects or just the closest one, defaults to True.max_distance (
Optional[float]) – An optional maximum distance to filter the results, defaults to None.return_distance (
bool) – Whether to return the distance to the nearest object, defaults to False.exclusive (
bool) – Whether to exclude the input geometries from the results, defaults to False.
- Return type:
Dict[MapLayer,Union[List[BaseMapObject],Dict[int,List[BaseMapObject]]]]- Returns:
A dictionary mapping each layer to a list of nearest map objects or a dictionary of indices to lists of nearest map objects.
- 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).
- classmethod deserialize(key)¶
Deserialize the type when loading from a string.
- Return type:
SerialIntEnum- Parameters:
key (str)