FME Version
Files
Introduction
INSPIRE, or Infrastructure for Spatial Information in Europe is a European Union directive that aims to create a spatial data infrastructure for EU data, to enable policy making across boundaries and improve public access to spatial information. Open standards such as OGC web services are used to facilitate the exchange of INSPIRE data. For more information, please visit the INSPIRE website.
With FME, it is possible to build a variety of web services that incorporate INSPIRE data. Building a new web service requires 3 main components:
- A GetCapabilities XML document that tells the client what services/data layers are available.
- An FME workspace to provides data to the client via FME Server’s Data Streaming Service.
- An FME workspace that will act as the service broker for the web service. It needs to accept service requests and transmit responses according to the service specification requirements.
The service broker approach can be applied to other web services, including WFS, WCS, WPS, WMTS, and SOS if you also have an understanding of the web service protocol client / server specifications and the workspace(s) configuration requirement that is necessary to implement other web services.
The approach outlined in this demo, as well as in the INSPIRE WFS demo, provide the user with a starting point to configure, customize, update and extend their web services. This approach can also be applied to other types of REST based web services beyond OGC or INSPIRE applications.
Safe’s INSPIRE WMS Live Demo
The demo outlined in this article has been deployed on FME Cloud so is available to view using any WMS Client, including the FME Data Inspector.
https://demos-safe-software.fmecloud.com/fmedatastreaming/INSPIRE/INSPIRE_WMS_GetCapabilities.fmw
Step-by-step Instructions
When using FME to create a WMS, two workspaces are required, this is because FME only allows one type of MIME encoding per workspace and for WMS the message handling (GetCapabilities) and data streaming (GetMap) responses are application/xml and image/png respectively. As these two responses cannot coexist in a single workspace, two workspaces are used.
Note: The key to getting this to work is to edit the GetCapabilities document so that each service request calls the appropriate workspace. A key advantage of this approach is that the web service components are defined in a more modular fashion, one workspace per request type, making it easier to understand, diagnose problems, and maintain.
Writer Mime type in the Navigator window
GetCapabilities Workflow
The INSPIRE_WMS_GetCapabilities workspace listens for GetCapabilities requests and transmits the appropriate response in the form of application/XML documents.
Process Get Request
- Using the ParameterFetcher transformer to obtain the URL parameter values.
Note: URL parameters are automatically mapped to workspace parameters of the same name.
- A TestFilter checks the Request and Service types and directs the data flow to the appropriate response.
Response: Generate GetCapabilities
- If the Request is like GetCapabilities then an Attribute File Reader fetches the corresponding xml document.
- This content is used to formulate the GetCapabilities response message. It is written to a Text File which can be streamed back to the client.
Response: Error Handling
- Addresses any case where the service, request or version parameters do not match what is expected or supported.
- Logs invalid requests for both GetMap and unexpected inputs.
GetCapabilities workspace
GetMap Workflow
The INSPIRE_WMS_GetMap workspace parses GetMap requests and transmits the actual WMS data responses in the form of image/png data.
Process Get Request
- Read in the request URL using a Text File Reader.
Note: the text line input is only used to generate a record to drive the translation. All the relevant request information is read in via parameters so we could just as easily parse the input URL if we wanted.
- Process GET request using URL parameters and filter by Request type.
Response: Generate GetMap
- Use Layer parameter to determine which features need to be requested
- Custom transformers for NamedPlace and CadastralParcel read in these features..
Note: Currently, only one layer per request is supported. Multiple layers could be supported, but would require some list processing related to multiple layer selection.
- The output features are drawn using the Mapnik Rasterizer transformer, a styling tool that allows the user to customize many rendering rules.
- Any constraint parameters are read in before the GetMap image is streamed back to the client using a PNG Writer to set up the MIME type.
Note: Under the Writer Format Parameters, World file and TAB file generation are set to ‘No’, as Data Streaming workspaces can only produce one file, or the result will be zipped.
Response: Error Handling
- A Logger is set up to capture any unexpected Get requests.
GetMap Workspace
FME Server
Workspace Publication
1. Unless you are running FME Server locally, open the GetCapablities.xml:
- Change all occurrences of localhost to the desired FME Server hostname and port number.
- Make sure the workspace and repository names match those you will use during publishing (If in doubt refer to this file in your initial publication).
Sample of GetCapabilities.xml
2. Open both workspaces and test run them locally - it’s always a good idea to test the workspace is running as expected before publishing to FME Server. In the GetMap workspace also check the FeatureReaders in the CadastralParcel and NamedPlace Custom transformers are pointing to the INSPIREdb.sdf file.
3. Publish both the workspaces to FME Server:
- In the ‘Publish workspace’ window, save the workspaces as INSPIRE_WMS_GetCapabilties.fmw and INSPIRE_WMS_GetMap.fmw in the INSPIRE repository, respectively (you may need to create this New Repository).
Add a new repository called INSPIRE to FME Server
- Ensure the ‘Upload data files’ box is checked and that this lists both GETrequest.txt and GetCapabilities.xml for the GetCapabilities workspace and the GETrequest.txt / INSPIREdb.sdf are selected for GetMap.
- On the ‘Register Services’ page select the Data Streaming service. Edit the Service Properties ‘Include Writer in Stream’ parameter so that “responseMessage [TEXTLINE]” / "INSPIRE_WMS_Demo [PNGRASTER]" are selected for the relevant workspace.
Testing the Service
- Open the FME Server Web UI and under the Last Published Workspaces window select the INSPIRE_WMS_GetCapabilities file.
- Expose the Advanced section and locate the Direct URL Example link.Direct URL location on FME Server Web UI
- Copy this URL and the open FME Data Inspector.
- Select Open Dataset , and choose WMS as the format and add this URL as the dataset.
Reading the WMS in Data Inspector
- Paste the URL into the dataset field. Click on ‘Parameters…’ Enter HTTP Authentication information (server authentication information), then select the Layer List [...], and choose one layer.
WMS Reader Parameters
Note: In FME Server if the fmeguest role has Read/Run permissions to the INSPIRE repository then you will not need to enter any authentication information.
Edit fmeguest role with Read/Run permissions to INSPIRE Repository
Results
Experiment with different layer and extent (search envelope) selections. Note that background maps can sometimes interfere with correctly rendering WMS imagery, so view the WMS with background maps turned off for better results.
Congratulations, you have now implemented your very own OGC WMS, just by publishing a few simple FME workspaces!
Results for the Named Place layer in the Data Inspector
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.