Skip to content

Feature Versioning for WFS 2.0.0

dstenger edited this page Jun 9, 2016 · 2 revisions

New experimental feature: Feature Versioning for WFS 2.0.0 (not part of deegree, yet)

Today, we present you a new feature of deegree: Feature Versioning for WFS 2.0.0 was implemented in branch "deegree-3.4-featureVersioning" [1]. The feature is currently in an experimental phase and not part of deegree, yet. Furthermore it is limited to SQLFeatureStores with PostgreSQL backend.

You are welcome to test the feature and provide us some feedback about the feature as well as the implementation.

Installation and activation of Feature Versioning

To set up the database prepared for versioning it is required to execute the following steps:

psql -h localhost -U postgres postgres -c "CREATE DATABASE transactiontest OWNER deegree"

psql -h localhost -U postgres transactiontest -c "CREATE EXTENSION postgis"
psql -h localhost -U postgres transactiontest -c "CREATE USER version"

psql -h localhost -U deegree transactiontest -f ./createDatabaseTransactionTest.sql
psql -h localhost -U deegree transactiontest -f ./pgversion_createFunctions_erweitert.sql
psql -h localhost -U deegree transactiontest -c "SELECT * FROM versions.pgvsinit('public.transactiontest')"
psql -h localhost -U deegree transactiontest -f ./insertTransactionTestData.sql

Use the attached scripts [2] to setup the test database, insert testdata and the extension pgVersion for PostgreSQL. The attached scripts to setup pgVersion bases on the extension from Horst Duester [3].

In the SQLFeatureStore VersionMapping must be configured as follows:

  <FeatureTypeMapping name="app:TransactionTest" table="transactiontest_version">
    <FIDMapping prefix="transactiontest_">
      <Column name="id" />
      <UUIDGenerator/>
    </FIDMapping>
    <VersionMapping>
      <VersionMetadataTable  name="versions.public_transactiontest_version_log" />
      <VersionColumn name="version_log_id" />
      <ActionColumn name="action" />
      <TimestampColumn name="systime" />
    </VersionMapping>
    <Primitive path="id" mapping="id" />
    <Primitive path="cdd" mapping="cdd" />
    <Primitive path="timestamp" mapping="timestamp" />
    <Primitive path="name" mapping="name" />
    <Geometry path="geom" mapping="geom" />
  </FeatureTypeMapping>

Furthermore it is required to reference the View created by pgVersion as table in FeatureTypeMapping instead of the original table (transactiontest_version instead of transactiontest).

In the WFS Service configuration FeatureVersioning must be enabled by

 <EnableFeatureVersioning>true</EnableFeatureVersioning>

Example requests which can be used for testing

Insert:

Version 1 of the feature is created.

<?xml version="1.0" encoding="UTF-8"?>
<wfs:Transaction version="2.0.0" service="WFS"
  xmlns:wfs="http://www.opengis.net/wfs/2.0">
  <wfs:Insert xmlns:gml="http://www.opengis.net/gml/3.2">
   <app:TransactionTest xmlns:app="http://www.deegree.org/app" gml:id="transactiontest_2">
      <app:id>2</app:id>
      <app:cdd>289.0</app:cdd>
      <app:timestamp>2009-01-01T00:00:00</app:timestamp>
      <app:name>FAIRFIELD</app:name>
      <app:geom>
        <!--Inlined geometry 'transactiontest_422701_APP_GEOM'-->
        <gml:Point gml:id="transactiontest_2_APP_GEOM" srsName="urn:ogc:def:crs:EPSG::4326">
          <gml:pos>40.270300 -112.094000</gml:pos>
        </gml:Point>
      </app:geom>
    </app:TransactionTest>
  </wfs:Insert>
</wfs:Transaction>

Update:

Version 2 of the feature is created.

<?xml version="1.0" encoding="UTF-8"?>
<wfs:Transaction version="2.0.0" service="WFS" xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:gml="http://www.opengis.net/gml/3.2"
  xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:app="http://www.deegree.org/app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd">
  <wfs:Update typeName="app:TransactionTest">
    <wfs:Property>
      <wfs:ValueReference action="replace">app:cdd</wfs:ValueReference>
      <wfs:Value>12</wfs:Value>
    </wfs:Property>
    <fes:Filter>
      <fes:ResourceId rid="transactiontest_2" />
    </fes:Filter>
  </wfs:Update>
</wfs:Transaction>

Delete:

Version 3 of the feature is created.

<?xml version="1.0" encoding="UTF-8"?>
<wfs:Transaction version="2.0.0" service="WFS" xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:gml="http://www.opengis.net/gml/3.2"
  xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:app="http://www.deegree.org/app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd">
  <wfs:Delete typeName="app:TransactionTest">
    <fes:Filter>
      <fes:ResourceId rid="transactiontest_2" />
    </fes:Filter>
  </wfs:Delete>
</wfs:Transaction>

GetFeature-with-version:

Version 1 of the feature is returned.

<GetFeature xmlns="http://www.opengis.net/wfs/2.0"
xmlns:app="http://www.deegree.org/app"
xmlns:fes="http://www.opengis.net/fes/2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.0.0" service="WFS" count="100"
xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd">
  <Query typeNames="app:TransactionTest">
   <fes:Filter>
    <fes:ResourceId rid="transactiontest_2" version="1"/>
   </fes:Filter>
  </Query>
</GetFeature>

All versions of the feature are returned.

<GetFeature xmlns="http://www.opengis.net/wfs/2.0"
xmlns:app="http://www.deegree.org/app"
xmlns:fes="http://www.opengis.net/fes/2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.0.0" service="WFS" count="100"
xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd">
  <Query typeNames="app:TransactionTest">
   <fes:Filter>
    <fes:ResourceId rid="transactiontest_2" version="ALL"/>
   </fes:Filter>
  </Query>
</GetFeature>

GetFeature-with-time-span:

All versions of the feature which have been created in the passed time span are returned.

<GetFeature xmlns="http://www.opengis.net/wfs/2.0"
xmlns:app="http://www.deegree.org/app"
xmlns:fes="http://www.opengis.net/fes/2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.0.0" service="WFS" count="100"
xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd">
  <Query typeNames="app:TransactionTest">
   <fes:Filter>
    <fes:ResourceId rid="transactiontest_2" startDate="2016-06-07T16:17:00Z" endDate="2016-12-24T10:01:00Z" />
   </fes:Filter>
  </Query>
</GetFeature>

[1] https://github.com/lat-lon/deegree3/tree/deegree-3.4-featureVersioning

[2] https://gist.github.com/dstenger/1b86441ee8a6f2e85dbf3733da8d1f94

[3] https://github.com/sourcepole/pgversion

Clone this wiki locally