[ZOO-Discuss] ZOO JS API
René-Luc D'Hont
rldhont at gmail.com
Mon May 17 03:17:41 PDT 2010
This is the script for Driftx WPS chaining :
function DriftxJS(aConf,aInputs,aOutputs) {
try {
var outputs=new Array();
outputs[0]={};
var inputs = {};
for (var i=0, len=aInputs.length; i<len; i++) {
var input = aInputs[i];
for (var key in input) {
inputs[key] = input[key];
}
}
var wps = new ZOO.Format.WPS();
var json = new ZOO.Format.JSON();
var wpProcess = new
ZOO.Process('http://localhost/zoosoo/driftx/wps/','writeParams');
var wpInputs = {
session:inputs.session,
xmin:inputs.xmin,
ymin:inputs.ymin,
xmax:inputs.xmax,
ymax:inputs.ymax,
vstartx:inputs.vstartx,
vstarty:inputs.vstarty,
nbrowsp:inputs.nbrowsp,
rowsleng:inputs.rowsleng,
tractorsp:inputs.tractorsp,
numrowsin:inputs.numrowsin,
nozzoutvel:inputs.nozzoutvel,
windx1:inputs.windx1,
windy1:inputs.windy1,
windspeed1:inputs.windspeed1,
winddir1:inputs.winddir1,
windx2:inputs.windx2,
windy2:inputs.windy2,
windspeed2:inputs.windspeed2,
winddir2:inputs.winddir2
};
var wpOutput = wpProcess.Execute(wpInputs);
wpOutput = wps.read(wpOutput);
var clipProcess = new
ZOO.Process('http://localhost/zoosoo/driftx/wps/','Gdal_Translate');
var ProjWin =
inputs.xmin.value+','+inputs.ymax.value+','+inputs.xmax.value+','+inputs.ymin.value+',urn:ogc:def:crs:EPSG:6.6:27572,2';
var clipInputs = {
Format:{value:'AAIGRID',datatype:'string'},
InputDSN:{value:'neffiesL2',datatype:'string'},
OutputDSN:{value:'neffiesL2_output',datatype:'string'},
SRS:{value:'EPSG:27572',datatype:'string'},
Type:{value:'Float32',datatype:'string'},
ProjWin:{value:ProjWin}
};
var clipOutput = clipProcess.Execute(clipInputs);
clipOutput = wps.read(clipOutput);
var csvProcess = new
ZOO.Process('http://localhost/zoosoo/driftx/wps/','grd2xyz');
var csvInputs = {
inFile:{value:clipOutput.value,datatype:'string'},
outFile:{value:aConf[0]['main']['tmpPath']+'/mnt.csv',datatype:'string'}
};
var csvOutput = csvProcess.Execute(csvInputs);
csvOutput = wps.read(csvOutput);
/*
var ftnProcess = new ZOO.Process('http://localhost/zoo/','driftx');
var ftnInputs = {
storePath:{value:aConf[0]['main']['tmpPath']+'/',datatype:'string'}
};
var ftnOutput = ftnProcess.Execute(ftnInputs);
var ftnOutput =
ZOO.Request.Get('http://localhost/zoo/?request=Execute&service=WPS&version=1.0.0&Identifier=driftx&DataInputs=storePath=/var/www/localhost/htdocs/ms_tmp/@datatype=string');
*/
var ftnOutput =
ZOO.Request.Get('http://localhost/zoo/?request=Execute&service=WPS&version=1.0.0&Identifier=driftx&DataInputs=storePath='+aConf[0]['main']['tmpPath']+'/@datatype=string');
var result = ZOO.Request.Get('http://localhost/ms_tmp/driftx.csv')
var ftxt = new ZOO.Format.Text({separator:',',
xcolumn:'longitude',
ycolumn:'latitude'});
result = ftxt.read(result);
var depotmax = 0;
result.forEach(function(ft,idx) {
if(Number(ft.attributes.depot)==0)
ft.attributes.display = 'none';
else
ft.attributes.display = '';
var depot = Number(ft.attributes.depot);
if (depot > depotmax)
depotmax=depot;
});
var qt = depotmax/5;
var limites = [qt,2*qt,3*qt,4*qt];
result.forEach(function(ft,idx) {
var depot = Number(ft.attributes.depot);
if (depot<limites[0])
ft.attributes.color = '#000066';
else if (depot<limites[1])
ft.attributes.color = '#006600';
else if (depot<limites[2])
ft.attributes.color = '#FFFF00';
else if (depot<limites[3])
ft.attributes.color = '#FFA500';
else
ft.attributes.color = '#E00100';
});
var geojson = new ZOO.Format.GeoJSON();
outputs[0]["result"]={"value": geojson.write(result),
"dataType":'string'};
/*
outputs[0]["result"]={"value":
ftxt.separator+'\n'+ftxt.xcolumn+'\n'+result2.length, "dataType":'string'};
*/
return {"result":3,"outputs": outputs};
} catch(e) {
outputs[0]["result"]={"value": e, "dataType":'string'};
return {"result":3,"outputs": outputs};
}
}
As you see ZOO JS API could be for managing and chaining process
providing by different WPS.
Cheers,
René-Luc D'Hont
3Liz
Le 17/05/2010 09:04, James.Sewell at lisasoft.com a écrit :
>
> Hey All,
>
> On the zoo-project IRC channel demo examples and the lack of
> documentation for the ZOO JS API were discussed recently.
>
> I realize that there is no documentation at the moment, but if anyone
> has some demos of how the API can be used to achieve process chaining
> would they be able to post it to the list?
>
>
> Cheers,
>
>
> James Sewell
>
>
> LISAsoft Developer
>
>
> +61 (3) 8680 3200 / +61 414 688 892
>
>
> _______________________________________________
> Zoo-discuss mailing list
> Zoo-discuss at gisws.media.osaka-cu.ac.jp
> http://gisws.media.osaka-cu.ac.jp/mailman/listinfo/zoo-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/zoo-discuss/attachments/20100517/02b86d38/attachment.html>
More information about the Zoo-discuss
mailing list