Bulk Processing

May the Force be with you

I travelled British Columbia (B.C.) two times and visited some national parks, let's say

  1. Pacific Rim National Park Reserve

  2. Banff National Park

  3. Glacier National Park

The Government of British Columbia publishes a WFS containing National Parks amongst others.

Parameter
Value

WFS URL

Version

2.0.0

Features Types

WHSE_BASEMAPPING.DBM_BC_7H_MIL_PARK_POLY

Max Features

leave blank

xmlns

pub="http://delivery.openmaps.gov.bc.ca/geo/"

Let's recap what we learned und put the things together into a Filter Expression to query the WFS:

<fes:Filter 
   xmlns:fes="http://www.opengis.net/fes/2.0"
   xmlns:pub="http://delivery.openmaps.gov.bc.ca/geo/">
   <fes:PropertyIsEqualTo>
      <fes:ValueReference>pub:ENGLISH_NAME</fes:ValueReference>
      <fes:Literal>Pacific Rim National Park Reserve</fes:Literal>
   </fes:PropertyIsEqualTo>
</fes:Filter>

Maybe you ask yourself: How did he open the XML Filter Expression editor this time?

The answer is: in FME there are often many ways to do something. This time, I accessed the editor via the WFS Reader Parameters, see Navigator (TOC) on the left.

It's your choice!

But coming back to our parks.

Using the Filter Expression shown above, only one park can be fetched at a time. But we have a list of three parks. How to query the two others?

Having only 3 parks in a list, the easiest way would be to edit the filter expression manually. But what to do, if you have a list of thousands of parks or cadastral parcels?

It would be really inefficient to edit the list manually.

We need a way to inject our list members into the WFS Reader.

To be precise, we need a way to inject our parks into the XML Filter Expression.

Injecting something into a reader which has no input port by default?

Hmm ...

Ok, I don't want to keep you in suspense.

The answer is: use the FeatureReader Transformer!

Let's check what the purpose is:

Oh wow, Safers!

This is really a modest description of such a powerful Transformer!

The real force of the FeatureReader Transformer is, that it enables you to pass something into any other format reader by an input port, called Initiator.

Note: the FeatureReader Transformer has a twin, the FeatureWriter.

First, we have to put our park list into a format, which is able to hold lists, e.g. CSV, a database or Excel as shown below.

Next open this list with the appropriate reader.

Then add the FeatureReader Transfomer to your FME canvas and connect it with the Reader.

Click the red gear icon on the top right-hand side of the FeatureReader to edit its properties.

Just choose the OGC WFS (Web Feature Service) format and open [Parameters ...]. This will forward you to the WFS Reader you already know.

Familiar faces ...

But what's the difference so far?

The difference comes next. Open the XML Filter Expression Editor and paste the XML from above. Then delete "Pacific Rim National Park Reserve" and replace it by the Feature Attribute "ENGLISH_NAME".

Again, there are two ways to do this:

  1. place the mouse cursor between >|< and double-click the attribute on the left-hand side

  2. just drag and drop it from the list into the expression

Click [Ok] to close the editor.

Caution!

Some (older) FME builds are faulty.

In this case you have to copy the [Feature Types] into the clipboard before you close the WFS Parameters, e.g.

Feature Types: WHSE_BASEMAPPING.DBM_BC_7H_MIL_PARK_POLY

Close WFS Parameters and paste the Feature Types from the clipboard into the FeatureReader Parameter called [Feature Types to Read].

If your build is affected, you will get an error, if this is left blank: <WFS> No feature types were selected

Next, a pop-up comes up

Just close it by clicking [OK].

Finally connect an Inspector for the first overview and run the Workbench!

As you can see, the FeatureReader

  • gets 3 features (park names) as input

  • and returns 6 features from WFS as output.

You're still able to follow?

Congratulations!

Now, you're a real Wizard of Ex knowing how to query a WFS for the concrete features you need using a fitting XML Filter Expression.

What's coming next?

I need a magic potion or just a coffee and then we will have a look at some Comparison Operators, i.e. attribute filters.

Stay tuned ...

Last updated