[PyWPS-dev] Handle complex input of a process within/without a chain in a same way possible?
gunnar.stroeer at yahoo.de
gunnar.stroeer at yahoo.de
Mon Dec 17 09:51:58 PST 2018
Hi Carsten,
thanks for your hint and support url.
The repository is public, I just have renamed some files for better
clarity of the project. New url is:
https://gitlab.com/hadlaskard/integration-of-wps-in-local-sdi/blob/master/processes/proc_vect_buffer.py
And here is a working request of a simple process chain... working in
our intranet:
-------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<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
http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd" response="document"
mode="sync">
<ows:Identifier>vect_buffer</ows:Identifier>
<wps:DataInputs>
<wps:Input>
<ows:Identifier>in_size</ows:Identifier>
<wps:Data>
<wps:LiteralData>10</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier>in_geom</ows:Identifier>
<wps:Reference mimeType="text/xml" xlink:href="https://geodev2/pywps"
method="POST">
<wps:Body>
<wps:Execute version="1.0.0" service="WPS">
<ows:Identifier>vect_intersect</ows:Identifier>
<wps:DataInputs>
<wps:Input>
<ows:Identifier>in_geom_a</ows:Identifier>
<ows:Title>Input Geometry A</ows:Title>
<wps:Reference
xlink:href="https://geodev2/wps/output/evac_zone.gml"
mimeType="text/xml" encoding="UTF-8"
schema="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd" method="GET" />
</wps:Input>
<wps:Input>
<ows:Identifier>in_geom_b</ows:Identifier>
<ows:Title>Input Geometry B</ows:Title>
<wps:Reference
xlink:href="https://geodev2/wps/output/location_etrs.gml"
mimeType="text/xml" encoding="UTF-8"
schema="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd" method="GET" />
</wps:Input>
</wps:DataInputs>
<wps:ResponseForm>
<wps:ResponseDocument lineage="false"
storeExecuteResponse="false" status="false">
<wps:Output asReference="true" mimeType="application/gml-3.1.1"
encoding="utf-8">
<ows:Identifier>out_intersect</ows:Identifier>
</wps:Output>
</wps:ResponseDocument>
</wps:ResponseForm>
</wps:Execute>
</wps:Body>
</wps:Reference>
</wps:Input>
</wps:DataInputs>
<wps:ResponseForm>
<wps:ResponseDocument lineage="false" storeExecuteResponse="false"
status="false">
<wps:Output asReference="true" mimeType="application/gml-3.1.1"
encoding="utf-8">
<ows:Identifier>out_buff</ows:Identifier>
</wps:Output>
</wps:ResponseDocument>
</wps:ResponseForm>
</wps:Execute>
-------------------------------------------------
Now the following single buffer request doesn't work anymore since I
parse the output of first process for the XML output url string. The
reason is: There is no XML output url string in the single buffer
process, it has an XML input string instead.
-------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<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
http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd" response="document"
mode="sync">
<ows:Identifier>vect_buffer</ows:Identifier>
<wps:DataInputs>
<wps:Input>
<ows:Identifier>in_size</ows:Identifier>
<ows:Title>Buffer Size [m]</ows:Title>
<wps:Data>
<wps:LiteralData>10</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier>in_geom</ows:Identifier>
<ows:Title>Input Geometry</ows:Title>
<wps:Reference
xlink:href="https://geodev2/wps/output/location_etrs.gml"
mimeType="text/xml" encoding="UTF-8"
schema="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd" method="GET" />
</wps:Input>
</wps:DataInputs>
<wps:ResponseForm>
<wps:ResponseDocument lineage="false" storeExecuteResponse="false"
status="false">
<wps:Output asReference="true" mimeType="application/gml-3.1.1"
encoding="utf-8">
<ows:Identifier>out_buff</ows:Identifier>
</wps:Output>
</wps:ResponseDocument>
</wps:ResponseForm>
</wps:Execute>
-------------------------------------------------
There are two cases:
1) Process in a chain -> I have to parse the result output string.
2) Process as single process -> standard usage, don't have to parse for
anything
Therefore I have to write code for both different cases, and I guess
it's wrong doing it that way. Probably wrong use of PyWPS or maybe wrong
request.
Cheers,
Gunnar
Am 17.12.2018 um 14:07 schrieb Carsten Ehbrecht:
> Hi Gunnar,
>
> I haven’t looked into process chaining, but this question was just
> raised recently:
>
> https://lists.osgeo.org/pipermail/pywps-dev/2018-December/001363.html
>
> Here is in addition a description of how a process chain can be done:
> http://geoprocessing.info/wpsdoc/Concepts#chaining
>
> I’m not sure how your code and your chain works (the gitlab link is not
> public). A comment from my side would be, that your “worker” process
> should not know that it is part of a process chain.
>
> Cheers,
> Carsten
>
>> On 12 Dec 2018, at 6:34 pm, gunnar.stroeer at yahoo.de
>> <mailto:gunnar.stroeer at yahoo.de> wrote:
>>
>> Hi Everybody,
>>
>> I currently develop some processes for a masterthesis using PyWPS v4
>> as implementation. Mostly it works fine for single processes, as well
>> with QGIS as client. However I stucked when it comes to chaining.
>>
>> Normally in single processes I use "in_file =
>> request.inputs['in_geom'][0].file" for read in some complex GML
>> geometry. In cases I wanna use the same process in a chain the code
>> above doesn't work anymore because the input is the same as the output
>> of the prior process. Therefore "in_file =
>> request.inputs['in_geom'][0].file" additionally gets all the XML code
>> of the prior response - and the process crashed.
>>
>> To handle this I use "import lxml" to parse the response XML looking
>> for the "xlink:href" attribute value with the referenced GML output
>> file of the first process. It works for the process in a chain, only.
>> Whether the process is used in a chain or not I could handle in the
>> process code, like a case distinction. Therefor I have to parse XML
>> all the time again and again... and it makes me feel that I use PyWPS
>> in a wrong way.
>>
>> I also could use "RawDataOutput", but this is obviously a bad solution
>> for large data inputs/outputs.
>>
>> Is there any method to handle the described problem without writing
>> too much code just to get know whether the process is used in a chain
>> or not? Or is there something completely wrong what I'm doing?
>>
>> https://gitlab.com/hadlaskard/integration-of-wps-in-local-sdi/blob/master/processes/proc_buffer.py
>>
>> Thanks,
>> Gunnar
>> _______________________________________________
>> pywps-dev mailing list
>> pywps-dev at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/pywps-dev
>
More information about the pywps-dev
mailing list