|
Testing CQL and came up with an unintuitive result:
Is represented internally as:
PropertyExists( [zipcode] ) = true
This is encoded as:
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:Function name="PropertyExists">
<ogc:Literal>zipcode</ogc:Literal>
</ogc:Function>
<ogc:Literal>true</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
The FilterVisitor that is used short-list Query properties for the renderer checks for PropertyName expressions, but does not detect "zipcode" as it is represented as a <Literal> zipcode</Literal>.
In Java this function is advertised with:
public static FunctionName NAME = new FunctionNameImpl("PropertyExists",
parameter("exists", Boolean.class),
parameter("propertyName", Object.class));
I can think of several fixes:
-
Special case PropertyExists in the visitor and grab the literal value (This would not work if the parameter was a more general _expression_)
-
Special case PropertyExists in the visitor and if the argument is more general purpose return Query.ALL_PROPERTIES
I note that the implementation of PropertyExists tries to account for this:
private String getPropertyName(_expression_ expr) {
String propertyName;
if (expr instanceof Literal) {
propertyName = String.valueOf(((Literal) expr).getValue());
} else if (expr instanceof PropertyName) {
propertyName = ((PropertyName) expr).getPropertyName();
} else {
throw new IllegalStateException("Not a property name _expression_: " + expr);
}
return propertyName;
}
So if CQL parser generated: PropertyExists( [zipcode] ) = true
|