function [A,R,attrib] = readBasemapImage(varargin)
%READBASEMAPIMAGE Read image from geographic basemap
%
%   [A,R,ATTRIB] = readBasemapImage(BASEMAP,LATLIM,LONLIM) reads an image
%   from the basemap specified by BASEMAP for the geographic limits
%   specified by LATLIM and LONLIM. Specify LATLIM as a two-element vector
%   of the form [slat nlat] where slat is the southernmost limit and nlat
%   is the northernmost limit. Both slat and nlat must be in the range
%   [-90,90] degrees. Specify LONLIM as a two-element vector of the form
%   [wlon elon] where wlon is the westernmost limit and elon is the
%   easternmost limit. A is an RGB image with a maximum size of
%   [2048,2048,3]. R is a map cells reference object in Web Mercator map
%   coordinates. ATTRIB is a string scalar specifying the attribution.
%
%   [___] = readBasemapImage(BASEMAP,MAPCENTER) reads the basemap specified
%   by BASEMAP at the geographic center specified by the two-element
%   vector, MAPCENTER. The function returns an image using the highest
%   possible zoom level, centered at MAPCENTER, and constrained to have a
%   maximum size of [1024,1024,3].
% 
%   [___] = readBasemapImage(___,zoomLevel) reads the basemap specified by
%   BASEMAP for the zoom level specified by the scalar numeric, zoomLevel.
%   The function rounds zoomLevel to the nearest integer value. zoomLevel
%   has a maximum value of 25. The function reduces zoomLevel if the output
%   image exceeds the maximum size [2048,2048,3] or if zoomLevel exceeds
%   the maximum zoom level of the basemap.
%  
%   [___] = readBasemapImage(BASEMAP,MAPCENTER,zoomLevel,rasterSize) reads
%   an image from the basemap specified by BASEMAP at the geographic center
%   specified by MAPCENTER and the zoom level specified by zoomLevel, with
%   an image size specified by rasterSize. Specify rasterSize as a scalar
%   or two-element vector. Each element of rasterSize must be in the range
%   [64,2048].
%
%   Example
%   -------
%   basemap = "satellite";
%   latlim = [42.3505 42.3722];
%   lonlim = [-71.0799 -71.0427];
%   zoomLevel = 15;
%   [A,R,attrib] = readBasemapImage(basemap,latlim,lonlim,zoomLevel);
%   figure
%   mapshow(A,R)
%   axis off
%
%   See also GEOBASEMAP, READGEORASTER, WMSREAD.

%  Copyright 2021 The MathWorks, Inc.

    try
        [A,R,attrib] = map.internal.readBasemapImage(varargin{:});
    catch e
        throw(e)
    end
end
