[Geoserver-users] Use of Geoserver raster processes within OpenLayers: WCS/WPS problem

Hello to everyone!
I've been working with some GeoServer processes using OpenLayers as client.
I've been successful in those which use WFS as input (like
gs:BufferFeatureCollection). My problem comes when I want to use processes
that need as input raster data (tiff). I know that OpenLayers is not a WCS
client, but you can send a POST request to the server to get back the
result, right?. Particularly I want to execute the
gs:RasterZontalStatistics, that needs a tiff and a WFS layer as input, and
returns some statistics (average, min, max, etc.) for the tiff inside the
geometries of the WFS Layer. This is the code I've used so far:

///*GEOPROCESS - Calculate the average/min/max values of the MDE raster
according to user drawing selection*/
function obtainElevationProcess(){
    var wpsFormat= new OpenLayers.Format.WPSExecute();

    var doc= wpsFormat.write({
        identifier: "gs:RasterZonalStatistics",
        dataInputs:[{
            identifier:'data',
            reference:{
                mimeType:"image/tiff",
                href: "http://geoserver/wcs",
                method: "POST",
                body: {
                    wcs: {
                        identifier:'forestry:mde200_V4',
                        version:"1.1.1",
                        domainSubset: {
                            boundingBox: {
                                projection:
'http://www.opengis.net/gml/srs/epsg.xml#3857’,
                                bounds: new
OpenLayers.Bounds(-200931.8344047, 4681799.186142525,32948.35238090271,
4948113.428142309)
                            }
                            },
                        output: {format:'image/tiff'},
                        }
                        }
                        }
                        },
            {
                identifier:"zones",
                reference:{
                            mimeType:"text/xml; subtype=wfs-collection/1.0",
                            href: "http://geoserver/wfs",
                            method: 'POST',
                            body:{
                                wfs:{
                                    version:'1.0.0',
                                    outputFormat: "GML2",
                                    featureNS:
"http://localhost:8080/thesis/forestry",
                                    featureType:'forestry:Lics',
                                }
                            }
                        }
            }],

            responseForm:{
                    rawDataOutput:{
                        mimeType:"text/xml;subtype=wfs-collection/1.0",
                        identifier:"statistics"
                }
            }

            });

    OpenLayers.Request.POST({
        url:"http://localhost:8080/geoserver/ows/",
        data:doc,
        headers: {
            "Content-Type": "text/xml;charset=utf-8"
        },
        success: function(response){
            alert(response.responseText);
            }
    });

}/

Once executed, OpenLayers returns this message (selection):

