[Pywps-commits] r488 - trunk/pywps/processes

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed May 28 07:55:41 CEST 2008


Author: jachym
Date: 2008-05-28 07:55:40 +0200 (Wed, 28 May 2008)
New Revision: 488

Added:
   trunk/pywps/processes/__init__.py
   trunk/pywps/processes/buffer.py
   trunk/pywps/processes/los.py
Removed:
   trunk/pywps/processes/__init__.py-dist
   trunk/pywps/processes/addvalue.py-dist
   trunk/pywps/processes/buffer.py-dist
   trunk/pywps/processes/classify.py-dist
   trunk/pywps/processes/convert.py-dist
   trunk/pywps/processes/flow.py-dist
   trunk/pywps/processes/inputsoutputs.py-dist
   trunk/pywps/processes/ndvi.py-dist
   trunk/pywps/processes/shortestpath.py-dist
   trunk/pywps/processes/spearpath.py-dist
   trunk/pywps/processes/visibility.py-dist
Log:
reordered processes

Added: trunk/pywps/processes/__init__.py
===================================================================
--- trunk/pywps/processes/__init__.py	2008-05-26 16:05:25 UTC (rev 487)
+++ trunk/pywps/processes/__init__.py	2008-05-28 05:55:40 UTC (rev 488)
@@ -0,0 +1,2 @@
+__all__ = ["buffer","los"]
+

Deleted: trunk/pywps/processes/__init__.py-dist
===================================================================
--- trunk/pywps/processes/__init__.py-dist	2008-05-26 16:05:25 UTC (rev 487)
+++ trunk/pywps/processes/__init__.py-dist	2008-05-28 05:55:40 UTC (rev 488)
@@ -1,15 +0,0 @@
-# Author:	Jachym Cepicky
-#		http://les-ejk.cz
-
-__all__ = [ 
-        "addvalue",
-        "classify" ,
-        "flow",
-        "ndvi",
-        "shortestpath", 
-        "spearpath", 
-        "visibility",
-        "inputsoutputs",
-        "buffer",
-        "convert",
-	]

Deleted: trunk/pywps/processes/addvalue.py-dist
===================================================================
--- trunk/pywps/processes/addvalue.py-dist	2008-05-26 16:05:25 UTC (rev 487)
+++ trunk/pywps/processes/addvalue.py-dist	2008-05-28 05:55:40 UTC (rev 488)
@@ -1,109 +0,0 @@
-"""
-pywps process example:
-
-addvalue: Adds some value to raster map
-"""
-# Author:	Jachym Cepicky
-#        	http://les-ejk.cz
-# Lince: 
-# 
-# Web Processing Service implementation
-# Copyright (C) 2006 Jachym Cepicky
-# 
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-
-import os,time,string,sys,shutil
-
-from pywps.Wps.process import GRASSWPSProcess
-
-class Process(GRASSWPSProcess):
-#####################################################################
-#
-# Configuration part of the process
-#
-#####################################################################
-    def __init__(self):
-        GRASSWPSProcess.__init__(self,
-                Identifier = "addvalue",
-                Title= "Add some value to some raster map",
-                processVersion = "0.2",
-                storeSupported = True,
-                statusSupported = True)
-
-        self.AddComplexInput(Identifier = "input",
-                            Title = "Input raster map",
-                            Formats= ["image/tiff"])
-                             
-        self.AddLiteralInput(Identifier = "value",
-                            Title = "Value to be added",
-                            value = ["*"],
-                            type = type(0.0),
-                            )
-                
-        self.AddComplexReferenceOutput(Identifier = "outputRef",
-                            Title = "Resulting output map",
-                            Formats = ["image/tiff"]
-                            )
-
-    #####################################################################
-    #
-    # Execute part of the process
-    #
-    #####################################################################
-    def execute(self):
-        """
-        This function
-            1) Imports the raster map
-            2) runs r.mapcalc out=in+value
-            3) Exports the raster map
-            4) returns the new file name or 'None' if something went wrong
-        """
-
-        # import of the data
-        self.GCmd("r.in.gdal -o input=%s output=input" %\
-                (self.GetInputValue('input')))
-
-        self.SetStatus(message="Data  imported", percent=10)
-
-        # compositing 3 bands to one raster file
-        for line in self.Cmd("gdalinfo %s" %\
-                (self.GetInputValue('input'))):
-            if line.split()[0] == "Band" and line.split()[1] == "3":
-                self.GCmd("""g.region rast=input.red""")
-                self.GCmd("r.composite r=input.red b=input.blue g=input.green out=input")
-
-        # region setting
-        self.GCmd("""g.region rast=input""")
-        for l in os.popen("r.info input").readlines():
-            sys.stderr.write(l+"\n")
-
-        # adding the value
-        self.GCmd("r.mapcalc output=input+%f >&2" % \
-                (float(self.GetInputValue('value'))))
-
-        for l in os.popen("r.info output").readlines():
-            sys.stderr.write(l+"\n")
-
-        self.GCmd("r.out.gdal in=output out=/tmp/pokus.png type=Byte")
-        # output
-        self.SetStatus("Raster file export", 90)
-        self.GCmd("r.out.gdal type=UInt32 in=output out=%s" %\
-                "output.tif")
-
-        # setting output values
-        if "output.tif" in os.listdir(os.curdir):
-            self.SetOutputValue("outputRef","output.tif")
-            return 
-        else:
-            return "Output file not created!"

