В этом примере показано, как получить доступ к формированию изображений от Геологической службы США (USGS) Национальная Карта сервер SOAP. Чтобы создать карту, вам нужна следующая информация.
Получите мозаику карты.
Получите имя карты.
Получите формат мозаик.
Этот пример показывает вам, как вызвать функции в веб-сервисе 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
Измените свою текущую папку в перезаписываемую папку.
Присвойте WSDL URL.
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
Добавьте файлы банки в путь 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_MapServerMATLAB® открывает страницу с описанием для 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 N 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)