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 GIS clients.

Modifying Feature Types using GeoNode

  1. Open your instance of GeoNode and log in as a superuser or a user having write rights on at least some Layers

    ../../../../_images/wfs-t_geonode1.png

    GeoNode Layers

  2. Select a Layer on which when you have right to edit data

    Warning

    You can edit only Layers which have been stored on a JDBC DataStore, like a DataBase. On GeoNode this is only possible if the DB datastore has been enabled from the settings.

    ../../../../_images/wfs-t_geonode2.png

    GeoNode Layer Select

  3. Click on Edit Layer and then, from the pop-up window, click on Edit data

    Warning

    The Edit data button will be available only for writable Layers (see above).

    ../../../../_images/wfs-t_geonode3.png

    GeoNode Edit Layer

  4. When the Map shows up along with your Layer, zoom in to a region you want to update or create.

    ../../../../_images/wfs-t_geonode4.png

    GeoNode Navigate Layer

  5. Identify the Edit button on the map top toolbar, click on the small arrow on the left in order to show up the context menu.

    ../../../../_images/wfs-t_geonode5.png

    GeoNode Edit Button

  6. Lets first Modify a FeatureType. Click on Modify.

    ../../../../_images/wfs-t_geonode6.png

    GeoNode Modify FeatureType

  7. Select a geometry and click over it. From the small info dialog window, select Edit

    ../../../../_images/wfs-t_geonode7.png

    GeoNode Editing a FeatureType

  8. Modify the geometry and/or the values of the field as you wish, and then click on Save.

    Hint

    If you want you can also completely delete the FeatureType by clicking on the Delete button from the same info dialog window.

    ../../../../_images/wfs-t_geonode8.png

    GeoNode Updating a FeatureType

  9. Verify that the changes have been stored on GeoServer.

    Replace the URL

    http://your_host/maps/new?layer=geonode:streams_1
    

    with

    http://your_host/geoserver/wms/reflect?layers=geonode:streams_1
    

    Warning

    Pay attention to the parameter: layer becomes layers, plural. If you want you can also add an output format parameter, like format=openlayers. In that case the complete URL becomes:

    http://your_host/geoserver/wms/reflect?layers=geonode:streams_1&format=openlayers

    ../../../../_images/wfs-t_geonode9.png

    GeoServer Displaying the Updated Layer

    Click over the FeautreType in order to display the updates values too.

  10. Repeat the FeatureType editing but this time click on Create (or simply click over the Edit button and not on its right small arrow).

    ../../../../_images/wfs-t_geonode10.png

    GeoNode Creating a FeatureType

    ../../../../_images/wfs-t_geonode11.png

    GeoServer Displaying the New Feature

Modifying Feature Types using a Desktop GIS client

  1. Open uDig GIS desktop client by going on the command line, changing directory in the training root if necessary, and running the udig command.

  2. Add GeoServer WFS to the catalog.

    ../../../../_images/wfs-t1.png

    Use the import button in the catalog tab, and select “data” in the first page of the wizard

    ../../../../_images/wfs-t2.png

    Selection of Web Feature Service data

    Insert into the URL text box the following address:

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

    The WFS URL

    Select the Mainrd from the list

    ../../../../_images/wfs-t4.png

    WFS Datasets shown into the uDig catalog

  3. Load the Mainrd Feature Type using drag-n-drop.

    ../../../../_images/wfs-t5.png

    Importing Mainrd into the map

  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.

    Warning

    In order to view the streets lines you have to specify the line style on the GetMap request.

    ../../../../_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 directory 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 …

    Note

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

    ../../../../_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