Added: trunk/pywps/processes/buffer.py
===================================================================
--- trunk/pywps/processes/buffer.py	2008-05-26 16:05:25 UTC (rev 487)
+++ trunk/pywps/processes/buffer.py	2008-05-28 05:55:40 UTC (rev 488)
@@ -0,0 +1,54 @@
+# Author: Luca Casagrande ( luca.casagrande at gmail.com )
+# Rewritten by: Jachym Cepicky <jachym les-ejk cz> 
+#               According to new process definition style
+
+import os,time,string,sys
+from pywps.Process import WPSProcess
+
+
+class Process(WPSProcess):
+    def __init__(self):
+        WPSProcess.__init__(self,
+            identifier = "buffer",
+            title="Buffer",
+            version = "0.2",
+            storeSupported = "true",
+            statusSupported = "true",
+            abstract="Create a buffer around an input vector file",
+            grassLocation = True)
+
+
+        self.dataIn = self.addComplexInput(identifier="data",
+                             title = "Input data")
+
+        self.widthIn = self.addLiteralInput(identifier = "width",
+                             title = "Width")
+
+        self.bufferOut = self.addComplexOutput(identifier="buffer",
+                                title="Output buffer file",asReference=True)
+
+        self.textOut = self.addLiteralOutput(identifier="text",
+                                title="just some text")
+        
+    def execute(self):
+
+        self.cmd("g.region -d")
+
+        self.status.set("Importing data",20)
+	self.cmd("v.in.ogr dsn=%s output=data" %\
+                (self.getInputValue('data')))
+            
+        self.status.set("Buffering",50)
+	self.cmd("v.buffer input=data output=data_buff buffer=%s scale=1.0 tolerance=0.01" %\
+                (self.getInputValue('width')))
+
+        self.status.set("Exporting data",90)
+
+	self.cmd("v.out.ogr type=area format=GML input=data_buff dsn=out.xml  olayer=path.xml")
+        
+        if "out.xml" in os.listdir(os.curdir):
+            self.bufferOut.setValue("out.xml")
+            self.textOut.setValue("ahoj, svete")
+            return
+        else:
+            return "Output file not created"

Deleted: trunk/pywps/processes/buffer.py-dist
===================================================================
--- trunk/pywps/processes/buffer.py-dist	2008-05-26 16:05:25 UTC (rev 487)
+++ trunk/pywps/processes/buffer.py-dist	2008-05-28 05:55:40 UTC (rev 488)
@@ -1,51 +0,0 @@
-# Author: Luca Casagrande ( luca.casagrande at gmail.com )
-# Rewritten by: Jachym Cepicky <jachym les-ejk cz> 
-#               According to new process definition style
-
-import os,time,string,sys
-from pywps.Wps.process import GRASSWPSProcess
-
-class Process(GRASSWPSProcess):
-    def __init__(self):
-        GRASSWPSProcess.__init__(self,
-            Identifier = "buffer",
-            processVersion = "0.2",
-            storeSupported = "true",
-            statusSupported = "true",
-            Title="Buffer",
-            Abstract="Create a buffer around an input vector file"
-            )
-
-        self.AddComplexInput(Identifier="data",
-                             Title = "Input data",
-                             Formats = ["text/xml"])
-
-        self.AddLiteralInput(Identifier = "width",
-                             Title = "Width",
-                             Abstract = "Reasonable buffer width, e.g. 0.01  for WGS84",
-                             type = type(0.0))
-
-
-	self.AddComplexReferenceOutput(
-                Identifier = "buffer",
-                Title = 'Buffer',
-                Formats = ["text/xml"])
-        
-    def execute(self):
-
-        self.GCmd("g.region -d")
-	    	
-	self.GCmd("v.in.ogr input=%s output=data" %\
-                (self.GetInputValue('data')))
-            
-	self.GCmd("v.buffer input=data output=data_buff buffer=%s scale=1.0 tolerance=0.01" %\
-                (self.GetInputValue('width')))
-            	
-	self.GCmd("v.out.ogr type=area format=GML input=punto_buff dsn=out.xml  olayer=path.xml")
-        
-        if "out.xml" in os.listdir(os.curdir):
-            self.SetOutputValue('output', "out.xml")
-            return
-        else:
-            return "Output file not created"
-

