You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

Extracting data from the WPS server is a three step process

  1. Get information about available processes (GetCapabilities)
  2. Get information about a specific process (DescribeProcess)
  3. Execute the process (Execute)

GetCapabilities

% Server URL
url = 'http://dtvirt5.deltares.nl/wps';

% Pass the required paramters
xml = urlread(url,'get',{'request','GetCapabilities','service','wps','version','1.0.0'});

% Now we have to save the XML file otherwise we can't use xmlread
fid = fopen('file.xml','w');
fwrite(fid, xml);
fclose(fid);

% Read the XML file we just saved
xmldoc = xmlread('file.xml');

% Look up the intersting elements (Processes)
offerings = xmldoc.getElementsByTagName('wps:Process');

% Look up all process Identifiers
for i = 0:offerings.getLength-1
    process = offerings.item(i);
    identifier = process.getElementsByTagName('ows:Identifier').item(0).getFirstChild.getData
end

DescribeProcess

Get all requested input parameters

% Pass the required parameters to read the process' meta data
xml = urlread(url,'get',{'request','DescribeProcess','service','wps','version','1.0.0','identifier',identifier});

% Now we have to save the XML file otherwise we can't use xmlread
fid = fopen('file.xml','w');
fwrite(fid, xml);
fclose(fid);

% Read the XML file we just saved
xmldoc = xmlread('file.xml');

% Look up the intersting elements (Processes)
inputs = xmldoc.getElementsByTagName('Input')

% Look up all input identifiers
for i = 0:inputs.getLength-1
    input = inputs.item(i);
    identifier = input.getElementsByTagName('ows:Identifier').item(0).getFirstChild.getData
end

Execute

 
% Specify the process with the process identifier
identifier = 'tidal_predict'

% Specify process inputs
inputs = 'location=POINT(3 52);startdate=2013-08-21 00:00;frequency=HOURLY;enddate=2013-08-29 23:00'

% Pass the required parameters to read the process' meta data
xml = urlread([url '?request=Execute&service=wps&version=1.0.0&identifier=' identifier '&DataInputs=' inputs]);

% Now we have to save the XML file otherwise we can't use xmlread
fid = fopen('file.xml','w');
fwrite(fid, xml);
fclose(fid);

% Read the XML file we just saved
xmldoc = xmlread('file.xml');

% Look up the intersting elements (Processes)
outputs = xmldoc.getElementsByTagName('wps:Output');
output = outputs.item(0);
identifier = output.getElementsByTagName('ows:Identifier').item(0).getFirstChild.getData;

% Look up the output data from the XML
outputdata = output.getElementsByTagName('wps:ComplexData').item(0).getFirstChild.getData;
outputdata = char(outputdata);

% Write output data to table
table = textscan(outputdata(2:end),'%s%f%f%f', 'Delimiter', ',','HeaderLines',1);
dates = table{1};
h = table{2};

% Plot output
plot(datenum(dates),h)
datetick;

  • No labels