Merge pull request 'Add bbox filtering to get mapillary images/sequences' (#8) from remonet/mapillary_download:tykayn/batch-get-mapillary-sequences into tykayn/batch-get-mapillary-sequences

Reviewed-on: #8
This commit is contained in:
tykayn 2024-11-02 18:38:13 +01:00
commit b43cacea56

View File

@ -23,6 +23,12 @@ def parse_args(argv=None):
default=500,
help="Limit of pictures to fetch, max=5000",
)
parser.add_argument(
"--bbox",
type=str,
default=None,
help="Limit to a bounding box, e.g. '-5.5,47.3,-1.2,48.9', use http://bboxfinder.com",
)
global args
args = parser.parse_args(argv)
@ -34,8 +40,9 @@ if __name__ == "__main__":
mly_key = args.access_token
creator_username = args.username
max_img = args.pictures
bbox_filter = f'&bbox={args.bbox}' if args.bbox is not None else ''
url = f"https://graph.mapillary.com/images?access_token={mly_key}&creator_username={creator_username}&limit={max_img}&fields=id,sequence"
url = f"https://graph.mapillary.com/images?access_token={mly_key}&creator_username={creator_username}&limit={max_img}&fields=id,sequence{bbox_filter}"
print(url)
response = requests.get(url)
@ -47,5 +54,7 @@ if __name__ == "__main__":
sequences_ids = [obj["sequence"] for obj in json["data"]]
unique_ids = list(set(sequences_ids))
print(unique_ids)
print("---")
print(" ".join(unique_ids))
else:
print(response)