Logical Operators
The power of combination
In previous chapters we learned how to do different attributive and spatial queries.
Let's combine them by using Logical Operators.
OR
Let's start with the OR-Operator (logical disjunction).
We will use the parking decks-WFS provided by Hanseatic City of Hamburg we already used in Comparison Operators.
WFS URL
Version
2.0.0
Features Types
verkehr_parkhaeuser
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 (en) keine Gebühr (de) = no charge (en)
The services provides an attribute called "preise", i.e. fees.
First, we will look for all parking decks, which can be used free of charge (kostenlos), at least for some time (half an hour or an hour).
The word "kostenlos" occurs in different mixtures like
1. Stunde kostenlos|2. Stunde 1,20 EUR | jede weitere Std. 1,50 EUR|Tageshöchstsatz k. A.
1. Stunde kostenlos|jede weitere Std. 1,50 EUR|Tageshöchstsatz 15,00 EUR
halbe Stunde: kostenlos|2. halbe Stunde: 0,50 EUR|2. Stunde: 1,00 EUR| (...)
Remember what we learned in Comparison Operators about Wildcards using the PropertyIsLike-Operator.
Using this filter expression, the service will return 5 features (at the time of publication of this chapter):
10047 Elbe Einkaufszentrum (EEZ)
10076 Alstertal Einkaufszentrum (AEZ) Ost
10094 Harburg Carree
10116 Alstertal Einkaufszentrum (AEZ) Mitte
10117 Alstertal Einkaufszentrum (AEZ) West
Next, we will look for all parking decks with no charges (keine Gebühren) using the well-known PropertyIsEqualTo-Operator.
The WFS will return 3 additional features:
10089 Sander Markt
10090 Frascatiplatz
10091 Lohbrügger Marktplatz
Instead of sending two separate (disjoined) requests, we can combine them into one single request using the OR-Operator as shown below:
The only simple trick is to embrace your expressions (to be precise, the conditions within the expression) by the logical operator needed, i.e.
If you're a programmer, this may be unfamiliar for you because you normally connect conditions by logical operators like this:
So please keep in mind: logical operators embrace conditions within filter expressions.
AND
Recapitulating what we have learned, using other logical operators is really easy:
take two or more filter expressions
make sure, that they are working stand-alone (please test them!)
combine them by enclosing them by logical operators
To do so, we will have a look at the AND-Operator (logical conjunction) using a mining-WFS provided by Federal State of Brandenburg.
WFS URL
Version
2.0
Features Types
bgberechtig (mining rights)
Max Features
leave blank
xmlns
fes="http://www.opengis.net/fes/2.0" app="http://www.deegree.org/app"
inhaber (de) = holder (en) bodenschatz_kurz (de) = resource, abbr. (en) Ton (de) = clay (en)
First, we want to get all mining rights in Brandenburg owned by the company called "BVVG Bodenverwertungs- und -verwaltungs GmbH".
The WFS will return 35 polygon features.
Next, we're interested in all clay pits.
We will get 29 polygon features.
If we want to see only the clay pits owned by BVVG, we have to put all of this together using the AND-Operator.
The WFS will return 7 polygon features.
Good to know #4
You may ask yourself: is it possible to combine both
Comparison Operators
Spatial Operators
???
The answer is: yes, it is possible!
Next, create a PropertyIsLike-Expression like this
Check, if both expressions are running stand-alone.
If so, please combine them using the AND-Operator:
What's the difference?
See for yourself!
Last updated