Crash Magic Online
  Intersection Magic
  Map Magic
  Knowledge Base
  Contact Us


Knowledge Base Article:IMW166 

Registration keys moved to client area: Select login on the left menu bar.

Search home page  

How to change a filter to its "inverse"

Article created: Oct 20 2005, updated: Oct 20 2005

Background:  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.

Status:  Info - "how to" article
Keywords:  negative,inverse,UnMatch,opposite,true,false
Categories:   *Filters / queries*


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.

October 22, 2019 10:54PM

© 1999-2019 Pd' Programming, Inc - Lafayette, CO USA