📁
Filter Expressions in FME
  • Introduction
  • Credits
  • Working Environment
  • GetCapabilities
  • 1st Filter
  • The Formula
  • Bulk Processing
  • Comparison Operators
  • Spatial Operators
  • Logical Operators
  • DefaultCRS vs OtherCRS
  • Outlook: WFS 3.0
  • Resources
  • Ideas for improvement
  • Expression Library
Powered by GitBook
On this page
  • PropertyIsEqualTo
  • PropertyIsBetween
  • PropertyIsLike - Wildcards
  • Umlauts

Comparison Operators

The good ones go into the pot, the bad ones go into your crop

PreviousBulk ProcessingNextSpatial Operators

Last updated 1 year ago

Remember , where I compared XML Filter Expressions with SQL.

Investigating WFS capabilities in shows us, which comparison operations are supported by the WFS, e.g.

<fes:ComparisonOperators>
   <fes:ComparisonOperator name="PropertyIsEqualTo"/>
   <fes:ComparisonOperator name="PropertyIsNotEqualTo"/>
   <fes:ComparisonOperator name="PropertyIsLessThan"/>
   <fes:ComparisonOperator name="PropertyIsGreaterThan"/>
   <fes:ComparisonOperator name="PropertyIsLessThanOrEqualTo"/>
   <fes:ComparisonOperator name="PropertyIsGreaterThanOrEqualTo"/>
   <fes:ComparisonOperator name="PropertyIsLike"/>
   <fes:ComparisonOperator name="PropertyIsNull"/>
   <fes:ComparisonOperator name="PropertyIsNil"/>
   <fes:ComparisonOperator name="PropertyIsBetween"/>
</fes:ComparisonOperators>

Now, we will have a look at some Comparison Operators. As they are easy to understand, we look only at a small selection.

To do so, we will use our traffic meter WFS again.

Parameter
Value

WFS URL

Version

2.0.0

Features Types

Zaehlstellen (counting points)

Max Features

leave blank

xmlns

ms="http://mapserver.gis.umn.edu/mapserver"

PropertyIsEqualTo

To recap, remember the Filter Expression we already used

<fes:Filter 
   xmlns:fes="http://www.opengis.net/fes/2.0"
   xmlns:ms="http://mapserver.gis.umn.edu/mapserver">
   <fes:PropertyIsEqualTo>
      <fes:ValueReference>ms:ZSTNR</fes:ValueReference>
      <fes:Literal>52082215</fes:Literal>
   </fes:PropertyIsEqualTo>
</fes:Filter>

PropertyIsEqualTo works similar to the equal operator ("=") in SQL.

Any feature which exactly matches the Filter Expresssion is returned.

PropertyIsBetween

PropertyIsBetween defines a range of values for 1 attribute by a

  1. LowerBoundary

  2. UpperBoundary

<fes:Filter
	xmlns:fes="http://www.opengis.net/fes/2.0"
	xmlns:ms="http://mapserver.gis.umn.edu/mapserver">
	<fes:PropertyIsBetween>
		<fes:ValueReference>ms:ZSTNR</fes:ValueReference>
		<fes:LowerBoundary><fes:Literal>39000000</fes:Literal></fes:LowerBoundary>
		<fes:UpperBoundary><fes:Literal>40000000</fes:Literal></fes:UpperBoundary>
	</fes:PropertyIsBetween>
</fes:Filter>

As our traffic meter WFS uses ascending integers for the counting point number (ZSTNR), we are able to cut out a piece like this

PropertyIsLike - Wildcards

Wildcards are really useful! The PropertyIsLike operator allows you to do pattern matching.

In our traffic meter WFS the attribute "ERFASSART" describes the type of traffic meter in combination with year dates, e.g. "2017".

Let's select all traffic meters containing "2017" in ERFASSART, no matter of the position within the description.

<fes:Filter 
   xmlns:fes="http://www.opengis.net/fes/2.0"
   xmlns:ms="http://mapserver.gis.umn.edu/mapserver">
   <fes:PropertyIsLike wildCard='*' singleChar='.' escapeChar='!'>
      <fes:ValueReference>ms:ERFASSART</fes:ValueReference>
      <fes:Literal>*2017*</fes:Literal>
   </fes:PropertyIsLike>
</fes:Filter>

Let's try another example. This time parking decks in Hamburg.

Key
Value

WFS URL

Version

2.0.0

Features Types

verkehr_parkhaeuser (parking decks)

Max Features

leave blank

xmlns

de.hh.up="https://registry.gdi-de.org/id/de.hh.up"

preise (de) = fees (en) kostenlos (de) = free of charge (de)

We want to select only those parking decks with no fees at least for the first 30 minutes.

<fes:Filter
	xmlns:fes="http://www.opengis.net/fes/2.0"
	xmlns:de.hh.up="https://registry.gdi-de.org/id/de.hh.up">
	<fes:PropertyIsLike wildCard='*' singleChar='.' escapeChar='!'>
		<fes:ValueReference>de.hh.up:preise</fes:ValueReference>
		<fes:Literal>*kostenlos*</fes:Literal>
	</fes:PropertyIsLike>
</fes:Filter>

Umlauts

If you struggle with umlauts (ÄÖÜäöüß) in Comparison Operators, please try wildcards (PropertyIsLike) instead!

Introduction
GetCapabilities
https://www.wfs.nrw.de/wfs/strassen_nrw?
https://qs-geodienste.hamburg.de/HH_WFS_Verkehr_opendata?SERVICE=WFS