source: branches/PublicaMundi_David-devel/docs/_build/html/api/examples.html @ 659

Last change on this file since 659 was 659, checked in by nbozon, 9 years ago

Massive update of zoo docs

File size: 12.2 KB
Line 
1
2
3<!DOCTYPE html>
4<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
5<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
6<head>
7  <meta charset="utf-8">
8  <meta name="viewport" content="width=device-width, initial-scale=1.0">
9 
10  <title>Examples &mdash; ZOO-Project 1.4a0 documentation</title>
11 
12  <link href="http://fonts.googleapis.com/css?family=Days+One" rel="stylesheet" type="text/css">
13 
14 
15
16 
17
18 
19 
20   
21      <link rel="search" type="application/opensearchdescription+xml" title="Search within ZOO-Project 1.4a0 documentation" href="../_static/opensearch.xml"/>
22   
23
24 
25
26 
27 
28    <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
29 
30
31 
32
33 
34    <link rel="top" title="ZOO-Project 1.4a0 documentation" href="../index.html"/>
35        <link rel="up" title="ZOO-API" href="index.html"/>
36        <link rel="next" title="ZOO-Client" href="../client/index.html"/>
37        <link rel="prev" title="ZOO.Request" href="zoo-request.html"/> 
38
39 
40  <script src="_static/js/modernizr.min.js"></script>
41
42</head>
43
44<body class="wy-body-for-nav" role="document">
45
46  <div class="wy-grid-for-nav">
47
48   
49    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
50      <div class="wy-side-nav-search">
51       
52
53       
54          <a class="shrink" href="http://zoo-project.org"><img src="http://zoo-project.org/img/zoo-sun-logo.png" class="img-responsive sun" style="display: inline;"> ZOO</a>
55       
56
57       
58        </a>
59
60       
61<div role="search">
62  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
63    <input type="text" name="q" placeholder="Search docs" />
64    <input type="hidden" name="check_keywords" value="yes" />
65    <input type="hidden" name="area" value="default" />
66  </form>
67</div>
68
69       
70      </div>
71
72      <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
73       
74         
75         
76              <ul class="current">
77<li class="toctree-l1"><a class="reference internal" href="../intro.html">Introduction</a><ul>
78<li class="toctree-l2"><a class="reference internal" href="../intro.html#what-is-zoo-project">What is ZOO-Project ?</a></li>
79<li class="toctree-l2"><a class="reference internal" href="../intro.html#zoo-project-components">ZOO-Project components</a></li>
80<li class="toctree-l2"><a class="reference internal" href="../intro.html#open-source">Open Source</a></li>
81</ul>
82</li>
83<li class="toctree-l1"><a class="reference internal" href="../install/index.html">ZOO-Project installation</a><ul>
84<li class="toctree-l2"><a class="reference internal" href="../install/install-prerequisites.html">Prerequisites</a></li>
85<li class="toctree-l2"><a class="reference internal" href="../install/install-download.html">Download</a></li>
86<li class="toctree-l2"><a class="reference internal" href="../install/install-confoptions.html">Configure options</a></li>
87<li class="toctree-l2"><a class="reference internal" href="../install/install-installation.html">Installation on Unix/Linux</a></li>
88<li class="toctree-l2"><a class="reference internal" href="../install/install-onwindows.html">Installation on Windows ™</a></li>
89<li class="toctree-l2"><a class="reference internal" href="../install/install-onmacos.html">Installation on MacOSX ™</a></li>
90</ul>
91</li>
92<li class="toctree-l1"><a class="reference internal" href="../kernel/index.html">ZOO-Kernel</a><ul>
93<li class="toctree-l2"><a class="reference internal" href="../kernel/what.html">What is ZOO-Kernel ?</a></li>
94<li class="toctree-l2"><a class="reference internal" href="../kernel/configuration.html">ZOO-Kernel configuration</a></li>
95<li class="toctree-l2"><a class="reference internal" href="../kernel/mapserver.html">Optional MapServer support</a></li>
96<li class="toctree-l2"><a class="reference internal" href="../kernel/orfeotoolbox.html">Optional Orfeo Toolbox support</a></li>
97<li class="toctree-l2"><a class="reference internal" href="../kernel/sagagis.html">Optional SAGA GIS support</a></li>
98</ul>
99</li>
100<li class="toctree-l1"><a class="reference internal" href="../services/index.html">ZOO-Services</a><ul>
101<li class="toctree-l2"><a class="reference internal" href="../services/what.html">What are ZOO-Services ?</a></li>
102<li class="toctree-l2"><a class="reference internal" href="../services/zcfg-reference.html">ZOO-Service configuration file</a></li>
103<li class="toctree-l2"><a class="reference internal" href="../services/process-profiles.html">Process profiles registry</a></li>
104<li class="toctree-l2"><a class="reference internal" href="../services/howtos.html">Create your own ZOO-Services</a></li>
105<li class="toctree-l2"><a class="reference internal" href="../services/status.html">ZOO Status Service</a></li>
106<li class="toctree-l2"><a class="reference internal" href="../services/debug.html">Debugging ZOO Services</a></li>
107<li class="toctree-l2"><a class="reference internal" href="../services/zoo-services.html">Available ZOO-Services</a></li>
108</ul>
109</li>
110<li class="toctree-l1 current"><a class="reference internal" href="index.html">ZOO-API</a><ul class="current">
111<li class="toctree-l2"><a class="reference internal" href="what.html">What is ZOO-API ?</a></li>
112<li class="toctree-l2"><a class="reference internal" href="howto.html">Using ZOO-API</a></li>
113<li class="toctree-l2"><a class="reference internal" href="classes.html">ZOO-API Classes</a></li>
114<li class="toctree-l2 current"><a class="current reference internal" href="">Examples</a></li>
115</ul>
116</li>
117<li class="toctree-l1"><a class="reference internal" href="../client/index.html">ZOO-Client</a><ul>
118<li class="toctree-l2"><a class="reference internal" href="../client/what.html">What is ZOO-Client ?</a></li>
119<li class="toctree-l2"><a class="reference internal" href="../client/howto.html">Using ZOO-Client</a></li>
120<li class="toctree-l2"><a class="reference internal" href="../client/example.html">Example application</a></li>
121</ul>
122</li>
123<li class="toctree-l1"><a class="reference internal" href="../contribute/index.html">Contributor Guide</a><ul>
124<li class="toctree-l2"><a class="reference internal" href="../contribute/howto.html">How to contribute ?</a></li>
125<li class="toctree-l2"><a class="reference internal" href="../contribute/code.html">Contribute code</a></li>
126</ul>
127</li>
128</ul>
129
130         
131       
132      </div>
133      &nbsp;
134    </nav>
135
136    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
137
138     
139      <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
140        <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
141        <a href="../contents.html">ZOO-Project</a>
142      </nav>
143
144
145     
146      <div class="wy-nav-content">
147        <div class="rst-content">
148          <div role="navigation" aria-label="breadcrumbs navigation">
149  <ul class="wy-breadcrumbs">
150
151    <li><a href="../contents.html"> Docs</a> &#8725; &#160;</li>
152     
153          <li><a href="index.html">ZOO-API</a> &#8725; &#160;</li>
154     
155    <li>Examples</li>
156      <li class="wy-breadcrumbs-aside">
157       
158          <a href="../_sources/api/examples.txt" rel="nofollow"> View page source</a>
159       
160      </li>
161  </ul>
162  <hr/>
163</div>
164          <div role="main" class="document">
165           
166  <div class="section" id="examples">
167<span id="api-examples"></span><h1>Examples<a class="headerlink" href="#examples" title="Permalink to this headline"></a></h1>
168<p>This section gathers sample scripts using <a class="reference internal" href="what.html#api-what"><span>ZOO-API</span></a>, the <a class="reference external" href="http://zoo-project.org">ZOO-Project</a> server-side JavaScript API.</p>
169<p>ZOO-API contains many classes and functions. You can find the description list <a class="reference internal" href="classes.html#api-classes"><span>here</span></a>.</p>
170<div class="section" id="zoo-process-example">
171<h2>ZOO.Process example<a class="headerlink" href="#zoo-process-example" title="Permalink to this headline"></a></h2>
172<div class="highlight-python"><div class="highlight"><pre>function SampleService(conf,inputs,outputs){
173   var myProcess = new ZOO.Process(&#39;http://localhost/cgi-bin-new1/zoo_loader_new1.cgi&#39;,&#39;Boundary&#39;);
174   var myInputs = {InputPolygon: { type: &#39;complex&#39;, value: &#39;{&quot;type&quot;:&quot;Polygon&quot;,&quot;coordinates&quot;:[[[-106.993853,35.998758],[-107.407233,35.997524],[-107.430525,35.997726],[-107.4824,35.99878],[-108.37013,35.999472],[-109.043633,35.996652],[-109.096265,35.997817],[-109.148763,36.001751],[-109.200981,36.008442],[-109.252775,36.017871],[-109.304,36.030014],[-109.354516,36.044835],[-106.468201,35.991497],[-106.855511,35.989504],[-106.90933,35.990676],[-106.963008,35.994743],[-106.993853,35.998758]]]}&#39;, mimeType: &quot;application/json&quot;} };
175   var myExecuteResult=myProcess.Execute(myInputs);
176   return {result: ZOO.SERVICE_SUCCEEDED, outputs: [ {name:&quot;Result&quot;, value: myExecuteResult} ] };
177}
178</pre></div>
179</div>
180<p>In this really short example you can see how to create <code class="docutils literal"><span class="pre">ZOO.Process</span></code> class instance and
181call the Execute method on such an instance. Then you&#8217;ll just need to return a JavaScript
182object containing the attributes result and outputs, which I&#8217;m sure you already know
183what is about. The first is about the status of the process (can be <code class="docutils literal"><span class="pre">ZOO.SERVICE_SUCEEDED</span></code>,
184<code class="docutils literal"><span class="pre">ZOO.SERVICE_FAILED</span></code> and so on), the last is obviously the resulting maps (take a
185look at the maps internal data structure used by ZOO Kernel in <code class="docutils literal"><span class="pre">service.h</span></code>).</p>
186</div>
187<div class="section" id="zoo-updatestatus-example">
188<h2>ZOO.UpdateStatus example<a class="headerlink" href="#zoo-updatestatus-example" title="Permalink to this headline"></a></h2>
189<div class="highlight-python"><div class="highlight"><pre>function SampleLongService(conf,inputs,outputs){
190   var my_i=0;
191   while(my_i&lt;100){
192       try{
193         conf[&quot;lenv&quot;][&quot;status&quot;]=my_i;
194       }
195       catch(e){
196       }
197       ZOOUpdateStatus(conf,my_i);
198       SampleService(conf,inputs,outputs);
199       my_i+=10;
200   }
201   return SampleService(conf,inputs,outputs);
202}
203</pre></div>
204</div>
205<p>You can see in this sample code how to use the <code class="docutils literal"><span class="pre">ZOOUpdateStatus</span></code> function to update the
206current status of your running process. This information will be really helpfull when the
207ZOO Kernel will run your JavaScript Service in background mode (if the user set to <code class="docutils literal"><span class="pre">true</span></code>
208the <code class="docutils literal"><span class="pre">storeExecuteResponse</span></code> parameter in his request).</p>
209</div>
210</div>
211
212
213          </div>
214          <footer>
215 
216    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
217     
218        <a href="../client/index.html" class="btn btn-neutral float-right" title="ZOO-Client">Next <span class="fa fa-arrow-circle-right"></span></a>
219     
220     
221        <a href="zoo-request.html" class="btn btn-neutral" title="ZOO.Request"><span class="fa fa-arrow-circle-left"></span> Previous</a>
222     
223    </div>
224 
225
226  <hr/>
227  <div class="pfoot">
228  <div role="contentinfo">
229    <p>
230        &copy; Copyright 2009-2015, ZOO-Project team.
231    </p>
232  </div>
233  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> inspired by <a href="https://readthedocs.org">Read the Docs</a>.
234</div>
235</footer>
236
237        </div>
238      </div>
239
240    </section>
241
242  </div>
243 
244
245
246 
247
248    <script type="text/javascript">
249        var DOCUMENTATION_OPTIONS = {
250            URL_ROOT:'../',
251            VERSION:'1.4a0',
252            COLLAPSE_INDEX:false,
253            FILE_SUFFIX:'.html',
254            HAS_SOURCE:  true
255        };
256    </script>
257      <script type="text/javascript" src="../_static/jquery.js"></script>
258      <script type="text/javascript" src="../_static/underscore.js"></script>
259      <script type="text/javascript" src="../_static/doctools.js"></script>
260
261 
262
263 
264 
265    <script type="text/javascript" src="../_static/js/theme.js"></script>
266 
267
268 
269 
270  <script type="text/javascript">
271      jQuery(function () {
272          SphinxRtdTheme.StickyNav.enable();
273      });
274  </script>
275   
276
277</body>
278</html>
Note: See TracBrowser for help on using the repository browser.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png