Deleted: trunk/pywps/processes/classify.py-dist
===================================================================
--- trunk/pywps/processes/classify.py-dist	2008-05-26 16:05:25 UTC (rev 487)
+++ trunk/pywps/processes/classify.py-dist	2008-05-28 05:55:40 UTC (rev 488)
@@ -1,85 +0,0 @@
-"""
-pywps process example:
-
-classify: Classify satellite image
-"""
-# Author:	Stepan Kafka
-# Rewritten by: Jachym Cepicky
-# Lince: 
-# 
-# Web Processing Service implementation
-# Copyright (C) 2006 Stepan Kafka
-# 
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-
-import os,time,string,sys
-from pywps.Wps.process import GRASSWPSProcess
-
-class Process(GRASSWPSProcess):
-#####################################################################
-#
-# Configuration part of the process
-#
-#####################################################################
-    def __init__(self):
-        GRASSWPSProcess.__init__(self,
-                Identifier = "classify",
-                processVersion = "0.1",
-                Title = "Image classification",
-                Abstract = "Unsupervised image classification",
-                storeSupported = True,
-                statusSupported = True
-                )
-
-        self.AddComplexInput(Identifier="input",
-                Title="Input raster map",
-                Formats = ["image/tiff"])
-
-        self.AddLiteralInput(Identifier="classes",
-                Title = "Number of classes",
-                Abstract = "Number of classes in unsupervised classification",
-                value = 20)
-
-
-        self.AddComplexReferenceOutput(Identifier = "output",
-                Title="Resulting output map",
-                Formats = ["image/tiff"])
-    #####################################################################
-    #
-    # Execute part of the process
-    #
-    #####################################################################
-    def execute(self):
-        """
-        This function
-            1) Imports the raster map
-            2) runs r.mapcalc out=in+value
-            3) Exports the raster map
-            4) returns the new file name or 'None' if something went wrong
-        """
-        
-        self.GCmd("r.in.gdal -o -k input=%s output=input 1>&2" % (self.DataInputs['input']))
-        self.GCmd("g.region -p rast=input.1")
-        self.GCmd("i.group group=gr subgroup=klas input=`g.mlist type=rast sep=',' pattern='input.*'`")
-        self.GCmd("i.cluster group=gr subgroup=klas sigfile=sig classes=%s" % (self.DataInputs['classes']))
-        self.GCmd("i.maxlik -q group=gr subgroup=klas sigfile=sig class=classif reject=rejected")
-        self.GCmd("r.out.gdal input=classif output=output.tif type=Byte")
-        
-        # check the resulting file or any other variable, which interrests you
-        if "output.tif" in os.listdir(os.curdir):
-            self.SetOutputValue('output', "output.tif")
-            return
-        else:
-            return "Output file not created"
-        

Deleted: trunk/pywps/processes/convert.py-dist
===================================================================
--- trunk/pywps/processes/convert.py-dist	2008-05-26 16:05:25 UTC (rev 487)
+++ trunk/pywps/processes/convert.py-dist	2008-05-28 05:55:40 UTC (rev 488)
@@ -1,99 +0,0 @@
-#!/usr/bin/python
-"""
-pywps process example:
-
-conversion: Convert a shape file to GML
-"""
-# Author:       Luca Casagrande (luca.casagrande at gmail.com)
-# Lince:
-#
-# Web Processing Service implementation
-# Copyright (C) 2006 Jachym Cepicky
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- 
-import os,time,string,sys
- 
- 
-class Process:
-    def __init__(self):
-        self.Identifier = "conversion"
-        self.processVersion = "0.1"
-        self.storeSupport = "true"
-        self.statusSupported = "true"
-	self.Title="Conversion from shp to gml"
-        self.Abstract="Convert a shape file in GML"
-        self.Inputs = [
-                    # 0
-                    {
-   			'Identifier': 'shp',
-   			'Title': 'Input vector',
-   			'ComplexValueReference': {
-       			'Formats':["application/octet-stream"],
-       				},
-		    },
-                    # 1
-                    {
-   			'Identifier': 'shx',
-   			'Title': 'Input vector',
-   			'ComplexValueReference': {
-       			'Formats':["application/octet-stream"],
-       				},
-		    },
- 
-                    # 2
-                    {
-   			'Identifier': 'dbf',
-   			'Title': 'Input vector',
-   			'ComplexValueReference': {
-       			'Formats':["application/octet-stream"],
-       				},
-		    },
- 
- 
-                     ]
- 
-	self.Outputs = [
-        	#0    
-		{
-                'Identifier': 'output',
-                'Title': 'Resulting output map',
-                'ComplexValueReference': {
-                'Formats':["text/xml"]
-                }
-            },
-        ]
- 
-    def execute(self):
-        try:
-            os.rename(self.DataInputs['shp'],"input.shp")
-            os.rename(self.DataInputs['dbf'],"input.dbf")
-            os.rename(self.DataInputs['shx'],"input.shx")
-        except:
-            return "Could not rename input files"
-
-        if os.system("ogr2ogr -f gml out.xml input.shp 1>&2"):
-            return "Could not convert vector file"
- 
-        if "out.xml" in os.listdir(os.curdir):
-            self.Outputs[0]['value'] = "out.xml"
-            return
-        else:
-            return "Output file not created"
-
-if __name__ == "__main__":
-    proc = Process()
-    proc.DataInputs = {}
-    proc.DataInputs['vector'] = "shape.shp"
-    proc.execute()

