use of org.opengis.filter.Expression in project geotoolkit by Geomatys.
the class XMLUtilitiesTest method createRasterSymbolizer.
private static RasterSymbolizer createRasterSymbolizer() {
String name = "Raster symbolizer name";
Description desc = STYLE_FACTORY.description("Raster symbolizer title", "Raster symbolizer description");
Unit uom = Units.METRE;
String geom = "geom";
Expression opacity = FILTER_FACTORY.literal(0.5);
ChannelSelection selection = STYLE_FACTORY.channelSelection(STYLE_FACTORY.selectedChannelType("chanel2", FILTER_FACTORY.literal(1)));
OverlapBehavior overlap = OverlapBehavior.RANDOM;
ColorMap colorMap = STYLE_FACTORY.colorMap();
ContrastEnhancement enchance = STYLE_FACTORY.contrastEnhancement();
ShadedRelief relief = STYLE_FACTORY.shadedRelief(FILTER_FACTORY.literal(3), true);
Symbolizer outline = createLineSymbolizer();
return STYLE_FACTORY.rasterSymbolizer(name, geom, desc, uom, opacity, selection, overlap, colorMap, enchance, relief, outline);
}
use of org.opengis.filter.Expression in project geotoolkit by Geomatys.
the class XMLUtilitiesTest method createTextSymbolizer.
private static TextSymbolizer createTextSymbolizer() {
String name = "Text symbolizer name";
Description desc = STYLE_FACTORY.description("Text symbolizer title", "Text symbolizer description");
Unit uom = Units.FOOT;
String geom = "geom";
Fill fill = STYLE_FACTORY.fill(Color.ORANGE);
Halo halo = STYLE_FACTORY.halo(Color.PINK, 12);
PointPlacement placement = STYLE_FACTORY.pointPlacement();
Font font = STYLE_FACTORY.font();
Expression label = FILTER_FACTORY.literal("the feature field name");
return STYLE_FACTORY.textSymbolizer(name, geom, desc, uom, label, font, placement, halo, fill);
}
use of org.opengis.filter.Expression in project geotoolkit by Geomatys.
the class JavaScriptFunction method prepare.
private static Expression[] prepare(final Expression jsFunction) {
final String str = jsFunction.apply(null).toString();
final List<Expression> properties = new ArrayList<Expression>();
properties.add(jsFunction);
String current = null;
for (int i = 0, n = str.length(); i < n; i++) {
char c = str.charAt(i);
if (current != null) {
if (END_CHARACTERS.contains(c)) {
if (!current.isEmpty()) {
properties.add(new DefaultPropertyName(current));
}
current = null;
} else {
current += c;
}
} else {
if (c == VAR_CHARACTER) {
current = "";
}
}
}
if (current != null && !current.isEmpty()) {
properties.add(new DefaultPropertyName(current));
}
return properties.toArray(new Expression[properties.size()]);
}
use of org.opengis.filter.Expression in project geotoolkit by Geomatys.
the class PropertyExistsFunction method equals.
@Override
public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof PropertyExistsFunction)) {
return false;
}
PropertyExistsFunction other = (PropertyExistsFunction) obj;
if (other.getParameters().size() != this.getParameters().size()) {
return false;
}
if (other.getParameters().size() > 0) {
final String propName = getPropertyName();
final Expression otherPropNameExpr = (Expression) other.getParameters().get(0);
final String otherPropName = getPropertyName(otherPropNameExpr);
return Objects.equals(propName, otherPropName);
} else {
return true;
}
}
use of org.opengis.filter.Expression in project geotoolkit by Geomatys.
the class AbstractFunctionFactory method createFunction.
@Override
public Expression createFunction(String name, Literal fallback, Expression... parameters) throws IllegalArgumentException {
final Class clazz = functions.get(name);
if (clazz == null) {
throw new IllegalArgumentException("Unknowed function name : " + name);
}
final Constructor construct = clazz.getConstructors()[0];
final Object[] cstParams = new Object[construct.getParameterTypes().length];
for (int i = 0; i < cstParams.length && i < parameters.length; i++) {
cstParams[i] = parameters[i];
}
try {
return (Expression) construct.newInstance(cstParams);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException ex) {
throw new IllegalArgumentException("Failed to initialize function wih given parameters : " + name + " " + ex.getMessage(), ex);
}
}
Aggregations