В этом примере показано, как получить доступ к изображениям с сервера SOAP Национальной геологической службы США (USGS). Для создания карты необходима следующая информация.
Получить плитку карты.
Получите название карты.
Получите формат плиток.
В этом примере показано, как вызывать функции веб-сервиса USGS. USGSImageryOnly_MapServer, чтобы получить эту информацию.
Установите программы Java ® JDK™ и Apache™ CXF и задайте пути к инструментам для выполнения этого примера.
p = matlab.wsdl.setWSDLToolPath; if (isempty(p.JDK) || isempty(p.CXF)) disp('Install the Java Development Kit (JDK) and Apache CXF programs.') disp('See the Set Up WSDL Tools link at the end of this example.') else disp('Paths set to:') matlab.wsdl.setWSDLToolPath end
Измените текущую папку на доступную для записи.
Назначьте URL WSDL.
wsdlFile = ... 'http://basemap.nationalmap.gov/arcgis/services/USGSImageryOnly/MapServer?wsdl';
Создайте файлы классов для клиента.
matlab.wsdl.createWSDLClient(wsdlFile)
Created USGSImageryOnly_MapServer.
.\USGSImageryOnly_MapServer.m
.\+wsdl
In order to use USGSImageryOnly_MapServer, you must run javaaddpath('.\+wsdl\mapserver.jar').
ans =
@USGSImageryOnly_MapServer
Добавьте jar-файлы в путь Java.
javaaddpath('.\+wsdl\mapserver.jar')Запустите службу.
wsdl = USGSImageryOnly_MapServer;
Изучите сервис.
help USGSImageryOnly_MapServerUSGSImageryOnly_MapServer A client to connect to the USGSImageryOnly_MapServer service
SERVICE = USGSImageryOnly_MapServer connects to http://basemap.nationalmap.gov/arcgis/services/USGSImageryOnly/MapServer and returns a SERVICE.
To communicate with the service, call a function on the SERVICE:
[...] = FUNCTION(SERVICE,arg,...)
See doc USGSImageryOnly_MapServer for a list of functions.Щелкните ссылку doc USGSImageryOnly_MapServer. MATLAB ® открывает справочную страницу дляUSGSImageryOnly_MapServer в браузере справки.
Ознакомьтесь с документацией для необходимых входных данных для GetMapTile функция.
help GetMapTile --- help for USGSImageryOnly_MapServer/GetMapTile ---
GetMapTile
Result = GetMapTile(obj,MapName,Level,Row,Column,Format)
Inputs:
obj - USGSImageryOnly_MapServer object
MapName - string
Level - numeric scalar (XML int)
Row - numeric scalar (XML int)
Column - numeric scalar (XML int)
Format - string
Output:
Result - vector of numbers 0-255 (XML base64Binary)
See also USGSImageryOnly_MapServer.
Вам нужно MapName, Level, Row, Column, и Format входные аргументы.
Ознакомьтесь с документацией для функции, которая предоставляет имя карты, GetDefaultMapName.
help GetDefaultMapName--- help for USGSImageryOnly_MapServer/GetDefaultMapName ---
GetDefaultMapName
Result = GetDefaultMapName(obj)
Inputs:
obj - USGSImageryOnly_MapServer object
Output:
Result - string
See also USGSImageryOnly_MapServer.Эта функция предоставляет имя карты.
Прочитайте документацию для функции, которая предоставляет информацию о формате карты, GetTileImageInfo.
help GetTileImageInfo--- help for USGSImageryOnly_MapServer/GetTileImageInfo ---
GetTileImageInfo
Result = GetTileImageInfo(obj,MapName)
Inputs:
obj - USGSImageryOnly_MapServer object
MapName - string
Output:
Result - TileImageInfo object
See also USGSImageryOnly_MapServer.Эта функция возвращает TileImageInfo объект.
Ознакомьтесь с документацией для TileImageInfo путем щелчка по ссылке в окне справки для TileImageInfo.
TileImageInfo(CacheTileFormat,CompressionQuality,Antialiasing) TileImageInfo object for use with USGSImageryOnly_MapServer web client
CacheTileFormat - string
The cache tile format.
CompressionQuality - numeric scalar (XML int)
The cache tile image compression quality.
Antialiasing - string
See also
USGSImageryOnly_MapServer.MATLAB открывает документ в браузере справки. Информация о формате: CacheTileFormat.
Создайте данные JPEG. Следующий код требует знания формата изображения JPEG и схемы мозаики, используемой сервером USGS.
% Get the default map name. defaultMapName = GetDefaultMapName(wsdl); % Get the map count. count = GetMapCount(wsdl); % Get the map name. There is only one map (count value), % but the index is zero-based. mapName = GetMapName(wsdl, count-1); % Get information about the tiles. tileImageInfo = GetTileImageInfo(wsdl, mapName); % Get the format of the data. format = tileImageInfo.CacheTileFormat; % Since format is specified as 'Mixed' it implies that % the result of GetMapTile is a JPEG-encoded stream. % The map tiles are organized with the lowest level as % the lowest level of detail and the tiles use % zero-based indexing. level = 0; row = 0; col = 0; jpeg = GetMapTile(wsdl,mapName,level,row,col,format);
Запишите данные в кодировке JPEG в файл. Использовать imread считывание и декодирование данных JPEG и возврат M-by-N-by-3 uint8 матрица.
ext = '.jpg'; tilename = ['USGSImageryOnly_MapServer' '0_0_0' ext]; fid = fopen(tilename,'w'); fwrite(fid,jpeg) fclose(fid)
Просмотрите карту.
tileImage = imread(tilename); figure imshow(tileImage)