[GIS] Execute OpenLayers WPS request using WPS Client

openlayers-2wpswpsclient

I am having trouble executing WPS processes with the OpenLayers WPS Client. I can execute the processes in Geoserver, however when I try to execute the process from my OpenLayers test app I keep getting errors in my browsers javascript console relating to JSON and xmlhttprequest.

My JS code for creating the client, geometry and executing the process is below – In the Javascript console I can see the WPS XML and it all looks well formed and good to go. Is the issue with my code trying to decipher the results? JS console image below.

enter image description here

    runoff = OpenLayers.Geometry.fromWKT('Point(148 -36)');

client = new OpenLayers.WPSClient({
    servers: {
        local: '/geoserver/wps'
    }
});

client.execute({
        server: 'local',
        process: 'gs:PointBuffers',
        inputs: {
            center: runoff,
            crs: 'EPSG:4326',
            distance: 1000
        },
        success: function(outputs) {
            for (var i=0, ii=outputs.result.length; i<ii; ++i) {
            alert(outputs.result[i].geometry.toString());
        }
        }
    });

Thanks Andrew

Best Answer

It looks to me that the problem is about the runoff variable (WKT) you're passing, because JS console is complaining about an unexpected token, probably you need to wrap your geometry with double quotes rather than single quotes as shown here:

Here you can find some more discussions about it: https://stackoverflow.com/questions/7936610/json-uncaught-syntaxerror-unexpected-token

Related Question