/Process execution ecacba6c-a676-46b5-9010-bd4a2bb35632 failed
Failed to retrieve value for input data
Unrecognized request type {service=WCS, Output=image/tiff,
Identifier=net.opengis.ows11.impl.CodeTypeImpl@anonymised.com (value:
forestry:mde200_V4, codeSpace: null),
DomainSubset=net.opengis.ows11.impl.BoundingBoxTypeImpl@anonymised.com
(lowerCorner: [-200931.8344047, 4681799.1861425], upperCorner:
[32948.352380903, 4948113.4281423], crs:
http://www.opengis.net/gml/srs/epsg.xml#3857, dimensions: null),
version=1.1.1}</ows:ExceptionText></ows:Exception></ows:ExceptionReport></wps:ProcessFailed></wps:Status></wps:ExecuteResponse>/

Does anyone an idea about how this can be done (if possible)? My environment
is: Geoserver 2.3.5 / OpenLayers 2.13 / localhost on Apache.

Help will be highly appreciated.

Thanks.

Constan.

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Use-of-Geoserver-raster-processes-within-OpenLayers-WCS-WPS-problem-tp5092361.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

Just a guess, try to use http://localhost:8080/geoserver/wps/" instead of http://localhost:8080/geoserver/ows/".

···

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for
more information.

Ing. Alessio Fabiani
@alfa7691
Founder/Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 331 6233686

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


On Tue, Dec 3, 2013 at 12:23 PM, constan.amurrio <constan.amurrio@anonymised.com> wrote:

Hello to everyone!
I’ve been working with some GeoServer processes using OpenLayers as client.
I’ve been successful in those which use WFS as input (like
gs:BufferFeatureCollection). My problem comes when I want to use processes
that need as input raster data (tiff). I know that OpenLayers is not a WCS
client, but you can send a POST request to the server to get back the
result, right?. Particularly I want to execute the
gs:RasterZontalStatistics, that needs a tiff and a WFS layer as input, and
returns some statistics (average, min, max, etc.) for the tiff inside the
geometries of the WFS Layer. This is the code I’ve used so far:

///GEOPROCESS - Calculate the average/min/max values of the MDE raster
according to user drawing selection
/
function obtainElevationProcess(){
var wpsFormat= new OpenLayers.Format.WPSExecute();

var doc= wpsFormat.write({
identifier: “gs:RasterZonalStatistics”,
dataInputs:[{
identifier:‘data’,
reference:{
mimeType:“image/tiff”,
href: “http://geoserver/wcs”,
method: “POST”,
body: {
wcs: {
identifier:‘forestry:mde200_V4’,
version:“1.1.1”,
domainSubset: {
boundingBox: {
projection:
http://www.opengis.net/gml/srs/epsg.xml#3857’,
bounds: new
OpenLayers.Bounds(-200931.8344047, 4681799.186142525,32948.35238090271,
4948113.428142309)
}
},
output: {format:‘image/tiff’},
}
}
}
},
{
identifier:“zones”,
reference:{
mimeType:“text/xml; subtype=wfs-collection/1.0”,
href: “http://geoserver/wfs”,
method: ‘POST’,
body:{
wfs:{
version:‘1.0.0’,
outputFormat: “GML2”,
featureNS:
http://localhost:8080/thesis/forestry”,
featureType:‘forestry:Lics’,
}
}
}
}],

responseForm:{
rawDataOutput:{
mimeType:“text/xml;subtype=wfs-collection/1.0”,
identifier:“statistics”
}
}

});

OpenLayers.Request.POST({
url:“http://localhost:8080/geoserver/ows/”,
data:doc,
headers: {
“Content-Type”: “text/xml;charset=utf-8”
},
success: function(response){
alert(response.responseText);
}
});

}/

Once executed, OpenLayers returns this message (selection):

/Process execution ecacba6c-a676-46b5-9010-bd4a2bb35632 failed
Failed to retrieve value for input data
Unrecognized request type {service=WCS, Output=image/tiff,
Identifier=net.opengis.ows11.impl.CodeTypeImpl@anonymised.com (value:
forestry:mde200_V4, codeSpace: null),
DomainSubset=net.opengis.ows11.impl.BoundingBoxTypeImpl@anonymised.com
(lowerCorner: [-200931.8344047, 4681799.1861425], upperCorner:
[32948.352380903, 4948113.4281423], crs:
http://www.opengis.net/gml/srs/epsg.xml#3857, dimensions: null),
version=1.1.1}</ows:ExceptionText></ows:Exception></ows:ExceptionReport></wps:ProcessFailed></wps:Status></wps:ExecuteResponse>/

Does anyone an idea about how this can be done (if possible)? My environment
is: Geoserver 2.3.5 / OpenLayers 2.13 / localhost on Apache.

Help will be highly appreciated.

Thanks.

Constan.


View this message in context: http://osgeo-org.1560.x6.nabble.com/Use-of-Geoserver-raster-processes-within-OpenLayers-WCS-WPS-problem-tp5092361.html
Sent from the GeoServer - User mailing list archive at Nabble.com.


Rapidly troubleshoot problems before they affect your business. Most IT
organizations don’t have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk


Geoserver-users mailing list
Geoserver-users@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Thank you very much Alessio. Unfortunately, it doesn't work. It's quite
strange. With WFS it works perfectly, but something is wrong with WCS. I've
checked the resulting POST xml file in FireBug when I call the process and
it's exactly the same the one Geoserver generates in the WPS Request
Builder.

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Use-of-Geoserver-raster-processes-within-OpenLayers-WCS-WPS-problem-tp5092361p5092369.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

Taking a better look at the error message however, the issue seems related to the input data. It looks like the WPS is not able to encode a correct request to the WCS in order to retrieve the raster.

Have you tried to copy the XML generated by OpenLayers and send it to the WPS directly using a tool like CURL or Poster?

···

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for
more information.

Ing. Alessio Fabiani
@alfa7691
Founder/Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 331 6233686

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


On Tue, Dec 3, 2013 at 12:50 PM, constan.amurrio <constan.amurrio@anonymised.com> wrote:

Thank you very much Alessio. Unfortunately, it doesn’t work. It’s quite
strange. With WFS it works perfectly, but something is wrong with WCS. I’ve
checked the resulting POST xml file in FireBug when I call the process and
it’s exactly the same the one Geoserver generates in the WPS Request
Builder.


View this message in context: http://osgeo-org.1560.x6.nabble.com/Use-of-Geoserver-raster-processes-within-OpenLayers-WCS-WPS-problem-tp5092361p5092369.html

Sent from the GeoServer - User mailing list archive at Nabble.com.


Rapidly troubleshoot problems before they affect your business. Most IT
organizations don’t have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk


Geoserver-users mailing list
Geoserver-users@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Thank you for your reply.

So I've been doing some tests with Poster. The XML file coming from Firebug
does not execute on it neither, the one of Geoserver does. I've been
comparing both files. Doing a couple of changes in the one from Firebug
makes it work: adding xmlns:wcs="http;//www.opengis.net/wcs/1.1.1" and doing
a change also in the getCoverage line. The problem is that I still don't
know which changes I might to do in the OpenLayers code to get that
"working" xml. If I'm able to obtain a working xml, I will post it back.

Again, thanks for the ideas.

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Use-of-Geoserver-raster-processes-within-OpenLayers-WCS-WPS-problem-tp5092361p5092466.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

SOLVED! The problem was not in my Javascript code. It was in the
interpretation of the OpenLayers library file itself. The WPSExecute
stablishes the default namespaces. In the case of WCS, in my library version
(2.13), the namespace is wcs:"http://www.opengis.net/wcs&quot;, which should be
changed to wcs:"http://www.opengis.net/wcs/1.1.1&quot; in order to make it work.
Once you do that change, the process is executed. Thank you Alessio again
for your ideas.

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Use-of-Geoserver-raster-processes-within-OpenLayers-WCS-WPS-problem-tp5092361p5092566.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

Cool.

Thanks for your feedbacks.

···

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for
more information.

Ing. Alessio Fabiani
@alfa7691
Founder/Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 331 6233686

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


On Wed, Dec 4, 2013 at 8:40 AM, constan.amurrio <constan.amurrio@anonymised.com> wrote:

SOLVED! The problem was not in my Javascript code. It was in the
interpretation of the OpenLayers library file itself. The WPSExecute
stablishes the default namespaces. In the case of WCS, in my library version
(2.13), the namespace is wcs:“http://www.opengis.net/wcs”, which should be
changed to wcs:“http://www.opengis.net/wcs/1.1.1” in order to make it work.
Once you do that change, the process is executed. Thank you Alessio again
for your ideas.


View this message in context: http://osgeo-org.1560.x6.nabble.com/Use-of-Geoserver-raster-processes-within-OpenLayers-WCS-WPS-problem-tp5092361p5092566.html
Sent from the GeoServer - User mailing list archive at Nabble.com.


Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk


Geoserver-users mailing list
Geoserver-users@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users