@Test public void numericExponentialDefaultValueTest() throws Exception { SimpleFeatureType SAMPLE = DataUtilities.createType("SAMPLE", "id:\"\",temperature:0.0,location=4326"); SimpleFeature feature = DataUtilities.createFeature(SAMPLE, "measure1=A|NOT_A_VALID_NUMBER|POINT(0,0)"); String jsonStr = "{'type':'exponential', 'base': 1.9, 'property':'temperature', 'stops':[[0,12],[30,24],[70,48]], 'default':42}"; MBFunction function = new MBFunction(MapboxTestUtils.object(jsonStr)); Expression fn = function.numeric(); Number result = fn.evaluate(feature, Number.class); assertEquals(42, result.intValue()); }
public Expression numeric() { Expression input = input(); FunctionType type = getTypeWithDefault(Number.class); if (type == FunctionType.EXPONENTIAL) { double base = parse.optional(Double.class, json, "base", 1.0); if (base == 1.0) { return numericGenerateInterpolation(input); } else { return numericGenerateExponential(input, base); } } if (type == FunctionType.CATEGORICAL) { return generateRecode(input); } else if (type == FunctionType.INTERVAL) { return generateCategorize(input); } else if (type == FunctionType.IDENTITY) { return withFallback(input); } throw new UnsupportedOperationException("Numeric unavailable for '" + type + "' function"); }
MBFunction { public Expression numeric() { Expression input = input(); FunctionType type = getTypeWithDefault(Number.class); if (type == FunctionType.EXPONENTIAL) { double base = parse.optional(Double.class, json, "base", 1.0); if (base == 1.0) { return numericGenerateInterpolation(input); } else { return numericGenerateExponential(input, base); } } if (type == FunctionType.CATEGORICAL) { return generateRecode(input); } else if (type == FunctionType.INTERVAL) { return generateCategorize(input); } else if (type == FunctionType.IDENTITY) { return withFallback(input); } throw new UnsupportedOperationException("Numeric unavailable for '" + type + "' function"); } }
MBFunction { public Expression numeric() { Expression input = input(); FunctionType type = getTypeWithDefault(Number.class); if (type == FunctionType.EXPONENTIAL) { double base = parse.optional(Double.class, json, "base", 1.0); if (base == 1.0) { return numericGenerateInterpolation(input); } else { return numericGenerateExponential(input, base); } } if (type == FunctionType.CATEGORICAL) { return generateRecode(input); } else if (type == FunctionType.INTERVAL) { return generateCategorize(input); } else if (type == FunctionType.IDENTITY) { return withFallback(input); } throw new UnsupportedOperationException("Numeric unavailable for '" + type + "' function"); } MBFunction(JSONObject json);  MBFunction(MBObjectParser parse, JSONObject json); }
MBFunction { public Expression numeric() { Expression input = input(); FunctionType type = getTypeWithDefault(Number.class); if (type == FunctionType.EXPONENTIAL) { double base = parse.optional(Double.class, json, "base", 1.0); if (base == 1.0) { return numericGenerateInterpolation(input); } else { return numericGenerateExponential(input, base); } } if (type == FunctionType.CATEGORICAL) { return generateRecode(input); } else if (type == FunctionType.INTERVAL) { return generateCategorize(input); } else if (type == FunctionType.IDENTITY) { return withFallback(input); } throw new UnsupportedOperationException("Numeric unavailable for '" + type + "' function"); } MBFunction(JSONObject json);  MBFunction(MBObjectParser parse, JSONObject json); FunctionType getType(); Object getDefault(); FunctionType getTypeWithDefault(Class<?> clazz); String getProperty(); EnumSet<FunctionCategory> category(); JSONArray getStops(); Number getBase(); static MBFunction create(JSONObject json); Expression color(); Expression font(); Expression numeric(); @SuppressWarnings("unchecked") Expression function(Class<?> clazz); Expression enumeration(Class<? extends Enum<?>> enumeration); boolean isArrayFunction(); List<MBFunction> splitArrayFunction(); }
MBFunction { public Expression numeric() { Expression input = input(); FunctionType type = getTypeWithDefault(Number.class); if (type == FunctionType.EXPONENTIAL) { double base = parse.optional(Double.class, json, "base", 1.0); if (base == 1.0) { return numericGenerateInterpolation(input); } else { return numericGenerateExponential(input, base); } } if (type == FunctionType.CATEGORICAL) { return generateRecode(input); } else if (type == FunctionType.INTERVAL) { return generateCategorize(input); } else if (type == FunctionType.IDENTITY) { return withFallback(input); } throw new UnsupportedOperationException("Numeric unavailable for '" + type + "' function"); } MBFunction(JSONObject json);  MBFunction(MBObjectParser parse, JSONObject json); FunctionType getType(); Object getDefault(); FunctionType getTypeWithDefault(Class<?> clazz); String getProperty(); EnumSet<FunctionCategory> category(); JSONArray getStops(); Number getBase(); static MBFunction create(JSONObject json); Expression color(); Expression font(); Expression numeric(); @SuppressWarnings("unchecked") Expression function(Class<?> clazz); Expression enumeration(Class<? extends Enum<?>> enumeration); boolean isArrayFunction(); List<MBFunction> splitArrayFunction();  }