How to change a filter to its “inverse”

Table of Contents

How to change a filter to its “inverse”


Suppose you’ve written a filter to show all collisions resulting from vehicles traveling in opposite directions. (i.e. east vs west or north vs south) Now suppose you want to get all the other crashes.


Suppose you’ve created this filter to identify crashes by opposing vehicles:

(@Setmatch(Veh_1_Direction,Veh_2_Direction,East,West)) |

How can you get all the crashes that do not fit this filter?


To get the opposite results from a filter, simply check for it to equal false:

((@Setmatch(Veh_1_Direction,Veh_2_Direction,East,West)) |
 (@Setmatch(Veh_1_Direction,Veh_2_Direction,North,South))) = false

Note the extra set of parentheses added to group the entire expression. 

This new filter will capture all the crashes that the original one did not.  That is, all the crashes where the vehicles were not coming from opposite directions. 

Note: To make this filter “generic” so that it will work with any configuration, change it to look like this:

@SetMatch( @Veh1Dir, @Veh2Dir, @North, @South ) |
@SetMatch( @Veh1Dir, @Veh2Dir, @East, @West )

Creating the filter like this makes use of the “DrawData” configuration file to “normalize” the vehicle directions.  For most configurations, this means that North-East and North-West will be converted to North, and South-East and  South-West will be converted to South. 

For more information on this, refer to the manual’s Filter chapter.  See the section on Filter functions / Schematic functions.

Was this article helpful?
0 out Of 5 Stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
How can we improve this article?
How Can We Improve This Article?