Re: [Geoserver-users] Python geoscript input types

2014-07-03 Thread Vassilis Dalakas
Hi Justin,

first of all thanks for finding the time to respond.

I am getting the following Could not convert -100 to target type [D
that is strange.

Where should I open the bug? On the geoserver-devel list or to geoscript?

Best regards,

V.

03 Jul 11:44:44 ERROR [org.geotools.rendering] - Failed to evaluate the process 
function, error is: Traceback (most recent call last):
  File __pyclasspath__/geoserver/wps.py, line 19, in wrapped
  File /usr/local/geoserver/data/scripts/wps/bc1.py, line 37, in run
return contour.run(data=barnesed, levels=levels1)['result']
  File __pyclasspath__/geoscript/process.py, line 86, in run
at 
org.geotools.process.factory.AnnotationDrivenProcessFactory$InvokeMethodProcess.buildProcessArguments(AnnotationDrivenProcessFactory.java:641)
at 
org.geotools.process.factory.AnnotationDrivenProcessFactory$InvokeMethodProcess.execute(AnnotationDrivenProcessFactory.java:515)
at sun.reflect.GeneratedMethodAccessor319.invoke(Unknown Source)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:491)

org.geotools.process.ProcessException: org.geotools.process.ProcessException: 
Could not convert -100 to target type [D



On 2 Ιουλ 2014, at 11:47 μ.μ., Justin Deoliveira jdeol...@boundlessgeo.com 
wrote:

 Hi Vassilis,
 
 I haven't tried this but one thing you could try is using the actual
 jython/python array type. So basically:
 
 from array import array
 
 ...
 
 'levels1': (ArrayListDouble(), 'Values of levels at which to generate
 contours')
 
 Like I said, not sure if that will work. If it doesn't feel free to open a
 bug report up for this one.
 
 -Justin
 
 
 
 
 On Wed, Jun 25, 2014 at 1:33 AM, Vassilis Dalakas vdala...@gmail.com
 wrote:
 
 Dear list,
 
 I need your help with a more advanced wps python script with Geoscript.
 Thank you all in advance for your valuable time and comments.
 
 I have successfully installed the 2.5.1 Geoserver with the geoscript and
 wps extensions and implemented some simple examples as the one described
 here:
 
 
 http://suite.opengeo.org/opengeo-docs/processing/scripting/processcreate.html
 
 I have also successfully implemented my own wps that combines
 gs:BarnesSurface and gs:Contour
 
 For your help gs:Contour is defined here:
 
 
 http://www.massapi.com/source/geoserver-2.1.1-src/geoserver-2.1.1/extension/wps/wps-core/src/main/java/org/geoserver/wps/gs/ContourProcess.java.html
 
 As you can see it requires as input either levels that is type double[]
 either interval that is type Double
 The following code is working fine having interval in place of levels
 and Double instead of ArrayListDouble() but I can't find how I should
 define levels1 in order to make it work with Double[].
 
 I have made some efforts as the following code that is throwing an error
 org.geotools.process.ProcessException: Could not convert -100 to target
 type [D
 
 Do you have any ideas how to define levels1 in order to make it work?
 
 Kind Regars,
 
 Vassilis Dalakas
 
 
 
 from java.lang import String, Integer, Double
 from geoscript.layer import Layer, Raster
 from geoserver.wps import process
 from geoscript.process import Process
 from geoscript.geom import *
 from org.geotools.data.simple import SimpleFeatureCollection
 from org.geotools.geometry.jts import ReferencedEnvelope
 from org.geotools.coverage.grid import GridCoverage2D
 from java.util import ArrayList as ArrayList
 
 barnes = Process.lookup('gs:BarnesSurface')
 contour = Process.lookup('gs:Contour')
 
 @process(
 title = 'Barnes and Contour',
 description = 'Uses Barnes Analysis to compute an interpolated surface
 over a set of irregular data points and computes contour lines at specified
 intervals or levels for the values in a raster.',
 inputs = {
   'data1': (SimpleFeatureCollection, 'Input features'),
   'valueAttr1': (String, 'Name of attribute containing the data value to
 be interpolated'),
   'scale1': (Double, 'Length scale for the interpolation, in units of the
 source data CRS'),
   'maxObservationDistance1': (Double, 'Maximum distance to an observation
 for it to support a grid cell, in units of the source CRS (default = 0,
 meaning all observations used)'),
   'pixelsPerCell1': (Integer, 'Resolution of the computed grid in pixels
 per grid cell (default = 1)'),
   'queryBuffer1': (Double, 'Distance to expand the query envelope by, in
 units of the source CRS (larger values provide a more stable surface)'),
   'outputBBOX1': (ReferencedEnvelope, 'Bounding box for output'),
   'outputWidth1': (Integer, 'Width of the output raster in pixels'),
   'outputHeight1': (Integer, 'Height of the output raster in pixels'),
   'levels1': (ArrayListDouble(), 'Values of levels at which to generate
 contours')
 },
 outputs = {
   'result': (SimpleFeatureCollection, 'Contour line features. Contour
 level is in value attribute.')
 }
 )
 
 def run(data1

[Geoserver-users] Python geoscript input types

2014-06-25 Thread Vassilis Dalakas
Dear list,

I need your help with a more advanced wps python script with Geoscript. Thank 
you all in advance for your valuable time and comments.

I have successfully installed the 2.5.1 Geoserver with the geoscript and wps 
extensions and implemented some simple examples as the one described here:

http://suite.opengeo.org/opengeo-docs/processing/scripting/processcreate.html

I have also successfully implemented my own wps that combines gs:BarnesSurface 
and gs:Contour

For your help gs:Contour is defined here:

http://www.massapi.com/source/geoserver-2.1.1-src/geoserver-2.1.1/extension/wps/wps-core/src/main/java/org/geoserver/wps/gs/ContourProcess.java.html

As you can see it requires as input either levels that is type double[] either 
interval that is type Double  
The following code is working fine having interval in place of levels and 
Double instead of ArrayListDouble() but I can't find how I should define 
levels1 in order to make it work with Double[].

I have made some efforts as the following code that is throwing an error
org.geotools.process.ProcessException: Could not convert -100 to target type [D

Do you have any ideas how to define levels1 in order to make it work?

Kind Regars,

Vassilis Dalakas



from java.lang import String, Integer, Double
from geoscript.layer import Layer, Raster
from geoserver.wps import process
from geoscript.process import Process
from geoscript.geom import *
from org.geotools.data.simple import SimpleFeatureCollection
from org.geotools.geometry.jts import ReferencedEnvelope
from org.geotools.coverage.grid import GridCoverage2D
from java.util import ArrayList as ArrayList

barnes = Process.lookup('gs:BarnesSurface')
contour = Process.lookup('gs:Contour')

@process(
 title = 'Barnes and Contour',
 description = 'Uses Barnes Analysis to compute an interpolated surface over a 
set of irregular data points and computes contour lines at specified intervals 
or levels for the values in a raster.',
 inputs = {
   'data1': (SimpleFeatureCollection, 'Input features'),
   'valueAttr1': (String, 'Name of attribute containing the data value to be 
interpolated'),
   'scale1': (Double, 'Length scale for the interpolation, in units of the 
source data CRS'),
   'maxObservationDistance1': (Double, 'Maximum distance to an observation for 
it to support a grid cell, in units of the source CRS (default = 0, meaning all 
observations used)'),
   'pixelsPerCell1': (Integer, 'Resolution of the computed grid in pixels per 
grid cell (default = 1)'),
   'queryBuffer1': (Double, 'Distance to expand the query envelope by, in units 
of the source CRS (larger values provide a more stable surface)'),
   'outputBBOX1': (ReferencedEnvelope, 'Bounding box for output'),
   'outputWidth1': (Integer, 'Width of the output raster in pixels'),
   'outputHeight1': (Integer, 'Height of the output raster in pixels'),
   'levels1': (ArrayListDouble(), 'Values of levels at which to generate 
contours')
 },
 outputs = {
   'result': (SimpleFeatureCollection, 'Contour line features. Contour level is 
in value attribute.')
 }
)

def run(data1, valueAttr1, scale1, maxObservationDistance1, pixelsPerCell1, 
queryBuffer1, outputBBOX1, outputWidth1, outputHeight1, levels1):
 barnesed = barnes.run(data=data1, valueAttr=valueAttr1, scale=scale1, 
maxObservationDistance=maxObservationDistance1, pixelsPerCell=pixelsPerCell1, 
queryBuffer=queryBuffer1, outputBBOX=outputBBOX1, outputWidth=outputWidth1, 
outputHeight=outputHeight1)['result']
 return contour.run(data=barnesed, levels=levels1)['result']
--
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft___
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users