Skip to content

Commit

Permalink
Adding a convenience method to simplify filters without having to wri…
Browse files Browse the repository at this point in the history
…te the same basic code over and over
  • Loading branch information
aaime committed Mar 28, 2013
1 parent a0e74f2 commit 8b97736
Showing 1 changed file with 14 additions and 1 deletion.
Expand Up @@ -264,6 +264,19 @@ public Object visit(org.opengis.filter.expression.Function function, Object extr
}
}


/**
* Tries to simplify the filter if it's not already a simple one
* @param filter
* @return
*/
public static Filter simplify(Filter filter) {
// if already as simple as possible, or cannot be simplified anyways
if(filter == Filter.INCLUDE || filter == Filter.EXCLUDE || filter == null) {
return filter;
}
// other filters might involve non volatile functions, so we need to look into them
SimplifyingFilterVisitor visitor = new SimplifyingFilterVisitor();
return (Filter) filter.accept(visitor, null);
}

}

0 comments on commit 8b97736

Please sign in to comment.