Deleted: trunk/pywps/processes/flow.py-dist
===================================================================
--- trunk/pywps/processes/flow.py-dist	2008-05-26 16:05:25 UTC (rev 487)
+++ trunk/pywps/processes/flow.py-dist	2008-05-28 05:55:40 UTC (rev 488)
@@ -1,152 +0,0 @@
-"""
-pywps process example:
-
-flow:   analysis of flowing water
-"""
-# Author:	Stepan Kafka
-# Lince: 
-# 
-# Web Processing Service implementation
-# Copyright (C) 2006 Stepan Kafka
-# 
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-
-import os,time,string,sys
-
-class Process:
-#####################################################################
-#
-# Configuration part of the process
-#
-#####################################################################
-    def __init__(self):
-        
-        # 
-        # Mandatory parameters
-        # 
-        
-        # Identifier - name of this process
-        self.Identifier = "flow"
-        
-        # processVersion - version of this process
-        self.processVersion = "0.2"
-        
-        # Title - title for this process
-        self.Title="Flow analysis"
-        self.Abstract="GRASS processed r.flow analysis."
-        self.grassLocation="/var/www/wps/spearfish60/"
-        
-        #
-        # Inputs
-        # Inputs is an array of input structure
-        # Inputs = [ {input1},{input2},{...} ]
-        #
-        self.Inputs = [
-                # 0
-                    {
-                        'Identifier': 'x1',
-                        'Title': 'X coordinate',
-                        'LiteralValue': {
-        		    'values':["*"],
-                        },
-        		'dataType': type(0.0),
-                    },
-        
-                # 1
-        	    {
-                        'Identifier': 'y1',
-                        'Title': 'Y coordinate',
-                        'LiteralValue': {
-        		    'values':["*"],
-                        },
-        		'dataType': type(0.0),
-                    },
-        	    
-                # 2
-        	    {
-                        'Identifier':'x2',
-                        'Title': 'X coordinate',
-                        'LiteralValue': {
-        		    'values':["*"],
-                        },
-        		'dataType': type(0.0),
-                    },
-        
-        	# 3
-        	    {
-                        'Identifier':'y2',
-                        'Title': 'Y coordinate',
-                        'LiteralValue': {
-        		    'values':["*"],
-                        },
-        		'dataType': type(0.0),
-                    }
-                ]
-        
-        #
-        # Output
-        # The structure is not much different from the input structure
-        #
-        self.Outputs = [
-                {
-                    'Identifier': 'output',
-                    'Title': 'Resulting output map',
-                    'ComplexValueReference': {
-                        'Formats':["image/tiff"],
-                        },
-                    },
-        ]
-        
-        #
-        # Optional attributes
-        #
-        #
-        # storeSuport = "true" or "false" - should the resulting map be stored on our disk?
-        self.storeSupported = "true"
-        
-        #
-        # statusSupported = "true" or "false" - if statusLocation is set, the server 
-        # will not wait for the end of the operation and will return the 
-        # ExectuceResponce XML file immediately, without the ProcessOutput section
-        # but with the statusLocation parameter
-        self.statusSupported = "true"
-        # and many others
-        
-    #####################################################################
-    #
-    # Execute part of the process
-    #
-    #####################################################################
-    def execute(self):
-        os.system("g.region -d")
-        if os.system("g.region w=%s s=%s e=%s n=%s align=dem_cr" % \
-                (self.Inputs[0]['value'],
-                    self.Inputs[1]['value'],
-                    self.Inputs[2]['value'],
-                    self.Inputs[3]['value'])):
-            return "Could not set region to desired region"
-        if os.system("r.flow elevin=dem_cr dsout=accum"):
-            return "Could use r.flow"
-        if os.system("r.out.tiff -t input=accum output=output0"):
-            return "Could use export raster map"
-        if os.system("/usr/local/bin/gdal_translate -of GTiff output0.tif output.tif >> /dev/null"):
-            return "Could not use gdal_translate"
-
-        # check the resulting file or any other variable, which interrests you
-        if "output.tif" in os.listdir(os.curdir):
-            self.Outputs[0]['value'] = "output.tif"
-            return
-        else:
-            return "Output file not created"
-

