Modifying Feature Types

GeoServer provides a fully Transactional Web Feature Service (WFS-T) which enables users to insert / delete / modify the available FeatureTypes. This section shows a few of the GeoServer WFS-T capabilities and interactions with desktop GIS clients.

Exploring the layer being modified

Go the the layer preview of GeoServer, and search for tiger:tiger_roads. Open the OpenLayers preview, and zoom into the top-right area, in order to make “Seaman Ave” visible:

../_images/roads_preview1.png
../_images/roads_preview2.png
../_images/roads_preview3.png

Previewing the editing area

Editing with QGIS

Warning

This section assumes all the layers are open for anyone to modify.

Open the Security -> Data page

Ensure the Rule path *.*.w is set to be available to any role (“Grant access to any role” checkbox).

Refer to the Layer level security section for further information

Warning

For this exercise, we will use QGIS GIS desktop client. In general, all GIS desktop clients provides same kind of features allowing to reproduce the exercise.

  1. Run qgis-bin.exe, available under the QGIS 3.26.0bin folder.

  2. (1) Right click and New WFS Connection,”Name” (2) , “URL” (3) , select version 1.0 (important!), and click the “OK” button (4)

    ../_images/wfs-t1v2.png

    Insert the following address into the URL text box

  3. Right click on the Manhattan (NY) roads layer from the list and select Add Layer to Project. The layer is now visible in the QGIS map

    ../_images/wfs-t5v2.png
  4. Perform a zoom operation on the upper-right part of the layer. Use the identify tool to make sure you are going to edit “Seaman Ave”.

    ../_images/wfs-t6v2.png
  5. By using the Vertex Tool (All Layers) tool try to move the middle vertex (click on the red X, move it, click again to release).

    ../_images/wfs-t8v2_step1.png
    ../_images/wfs-t8v2_step2.png
    ../_images/wfs-t8v2_step3.png
    ../_images/wfs-t8v2_step4.png

    Playing with the Geometry

  6. Once finished use the Save Layer Edits tool to persist the changes on GeoServer.

    ../_images/wfs-t9v2.png

    Committing changes through the WFS-T protocol

  7. Go back to the layer preview, move the map, and the map should update with the new edit.

    ../_images/wfs-t10.png

    Showing the changes to the topp:tiger_roads Feature Type

Mass updating features with a WFS-T POST request

The map in the preview contains a number of segments called “Seaman Ave” (zoom in to confirm). Let’s assume the task is to update all of them with a new label, “Seaman Avenue”. One could identify all of the in QGIS, and update each one with a new label.

A possible alternative is to send a direct WFS-T request to GeoSever, that updates all of them based on a search criteria.

  1. Open / create the request.xml file in the training root dir and set in the following request, which will be used to issue an update Feature type request to the WFS-T updating all roads labelled as Seaman Ave to Seaman Avenue

    <wfs:Transaction xmlns:tiger="http://www.census.gov" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0">
      <wfs:Update typeName="tiger:tiger_roads">
            <wfs:Property>
              <wfs:Name>NAME</wfs:Name>
              <wfs:Value>Seaman Avenue</wfs:Value>
            </wfs:Property>
            <ogc:Filter>
              <ogc:PropertyIsEqualTo>
                  <ogc:PropertyName>NAME</ogc:PropertyName>
                  <ogc:Literal>Seaman Ave</ogc:Literal>
              </ogc:PropertyIsEqualTo>
            </ogc:Filter>
      </wfs:Update>
    </wfs:Transaction>
    
  2. Issue the WFS-T request towards GeoServer using curl on the command line:

    curl -XPOST -d @request.xml -H "Content-type: application/xml" "http://localhost:8083/geoserver/ows"
    
  3. The response should be a TransactionResponse XML document containing a wfs:SUCCESS element

  4. Move the map in the layer preview, the road labels show now state “Seaman Avenue”

    ../_images/wfs-t11.png

    Showing the changes to the topp:tiger_roads Feature Type