double arg2 = (getExpression(2).evaluate(feature, Double.class)).doubleValue();
return evaluate(arg0, arg1, arg2);
}
public Object evaluate(String colorMap, final double min, final double max) {
GradientColorMapGenerator generator = null;
Resource xmlFile = null;
if (!colorMap.startsWith(GradientColorMapGenerator.RGB_INLINEVALUE_MARKER)
&& !colorMap.startsWith(GradientColorMapGenerator.HEX_INLINEVALUE_MARKER)) {
GeoServerResourceLoader loader = GeoServerExtensions.bean(GeoServerResourceLoader.class);
colorMap = colorMap.replace('\\', '/');
String path = Paths.path("styles", "ramps", colorMap + ".svg");
xmlFile = loader.get( path );
if( xmlFile.getType() != Type.RESOURCE ){
throw new IllegalArgumentException(
"The specified colorMap do not exist in the styles/ramps folder\n"
+ "Check that "
+ path
+ " exists and is an .svg file");
}
}
try {
if (xmlFile != null) {
generator = GradientColorMapGenerator.getColorMapGenerator(xmlFile.file());
} else {
generator = GradientColorMapGenerator.getColorMapGenerator(colorMap);
}
return generator.generateColorMap(min, max);
} catch (Exception e) {
// probably a type error
throw new IllegalArgumentException("Filter Function problem for function colormap", e);
}
}