How to Create a WMS Service Using FME Flow

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

Introduction

The OGC Web Mapping Service (WMS) was designed as a means of providing georeferenced, configurable images of your data over the internet. Examples of these use include setting an image as a background map in a web application or even an image overlay in services such as Google Earth.
OGC services define open standards that allow for data integration across a wide range of proprietary and open-source applications.
FME Flow provides a means of supporting these services by enabling users to register workspaces to a designated service to handle the receiving and transmission of web service messages to the client. This guide makes use of the Data Streaming service in FME Flow. Upon completion of these instructions, you will have a functional WMS Service running from your FME Flow and have the skills to implement this service from your own data.

 

Technical Details

  • There are two workspaces:
    • GetCapabilities.fmw is the initial workspace that returns the required information to describe the available WMS services.
    • GetPNG.fmw is the workspace that returns the image for the requested layers and extents.
  • The workspaces were updated using FME 2023.1 and have been tested using FME 2023.1.
  • The WMS services you create are compliant with the OGC WMS 1.1.1 and 1.3.0 specifications.

​​​​​​​

Step-by-step Instructions

Part 1:  Create a WMS Service with FME Flow

There are two steps to set up the WMS Service:

  • Set the source dataset
  • Set the style for how your data should look in the output images

The attached download package is ready to publish to FME Flow and is set up to read and render the included sample SpatiaLite database. You may wish to publish the sample and test it in your desired WMS viewer before modifying the workspaces to serve your own data.

1. Open Workspace
Download then open the GetCapabilities.fmw workspace in FME Workbench. This workspace creates the WMS Service and can be customized to use with your data. 

2. Load Data
In the Navigator window, expand Transformers and then double-click on the first one (_Data_Source) to navigate to the FeatureReader transformer. 
DataSource.png

Open the _Data_Source FeatureReader. In the parameters, update the Format and Dataset to your desired dataset. 

For this example, leave the Format set to SpatiaLite and the Dataset set to Vancouver.sl3. 

FeatureReader.png


3. Modify Workspace Private Parameters
In the Navigator window, expand the Private Parameters section under User Parameters. 
PrivateParams.png


Modify the Private Parameters to fit your data. For this example, they can be left as the default.

  • FeatureTypes: Set the Layers to be available in your service. These must have the same name as the Layers/Feature Classes/Tables in your source data
  • Source SRS: The coordinate system of the available layers.
  • MinX, MinY, MaxX, MaxY: The bounds of the source data. This does not need to be exact. You can use the entire world if you like, but proper bounds will prevent the WMS viewer from requesting data you can’t provide.
  • Title: A title for your WMS service


4. Publish Workspace to FME Flow
Publish the workspace to FME Flow.
Publish.png

On the Register Services dialog of the publishing wizard, select the Data Streaming Service. Next, click the Edit button to modify the Data Streaming properties. In the properties, set Include Writers in Stream to return [TEXTLINE]. Click Publish to finish publishing. 
Services.png

After publishing, save and close the workspace. 

5. Open Workspace
Download then open the GetPNG.fmw workspace in FME Workbench. This workspace gets the PNG files, and can be customized to use with your data. 

6. Load Data
In the Navigator window, expand Transformers and then double-click on the first one (_Data_Source) to navigate to the FeatureReader transformer. 

Open the _Data_Source FeatureReader. In the parameters, update the Format and Dataset to your desired dataset. 

For this example, leave the Format set to SpatiaLite and the Dataset set to Vancouver.sl3. 

FeatureReader2.png

7. Modify the Styling and Rendering
In the Navigator window, expand Bookmarks and double-click on the _Create Image bookmark to navigate to it. This section has already been set up for this example and can be left as the default. 
Bookmar.png

This section contains the logic required to render your data to a representative image. The key transformer is the MapnikRasterizer, which does the actual rendering using user-defined rules. The other transformers are used to prepare the geometry for rendering or to calculate label sizes appropriate for the requested coordinate system. The text size multiplier and image resolution calculated before this section will be used for calculating the annotation sizes.
The existing logic is a simple example of what can be done for rendering. 
MapnikRasterizer.png


8. Publish the workspace to FME Flow
Publish the workspace to FME Flow. Be sure to publish to the same repository as the GetCapabilities.fmw workspace. 
Publish2.png

On the Register Services dialog of the publishing wizard, select the Data Streaming Service. Next, click the Edit button to modify the Data Streaming properties. In the properties, set Include Writers in Stream to out [PNGRASTER]. Click OK then click Publish. 
Streaming.png

