Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
alextts627 committed Oct 10, 2022
1 parent f65e3ad commit fe1eca2
Show file tree
Hide file tree
Showing 16 changed files with 106 additions and 110 deletions.
20 changes: 10 additions & 10 deletions sdk/maps/azure-maps-render/azure/maps/render/_render_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
Copyright,
MapTileset,
CopyrightCaption,
RasterTileFormat
RasterTileFormat,
MapAttribution
)

class MapsRenderClient(MapsRenderClientBase):
Expand Down Expand Up @@ -179,7 +180,7 @@ def get_map_attribution(
zoom: int,
bounds: BoundingBox,
**kwargs: Any
) -> List[str]:
) -> MapAttribution:
"""The Get Map Attribution API allows users to request map copyright attribution information for a
section of a tileset.
Expand All @@ -196,8 +197,8 @@ def get_map_attribution(
position of the bounding box as float.
E.g. BoundingBox(west=37.553, south=-122.453, east=33.2, north=57)
:type bounds: BoundingBox
:return: List[str]
:rtype: List[str]
:return: MapAttribution
:rtype: ~azure.maps.render.models.MapAttribution
:raises ~azure.core.exceptions.HttpResponseError:
.. admonition:: Example:
Expand All @@ -221,7 +222,7 @@ def get_map_attribution(
zoom=zoom,
bounds=bounds,
**kwargs
).copyrights
)

@distributed_trace
def get_map_state_tile(
Expand Down Expand Up @@ -294,7 +295,6 @@ def get_copyright_caption(
@distributed_trace
def get_map_static_image(
self,
img_format: Union[str, RasterTileFormat],
**kwargs: Any
) -> Iterator[bytes]:
""" The static image service renders a user-defined, rectangular image containing a map section
Expand All @@ -306,9 +306,9 @@ def get_map_static_image(
choice. If you want to support a lot of zooming, panning and changing of the map content, the
map tile service would be a better choice.
:param img_format:
:keyword img_format:
Desired format of the response. Possible value: png. "png" Default value is "png".
:type img_format: str or ~azure.maps.render.models.RasterTileFormat
:paramtype img_format: str or ~azure.maps.render.models.RasterTileFormat
:keyword layer:
Map layer requested.
:paramtype layer: str or ~azure.maps.render.models.StaticMapLayer
Expand Down Expand Up @@ -367,10 +367,10 @@ def get_map_static_image(

_bbox = kwargs.pop("bounding_box_private", None)
if _bbox is not None:
_bbox = f"{_bbox.south}, {_bbox.west}, {_bbox.north}, {_bbox.east}"
_bbox = [_bbox.south, _bbox.west, _bbox.north, _bbox.east]

return self._render_client.get_map_static_image(
format=img_format,
format=kwargs.pop("img_format", "png"),
center=_center,
bounding_box_private=_bbox,
**kwargs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# ---------------------------------------------------------------------

# pylint: disable=unused-import,ungrouped-imports, R0904, C0302
from typing import Iterator, Any, Union, Tuple, List
from typing import AsyncIterator, Any, Union, Tuple, List
from azure.core.tracing.decorator_async import distributed_trace_async
from azure.core.exceptions import HttpResponseError
from azure.core.credentials import AzureKeyCredential
Expand Down Expand Up @@ -68,7 +68,7 @@ async def get_map_tile(
x: int,
y: int,
**kwargs: Any
) -> Iterator[bytes]:
) -> AsyncIterator[bytes]:
"""The Get Map Tiles API allows users to request map tiles in vector or raster formats typically
to be integrated into a map control or SDK. Some example tiles that can be requested are Azure
Maps road tiles, real-time Weather Radar tiles. By default, Azure Maps uses vector tiles for its web map
Expand Down Expand Up @@ -104,8 +104,8 @@ async def get_map_tile(
regions.
:paramtype localized_map_view: str or ~azure.maps.render.models.LocalizedMapView
:return:
Iterator of the response bytes
:rtype: Iterator[bytes]
AsyncIterator of the response bytes
:rtype: AsyncIterator[bytes]
:raises ~azure.core.exceptions.HttpResponseError:
.. admonition:: Example:
Expand Down Expand Up @@ -184,7 +184,7 @@ async def get_map_attribution(
zoom: int,
bounds: BoundingBox,
**kwargs: Any
) -> List[str]:
) -> MapAttribution:
"""The Get Map Attribution API allows users to request map copyright attribution information for a
section of a tileset.
Expand All @@ -201,8 +201,8 @@ async def get_map_attribution(
position of the bounding box as float.
E.g. BoundingBox(west=37.553, south=-122.453, east=33.2, north=57)
:type bounds: BoundingBox
:return: List[str]
:rtype: List[str]
:return: MapAttribution
:rtype: ~azure.maps.render.models.MapAttribution
:raises ~azure.core.exceptions.HttpResponseError:
.. admonition:: Example:
Expand All @@ -227,7 +227,7 @@ async def get_map_attribution(
bounds=bounds,
**kwargs
)
return async_result.copyrights
return async_result

@distributed_trace_async
async def get_map_state_tile(
Expand All @@ -237,7 +237,7 @@ async def get_map_state_tile(
x: int,
y: int,
**kwargs: Any
) -> Iterator[bytes]:
) -> AsyncIterator[bytes]:
"""Fetches state tiles in vector format typically to be integrated into indoor maps module of map
control or SDK.
Expand All @@ -253,8 +253,8 @@ async def get_map_state_tile(
:param stateset_id:
The stateset id.
:type stateset_id: str
:return: Iterator of the response bytes
:rtype: Iterator[bytes]
:return: AsyncIterator of the response bytes
:rtype: AsyncIterator[bytes]
:raises ~azure.core.exceptions.HttpResponseError:
"""
return await self._render_client.get_map_state_tile(
Expand Down Expand Up @@ -298,9 +298,8 @@ async def get_copyright_caption(
@distributed_trace_async
async def get_map_static_image(
self,
img_format: Union[str, RasterTileFormat],
**kwargs: Any
) -> Iterator[bytes]:
) -> AsyncIterator[bytes]:
""" The static image service renders a user-defined, rectangular image containing a map section
using a zoom level from 0 to 20. The static image service renders a user-defined, rectangular
image containing a map section using a zoom level from 0 to 20. The supported resolution range
Expand All @@ -310,9 +309,9 @@ async def get_map_static_image(
choice. If you want to support a lot of zooming, panning and changing of the map content, the
map tile service would be a better choice.
:param img_format:
:keyword img_format:
Desired format of the response. Possible value: png. "png" Default value is "png".
:type img_format: str or ~azure.maps.render.models.RasterTileFormat
:paramtype img_format: str or ~azure.maps.render.models.RasterTileFormat
:keyword layer:
Map layer requested.
:paramtype layer: str or ~azure.maps.render.models.StaticMapLayer
Expand Down Expand Up @@ -350,8 +349,8 @@ async def get_map_static_image(
Path style and locations. Use this parameter to optionally add lines, polygons
or circles to the image.
:paramtype path: list[str]
:return: Iterator of the response bytes
:rtype: Iterator[bytes]
:return: AsyncIterator of the response bytes
:rtype: AsyncIterator[bytes]
:raises ~azure.core.exceptions.HttpResponseError:
.. admonition:: Example:
Expand All @@ -371,10 +370,10 @@ async def get_map_static_image(

_bbox = kwargs.pop("bounding_box_private", None)
if _bbox is not None:
_bbox = f"{_bbox.south}, {_bbox.west}, {_bbox.north}, {_bbox.east}"
_bbox = [_bbox.south, _bbox.west, _bbox.north, _bbox.east]

return await self._render_client.get_map_static_image(
format=img_format,
format=kwargs.pop("img_format", "png"),
center=_center,
bounding_box_private=_bbox,
**kwargs
Expand Down Expand Up @@ -465,7 +464,7 @@ async def get_copyright_for_tile(
_include_text=kwargs.pop("include_text", True)

return await self._render_client.get_copyright_for_tile(
z=tile_index_z,
z=z,
x=x,
y=y,
include_text= "yes" if _include_text else "no",
Expand Down
79 changes: 37 additions & 42 deletions sdk/maps/azure-maps-render/azure/maps/render/models/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Licensed under the MIT License.
# ------------------------------------

# pylint: disable=unused-import,ungrouped-imports, C0302, C0203
from typing import NamedTuple
# pylint: disable=unused-import,ungrouped-imports,super-init-not-called, C0302, C0203
from typing import NamedTuple, Any
from .._generated.models import (
Copyright as GenCopyright,
RegionCopyrights as GenRegionCopyrights,
Expand Down Expand Up @@ -52,9 +52,12 @@ class RegionalCopyrights(GenRegionCopyrights):
:keyword country: Country property.
:paramtype country: ~azure.maps.render.models.RegionCopyrightsCountry
"""
def __init__(self, copyrights=None, country=None):
self.copyrights = copyrights
self.country = country
def __init__(
self,
**kwargs: Any
):
self.copyrights = kwargs.get("copyrights", None)
self.country = kwargs.get("country", None)

class Copyright(GenCopyright):
"""Represents information about the coordinate range
Expand All @@ -66,10 +69,13 @@ class Copyright(GenCopyright):
:keyword regional_copyrights: Regions array.
:paramtype regional_copyrights: list[RegionalCopyrights]
"""
def __init__(self, format_version=None, general_copyrights=None, regional_copyrights=None):
self.format_version = format_version
self.general_copyrights = general_copyrights
self.regional_copyrights = regional_copyrights
def __init__(
self,
**kwargs: Any
):
self.format_version = kwargs.get("format_version", None)
self.general_copyrights = kwargs.get("general_copyrights", None)
self.regional_copyrights = kwargs.get("regional_copyrights", None)

class RegionCopyrightsCountry(GenRegionCopyrightsCountry):
"""Country property.
Expand All @@ -81,9 +87,12 @@ class RegionCopyrightsCountry(GenRegionCopyrightsCountry):
:keyword label: Label property.
:paramtype label: str
"""
def __init__(self, iso3_code=None, label=None):
self.iso3_code = iso3_code
self.label = label
def __init__(
self,
**kwargs: Any
):
self.iso3_code = kwargs.get("iso3_code", None)
self.label = kwargs.get("label", None)


class MapTileset(GenMapTileset): # pylint: disable=too-many-instance-attributes
Expand Down Expand Up @@ -137,34 +146,20 @@ class MapTileset(GenMapTileset): # pylint: disable=too-many-instance-attributes
"""
def __init__(
self,
tilejson_version= None,
name= None,
description= None,
version= None,
map_attribution= None,
template= None,
legend= None,
scheme= None,
tiles_endpoints= None,
grid_endpoints= None,
data_files = None,
min_zoom= None,
max_zoom= None,
bounds= None,
center= None
**kwargs: Any
):
self.tilejson_version = tilejson_version
self.name = name
self.description = description
self.version = version
self.map_attribution = map_attribution
self.template = template
self.legend = legend
self.scheme = scheme
self.tiles_endpoints = tiles_endpoints
self.grid_endpoints = grid_endpoints
self.data_files = data_files
self.min_zoom = min_zoom
self.max_zoom = max_zoom
self.bounds = bounds
self.center = center
self.tilejson_version = kwargs.get("tilejson_version", None)
self.name = kwargs.get("name", None)
self.description = kwargs.get("description", None)
self.version = kwargs.get("version", None)
self.map_attribution = kwargs.get("map_attribution", None)
self.template = kwargs.get("template", None)
self.legend = kwargs.get("legend", None)
self.scheme = kwargs.get("scheme", None)
self.tiles_endpoints = kwargs.get("tiles_endpoints", None)
self.grid_endpoints = kwargs.get("grid_endpoints", None)
self.data_files = kwargs.get("data_files", None)
self.min_zoom = kwargs.get("min_zoom", None)
self.max_zoom = kwargs.get("max_zoom", None)
self.bounds = kwargs.get("bounds", None)
self.center = kwargs.get("center", None)
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async def get_map_attribution_async():
)

print("Get map attribution result:")
print(result[0])
print(result.copyrights[0])
# [END get_map_attribution_async]

if __name__ == '__main__':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def get_map_attribution():
)

print("Get map attribution result:")
print(result[0])
print(result.copyrights[0])
# [END get_map_attribution]

if __name__ == '__main__':
Expand Down
21 changes: 15 additions & 6 deletions sdk/maps/azure-maps-render/samples/sample_get_map_static_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,25 @@ def get_map_static_image():
# [START get_map_static_image]
from azure.core.credentials import AzureKeyCredential
from azure.maps.render import MapsRenderClient
from azure.maps.render.models import BoundingBox

maps_render_client = MapsRenderClient(credential=AzureKeyCredential(subscription_key))

result = maps_render_client.get_map_static_image(img_format="png", center=(52.41064, 5.84228))

print("Get map tile result to png:")
result = maps_render_client.get_map_static_image(
img_format="png",
layer="basic",
style="dark",
zoom=10,
bounding_box_private= BoundingBox(
13.228, 52.4559, 13.5794, 52.629
)
)

print("Get map tile result to png file as 'map_static_image.png'")
# Save result to file as png
file = open('map_static_image', 'wb')
file.write(next(result))
file.close()
with open('map_static_image.png', 'wb') as file:
file.write(next(result))
file.close()
# [END get_map_static_image]

if __name__ == '__main__':
Expand Down
8 changes: 4 additions & 4 deletions sdk/maps/azure-maps-render/samples/sample_get_map_tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ def get_map_tile():
tile_size="512"
)

print("Get map tile result:")
print("Get map tile result store in file name 'map_tile.png'")
# print(result)
file = open('map_tile.png', 'wb')
file.write(next(result))
file.close()
with open('map_tile.png', 'wb') as file:
file.write(next(result))
file.close()
# [END get_map_tile]

if __name__ == '__main__':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
"Cache-Control": "max-age=86400",
"Content-Length": "81",
"Content-Type": "application/json; charset=utf-8",
"Date": "Wed, 05 Oct 2022 19:16:56 GMT",
"Date": "Thu, 06 Oct 2022 06:50:55 GMT",
"ETag": "W/\u0022f3cfa19fc3c68912b94faa097ee62351\u0022",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"X-Cache": "CONFIG_NOCACHE",
"X-Content-Type-Options": "nosniff",
"x-ms-azuremaps-region": "West US 2",
"X-MSEdge-Ref": "Ref A: 5BF71D0B7653476B8324DC9528C37E47 Ref B: TPE30EDGE0622 Ref C: 2022-10-05T19:16:56Z"
"X-MSEdge-Ref": "Ref A: 8E47AD95A8F2417B99DCB4D5EB4930ED Ref B: TPE30EDGE0920 Ref C: 2022-10-06T06:50:56Z"
},
"ResponseBody": {
"formatVersion": "0.0.1",
Expand Down
Loading

0 comments on commit fe1eca2

Please sign in to comment.