in src/mapillary/models/api/entities.py [0:0]
def fetch_detections(self, identity: int, id_type: bool = True, fields: list = []):
"""
Fetches detections depending on the id, detections for either map_features or
images and the fields provided
:param identity: The id to extract for
:type identity: int
:param id_type: Either True(id is for image), or False(id is for map_feature),
defaults to True
:type id_type: bool
:param fields: The fields to extract properties for, defaults to []
:type fields: list
:return: The fetched GeoJSON
:rtype: dict
"""
# If id_type is True(id is for image)
if id_type:
# Store the URL as ...
url = Entities.get_detection_with_image_id(
# .. extracted by setting image_id as id ...
image_id=str(identity),
# ... passing in the fields given ...
fields=fields
# ... only if the fields are not provided empty ...
if fields != []
# ... but if they are, set the fields as all possible fields ...
else Entities.get_detection_with_image_id_fields(),
)
# If id_type is False(id is for map_feature)
else:
# Store the URL as ...
url = Entities.get_detection_with_map_feature_id(
# ... extracted by setting map_feature_id as id ...
map_feature_id=str(identity),
# ... passing in the fields given ...
fields=fields
# ... only if the fields are not provided empty ...
if fields != []
# ... but if they are, set the fields as all possible fields ...
else Entities.get_detection_with_map_feature_id_fields(),
)
# Retrieve the relevant data with `url`, get content, decode to utf-8, return
return detection_features_to_geojson(
json.loads(self.client.get(url).content.decode("utf-8"))["data"]
)