Deleted: trunk/pywps/processes/inputsoutputs.py-dist
===================================================================
--- trunk/pywps/processes/inputsoutputs.py-dist	2008-05-26 16:05:25 UTC (rev 487)
+++ trunk/pywps/processes/inputsoutputs.py-dist	2008-05-28 05:55:40 UTC (rev 488)
@@ -1,55 +0,0 @@
-"""
-Process for testing in and outputs of WPS
-"""
-
-# Author:	Jachym Cepicky
-# Lince: 
-# 
-# Web Processing Service implementation
-# Copyright (C) 2006 Stepan Kafka
-# 
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# 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.Wps.process import WPSProcess
-
-class Process(WPSProcess):
-    def __init__(self):
-        WPSProcess.__init__(self)
-        self.Identifier = "inputsoutputs"
-        self.processVersion = "0.2"
-        self.Title="Test input and output structures"
-        self.statusSupported="false"
-        self.storeSupported="false"
-        #self.grassLocation = None
-
-        self.AddLiteralInput("literal","Literal Value","Literal Value",
-                    allowedvalues=[[1,10],[20,40],100],MinimumOccurs=3, type=type(0))
-        self.AddComplexInput("complexref", "Literal Value Reference", 
-                "Complex Value Reference", Formats="image/jpeg",value="http://les-ejk.cz/img/jaja.jpg")
-        self.AddBBoxInput("bbox", "Bounding Box Value",value=[0,0,10,10])
-        self.AddComplexInput("xml")
-
-        self.AddLiteralOutput("literal", UOMs=["cm"])
-        self.AddComplexOutput("complexref", Formats="image/jpeg")
-        self.AddBBoxOutput("bbox", value=[11,11,14,14.4])
-        
-    def execute(self):
-        self.Outputs[1]['value'] = self.Inputs[1]['value']
-        self.Outputs[2]['value'] = [self.Inputs[2]['value'][0],
-                                    self.Inputs[2]['value'][1],
-                                    self.Inputs[2]['value'][2],
-                                    self.Inputs[2]['value'][3]]
-
-        self.Outputs[3]['value'] = self.Inputs[3]['value']
-        return 

Added: trunk/pywps/processes/los.py
===================================================================
--- trunk/pywps/processes/los.py	2008-05-26 16:05:25 UTC (rev 487)
+++ trunk/pywps/processes/los.py	2008-05-28 05:55:40 UTC (rev 488)
@@ -0,0 +1,147 @@
+import sys, os
+
+from pywps.Wps.process import GRASSWPSProcess
+
+class Process(GRASSWPSProcess):
+    def __init__(self):
+        GRASSWPSProcess.__init__(self,
+                Identifier = "los",
+                Title= "Lines of sight",
+                processVersion = "0.1",
+                storeSupported = True,
+                statusSupported = True)
+
+        self.AddComplexInput(Identifier = "dmt",
+                            Title = "Digital elevation model",
+                            Formats= ["image/tiff"])
+                             
+        self.AddLiteralInput(Identifier = "x",
+                            Title = "x coordinate",
+                            value = ["*"],
+                            type = type(0.0))
+                
+        self.AddLiteralInput(Identifier = "y",
+                            Title = "y coordinate",
+                            value = ["*"],
+                            type = type(0.0))
+
+        self.AddLiteralInput(Identifier = "extent",
+                            Title = "Extent",
+                            Abstract = "w s e n",
+                            type = type(""),
+                            value = "")
+
+        self.AddLiteralInput(Identifier = "height",
+                            Title = "Height",
+                            Abstract = "Observer height",
+                            type = type(0.0),
+                            value = 0)
+
+        self.AddLiteralInput(Identifier = "min",
+                            Title = "Min level",
+                            Abstract = "Min level in dem",
+                            type = type(0.0),
+                            value = 0)
+
+        self.AddLiteralInput(Identifier = "max",
+                            Title = "Max level",
+                            Abstract = "Max level in dem",
+                            type = type(0.0),
+                            value = 0)
+
+        self.AddComplexReferenceOutput(Identifier = "map",
+                            Title = "Resulting output map",
+                            Formats = ["image/gif"])
+        self.AddLiteralOutput(Identifier = "size",
+                            Title = "Image size")
+        self.AddLiteralOutput(Identifier = "extent",
+                            Title = "Image extent")
+
+    def execute(self):
+
+        w,s,e,n = [None, None, None, None]
+        dmt = self.GetInputValue("dmt")
+        height = self.GetInputValue("height");
+
+        min = self.GetInputValue("min");
+        max = self.GetInputValue("max");
+
+        # import of the data
+        if (self.GetInputValue("extent") != ""):
+            w,s,e,n = self.GetInputValue("extent").split(" ")
+            try:
+                w = float(w)
+                s = float(s)
+                e = float(e)
+                n = float(n)
+            except Exception, e:
+                return e
+
+            self.GCmd("gdal_translate -ot Byte -a_ullr %s %s %s %s -of GTiff %s dmt.tif" % (w,n,e,s,dmt))
+            dmt = "dmt.tif"
+
+        if float(height) >0:
+            #height = float(256)/float(3000)*float(height)
+            pass
+        else:
+            height = 0
+        self.GCmd("r.in.gdal -o input=%s output=dmt" % (dmt))
+        self.GCmd("g.region rast=dmt")
+        if min != max:
+            if min == 0:
+                min = 1
+            if min < max:
+                self.GCmd("r.mapcalc dmt=(%s-%s)/dmt+%s" % \
+                        (float(max),float(min),float(min)))
+            else:
+                self.GCmd("r.mapcalc dmt=(%s-%s)/dmt+%s" % \
+                        (float(min),float(max),float(min)))
+
+
+        self.SetStatus(message="Data  imported", percent=10)
+
+        self.SetStatus(message="Calculating  lines of sigth", percent=20)
+        # adding the value
+        max = abs(float(e)-float(w))
+        if max > 5000:
+            max = 5000
+        self.GCmd("r.los in=dmt out=los coor=%f,%f obs_e=%s max=%s >&2" % \
+                (self.GetInputValue('x'),self.GetInputValue("y"),height,max))
+
+        self.SetStatus(message="Making transparency", percent=70)
+        self.GCmd("r.null map=los setnull=0")
+
+        self.SetStatus(message="Exporting resulting image", percent=80)
+        self.GCmd("r.out.png in=los out=los.png")
+
+        self.SetStatus(message="Creating png image file", percent=90)
+        #self.GCmd("export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/cepicky/lib; /home/cepicky/bin/convert los.png -alpha reset -transparent white los.png")
+        self.GCmd("convert los.png -transparent white los.png")
+        self.SetOutputValue("map","los.png")
+        self.SetStatus(message="Final region settings", percent=100)
+
+        n = None
+        s = None
+        w = None
+        e = None
+        rows = 0
+        cols = 0
+
+        for line in self.GCmd("g.region -g"):
+            key,val=line.strip().split("=")
+            if key == "n":
+                n=val
+            elif key == "s":
+                s=val
+            elif key == "w":
+                w=val
+            elif key == "e":
+                e=val
+            elif key == "rows":
+                rows=val
+            elif key == "cols":
+                cols=val
+
+        self.SetOutputValue("size","%s %s" % (cols, rows))
+        self.SetOutputValue("extent","%s %s %s %s" % (w,s,e,n))
+

