[Pywps-commits] r1006 - in branches/pywps-foss4g2010: doc/source/_static doc/source/clients doc/source/special pywps pywps/Process pywps/Templates/1_0_0/inc pywps/Wps/Execute tests/Templates/1_0_0/inc tests/processes webservices/tomcat

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Sep 6 10:57:05 CEST 2010


Author: jachym
Date: 2010-09-06 10:57:04 +0200 (Mon, 06 Sep 2010)
New Revision: 1006

Added:
   branches/pywps-foss4g2010/doc/source/_static/pywps_jython.png
   branches/pywps-foss4g2010/doc/source/special/java.rst
Modified:
   branches/pywps-foss4g2010/doc/source/clients/javascript.rst
   branches/pywps-foss4g2010/pywps/Process/__init__.py
   branches/pywps-foss4g2010/pywps/Template.py
   branches/pywps-foss4g2010/pywps/Templates/1_0_0/inc/DescribeProcess_BoundingBoxValue.tmpl
   branches/pywps-foss4g2010/pywps/Wps/Execute/UMN.py
   branches/pywps-foss4g2010/tests/Templates/1_0_0/inc/DescribeProcess_BoundingBoxValue.tmpl
   branches/pywps-foss4g2010/tests/processes/buffer.py
   branches/pywps-foss4g2010/tests/processes/dummyprocess.py
   branches/pywps-foss4g2010/webservices/tomcat/PywpsServlet.py
   branches/pywps-foss4g2010/webservices/tomcat/web.xml
Log:
merged up to r1005 from trunk

Copied: branches/pywps-foss4g2010/doc/source/_static/pywps_jython.png (from rev 1005, trunk/doc/source/_static/pywps_jython.png)

Modified: branches/pywps-foss4g2010/doc/source/clients/javascript.rst
===================================================================
--- branches/pywps-foss4g2010/doc/source/clients/javascript.rst	2010-09-03 11:01:28 UTC (rev 1005)
+++ branches/pywps-foss4g2010/doc/source/clients/javascript.rst	2010-09-06 08:57:04 UTC (rev 1006)
@@ -4,7 +4,7 @@
 `OpenLayers <http://openlayers.org>`_. The client *does not show any
 results in the map*, but it enables you, as client coder, to program the
 client in hopefully easy way. The client is located in
-:file:`pywps-source/webclient/WPS.js`. Beside this file, OpenLayers have to
+:file:`PyWPS-source/webclient/WPS.js`. Beside this file, OpenLayers have to
 be included in the web page.
 
 Initialization and GetCapabilities request
@@ -215,3 +215,60 @@
     };
 
 The rest was already defined before.
