01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2005-2006, Geotools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or (at your option) any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.filter.function;
17:
18: import java.util.logging.Logger;
19:
20: import org.geotools.filter.FunctionExpression;
21:
22: public class ClassificationFunctionTest extends FunctionTestSupport {
23:
24: protected static final Logger LOGGER = org.geotools.util.logging.Logging
25: .getLogger("org.geotools.filter");
26:
27: public ClassificationFunctionTest(String testName) {
28: super (testName);
29: }
30:
31: public void testDecimalPlaces() throws Exception {
32: FunctionExpression func = fac
33: .createFunctionExpression("EqualInterval");
34: EqualIntervalFunction eif = (EqualIntervalFunction) func;
35: assertEquals(0, eif.decimalPlaces(100.0));
36: assertEquals(3, eif.decimalPlaces(25.99312));
37: assertEquals(1, eif.decimalPlaces(1.1));
38: assertEquals(1, eif.decimalPlaces(0.9));
39: assertEquals(1, eif.decimalPlaces(0.1));
40: assertEquals(2, eif.decimalPlaces(0.01));
41: assertEquals(3, eif.decimalPlaces(0.001));
42: }
43:
44: public void testRound() throws Exception {
45: FunctionExpression func = fac
46: .createFunctionExpression("Quantile");
47: QuantileFunction classifier = (QuantileFunction) func;
48: assertEquals(100.0, classifier.round(100.0, 0), 0);
49: assertEquals(1.1, classifier.round(1.12, 1), 0);
50: assertEquals(0.35, classifier.round(0.34523, 2), 0);
51: }
52: }
|