Deleted: trunk/pywps/processes/ndvi.py-dist
===================================================================
--- trunk/pywps/processes/ndvi.py-dist	2008-05-26 16:05:25 UTC (rev 487)
+++ trunk/pywps/processes/ndvi.py-dist	2008-05-28 05:55:40 UTC (rev 488)
@@ -1,139 +0,0 @@
-"""
-pywps process example:
-
-ndvi
-"""
-# Author:	Jachym Cepicky
-#        	http://les-ejk.cz
-# Lince: 
-# 
-# Web Processing Service implementation
-# Copyright (C) 2006 Jachym Cepicky
-# 
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-
-import os
-
-class Process:
-#####################################################################
-#
-# Configuration part of the process
-#
-#####################################################################
-    def __init__(self):
-        # 
-        # Mandatory parameters
-        # 
-        # Identifier - name of this process
-        self.Identifier = "ndvi"
-        # processVersion - version of this process
-        self.processVersion = "0.1"
-        # Title - title for this process
-        self.Title="NDVI"
-        self.Abstract = """
-        Calculates normalized vegetation index: NDVI =(LANDSAT.4 - LANDSAT.3) / (LANDSAT.4 + LANDSAT.3)" or
-        NDVI =(nir - red) / (nir + red)"
-
-        """
-        self.grassLocation=None
-        
-        #
-        # Inputs
-        #
-        self.Inputs = [
-        
-                # 0 input
-                    {
-                        'Identifier': 'landsat3',
-                        'Title': 'Landsat 3',
-                        'Abstract':'Channel 3 of LANDSAT TM (RED)',
-                        'ComplexValueReference': {
-                            'Formats':['image/tif','image/png'], # AllowedValues, AnyValue, ValuesReference
-                        },
-                        'dataType' : type(''), # you should set this for input params controll
-                        'value':None,
-                    },
-                # 1 input
-                    {
-                        'Identifier': 'landsat4',
-                        'Title': 'Landsat 4',
-                        'Abstract':'Channel 4 of LANDSAT TM (NIR)',
-                        'ComplexValueReference': {
-                            'Formats':['image/tif','image/png'], # AllowedValues, AnyValue, ValuesReference
-                        },
-                        'dataType' : type(''), # you should set this for input params controll
-                        'value':None,
-                    },
-
-                ]
-        
-        #
-        # Output
-        #
-        self.Outputs = [
-            {
-               'Identifier': 'ndvi',
-               'Title': 'NDVI',
-               'ComplexValueReference': {'Formats':["image/tif"]},
-               'value': 'ndvi.tif',
-           },
-        ]
-        
-        #
-        # Optional attributes
-        #
-        #
-        # storeSuport = "true" or "false" - should the resulting map be stored on our disk?
-        self.storeSupported = "true"
-        
-        #
-        # statusSupported = "true" or "false" - if statusLocation is set, the server 
-        # will not wait for the end of the operation and will return the 
-        # ExectuceResponce XML file immediately, without the ProcessOutput section
-        # but with the statusLocation parameter
-        self.statusSupported = "true"
-        # and many others
-
-    #####################################################################
-    #
-    # Execute part of the process
-    #
-    #####################################################################
-    def execute(self):
-        """
-        NDVI
-        """
-
-        # import
-        if os.system("r.in.gdal in=%s out=red >&2" % (self.Inputs[0]['value'])):
-            return "Could not import <%s>" % (self.Inputs[0]['value'])
-        if os.system("r.in.gdal in=%s out=nir >&2" % (self.Inputs[1]['value'])):
-            return "Could not import <%s>" % (self.Inputs[2]['value'])
-        
-        # ndvi
-        if os.system("""r.mapcalc ndvi"="float(nir-red)/float(nir+red)" >&2"""):
-            return   """Could not r.mapcalc ndvi"="float(nir-red)/float(nir+red)" """
-        
-        # export
-        if os.system("""r.out.gdal in=ndvi out=ndvi.tif type=Int32 >&2"""):
-            return   """Could r.out.gdal in=ndvi out=ndvi.tif type=Int32 """
-        
-if __name__ == "__main__":
-        
-    ps = Process()
-    ps.Inputs[0]['value'] = "red"
-    ps.Inputs[1]['value'] = "nir"
-
-    ps.execute()
-    print ps.Outputs[0]

