Skip to content

Commit

Permalink
initial implementation for req #6
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarMuhammedAli committed Jul 10, 2021
1 parent 727be35 commit 84a0bd4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
Empty file.
25 changes: 25 additions & 0 deletions mapillary/controller/image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
mapillary.controller.image
~~~~~~~~~~~~~~~~~~~~~~~~~~
This module implements the business logic
functionalities of the Mapillary Python SDK. For
more information, please check out
https://www.mapillary.com/developer/api-documentation/
:copyright: (c) 2021 ...
:license: See LICENSE for more details
"""

# Local imports
from config.api.entities import Entities

# Client
from models.client import Client

import json

def get_imgae_thumbnail(image_id, resolution):
url = Entities.get_image(image_id, [resolution])
res = json.loads(Client().get(url).content.decode('utf-8'))
# print(res)
return res[resolution]

10 changes: 6 additions & 4 deletions mapillary/mapillary.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# Local
from models.client import Client
from models.auth import auth
from controller.image import get_imgae_thumbnail

@auth()
def greetings(name):
Expand Down Expand Up @@ -250,13 +251,14 @@ def get_detections_for_feature_from_key(feature_key):
return None

@auth()
def get_image_thumbnail_from_key(map_key, size=1024):
def get_image_thumbnail_from_key(image_id, resolution=1024):
"""Gets the thumbnails of images from the API
:param map_key: Image key as the argument
:type map_key: str # ? To check if valid
:param size: Option for the thumbnail size, ranging from 320 to 2048 width
:param size: Option for the thumbnail size, with available resolutions:
256, 1024, and 2048
:type size: int
:return: A URL for the thumbnail
Expand All @@ -268,11 +270,11 @@ def get_image_thumbnail_from_key(map_key, size=1024):

# TODO: Write logic below that implements
# TODO: an exception handling mechanism for
# TODO: checking if the size is the range 320 to 2048, inclusive
# TODO: checking if the size is 256, 1024, or 2048

# TODO: This functions needs implementation

return "https://www.mapillary.com/"
return get_imgae_thumbnail(image_id, resolution=f'thumb_{resolution}_url')

@auth()
def get_images_in_bbox(bbox, **filters):
Expand Down

0 comments on commit 84a0bd4

Please sign in to comment.