+
+Handling vector data 
+......................................................
+A typical operation performed using OpenLayers and a WPS service,
+is to send data to the server and display the results directly over the map.
+For example consider a process that allows to generate a buffer starting from
+vector data and a number to use as buffer's value. From the DescribeProcess we 
+see that those two inputs must be passed as "data" and "buffer".
+At this point we start with the configuration of OpenLayers:
+
+Add vector layer used for editing and the editing toolbar control:
+
+.. code-block:: javascript
+
+    vlayer = new OpenLayers.Layer.Vector("Editable");
+    edit = new OpenLayers.Control.EditingToolbar(vlayer);
+    map.addControl(edit);
+
+Now create the WPS object as defined before;a bit of attention to input/output parameters
+because we're going to use the featues drawn by the user (vlayer) and a literaldata inserted 
+in a HTML text box with buffer as id.
+
+Input:
+.. code-block:: javascript
+
+    var dataInput = new OpenLayers.WPS.ComplexPut({
+        identifier:"data",
+        value:  OpenLayers.Format.GML.prototype.write(vlayer.features)
+    });
+
+    var literalInput = new OpenLayers.WPS.LiteralPut({
+        identifier:"buffer",
+        value: document.getElementById("buffer").value
+    });
+
+Ouput:
+
+..code-block:: javascript
+    var complexOutput = new OpenLayers.WPS.ComplexPut({
+        identifier: "output",
+        asReference: "true"
+    });
+    
+Now move to the onSuceedeed function, the one executed once the process has successfully run.
+Basically we need to add the output file to the list of layers in the map object. OpenLayers 
+allows to add GML directly on the map, but watch out for file too big:
+
+..code-block:: javascript
+    var onWPSSussceeded = function(process) {
+		//We need to remove the layer generated by previous instance of the script
+	    try {
+		    map.removeLayer(rlayer);
+	        rlayer.destroy();
+		} catch(e) {}
+	    	url = process.getOutput("output").value;
+		    rlayer = new OpenLayers.Layer.GML("Result",url);
+	    	Pap.addLayer(rlayer);

Copied: branches/pywps-foss4g2010/doc/source/special/java.rst (from rev 1005, trunk/doc/source/special/java.rst)

Modified: branches/pywps-foss4g2010/pywps/Process/__init__.py
===================================================================
--- branches/pywps-foss4g2010/pywps/Process/__init__.py	2010-09-03 11:01:28 UTC (rev 1005)
+++ branches/pywps-foss4g2010/pywps/Process/__init__.py	2010-09-06 08:57:04 UTC (rev 1006)
@@ -615,7 +615,7 @@
                 printed. nothing happen otherwise.
         """
 
-        if self.debug or force and self.logFile:
+        if (self.debug or force) and self.logFile:
             if type(self.logFile) == type(""):
                 try:
                     f = open(self.logFile,"w")

Modified: branches/pywps-foss4g2010/pywps/Template.py
===================================================================
--- branches/pywps-foss4g2010/pywps/Template.py	2010-09-03 11:01:28 UTC (rev 1005)
+++ branches/pywps-foss4g2010/pywps/Template.py	2010-09-06 08:57:04 UTC (rev 1006)
@@ -41,7 +41,7 @@
 VARTYPES=[types.StringType, types.FileType,
         types.FloatType, types.IntType,
         types.NoneType,
-        types.BooleanType, types.LongType]
+        types.BooleanType, types.LongType, types.UnicodeType]
 
 class Token:
     """Base Token class. Token is snipplet of input template. Template

Modified: branches/pywps-foss4g2010/pywps/Templates/1_0_0/inc/DescribeProcess_BoundingBoxValue.tmpl
===================================================================
--- branches/pywps-foss4g2010/pywps/Templates/1_0_0/inc/DescribeProcess_BoundingBoxValue.tmpl	2010-09-03 11:01:28 UTC (rev 1005)
+++ branches/pywps-foss4g2010/pywps/Templates/1_0_0/inc/DescribeProcess_BoundingBoxValue.tmpl	2010-09-06 08:57:04 UTC (rev 1006)
@@ -1,8 +1,8 @@
                     <Default>
-                        <CRS xlink:href="<TMPL_VAR crs>" />
+                        <CRS><TMPL_VAR crs></CRS>
                     </Default>
                     <Supported>
                         <TMPL_LOOP CRSs>
-                        <CRS xlink:href="<TMPL_VAR crs>" />
+                        <CRS><TMPL_VAR crs></CRS>
                         </TMPL_LOOP>
                     </Supported>

Modified: branches/pywps-foss4g2010/pywps/Wps/Execute/UMN.py
===================================================================
--- branches/pywps-foss4g2010/pywps/Wps/Execute/UMN.py	2010-09-03 11:01:28 UTC (rev 1005)
+++ branches/pywps-foss4g2010/pywps/Wps/Execute/UMN.py	2010-09-06 08:57:04 UTC (rev 1006)
@@ -20,12 +20,14 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
+
 from pywps import config
 import os
 import urllib2
 import logging
 
 mapscript=False
+gdal=False
 try:
     from mapscript import *
     mapscript=True
@@ -37,12 +39,14 @@
     from osgeo import gdal
     from osgeo import ogr
     from osgeo import osr
-    mapscript=True
+    gdal=True
 except Exception,e:
-    mapscript=False
+    gdal=False
     logging.info("osgeo package could not be loaded, mapserver not supported: %s" %e)
 
 
+#pydevd.settrace('localhost', port=5678, stdoutToServer=True, stderrToServer=True)
+
 class UMN:
     """
     UMN MapServer Mapscript handler
@@ -86,7 +90,7 @@
 
     def __init__(self,process):
 
-        if mapscript == False:
+        if ((mapscript == False) or (gdal== False)):
             return
 
         self.pid = os.getpid()
@@ -293,7 +297,8 @@
  
     def save(self):
         """Save the mapfile to disc"""
-        self.mapObj.save(self.mapFileName)
+        if self.mapObj:
+            self.mapObj.save(self.mapFileName)
 
     def getMapServerWCS(self,output):
         """Get the URL for mapserver WCS request of the output"""

Modified: branches/pywps-foss4g2010/tests/Templates/1_0_0/inc/DescribeProcess_BoundingBoxValue.tmpl
===================================================================
--- branches/pywps-foss4g2010/tests/Templates/1_0_0/inc/DescribeProcess_BoundingBoxValue.tmpl	2010-09-03 11:01:28 UTC (rev 1005)
+++ branches/pywps-foss4g2010/tests/Templates/1_0_0/inc/DescribeProcess_BoundingBoxValue.tmpl	2010-09-06 08:57:04 UTC (rev 1006)
@@ -1,8 +1,8 @@
                     <Default>
-                        <CRS xlink:href="<TMPL_VAR crs>" />
+                        <CRS><TMPL_VAR crs></CRS>
                     </Default>
                     <Supported>
                         <TMPL_LOOP CRSs>
-                        <CRS xlink:href="<TMPL_VAR crs>" />
+                        <CRS><TMPL_VAR crs></CRS>
                         </TMPL_LOOP>
                     </Supported>

Modified: branches/pywps-foss4g2010/tests/processes/buffer.py
===================================================================
--- branches/pywps-foss4g2010/tests/processes/buffer.py	2010-09-03 11:01:28 UTC (rev 1005)
+++ branches/pywps-foss4g2010/tests/processes/buffer.py	2010-09-06 08:57:04 UTC (rev 1006)
@@ -41,8 +41,8 @@
 
         # create output file
         driver = ogr.GetDriverByName('GML')
-        outSource = driver.CreateDataSource(out)
-        outLayer = outSource.CreateLayer(out,geom_type=ogr.wkbPolygon)
+        outSource = driver.CreateDataSource(out, ["XSISCHEMAURI=http://schemas.opengis.net/gml/2.1.2/ feature.xsd"])
+        outLayer = outSource.CreateLayer(out,None,ogr.wkbUnknown)
 
         # for each feature
         featureCount = inLayer.GetFeatureCount()

Modified: branches/pywps-foss4g2010/tests/processes/dummyprocess.py
===================================================================
--- branches/pywps-foss4g2010/tests/processes/dummyprocess.py	2010-09-03 11:01:28 UTC (rev 1005)
+++ branches/pywps-foss4g2010/tests/processes/dummyprocess.py	2010-09-06 08:57:04 UTC (rev 1006)
@@ -18,10 +18,10 @@
               
          self.Input1 = self.addLiteralInput(identifier = "input1",
                                             title = "Input1 number", 
-                                            default="100")
+                                            default=100)
          self.Input2= self.addLiteralInput(identifier="input2", 
                                            title="Input2 number", 
-                                          default="200")
+                                          default=200)
          self.Output1=self.addLiteralOutput(identifier="output1", 
                                             title="Output1 add 1 result")
          self.Output2=self.addLiteralOutput(identifier="output2",title="Output2 subtract 1 result" )                                   

Modified: branches/pywps-foss4g2010/webservices/tomcat/PywpsServlet.py
===================================================================
--- branches/pywps-foss4g2010/webservices/tomcat/PywpsServlet.py	2010-09-03 11:01:28 UTC (rev 1005)
+++ branches/pywps-foss4g2010/webservices/tomcat/PywpsServlet.py	2010-09-06 08:57:04 UTC (rev 1006)
@@ -9,9 +9,8 @@
 import pywps
 from pywps.Exceptions import *
 import traceback
-import sys
 
-class PywspServlet(HttpServlet):
+class PywpsServlet(HttpServlet):
 
     def doGet(self,request,response):
 

Modified: branches/pywps-foss4g2010/webservices/tomcat/web.xml
===================================================================
--- branches/pywps-foss4g2010/webservices/tomcat/web.xml	2010-09-03 11:01:28 UTC (rev 1005)
+++ branches/pywps-foss4g2010/webservices/tomcat/web.xml	2010-09-06 08:57:04 UTC (rev 1006)
@@ -20,8 +20,8 @@
          ...
          tomcat/webapps/wps/WEB-INF/
          tomcat/webapps/wps/WEB-INF/web.xml (this file)
-         tomcat/webapps/wps/WEB-INF/classes/
-         tomcat/webapps/wps/WEB-INF/classes/jythonlib.jar
+         tomcat/webapps/wps/WEB-INF/lib/
+         tomcat/webapps/wps/WEB-INF/lib/jythonlib.jar
 
          This should be described in the documentation more detaily.
     -->



More information about the Pywps-commits mailing list