FME currently supports only a single MIME type for the workspace output. If you want to support other image formats like JPEG or SVG, you will need to create an additional workspace for each. You will also need to edit the XMLTemplater in the GetCapabilities.fmw to add a new GetMap element for the new image type.

9. Configure Authentication
To allow access to the WMS service, we will create a dedicated WMS user in FME Flow with access only to the WMS workspaces. 

Log into FME Flow as an administrator. Navigate to Users under the User Management section on the side menu. 

Click the Create button to create a new user. Set the Username, Full Name, and Password to the desired values. 
WMSUser.png

Scroll down to the Permission section to Repositories. Click the drop-down arrow on the right to display all the available repositories, then check the Read and Run boxes for the WMS repository. Also, check the Run Workspace - Access box below the Repositories.
UserPermissions.png

Scroll down to Services, then click the drop-down arrow to display all the available services. Check the Full Access box for the Data Streaming Service:
UserPermissions2.png

Finally, scroll all the way to the bottom, then Click OK to save the new user. 
 

Part 2: Verify your WMS Service

There are a number of ways to ensure that your WMS Service is functioning correctly. Listed below is a simple web browser-based method. However, as WMS is a standard, you can use multiple tools. For example, software packages such as ArcGIS, Google Earth, and QGIS have methods to connect to a WMS Service and there is also a WMS reader within FME Workbench.

Browser
To verify your WMS service, use a GetCapabilites request. The resulting XML stream will serve information about the available functionality of the service, including which Layers are available.
Enter the following in the address bar of your browser, editing the string where necessary. 

http://<serverhostname>:port/fmedatastreaming/<Repository>/GetCapabilities.fmw?services=wms&version=1.1.1&request=GetCapabilities

GetCapabilitiesBrowser.png

 

 



Part 3: Testing the Workspaces

It is much faster to test your workspace modifications locally before publishing up to FME Flow. However, both workspaces use the URL that called them to determine image size and the layers and bounds to render on the returned image. Therefore, in order to run these workspaces successfully in FME Form, we will first need to create a Webhook.
 

GetCapabilities

1. Create a Webhook for the Workspace
A webhook allows users to directly run the workspace using a URL, with no intermediate forms to manually fill in.

Log into FME Flow as an administrator. From the Run Workspace space, select the Repository where the GetCapabilities.fmw workspace was published. From the Workspace Actions drop-down menu in the top corner, select Create Webhook. 
Webhook1.png

Click OK on the Webhook URL page to create the webhook:
Webhook2.png

In the final page, copy the URL from the Authorization with Header. This webhook will be used in FME Workbench to find the GetPNG URL. 
Webhook3.png

GetPNG

The GetPNG URL is more complex since it contains the layers and bounds of the request.

1. Create a Workspace with a WMS Reader
Return to FME Workbench and open a blank workspace. Add an OGC WMS (Web Map Service) reader to the canvas, with the webhook URL generated in the previous step above for the Dataset. Then open the Parameters. 
Reader.png

In the Parameters, click the checkbox next to Use Network Authentication, then enter the Username and Password created with the new WMS user on FME Flow. 
NetworkAuthenticate.png

Next, click on the ellipsis next to Layers and select {Generic WMS Service}, then optionally, click Transparent Background if you would like to overlay the PNG on a basemap. Click OK twice to finish adding the reader. 
WMSParams.png


2. Find the GET Requests
Run the workspace, then examine the Translation Log for lines starting with <WMS>. Copy the second URL starting with GetMap. You can easily find these in the translation log by using the search button.
Search.png

An additional way to test your WMS is with the WMS reader. After running the workspace, open Visual Preview and the image can be inspected. You can also overlay your data on a background map to confirm accuracy. 


3. Test the GET Requests
Return to the GetPNG.fmw workspace. To test the workspace,  you can enter the URI in the Navigator Window under User Parameters > FME Flow Parameters > [FME_SERVER_REQUEST_URI]
URI.png

Paste in the entire GetMap URI from the Translation Log into the [FME_SERVER_REQUEST_URI] and then run the workspace. Open Output.png in Visual Preview. 
Output.png

 

WMS Service Capabilities

The WMS Service created by this tutorial contains the following operations:

  • GetCapabilities: Retrieve metadata about the service, including available Feature Types.
  • GetMap: Retrieve data.

These are the two mandatory operations for creating a WMS and more information on these can be found on the OGC Website: WMS Standard.

 

Additional Resources

WMS Tutorials: INSPIRE WMS Tutorial

 

Data Attribution

The data used here originates from open data made available by the City of Vancouver, British Columbia. It contains information licensed under the Open Government License - Vancouver.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.