/** * Used to rescale the provided unscaled value. * * @param unscaled * the unscaled value. * @param mapScale * the mapScale in pixels per meter. * @param uom * the unit of measure that will be used to scale. * @return a scaled value. */ protected double rescale(double unscaled, double mapScale, Unit<Length> uom) { // computes the basic rescaled value return unscaled * computeRescaleMultiplier(mapScale, uom); }
/** * Used to rescale the provided unscaled value. * * @param unscaled * the unscaled value. * @param mapScale * the mapScale in pixels per meter. * @param uom * the unit of measure that will be used to scale. * @return the expression multiplied by the provided scale. */ protected Expression rescale(Expression unscaled, double mapScale, Unit<Length> uom) { if (unscaled == null || unscaled.equals(Expression.NIL)) return unscaled; if (unscaled instanceof Literal && unscaled.evaluate(null, Double.class) != null) { // if given Expression is a literal, we can return a literal double rescaled = rescale(unscaled.evaluate(null, Double.class), mapScale, uom); return ff.literal(rescaled); } else { // otherwise, we return a Multiply expression with the rescaling multiplier double rescaleMultiplier = computeRescaleMultiplier(mapScale, uom); return ff.multiply(unscaled, ff.literal(rescaleMultiplier)); } }