[Tagging] Extended Conditions - response to votes

Eckhart Wörner ewoerner at kde.org
Fri Jul 6 15:15:30 BST 2012


Hi Martin,

Am Freitag, 6. Juli 2012, 14:54:01 schrieb Martin Vonwald:
> If you say so. So a general speed limit of 100, 80 for hgv and 70 for all in case of rain, snow and ice is crystal clear (for mappers and apps)?
> […]
> Good point. If the "specificness" is just a "bit of routine programming work" everything's fine.

Let's have a look at an example again, and see how an algorithm might work:

maxspeed=none
maxspeed:hgv=100
maxspeed:(22:00-06:00)=120
maxspeed:(22:00-06:00):hgv=80
maxspeed:wet=80

First we have to find out the set of conditions each key contains:

- for the maxspeed key, the set of conditions is empty: {}
- for the maxspeed:hgv key, the set of conditions is {"hgv"}
 -for the maxspeed:(22:00-06:00) key, the set of conditions is {"22:00-06:00"}
- for the maxspeed:(22:00-06:00):hgv key, the set of conditions is {"22:00-06:00", "hgv"}
- for the maxspeed:wet key, the set of conditions is {"wet"}

Key X is more specific than key Y if the set of conditions of X is a superset of the set of conditions of Y.
Key X conflicts with Y if neither X is more specific than Y nor Y is more specific than X.

Therefore,
- maxspeed:(22:00-06:00):hgv is more specific than both maxspeed:(22:00-06:00) and maxspeed
- maxspeed:(22:00-06:00) is more specific than maxspeed
- maxspeed:wet is more specific than maxspeed
- maxspeed:(22:00-06:00), maxspeed:wet and maxspeed:hgv conflict with each other

We now order the keys according to their specificness, most specific ones first (this is possible since specificness defines a partial order):
maxspeed:(22:00-06:00):hgv=80
maxspeed:wet=80
maxspeed:hgv=100
maxspeed:(22:00-06:00)=120
maxspeed=none

This is all part of the preprocessing. Now comes the time to actually evaluate the maxspeed (e.g. to display a speed limit to the driver). Let us assume we are driving a normal car, it is midnight and it is raining:
- maxspeed:(22:00-06:00):hgv does not apply, we just move on in the list
- maxspeed:wet applies, we write down 80, we note that we have to skip maxspeed, since maxspeed:wet is more specific than maxspeed
- maxspeed:hgv does not apply, we just move on in the list
- maxspeed:(22:00-06:00) applies, we write down 120, we note that we have to skip maxspeed since maxspeed:(22:00-06:00) is more specific than maxspeed
- we skip maxspeed
We found two possible values, 120 and 80, and take 80 as the more restrictive one.


Another use case is reducing the above list, based on some fact we know. Let us assume that we are designing a navigation system built into an hgv vehicle (therefore, the condition "hgv" is always true):
- maxspeed:(22:00-06:00):hgv becomes maxspeed:(22:00-06:00)
- maxspeed:wet stays maxspeed:wet
- maxspeed:hgv becomes maxspeed, since hgv is always true
- maxspeed:(22:00-06:00) stays maxspeed:(22:00-06:00), however, since we already have a maxspeed:(22:00-06:00) from above, we ignore this one
- maxspeed stays maxspeed, however, since we already have a maxspeed from above, we ignore this one

We therefore end up with a reduced maxspeed table for hgv:
- maxspeed:(22:00-06:00)=80
- maxspeed:wet=80
- maxspeed=100

Eckhart



More information about the Tagging mailing list