Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional support for LINZ Maps Tiles #2048

Merged
merged 6 commits into from
Aug 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions lib/cartopy/io/img_tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,3 +682,39 @@ def _image_url(self, tile):
f'https://atlas.microsoft.com/map/tile?'
f'api-version={self.api_version}&tilesetId={self.tileset_id}&'
f'x={x}&y={y}&zoom={z}&subscription-key={self.subscription_key}')


class LINZMapsTiles(GoogleWTS):
aluthfian marked this conversation as resolved.
Show resolved Hide resolved

def __init__(self, apikey, layer_id, api_version="v4",
desired_tile_form='RGB', cache=False):
"""
Set up a new instance to retrieve tiles from The LINZ
aka. Land Information New Zealand

Access to LINZ WMTS GetCapabilities requires an API key.
Register yourself free in https://id.koordinates.com/signup/
to gain access into the LINZ database.

Parameters
----------
apikey
A valid LINZ API key specific for every users.
layer_id
A layer ID for a map. See the "Technical Details" lower down the
"About" tab for each layer displayed in the LINZ data service.
api_version
API version to use. Defaults to v4 for now.

"""
super().__init__(desired_tile_form=desired_tile_form, cache=cache)
self.apikey = apikey
self.layer_id = layer_id
self.api_version = api_version

def _image_url(self, tile):
x, y, z = tile
return (
f'https://tiles-a.koordinates.com/services;'
f'key={self.apikey}/tiles/{self.api_version}/'
f'layer={self.layer_id}/EPSG:3857/{z}/{x}/{y}.png')