Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have generated the WPS request below using GeoServer's WPS Request Builder. I wish to append more parameters to this request (geometry selection), and then send it either using GET or POST from within my OpenLayers JavaScript code. I can't seem to get information on how this can be done. How can I append geometry selection parameter to the request, and how can I send the request using OpenLayers? Any assistance will highly appreciated.

<?xml version="1.0" encoding="UTF-8"?>
<wps:Execute version="1.0.0" service="WPS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opengis.net/wps/1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wcs="http://www.opengis.net/wcs/1.1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd">
  <ows:Identifier>gs:Aggregate</ows:Identifier>
  <wps:DataInputs>
    <wps:Input>
      <ows:Identifier>features</ows:Identifier>
      <wps:Reference mimeType="text/xml; subtype=wfs-collection/1.0" xlink:href="http://geoserver/wfs" method="POST">
        <wps:Body>
          <wfs:GetFeature service="WFS" version="1.0.0" outputFormat="GML2">
            <wfs:Query typeName="learning_workspace:pop_layer"/>
          </wfs:GetFeature>
        </wps:Body>
      </wps:Reference>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>aggregationAttribute</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>pop</wps:LiteralData>
      </wps:Data>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>function</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>Sum</wps:LiteralData>
      </wps:Data>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>singlePass</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>Yes</wps:LiteralData>
      </wps:Data>
    </wps:Input>
  </wps:DataInputs>
  <wps:ResponseForm>
    <wps:RawDataOutput mimeType="text/xml">
      <ows:Identifier>result</ows:Identifier>
    </wps:RawDataOutput>
  </wps:ResponseForm>
</wps:Execute>

My environment: GeoServer 2.1.3, OpenLayers 2.11, PostGIS 1.5.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Incorporate filters within the <wfs:Query><wfs:Query/> section in a <Filter></Filter>. The format of the filter is dependent on its type. More info on filters and examples is available here and here.

As for requests, I used OpenLayers' POST method to send request, as illustrated below:

var request = new OpenLayers.Request.POST({
        url: WPS_HOST,
        data: wpsRequestData,
        headers: {
            "Content-Type": "text/xml;charset=utf-8"
        },
        callback: function (response) {
            //read the response from GeoServer
            var gmlParser = new OpenLayers.Format.GML();
            var xmlSum = gmlParser.read(response.responseText);
            // TODO: More operations here
        },
        failure: function (response) {
            alert("Something went wrong in the request");
        }
    });

I hope this will be of help to someone.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.