[Zoo-discuss] [ZOO-Discuss] FOSS4G 2010 ZOO Workshop Problem
Christian Rüh
christian.rueh at uni-rostock.de
Tue Nov 26 11:31:00 PST 2013
Hi Gerald,
I rearranged the whole layer thing and now am at the point where I can
select multiple polygons from the WFS layer and can execute the simple
processing functions on a polygon :-)
However, I am stuck at the Union function. You can find my zcfd and py
as attachment.
I use the test_services.html of the workshop to perform a POST request
which is:
<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>Union</ows:Identifier>
<wps:DataInputs>
<wps:Input>
<ows:Identifier>InputEntity1</ows:Identifier>
<ows:Title>Playground area</ows:Title>
<wps:Reference
xlink:href="http://localhost:8082/geoserver/ows/?SERVICE=WFS&REQUEST=GetFeature&VERSION=1.0.0&typename=topp:states&SRS=EPSG:4326&FeatureID=states.15"/>
</wps:Input>
<wps:Input>
<ows:Identifier>InputEntity2</ows:Identifier>
<ows:Title>Playground area</ows:Title>
<wps:Reference
xlink:href="http://localhost:8082/geoserver/ows/?SERVICE=WFS&REQUEST=GetFeature&VERSION=1.0.0&typename=topp:states&SRS=EPSG:4326&FeatureID=states.1"/>
</wps:Input>
</wps:DataInputs>
<wps:ResponseForm>
<wps:ResponseDocument>
<wps:Output>
<ows:Identifier>Result</ows:Identifier>
<ows:Title>Area serviced by playground.</ows:Title>
<ows:Abstract>Area within which most users of this
playground will live.</ows:Abstract>
</wps:Output>
</wps:ResponseDocument>
</wps:ResponseForm>
</wps:Execute>
The error message I get is:
<ows:ExceptionText>
TRACE : ('mimeType',)
TRACE : <type 'exceptions.KeyError'>
Unable to run your python process properly. Please check the following
messages : [' File "/usr/lib/cgi-bin/ogr_ws_service_provider.py", line
60, in Union\n geometry2=extractInputs(inputs["InputEntity2"])\n', '
File "/usr/lib/cgi-bin/ogr_ws_service_provider.py", line 13, in
extractInputs\n if obj["mimeType"]=="application/json":\n']
</ows:ExceptionText>
I don't know why it's stuck at JSON format since the input polygons come
from a wfs (and they really do because it works with the other functions).
Cheers and thanks in advance,
Christian
________________________________________
Von: Fenoy Gerald [gerald.fenoy at geolabs.fr]
Gesendet: Donnerstag, 21. November 2013 16:14
An: Christian Rüh
Cc: ZOO-discuss
Betreff: Re: [ZOO-Discuss] FOSS4G 2010 ZOO Workshop Problem
Hi Christian,
thanks for insisting.
In fact the explanation text is probably not clear enough as you should
not have to select multiple polygons. In fact, once you run a single
geometry service, then you can select another feature nearby (the best
would be one which overlay the first result) then you can run, once the
second feature is selected, the « multiple features » services.
So a good example to use is the following:
* you select for instance the Texas feature,
* then, you run Buffer service on the selected feature,
* select the New Mexico / Oklahoma / Colorado or Kansas feature then
you run for instance Intersection
At the last step you get two features « selected » the first one is the
resulting feature created by the service and the second one is the
latest feature selected.
I hope this is clear enough and it helps you, in other case please do
not hesitate to ask any question you may have.
Best regards,
Gérald Fenoy
gerald.fenoy at geolabs.fr
Le 21 nov. 2013 à 10:19, Christian Rüh <christian.rueh at uni-rostock.de> a
écrit :
> Hi Gerald,
>
> I'm just beginning with the Exercise part of the workshop (with the multiProcessing() function). My initial problem is: For these function multiple polygons have to be selected and then they will be processed. But how can I select multiple polygons in the OpenLayers page (zoo-ogr.html)?
> I guess the "multi" layer should be used for that but that layer does nothing for me.
> I looked into examples from OpenLayers (e.g. http://dev.openlayers.org/releases/OpenLayers-2.13.1/examples/select-feature-multilayer.html) but even when I used code like this:
> selectControl = new OpenLayers.Control.SelectFeature(
> //{protocol: OpenLayers.Protocol.WFS.fromWMSLayer(layer)},
> layer,
> {
> clickout: true, toggle: false,
> multiple: false, hover: false,
> toggleKey: "ctrlKey", // ctrl key removes from selection
> multipleKey: "shiftKey" // shift key adds to selection
> }
> );
> map.addControl(selectControl);
> It still does not let me select multiple polygons.
>
> I know this is not a ZOO question but I just want to finish the ZOO workshop from start till finish.
>
> Cheers and thanks so much again,
> Christian
>
> Am 19.11.2013 15:28, schrieb Fenoy Gerald:
>> Hi Christian,
>> ok, so if you want to use this ZOO-Kernel version you will have to slightly modify the source code of the HTML file on line 82 you should add just before &.
>> So the line 82 is currently:
>>
>> url += '&RawDataOutput=Result at mimeType=application/json’;
>>
>> but should be
>>
>> url += ‘@mimeType=text/xml&RawDataOutput=Result at mimeType=application/json’;
>>
>> I guess you may try using the ZOO-Kernel 1.3.0 version and give it a try, I’m pretty sure it will work smoothly with the same services. But I can also understand that you don’t wasting time on compiling your own new version. Nevertheless, I think that now it is straightforward enough to be done. Anyway, you may probably have to issue with linked libraries.
>>
>> Hope you can confirm that the solution worked on your side.
>>
>> Best regards,
>>
>>
>>
>>
>> Le 19 nov. 2013 à 15:37, Christian Rüh
>> <christian.rueh at uni-rostock.de>
>> a écrit :
>>
>>
>>> Hi Gerald,
>>>
>>> thanks for your answer :-)
>>>
>>> I think I'm using 1.0 because for this workshop version 3.0 of the OSGeo live disk was suggested.
>>>
>>> Anyway, your request works and I saw the problem. Somehow in the request of the buffer function
>>> "@mimeType=text/xml"
>>> turns up right before the "&RawDataOutput=" part. This seems to cause the problem but I just can't find the spot where this is added to the url String in the "zoo-ogr.html".
>>> I attached the zoo-ogr.html maybe you can point me to the problem, thank you very much in advance :-)
>>>
>>> Cheers and thanks again,
>>> Christian
>>> ________________________________________
>>> Von: Fenoy Gerald [
>>> gerald.fenoy at geolabs.fr
>>> ]
>>> Gesendet: Dienstag, 19. November 2013 00:14
>>> An: Christian Rüh
>>> Cc: ZOO-discuss
>>> Betreff: Re: [ZOO-Discuss] FOSS4G 2010 ZOO Workshop Problem
>>>
>>> Hi Christian,
>>> thanks for providing feedbacks.
>>>
>>> I’m wondering what is the version of ZOO-Kernel you are using. Indeed, I noticed nothing wrong in both your query and the ZCFG file.
>>>
>>> So I guess there is some issue with the ZOO-Kernel version you are using for running the workshop. May I invite you to try the following request and see if anything change [1] ?
>>>
>>>
>>> If it solves the issue, then I would invite your to try with 1.3.0 version or SVN trunk version [2],
>>>
>>> Hope this helps,
>>> Best regards
>>>
>>> [1]
>>> http://localhost/zoo/?request=Execute&service=WPS&version=1.0.0&Identifier=Buffer&DataInputs=BufferDistance=1@datatype=interger;InputPolygon=Reference@xlink:href=http%3A%2F%2Flocalhost%3A8082%2Fgeoserver%2Fows%3FSERVICE%3DWFS%26REQUEST%3DGetFeature%26VERSION%3D1.0.0%26typename%3Dtopp%3Astates%26SRS%3DEPSG%3A4326%26FeatureID%3Dstates.25@mimeType=text/xml&RawDataOutput=Result@mimeType=application/json
>>>
>>> [2]
>>> http://zoo-project.org/site/Downloads#Fordevelopers
>>>
>>>
>>> Gérald Fenoy
>>>
>>> gerald.fenoy at geolabs.fr
>>>
>>>
>>>
>>> Le 18 nov. 2013 à 16:48, Christian Rüh
>>> <christian.rueh at uni-rostock.de>
>>> a écrit :
>>>
>>>
>>>> Hi Gerald,
>>>>
>>>> ah, no need to apologize, I'm happy for your fast answer :-)
>>>>
>>>> The initial error is resolved and for a query like this:
>>>>
>>>> http://localhost/cgi-bin/zoo_loader.cgi?request=Execute&service=WPS&version=1.0.0&Identifier=Buffer&DataInputs=InputPolygon=Reference@xlink:href=http%3A%2F%2Flocalhost%3A8082%2Fgeoserver%2Fows%3FSERVICE%3DWFS%26REQUEST%3DGetFeature%26VERSION%3D1.0.0%26typename%3Dtopp%3Astates%26SRS%3DEPSG%3A4326%26FeatureID%3Dstates.15
>>>>
>>>> I get a satisfying result.
>>>>
>>>> However, if i want to use the OpenLayers application I run into problems (maybe the kind you suggested with "Note that with this version of the Python service you will have to use the Polygon and MultiPolygon.").
>>>> For the request
>>>>
>>>> http://localhost/zoo/?request=Execute&service=WPS&version=1.0.0&Identifier=Buffer&DataInputs=BufferDistance=1@datatype=interger;InputPolygon=Reference@xlink:href=http%3A%2F%2Flocalhost%3A8082%2Fgeoserver%2Fows%3FSERVICE%3DWFS%26REQUEST%3DGetFeature%26VERSION%3D1.0.0%26typename%3Dtopp%3Astates%26SRS%3DEPSG%3A4326%26FeatureID%3Dstates.25&RawDataOutput=Result@mimeType=application/json
>>>>
>>>> I get the error:
>>>> <ows:ExceptionText>
>>>> TRACE : ('mimeType',)
>>>> TRACE : <type 'exceptions.KeyError'>
>>>> Unable to run your python process properly. Please check the following messages : [' File "/usr/lib/cgi-bin/ogr_ws_service_provider.py", line 48, in Buffer\n geometry=extractInputs(inputs["InputPolygon"])\n', ' File "/usr/lib/cgi-bin/ogr_ws_service_provider.py", line 13, in extractInputs\n if obj["mimeType"]=="application/json":\n']
>>>> </ows:ExceptionText>
>>>>
>>>> I looked into the zcfg and it's InputPolygon there, application/json is also spelled correctly everywhere as far as I can see.
>>>>
>>>> Since I haven't changed a thing in ogr_ws_service_provider.py I've only attached the Buffer.zcfg.
>>>>
>>>> Cheers and thanks again,
>>>> Christian
>>>>
>>>> ________________________________________
>>>> Von: Fenoy Gerald [
>>>> gerald.fenoy at geolabs.fr
>>>> ]
>>>> Gesendet: Montag, 18. November 2013 14:57
>>>> An: ZOO-discuss
>>>> Cc: Christian Rüh
>>>> Betreff: Re: [ZOO-Discuss] FOSS4G 2010 ZOO Workshop Problem
>>>>
>>>> Hi Christian,
>>>> sorry for answering your email so late.
>>>>
>>>> I found an issue in the ZCFG file the output was not named « Result » but « BufferedPolygon ».
>>>>
>>>> I guess that once you updated the ZCFG file everything should run smoothly.
>>>>
>>>> Note that with this version of the Python service you will have to use the Polygon and MultiPolygon.
>>>>
>>>> Hope this helps you,
>>>> Best regards,
>>>>
>>>> Gérald Fenoy
>>>>
>>>> gerald.fenoy at geolabs.fr
>>>>
>>>>
>>>>
>>>>
>>>> Le 18 nov. 2013 à 14:51, Christian Rüh
>>>> <christian.rueh at uni-rostock.de>
>>>> a écrit :
>>>>
>>>>
>>>>> Hi Gerald,
>>>>>
>>>>> thank you for the fast answer that helped me a lot :-)
>>>>> I was able to fix the problem with your hint.
>>>>>
>>>>> However, the next problem was right around the corner. After the ConvexHull and Centroid functions worked fine the Buffer function won't.
>>>>>
>>>>> I get the following error:
>>>>> <ows:ExceptionText>
>>>>> TRACE : ('Result',)
>>>>> TRACE : <type 'exceptions.KeyError'>
>>>>> Unable to run your python process properly. Please check the following messages : [' File "/usr/lib/cgi-bin/ogr_ws_service_provider.py", line 54, in Buffer\n outputResult(outputs["Result"],rgeom)\n']
>>>>> </ows:ExceptionText>
>>>>>
>>>>> I've looked into keyerrors and python but wasn't able to resolve this issue. Especially since the line (54)
>>>>> "outputResult(outputs["Result"],rgeom)"
>>>>> was used in all the other functions as well and worked fine there.
>>>>>
>>>>> I attached my Buffer.zcfg and ogr_ws_service_provider.py.
>>>>>
>>>>> I really hope you can help me with this problem, too, and am thankful in advance :-)
>>>>>
>>>>> Cheers and thanks,
>>>>> Christian
>>>>>
>>>>> ________________________________________
>>>>> Von: Fenoy Gerald [
>>>>> gerald.fenoy at geolabs.fr
>>>>> ]
>>>>> Gesendet: Freitag, 15. November 2013 16:18
>>>>> An: ZOO-discuss
>>>>> Cc: Christian Rüh
>>>>> Betreff: Re: [ZOO-Discuss] FOSS4G 2010 ZOO Workshop Problem
>>>>>
>>>>> Hi Christian,
>>>>> it seems that the issue is only in the Python service code.
>>>>>
>>>>> I noticed a strange thing in the error message, it seems that there is a tabulation ("\t") which was inserted by mistake in the ogr_ws_service_provider.py file on line 18.
>>>>>
>>>>> Check the expression on line 18 and remove any tabulation located near the "name()=\’Multipolygon\’"
>>>>>
>>>>> Hope this solve your issue.
>>>>>
>>>>> Best regards,
>>>>>
>>>>>
>>>>> Le 15 nov. 2013 à 15:24, Sickboy
>>>>> <christian.rueh at uni-rostock.de>
>>>>> a écrit :
>>>>>
>>>>>
>>>>>> Hi there,
>>>>>>
>>>>>> I tried to do the above workshop
>>>>>> (
>>>>>> http://www.zoo-project.org/site/ZooWorkshop2010/Content
>>>>>> ) and got stuck at
>>>>>> step 3.3.1.2 (Creating WPS compliant OGR based Web Services -> Implementing
>>>>>> single geometry processes -> Boundary -> Python version). I wasn't able to
>>>>>> compile the C version (I'm don't really know anything about C and Linux
>>>>>> which might be the problem) so I went for the Python version. If I try one
>>>>>> of the URLs given to test the process I get:
>>>>>> <ows:ExceptionReport xsi:schemaLocation=
>>>>>> "http://www.opengis.net/ows/1.1
>>>>>> http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd"
>>>>>> xml:lan="en"
>>>>>> service="WPS" version="1.0.0">
>>>>>> <ows:Exception exceptionCode="NoApplicableCode">
>>>>>> <ows:ExceptionText>
>>>>>> TRACE : xmlXPathEval() failed
>>>>>> TRACE : <class 'libxml2.xpathError'>
>>>>>> Unable to run your python process properly. Please check the following
>>>>>> messages : [' File "/usr/lib/cgi-bin/ogr_ws_service_provider.py", line 18,
>>>>>> in Boundary\n
>>>>>> geometry=createGeometryFromWFS(inputs["InputPolygon"]["value"])\n', ' File
>>>>>> "/usr/lib/cgi-bin/ogr_ws_service_provider.py", line 7, in
>>>>>> createGeometryFromWFS\n
>>>>>> res=ctxt.xpathEval("/*/*/*/*/*[local-name()=\'Polygon\' or
>>>>>> local-\tname()=\'MultiPolygon\']")\n', ' File
>>>>>> "/usr/lib/pymodules/python2.6/libxml2.py", line 4894, in xpathEval\n if
>>>>>> ret is None:raise xpathError(\'xmlXPathEval() failed\')\n']
>>>>>> </ows:ExceptionText>
>>>>>> </ows:Exception>
>>>>>> </ows:ExceptionReport>
>>>>>>
>>>>>> There seems to be a problem with the libxml2 library but even with googling
>>>>>> I was not able to fix it.
>>>>>>
>>>>>> The Geoserver was started when the document told me to (but this does not
>>>>>> matter as I've tested it without a running Geoserver, too).
>>>>>> I'm using the OSGeo Live disk 3.0 because the README
>>>>>> (
>>>>>> http://zoo-project.org/trac/attachment/wiki/ZooWorkshop2010/Content/README
>>>>>> )
>>>>>> indicated that.
>>>>>> I guess it ain't important but I'm using it with VMWare Player 5 on Windows
>>>>>> 7 x64.
>>>>>>
>>>>>> Help would be greatly appreciated since I'm needing this for a seminar with
>>>>>> my students in 2 weeks.
>>>>>>
>>>>>> Cheers and thanks in advance for any help,
>>>>>> Christian
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://zoo-discuss.1049523.n5.nabble.com/FOSS4G-2010-ZOO-Workshop-Problem-tp5706683.html
>>>>>>
>>>>>> Sent from the ZOO-Discuss mailing list archive at
>>>>>> Nabble.com
>>>>>> .
>>>>>> _______________________________________________
>>>>>> Zoo-discuss mailing list
>>>>>>
>>>>>> Zoo-discuss at gisws.media.osaka-cu.ac.jp
>>>>>> http://gisws.media.osaka-cu.ac.jp/mailman/listinfo.cgi/zoo-discuss
>>>>> Gérald Fenoy
>>>>>
>>>>> gerald.fenoy at geolabs.fr
>>>>>
>>>>>
>>>>> <Buffer.zcfg><ogr_ws_service_provider.py>
>>>>>
>>>> <Buffer.zcfg>
>>>>
>>> <zoo-ogr.html>
>>>
>> Gérald Fenoy
>>
>> gerald.fenoy at geolabs.fr
>>
>>
>>
>
> <zoo-ogr.html>
-------------- next part --------------
import osgeo.ogr
import libxml2
def createGeometryFromWFS(my_wfs_response):
doc=libxml2.parseMemory(my_wfs_response,len(my_wfs_response))
ctxt = doc.xpathNewContext()
res=ctxt.xpathEval("/*/*/*/*/*[local-name()='Polygon' or local-name()='MultiPolygon']")
for node in res:
geometry_as_string=node.serialize()
geometry=osgeo.ogr.CreateGeometryFromGML(geometry_as_string)
return geometry
return geometry
def extractInputs(obj):
if obj["mimeType"]=="application/json":
return osgeo.ogr.CreateGeometryFromJson(obj["value"])
else:
return createGeometryFromWFS(obj["value"])
return null
def outputResult(obj,geom):
if obj["mimeType"]=="application/json":
obj["value"]=geom.ExportToJson()
obj["mimeType"]="text/plain"
else:
obj["value"]=geom.ExportToGML()
def Boundary(conf,inputs,outputs):
geometry=extractInputs(inputs["InputPolygon"])
rgeom=geometry.GetBoundary()
outputResult(outputs["Result"],rgeom)
geometry.Destroy()
rgeom.Destroy()
return 3
def ConvexHull(conf,inputs,outputs):
geometry=extractInputs(inputs["InputPolygon"])
rgeom=geometry.ConvexHull()
outputResult(outputs["Result"],rgeom)
geometry.Destroy()
rgeom.Destroy()
return 3
def Centroid(conf,inputs,outputs):
geometry=extractInputs(inputs["InputPolygon"])
if geometry.GetGeometryType()!=3:
geometry=geometry.ConvexHull()
rgeom=geometry.Centroid()
outputResult(outputs["Result"],rgeom)
geometry.Destroy()
rgeom.Destroy()
return 3
def Buffer(conf,inputs,outputs):
geometry=extractInputs(inputs["InputPolygon"])
try:
bdist=int(inputs["BufferDistance"]["value"])
except:
bdist=10
rgeom=geometry.Buffer(bdist)
outputResult(outputs["Result"],rgeom)
geometry.Destroy()
rgeom.Destroy()
return 3
def Union(conf,inputs,outputs):
geometry1=extractInputs(inputs["InputEntity1"])
geometry2=extractInputs(inputs["InputEntity2"])
rgeometries=[]
i=0
while i < len(geometry1):
j=0
while j < len(geometry2):
tres=geometry1[i].Union(geometry2[j])
if not(tres.IsEmpty()):
rgeometries+=[tres]
j+=1
geometry1[i].Destroy()
i+=1
i=0
while i < len(geometry2):
geometry2[i].Destroy()
i+=1
outputResult(conf,outputs["Result"],rgeometries)
return 3
-------------- next part --------------
[Union]
Title = Compute union.
Abstract = Generates a new geometry which is the region of union of the two geometries operated on.
Profile = urn:ogc:wps:1.0.0:union
processVersion = 2
storeSupported = true
statusSupported = true
serviceProvider = ogr_ws_service_provider
serviceType = Python
<MetaData>
title = Demo
</MetaData>
<DataInputs>
[InputEntity1]
Title = the first geometry
Abstract = the first geometry to compare against.
minOccurs = 1
maxOccurs = 1
<MetaData>
title = Mon test
</MetaData>
<ComplexData>
<Default>
mimeType = text/xml
encoding = UTF-8
schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
</Default>
<Supported>
mimeType = application/json
encoding = UTF-8
</Supported>
</ComplexData>
[InputEntity2]
Title = the other geometry
Abstract = the other geometry to compare against.
minOccurs = 1
maxOccurs = 1
<MetaData>
title = Mon test
</MetaData>
<ComplexData>
<Default>
mimeType = text/xml
schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
encoding = UTF-8
</Default>
<Supported>
mimeType = application/json
encoding = UTF-8
</Supported>
</ComplexData>
</DataInputs>
<DataOutputs>
[Result]
Title = The union of two geometries
Abstract = The geometry representing the union of the two geometries.
<MetaData>
title = Mon test
</MetaData>
<ComplexData>
<Default>
mimeType = text/xml
schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
encoding = UTF-8
extension = xml
</Default>
<Supported>
mimeType = application/json
encoding = UTF-8
extension = js
</Supported>
</ComplexData>
</DataOutputs>
More information about the Zoo-discuss
mailing list