В этом примере показано, как получить доступ к изображениям с сервера 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)