Deleted: trunk/pywps/processes/shortestpath.py-dist
===================================================================
--- trunk/pywps/processes/shortestpath.py-dist	2008-05-26 16:05:25 UTC (rev 487)
+++ trunk/pywps/processes/shortestpath.py-dist	2008-05-28 05:55:40 UTC (rev 488)
@@ -1,92 +0,0 @@
-"""
-pywps process example:
-
-shortestpath:   calculate shortest path on vector network
-"""
-# Author:	Jachym Cepicky
-# Lince: 
-# 
-# Web Processing Service implementation
-# Copyright (C) 2006 Stepan Kafka
-# 
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-
-
-import os,time,string,sys,shutil
-from pywps.Wps.process import GRASSWPSProcess
-
-class Process(GRASSWPSProcess):
-    def __init__(self):
-        GRASSWPSProcess.__init__(self,
-                Identifier="shortestpath",
-                processVersion = "0.2",
-                storeSupported = "true",
-                Title="Find the shortes path on the roads map",
-                )
-        self.AddComplexInput(Identifier= "streetmap",
-                            Title="Street map",
-                            Abstract = """Street map on which the shortest path operation should be performed""",
-                            Formats = ["text/xml"])
-        self.AddLiteralInput(Identifier = "x1",
-                            Title = "Start x coordinate",
-                            type = type(0.0)
-                            )
-        self.AddLiteralInput(Identifier = "y1",
-                            Title = "Start y coordinate",
-                            type = type(0.0)
-                            )
-        self.AddLiteralInput(Identifier = "x2",
-                            Title = "Stop x coordinate",
-                            type = type(0.0)
-                            )
-        self.AddLiteralInput(Identifier = "y2",
-                            Title = "Stop y coordinate",
-                            type = type(0.0)
-                            )
-        self.AddComplexReferenceOutput(
-                Identifier= "outputReference",
-                Title = "Resulting output map",
-                Formats = ["text/xml"])
-
-        self.AddComplexOutput(
-                Identifier= "outputData",
-                Title = "Resulting output map",
-                Formats = ["text/xml"])
-                
-    # --------------------------------------------------------------------
-    def execute(self):
-        """
-        This function serves like simple GRASS - python script
-
-        It returns None, if process succeed or String if process failed
-        """
-        self.GCmd("v.in.ogr dsn=%s out=roads" % \
-                (self.GetInputValue('streetmap')))
-        self.GCmd("g.region -d")
-
-
-        self.GCmd("v.net.path in=roads out=path","0 %s %s %s %s" % (self.GetInputValue('x1'),
-                self.GetInputValue('y1'),
-                self.GetInputValue('x2'),
-                self.GetInputValue('y2')))
-
-        self.GCmd("v.out.ogr format=GML input=path dsn=out.xml olayer=path.xml")
-
-        if "out.xml" in os.listdir(os.curdir):
-            shutil.copy("out.xml","out2.xml")
-            self.SetOutputValue('outputReference',"out.xml")
-            self.SetOutputValue('outputData',"out2.xml")
-            return
-        else:
-            return "Ouput file not created!"

