Add bbox filtering to get mapillary images/sequences #8

View File

@ -23,6 +23,12 @@ def parse_args(argv=None):
default=500, default=500,
help="Limit of pictures to fetch, max=5000", 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 global args
args = parser.parse_args(argv) args = parser.parse_args(argv)
@ -34,8 +40,9 @@ if __name__ == "__main__":
mly_key = args.access_token mly_key = args.access_token
creator_username = args.username creator_username = args.username
max_img = args.pictures 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) print(url)
response = requests.get(url) response = requests.get(url)
@ -47,5 +54,7 @@ if __name__ == "__main__":
sequences_ids = [obj["sequence"] for obj in json["data"]] sequences_ids = [obj["sequence"] for obj in json["data"]]
unique_ids = list(set(sequences_ids)) unique_ids = list(set(sequences_ids))
print(unique_ids) print(unique_ids)
print("---")
print(" ".join(unique_ids))
else: else:
print(response) print(response)