I am implementing gs:Nearest WPS process available in GeoServer using openlayers in OpenGeo Suite SDK. I am trying to implement this process as a openlayers plugin to hook into my custom web mapping application.Though there is many tutorial on how to implement JTS:Split and JTS:Buffer process there is no tutorial for any other wps process.This Process Require Feature collection or Vector Layer as a input.
Firebug Error Geometry.CLASS_NAME undefined i think this is because I am not able to collect all the features from the vector layer.
So How can I create a vector layer using OpenLayers.Layer.Vector????
var test = Ext.extend(gxp.plugins.Tool, {
ptype: 'myapp_test',
/** Initialization of the plugin */
init: function(target) {
test.superclass.init.apply(this, arguments);
// Create a WPSClient instance for use with the local GeoServer
this.wpsClient = new OpenLayers.WPSClient({
servers: {
local: '/geoserver/wps'
}
});
// Add action buttons when the viewer is ready
target.on('ready', function() {
// Get a reference to the vector layer from app.js
this.layer = target.getLayerRecordFromMap({
name: 'sketch',
source: 'ol'
}).getLayer();
//I am not getting Feature Collection or can not create Vector layer
this.layer2 = new OpenLayers.Layer.Vector("parks", {
strategies: [new OpenLayers.Strategy.Fixed()],
projection: new OpenLayers.Projection("EPSG:4326"),
protocol: new OpenLayers.Protocol.WFS({
version: "1.1.0",
url: "/geoserver/wfs",
featurePrefix: "medford",
featureType: "parks",
featureNS: "http://medford.opengeo.org"
})
});
// Some defaults
var actionDefaults = {
map: target.mapPanel.map,
enableToggle: true,
toggleGroup: this.ptype,
allowDepress: true
};
this.addActions([
// Action for splitting by drawing a line
new GeoExt.Action(Ext.apply({
text: 'TEST',
control: new OpenLayers.Control.DrawFeature(
this.layer, OpenLayers.Handler.Point, {
eventListeners: {
featureadded: this.nearf,
scope: this
}
})
}, actionDefaults))
]);
}, this);
},
/** Handler function for splitting geometries */
nearf: function(evt) {
var wkt = new OpenLayers.Format.WKT();
var pt=wkt.write(evt.feature);
//var f =JSON.parse(this.request.responseText);
//var myline = OpenLayers.Geometry.fromWKT('point(117 22)');
var g = new OpenLayers.Format.GeoJSON();
var f=g.read(this.request.responseText);
this.wpsClient.execute({
server: 'local',
process: 'gs:Nearest',
inputs: {features:this.layer2, point:pt},
success: this.addResult
});
},
/** Helper function for adding process results to the vector layer */
addResult: function(outputs) {
alert('Hello World');
}
});
Ext.preg(test.prototype.ptype, test);