Products
  
  
  Intersection Magic
  
  Map Magic
  
  Crash Magic Online
  
  Crash Magic Desktop
  
  Diagram Magic
  
  Magic Wands
  
  Knowledge Base
  
  
  Custom Software
  
  Traffic Data Consulting
  
  
  Contact Us
  
  Links
  
  Login
  
Search pdmagic.com:

 

Knowledge Base Article:IMW166 


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

kbase:
Search:  

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*

Explanation:

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

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

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



Solution:

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.


September 08, 2010 5:52AM

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