3

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
Unrecognised request type {service=WCS, Output=image/tiff,   Identifier=net.opengis.ows11.impl.CodeTypeImpl@1ad2fc (value: forestry:mde200_V4, codeSpace: null), DomainSubset=net.opengis.ows11.impl.BoundingBoxTypeImpl@111d0b5 (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.

  • 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?. You don't need to POST you can GET too. We have an OpenLayers WCS demo (using GeoServer as the WCS server) so certainly it is possible to to use OpenLayers for WCS interaction – nmtoken Oct 13 '16 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.