FME Version
Files
-
- 10 MB
- Download
Introduction
INSPIRE is a European Union directive that aims to create an infrastructure of EU spatial data to enable policy making across boundaries and improve public access to spatial information. Open standards such as the Open Geospatial Consortium Web Feature Service (OGC WFS) are used to facilitate the exchange of INSPIRE data. For more information, please visit the INSPIRE website.
Web services are a great way to share INSPIRE data and this is made possible with FME. In FME, OGC web services are hosted by publishing a ‘service broker’ workspace to FME Server registered under the Data Streaming Service.
Note: this requires FME Server 2014 or later to support the INSPIRE GML Writer.
FME workspace as web service broker for WFS
Safe’s INSPIRE WFS Live Demo
Safe Software has deployed this WFS demo live on FME Cloud. Users can view the service using the WFS Reader in FME Data Inspector or from any WFS client.
https://demos-safe-software.fmecloud.com/fmedatastreaming/INSPIRE/INSPIRE_WFS.fmw
Step-by-step Instructions
When published locally, the service URL is:
http://localhost/fmedatastreaming/INSPIRE/INSPIRE_WFS.fmw
This tutorial contains a basic example of a WFS with 2 feature types, spatial extents queries and an XML filter operation, though these can be extended by following the approach laid out in this workspace.
Instead of a workspace that just handles data conversion, the ‘service broker’ workspace handles the web message traffic – accepting requests and generating responses according to the chosen service standard.
The INSPIRE_WFS workspace accepts GET (URL) or POST (XML) requests, commonly known as: GetCapabilities, DescribeFeatureType and GetFeature. Two writers are used depending on which request is being made. For the GetCapabilities and DescribeFeatureType XML document responses, the Text File (TEXTLINE) writer is used. For GetFeature responses, the INSPIRE GML writer is used.
In general, this workspace checks for character encoding. If URLs / requests are percent encoded (which is the case for those coming from Data Inspector) then they will be decoded to ASCII.
Workflow
There are 3 steps to determine which request type is being made:
- Check input to determine whether the request is GET or POST using the XMLValidator transformer
- Extract parameters from the request
- Determine request type (GetCapabilities, DescribeFeatureType, or GetFeature)
GetCapabilities
- Generate the XML response from the XML template
- Output XML to the outText.xml file
Note: the GetCapabilities document does not usually change so it could be a static file. The XMLTemplater process was included to demonstrate how a response message could be composed.
DescribeFeatureType
- Read the appropriate XSD file based on the user parameter Type Name selection
- Output XSD to the outText.xml file
GetFeature
- Parse filter XML to extract filter fields for WHERE clause
- Parse bbox parameters to generate bbox geometry
- Apply extents bbox and WHERE filter to FeatureReader
- Apply schema transformation and generate output GML file
Other Notes
- Error handling techniques and adding another theme to the workspace are covered in the Docs section of the demo workspace
- The workspace can only handle one feature type per request
- The workspace is only set up to handle a POST GetFeature request for NamedPlace
- The workspace can handle invalid field values, but an invalid column value causes the workspace to hang due to a bug in FDO
- The workspace is set up to support both WFS version 1.1 and 2.0 but these are dependent on a type name and type names parameter, respectively.
FME Server
Workspace Publication
- Locally test each WFS request type through Prompt and Run translation (GetCapabilities, DescribeFeatureType, and GetFeature) to ensure source paths and configuration settings are valid. Check the FeatureReaders in the CadastralParcel and NamedPlace Custom transformers are pointing to the INSPIREdb.sdf file.
- Set the workspace published and private parameters to desired default values (default theme, max features etc), remove any filters, other than max features and set Request default parameter to GetCapabilities.
- Set desired GML writer default parameters such as axis order, SRS etc.
- Publish the workspace to FME Server to a new repository called INSPIRE, upload all required resources (including the INSPIRE database and INSPIRE XSDs used in DescribeFeatureType request) and enable both the Data Streaming and Job Submitter services. Edit the data streaming properties to ensure the Text File reader and the Text File / INSPIRE writers are all included.
Upload all required resources
Ensure that the reader and writers are registered with the Data Streaming service
- Test the requests and filter types with a WFS client, such as FME Data Inspector. Instructions on how to do this can be found under the ‘Accessing the WFS through a URL’ section of this tutorial.
In FME Server if there is a GET request the input parameters captured by the user selections in the workspace published parameters are implemented in the request URL and the text file input is not used.
If you send a POST request it automatically overrides the input of this workspace with the POST body (The POST body is the complete WFS request, for example the WFS GetFeature XML with any filter query embedded).
Testing the Service
- In FME Server select the INSPIRE_WFS.fmw file under the ‘Last Published Workspaces’ board to take you to the Run Workspace page.
- Set the Service to Data Streaming and then set the desired Published Parameters.
- Click Run to start the Workspace.
Published parameters accessible through Data Streaming on FME Server
Direct URL
- In FME Server, navigate to the Run Workspace page and select the Inspire_WFS workspace.
- Under the Advanced section click on the Direct URL link to run the workspace in a new browser.
Example URL for accessing the WFS
View in Data Inspector
- Open a new Dataset and set the Reader Format to WFS (Web Feature Service)
- For the Reader Dataset, enter the Direct URL link up until the question mark, this follows the pattern: http://<host>:<port>/fmedatastreaming/<repositoryname>/INSPIRE_WFS.fmw
- Open the Parameters and select the WFS Version. Under the Constraints section choose the Feature Type layer you wish to display and set the Max Features.
If you would like to add a Filter you can add an XML Filter Expression and/or a Search Envelope. You can find some examples of this below:
Results
Example 1: Cadastral Parcels
Use the following XML filter expression in the Reader Constraints:
<Filter><PropertyIsEqualTo><PropertyName>inspireId.Identifier.localId</PropertyName><Literal>136000AZ0063</Literal></PropertyIsEqualTo></Filter>
Response in WFS client:
Filter Cadastral Parcels by ID. Map tiles by Stamen Design, under CC-BY-3.0. Data by OpenStreetMap, under CC-BY-SA.
Example 2: Named Place
Use the following XML filter expression:
<Filter><PropertyIsEqualTo><PropertyName>GeographicalName_language</PropertyName><Literal>Italian</Literal></PropertyIsEqualTo></Filter>
Result in WFS Client:
Filter NamedPlace data by Language = Italian. Map tiles by Stamen Design, under CC-BY-3.0. Data by OpenStreetMap, under CC-BY-SA.
Any web service, such as WCS, WPS, WMTS or SOS could also be supported by this FME service broker workspace approach. All that is required is to understand the web service protocol client / server requirements and configure accordingly. New service types would require some setup / configuration to implement the message handling compatible with that service standard, but this approach gives the user control to configure, customize, update and extend their web services how they want.
Troubleshooting
- Note that while WFS is an OGC standard, there are variations in different implementations. For example, GeoServer uses TypeNames and FME client makes a request using TypeName as the parameter query for v1.1 but TypeNames for v2.0.
- Try to make a simple request, such as setting max features to a low number to see whether the WFS is responding. Then, if the WFS is responding, examine the syntax of the desired request to check for errors.
- If you don't see any output displayed in FME Data Inspector, copy or click on the URL's embedded in the log to open them in your web browser. This may display useful diagnostic information such as 'server not found', 'access denied' or 'request did not return any features' etc.
- Please submit a support request for assistance.
Data Attribution
The data used here originates from data made available by the INSPIRE and contains information and reads from a staging PostGIS database licensed under the Creative Commons Attribution (cc-by) 4.0
Comments
0 comments
Please sign in to leave a comment.