Permalink
Browse files

Adding a convenience method to simplify filters without having to wri…

…te the same basic code over and over
  • Loading branch information...
1 parent a0e74f2 commit 8b977362703eea537a05cd4c96389c86740da46b @aaime aaime committed Mar 28, 2013
@@ -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.