Deleted: trunk/pywps/processes/spearpath.py-dist
===================================================================
--- trunk/pywps/processes/spearpath.py-dist	2008-05-26 16:05:25 UTC (rev 487)
+++ trunk/pywps/processes/spearpath.py-dist	2008-05-28 05:55:40 UTC (rev 488)
@@ -1,87 +0,0 @@
-"""
-pywps process example:
-
-spearpath:   find shortest path at GRASS spearfish demo dataset
-"""
-# Author:	Jachym Cepicky
-# Lince: 
-# 
-# Web Processing Service implementation
-# Copyright (C) 2006 Stepan Kafka
-# 
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-
-
-import os,time,string,sys,shutil
-from pywps.Wps.process import GRASSWPSProcess
-
-class Process(GRASSWPSProcess) :
-    def __init__(self):
-        GRASSWPSProcess.__init__(self,
-        Identifier = "spearpath",
-        processVersion = "0.1",
-        storeSupported = "true",
-        Title="Find the shortes path on the roads map on Spearfish dataset",
-        grassLocation="/var/www/wps/spearfish60/")
-
-        self.AddLiteralInput(Identifier = "x1",
-                            Title = "Start x coordinate",
-                            type = type(0.0)
-                            )
-        self.AddLiteralInput(Identifier = "y1",
-                            Title = "Start y coordinate",
-                            type = type(0.0)
-                            )
-        self.AddLiteralInput(Identifier = "x2",
-                            Title = "Stop x coordinate",
-                            type = type(0.0)
-                            )
-        self.AddLiteralInput(Identifier = "y2",
-                            Title = "Stop y coordinate",
-                            type = type(0.0)
-                            )
-        self.AddComplexReferenceOutput(
-                Identifier= "outputReference",
-                Title = "Resulting output map",
-                Formats = ["text/xml"])
-
-        self.AddComplexOutput(
-                Identifier= "outputData",
-                Title = "Resulting output map",
-                Formats = ["text/xml"])
-
-    # --------------------------------------------------------------------
-    def execute(self):
-        """
-        This function serves like simple GRASS - python script
-
-        It returns None, if process succeed or String if process failed
-        """
-        self.GCmd("g.region -d")
-
-
-        self.GCmd("v.net.path in=roads out=path","0 %s %s %s %s" % (self.GetInputValue('x1'),
-                self.GetInputValue('y1'),
-                self.GetInputValue('x2'),
-                self.GetInputValue('y2')))
-
-        self.GCmd("v.out.ogr format=GML input=path dsn=out.xml olayer=path.xml")
-
-        if "out.xml" in os.listdir(os.curdir):
-            shutil.copy("out.xml","out2.xml")
-            self.SetOutputValue('outputReference',"out.xml")
-            self.SetOutputValue('outputData',"out2.xml")
-            return
-        else:
-            return "Ouput file not created!"

Deleted: trunk/pywps/processes/visibility.py-dist
===================================================================
--- trunk/pywps/processes/visibility.py-dist	2008-05-26 16:05:25 UTC (rev 487)
+++ trunk/pywps/processes/visibility.py-dist	2008-05-28 05:55:40 UTC (rev 488)
@@ -1,98 +0,0 @@
-"""
-pywps process example:
-
-visibility: Visibility analysis
-"""
-# Author : Jachym Cepicky
-# Lince: 
-# 
-# Web Processing Service implementation
-# Copyright (C) 2006 Jachym Cepicky
-# 
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-
-import os,time,string,sys
-
-from pywps.Wps.process import GRASSWPSProcess
-
-class Process(GRASSWPSProcess):
-    #####################################################################
-    #
-    # Configuration part of the process
-    #
-    #####################################################################
-    def __init__(self):
-        GRASSWPSProcess.__init__(self,
-                    Identifier = "visibility",
-                    processVersion = "0.3",
-                    Title="Visibility analysis",
-                    Abstract="GRASS visibility (Lines of Sight) analysis.",
-                    storeSupported = "true",
-                    statusSupported = "true")
-
-        self.AddLiteralInput(Identifier = "lon",
-                            Title = "Longitude",
-                            Abstract = "X coordinate of the observer",
-                            type = type(0.0))
-
-        self.AddLiteralInput(Identifier = "lat",
-                            Title = "Latitude",
-                            Abstract = "Y coordinate of the observer",
-                            type = type(0.0))
-
-        self.AddComplexInput(Identifier = "dem",
-                            Title = 'Digital elevation model',
-                            Abstract = 'URL (e.g. WCS) of digital elevation model')
-
-        self.AddLiteralInput(Identifier = "observer",
-                            type = type(0.0),
-                            Title = 'Observer height above the DTM',
-                            Abstract = 'The height of observer eye over the terrain (meters)',
-                            value = 1.8)
-
-        self.AddLiteralInput(Identifier = "format",
-                            type = type(''),
-                            Title = 'Required format',
-                            Abstract = 'Required output format',
-                            allowedvalues = ["image/tiff","image/png"],
-                            value = "image/tiff")
-        
-        self.AddComplexReferenceOutput(Identifier = "visibility",
-                Title =   'Resulting output visibility map',
-                Formats = ["image/tiff","image/png"],
-                Schemas=[None,None])
-        
-    #
-    # Execute part of the process
-    #
-    def execute(self):
-
-	self.SetStatus("Importing data", 10)
-        os.system("cp %s /tmp/dem" % (self.GetInputValue("dem")))
-        self.GCmd("r.in.gdal in=%s out=dem" % (self.GetInputValue("dem")))
-        self.GCmd("g.region rast=dem")
-	self.SetStatus("Calculating visibility", 30)
-        self.GCmd("r.los input=dem output=output coordinate=%s,%s obs_elev=%s" % \
-                (self.GetInputValue("lon"),self.GetInputValue("lat"), self.GetInputValue('observer')))
-	self.SetStatus("Creating output",70)
-        self.GCmd("""r.mapcalc "output0=if(output,1,0)" """)
-	self.SetStatus("Exporting output",90)
-
-        if self.GetInputValue("format") == "image/tiff":
-            self.GCmd("r.out.gdal input=output0 output=visibility.tif type=Byte")
-            self.SetOutputValue("visibility","visibility.tif")
-        elif self.GetInputValue("format") == "image/png":
-            self.GCmd("r.out.png input=output0 output=visibility.png")
-            self.SetOutputValue("visibility","visibility.png")
-        return



More information about the Pywps-commits mailing list