Spatial Operators
What really happens under the hood
Last updated
What really happens under the hood
Last updated
We will have a look at some Spatial Operators now. Remember what we saw in GetCapabilities:
As we are using the FeatureReader, you may ask yourself: FeatureReader comes with predefined Spatial Filters, so why should I look into Spatial Filter Expressions?
The answer is: Yes, the Spatial Filters listed above are working in most cases, but they don't use XML Filter Expressions!
Let's consult our best friend the Translation Log. To do so, you may use the following lightweight Workbench.
WFS URL
Version
2.0
Features Types
Flurstueck (cadastral parcel)
Max Features
leave blank
Select a Spatial Filter of your choice (except OGC-Disjoint), run the Workbench, switch to Translation Log and look for the already known
You'll find a really long URL like this
And the most interesting thing is this
&BBOX=xmin,ymin,xmax,ymax,urn:ogc:def:crs:EPSG::25832&
According to OGC WFS specification, you may also pass a Bounding Box (BBOX) as URL Parameter (see ampersands &) to the WFS service.
Bounding Boxes OGC-Intersect
BBOX as URL Parameter
Initiator OGC-Intersects Result
BBOX as URL Parameter
Initiator OGC-Contains Result
BBOX as URL Parameter
Initiator OGC-Crosses Result
BBOX as URL Parameter
Initiator is OGC-Disjoint from Result
No filter
get's max. number of features and may run into a timeout
Initiator OCG-Equals Result
BBOX as URL Parameter
Initiator OGC-Overlaps Result
BBOX as URL Parameter
Initiator OGC-Touches Result
BBOX as URL Parameter
Initiator is OGC-Within Result
BBOX as URL Parameter
What does this mean?
This means, that the FeatureReader sends a BBOX to the WFS and does the spatial filtering within this BBOX locally, which means inside FME itself (client-side).
That's generally ok, but as we are dealing with Filter Expressions where the WFS service does the filtering server-side, we will have a look, what's possible using XML Filter Expressions.
Let's return to our already known INSPIRE cadastral parcel WFS.
WFS URL
Version
2.0
Features Types
CadastralParcel
Max Features
leave blank
xmlns
gml="http://www.opengis.net/gml/3.2" cp="http://inspire.ec.europa.eu/schemas/cp/4.0"
The BBOX is the most powerful filter. It's a real swiss army knife! Not without good reason the FeatureReader uses a Bounding Box (BBOX) for spatial filtering.
You may paste the following Filter Expression into a WFS Reader
but we'll skip that step.
Utilize Creator instead to build a BBOX using the coordinates shown above.
Set the Coordinate System to EPSG:25832 and fetch the Coordinates (xmin, ymin, xmax, ymax) with BoundsExtractor.
Color the outline of the BBOX (FeatureColorSetter) and connect the Inspector.
Insert a FeatureReader, configure the WFS connection as shown above and paste the following Filter Expression
As you can see, it get's the BBOX corner coordinates dynamically as well.
Connect the FeatureReader also with the Inspector and run the Workbench.
The BBOX Filter selects all features, that are touched by the BBOX on the WFS server (server-side). So far so good.
But what's the magic?
Imagine, you don't know the cadastral parcel number(s) of the parcel(s) you need. For this reason you can't do the attributive query we've seen before (see 1st Filter).
But you've postal addresses instead and you are able to geocode them, i.e. you know the xy-coordinates of the address point, e.g.
If so
Tadaa: what's the result?
We got our already known cadastral parcel 05430202600946______, this time using a Spatial Filter Expression.
As you can replace nearly any geometry by its BBOX, now you know how to use it, either by a
BBOX Filter Expression or
FMEs built-in BBOX Filter
For the sake of completeness, we will have a look at some other Spatial Operators.
Please keep in mind, that the filtering is done server-side when using XML Filter Expressions!
In contrast to BBOX, Within only filters the features, which are completely within the bounding box.
We use a bounding box which fits the large green polygon, but as you can see an additional polygon is returned, see top right.
DWithin uses a radius (circle) defined by
a center point - don't forget to secifiy the Spatial Reference System aka coordinate system in srsName, check GetCapabilities which are supported by your WFS
a distance - please check, if the Unit of Measure (uom) fits to your needs
The WFS returns all features within the defined search radius.
Yes, it's possible!
I'm preparing an example. Stay tuned and come back!