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.

Warning

The layer Mainrd is required for this exercise. Be sure to have completed the Adding a Shapefile section.

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

Refer to the Layer level security section for further information

Warning

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

  1. Open your preferred GIS desktop client. In our case QGIS.

  2. Add GeoServer WFS to the catalog. Use the import button in the catalog tab (1), and select “data” (2) in the first page of the wizard

    ../_images/wfs-t1.png

    Select the Web Feature Service Data Source

    ../_images/wfs-t2.png

    Insert the following address into the URL text box and press finish:

    http://localhost:8083/geoserver/wfs?request=GetCapabilities&service=WFS
    
    ../_images/wfs-t3.png

    Right click on the Mainrd layer from the list and select Add to current map

    ../_images/wfs-t4.png
  3. The Mainrd layer is now visible in the uDig map

    ../_images/wfs-t5.png
  4. Perform a zoom operation on the upper-right part of the layer.

    ../_images/wfs-t6.png

    Zooming in ...

    ../_images/wfs-t7.png

    Zooming in ...

  5. By using the Select and Edit Geometry tool try to move/add/remove some vertex to the small line at the center of the screen.

    ../_images/wfs-t8.png

    Playing with the Geometry

  6. Once finished use the Commit tool to persist the changes on GeoServer.

    ../_images/wfs-t9.png

    Committing changes throught the WFS-T protocol

  7. Use GeoServer Layer Preview to view the changes on the Mainrd layer.

    ../_images/wfs-t10.png

    Showing the changes to the Mainrd Feature Type

  8. On uDig look the Feature attribute values using the Info tool.

    ../_images/wfs-t11.png

    Retrieving Feature Type info from uDig interface

  9. Now 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 Monarch Rd to Monarch Road

    <wfs:Transaction xmlns:topp="http://www.openplans.org/topp" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0">
      <wfs:Update typeName="geosolutions:Mainrd">
            <wfs:Property>
              <wfs:Name>LABEL_NAME</wfs:Name>
              <wfs:Value>Monarch Road</wfs:Value>
            </wfs:Property>
            <ogc:Filter>
              <ogc:PropertyIsEqualTo>
                  <ogc:PropertyName>LABEL_NAME</ogc:PropertyName>
                  <ogc:Literal>Monarch Rd</ogc:Literal>
              </ogc:PropertyIsEqualTo>
            </ogc:Filter>
      </wfs:Update>
    </wfs:Transaction>
    
  10. 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"
    
  11. The response should be a TransactionResponse XML document containing a wfs:SUCCESS element

  12. Ask the info again using the uDig Info tool. In some cases you have also to refresh the catalog to see the data changes in uDig.

    ../_images/wfs-t13.png

    Obtaining the updated Feature Type info from uDig interface

  13. Finally, obtain the Feature type info using the GetFeatureInfo operation issued directly by the Map Preview.

    ../_images/wfs-t14.png

    Obtaining the updated Feature Type info from OpenLayers MapPreview GetFeatureInfo

Note

In order to issue a GetFeatureInfo request from the OpenLayers MapPreview tool, just left-click over the line.