Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I develop a WebGIS application with GeoServer (2.1.1) and GeoExt (with the last version of OL). Data (polygons features) are stored in a postgis DB.

I've implemented editing tools that allow users to add/delete and modify features and their attributes directly on-line. It's work fine.

Now, I add a new control for splitting polygons in two (or more) parts. It's possible with the GeoServer's split polygon WPS process (gs:SplitPolygon).

I've followed the tuto here ( and implemented the tools on my appl. For information, this is the code I've used:

function handleSplitDraw(event) {
var splitter = event.feature;
var features = map.layers[2].features;
var candidates = OpenLayers.Array.filter(map.layers[2].features, function(feature) {
var hit = false;
    if (feature.geometry.intersects(splitter.geometry)) {
        hit = true;
    return hit;
var candidate;
for (var i=0, ii=candidates.length; i<ii; ++i) {
    candidate = candidates[i];
    if (candidate.geometry.intersects(splitter.geometry)) {
        executeSplit(candidate, splitter);
return false;}
var wktFormat = new OpenLayers.Format.WKT();
var wpsFormat = new OpenLayers.Format.WPSExecute();
function executeSplit(poly, line) {      
var doc = this.wpsFormat.write({
    identifier: "gs:SplitPolygon",
    dataInputs: [{
        identifier: "polygon",
        data: {
            complexData: {
                mimeType: "application/wkt",
                value: wktFormat.write(poly)
    }, {
        identifier: "line",
        data: {
            complexData: {
                mimeType: "application/wkt",
                value: wktFormat.write(line)
    responseForm: {
        rawDataOutput: {
            mimeType: "application/wkt",
            identifier: "result"
    url: "http://localhost:8080/geoserver/wps",
    data: doc,
    success: function(response) {
        handleSuccess(response, poly);
function handleSuccess(response, poly) {
var features =;
if (features && features.length > 0) {
} else {
   // map.layers[1].addFeatures([poly]);


var drawLine = new OpenLayers.Control.DrawFeature(map.layers[2], OpenLayers.Handler.Path);]);

WFS definition:

saveStrategy = new OpenLayers.Strategy.Save();
wfs_layer =     new OpenLayers.Layer.Vector(
        "Editable plot Layer", 
        styleMap: WFSStyle,
            eventListeners: {
                sketchcomplete: function(event) {
                        var proceed = true;
                        if (event.feature.geometry instanceof OpenLayers.Geometry.LineString) {
                            proceed = false;
                        return proceed;
                visibility: false,
                strategies: [new OpenLayers.Strategy.BBOX(), saveStrategy],
                    projection: new OpenLayers.Projection("EPSG:4326"),
                    protocol: new OpenLayers.Protocol.WFS({
                        version: "1.1.0",
                        url: "note_url",
                        featureNS :  "FNS",
                        featureType: "fname",
                        geometryName: "the_geom",
                        extractAttributes: true,
                        schema: "myschema"

The process work very fine. I can split polygons by line and splitted features are added on my map. In FB consol, I receive a correct response (Geom Collection).

Now, I would like to save back these changes (splitted polygons) to GeoServer. How can I do this? Can I use the WKT response and save the Geometry on a GeoJSON File (for example) for update the database? Do you have any idea of this step?

share|improve this question

Your Answer


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

Browse other questions tagged or ask your own question.