[ZOO-Discuss] Wanna test the ZOO JavaScript Support

René-Luc D'Hont rldhont at gmail.com
Tue Feb 23 14:07:56 PST 2010


If you wanna test the ZOO JavaScript support, you can do it here :
http://shilpa.media.osaka-cu.ac.jp/demo/test_services_post_jsr.html

You can use this XML :

<wps:Execute service="WPS" version="1.0.0" 
xmlns:wps="http://www.opengis.net/wps/1.0.0" 
xmlns:ows="http://www.opengis.net/ows/1.1" 
xmlns:xlink="http://www.w3.org/1999/xlink" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.opengis.net/wps/1.0.0/../wpsExecute_request.xsd">
<ows:Identifier>EvaluateJS</ows:Identifier>
<wps:DataInputs>
<wps:Input>
<ows:Identifier>Code</ows:Identifier>
<wps:Data>
<wps:ComplexData mimeType="text/plain">
<![CDATA[
         ]]>
</wps:ComplexData>
</wps:Data>
</wps:Input>
</wps:DataInputs>
<wps:ResponseForm>
<wps:RawDataOutput>
<ows:Identifier>Result</ows:Identifier>
</wps:RawDataOutput>
</wps:ResponseForm>
</wps:Execute>

And set the Code input with JavaScript Code!

For helping you here an example:

   var process = new ZOO.Process('http://localhost/zoo/','Union');
   var inputs1 = {
     
InputEntity1:{type:'reference',value:'http://demo.opengeo.org/geoserver/ows?SERVICE=WFS&REQUEST=GetFeature&VERSION=1.0.0&typename=topp:states&SRS=EPSG:4326&FeatureID=states.45'},
     
InputEntity2:{type:'complex',mimetype:'application/json',value:'{"type":"Polygon","coordinates":[[[-111.07132,31.335535],[-114.820969,32.487114],[-114.735397,35.987667],[-114.727333,36.085983],[-114.043137,36.996563],[-110.483398,37.003929],[-109.047821,36.996643],[-109.045998,34.954613],[-109.045006,31.343348],[-110.451942,31.337559],[-111.07132,31.335535]]]}'}
   };
   var str = process.Execute(inputs1);
   return {value:str,mimeType:'text/plain'};

And an other one:

      var str = ZOO.Request.Get('http://demo.opengeo.org/geoserver/ows',
           {SERVICE:'WFS',
            REQUEST:'GetFeature',
            VERSION:'1.0.0',
            typename:'topp:states',
            SRS:'EPSG:4326',
            FeatureID:'states.45'});

       var gml = new ZOO.Format.GML();
       var features = gml.read(str);
       var geojson = new ZOO.Format.GeoJSON();
       str = geojson.write(features);
       var kml = new ZOO.Format.KML();
       str = kml.write(features);
       return {value:str,mimeType:'text/plain'};

You can define more than 1 input, for example with this XML :

<wps:Execute service="WPS" version="1.0.0" 
xmlns:wps="http://www.opengis.net/wps/1.0.0" 
xmlns:ows="http://www.opengis.net/ows/1.1" 
xmlns:xlink="http://www.w3.org/1999/xlink" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.opengis.net/wps/1.0.0/../wpsExecute_request.xsd">
<ows:Identifier>EvaluateJS</ows:Identifier>
<wps:DataInputs>
<wps:Input>
<ows:Identifier>Code</ows:Identifier>
<wps:Data>
<wps:ComplexData mimeType="text/plain">
<![CDATA[
         ]]>
</wps:ComplexData>
</wps:Data>
</wps:Input>
<wps:Input><ows:Identifier>InputEntity1</ows:Identifier><wps:Reference 
mimeType="text/xml" 
xlink:href="http://demo.opengeo.org/geoserver/ows?SERVICE=WFS&REQUEST=GetFeature&VERSION=1.0.0&typename=topp:states&SRS=EPSG:4326&FeatureID=states.45"/></wps:Input><wps:Input><ows:Identifier>InputEntity2</ows:Identifier><wps:Data><wps:ComplexData 
mimeType="application/json"> 
{"type":"Polygon","coordinates":[[[-111.07132,31.335535],[-114.820969,32.487114],[-114.735397,35.987667],[-114.727333,36.085983],[-114.043137,36.996563],[-110.483398,37.003929],[-109.047821,36.996643],[-109.045998,34.954613],[-109.045006,31.343348],[-110.451942,31.337559],[-111.07132,31.335535]]]} 
</wps:ComplexData></wps:Data></wps:Input>
</wps:DataInputs>
<wps:ResponseForm>
<wps:RawDataOutput>
<ows:Identifier>Result</ows:Identifier>
</wps:RawDataOutput>
</wps:ResponseForm>
</wps:Execute>

Which mean that you can test your own process with your input and your 
code process. You can test the disponible inputs with this code :

         var str = aInputs.length+'\n';
         for (var key in inputs) {
           str += key+'\n';
         }
         for (var i=0, len=aInputs.length; i<len; i++) {
           var input = aInputs[i];
           for (var key in input) {
             str += key+'\n';
           }
         }
         return {value:str,mimeType:'text/plain'};

Or with the other one :

         function dump(){
         var str = '';
         for (var key in arguments[0]) {
           for(var key1 in arguments[0][key]){
             str += '**********************************\n';
             str += key1+'\n**********************************\n';
             for(var key2 in arguments[0][key][key1])
               str += key2+' <=> '+arguments[0][key][key1][key2]+'\n';
           }
         }
         return str;
         }
         var aconf=dump(aConf);
         var ainputs=dump(aInputs);
         var aoutputs=dump(aOutputs);
         return 
{value:aconf+"\n\n"+ainputs+"\n\n"+aoutputs,mimeType:'text/plain'};

Enjoy!

René-Luc D'Hont
3Liz



More information about the Zoo-discuss mailing list