Source Code Cross Referenced for EqualIntervalFunctionTest.java in  » GIS » GeoTools-2.4.1 » org » geotools » filter » function » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeoTools 2.4.1 » org.geotools.filter.function 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2004-2006, Geotools Project Managment Committee (PMC)
005:         *
006:         *    This library is free software; you can redistribute it and/or
007:         *    modify it under the terms of the GNU Lesser General Public
008:         *    License as published by the Free Software Foundation; either
009:         *    version 2.1 of the License, or (at your option) any later version.
010:         *
011:         *    This library is distributed in the hope that it will be useful,
012:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *    Lesser General Public License for more details.
015:         */
016:        package org.geotools.filter.function;
017:
018:        import org.geotools.feature.Feature;
019:        import org.geotools.feature.FeatureIterator;
020:        import org.geotools.filter.Expression;
021:        import org.geotools.filter.FilterFactory;
022:        import org.geotools.filter.FilterFactoryFinder;
023:        import org.geotools.filter.FunctionExpression;
024:        import org.opengis.filter.expression.Function;
025:        import org.opengis.filter.expression.Literal;
026:        import org.opengis.filter.expression.PropertyName;
027:
028:        /**
029:         *
030:         * @author James
031:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/test/java/org/geotools/filter/function/EqualIntervalFunctionTest.java $
032:         */
033:        public class EqualIntervalFunctionTest extends FunctionTestSupport {
034:
035:            private static final FilterFactory ff = FilterFactoryFinder
036:                    .createFilterFactory();
037:
038:            public EqualIntervalFunctionTest(String testName) {
039:                super (testName);
040:            }
041:
042:            protected void tearDown() throws java.lang.Exception {
043:            }
044:
045:            public static junit.framework.Test suite() {
046:                junit.framework.TestSuite suite = new junit.framework.TestSuite(
047:                        EqualIntervalFunctionTest.class);
048:                return suite;
049:            }
050:
051:            /**
052:             * Test of getName method, of class org.geotools.filter.functions.EqualIntervalFunction.
053:             */
054:            public void testInstance() {
055:                Function equInt = ff.createFunctionExpression("EqualInterval");
056:                assertNotNull(equInt);
057:                assertEquals("test get name", "EqualInterval", equInt.getName());
058:            }
059:
060:            /**
061:             * Test of setNumberOfClasses method, of class org.geotools.filter.functions.EqualIntervalFunction.
062:             */
063:            public void testSetClasses() throws Exception {
064:                PropertyName property = ff.property("foo");
065:                Literal literal = ff.literal(3);
066:
067:                EqualIntervalFunction func = (EqualIntervalFunction) ff
068:                        .function("EqualInterval", property, literal);
069:                assertEquals(3, func.getClasses());
070:
071:                func.getParameters().set(1, ff.literal(12));
072:                assertEquals(12, func.getClasses());
073:            }
074:
075:            public void testEvaluateWithExpressions() throws Exception {
076:                Expression classes = (Expression) builder.parser(dataType, "3");
077:                Expression expr1 = (Expression) builder.parser(dataType, "foo");
078:                FunctionExpression func = fac
079:                        .createFunctionExpression("EqualInterval");
080:                func.setArgs(new Expression[] { expr1, classes });
081:
082:                Object classifier = func.evaluate(featureCollection);
083:                assertTrue(classifier instanceof  RangedClassifier);
084:                RangedClassifier ranged = (RangedClassifier) classifier;
085:                //values = 4,90,20,43,29,61,8,12
086:                //4..90 = 4..32.67, 32.67..61.33, 61.33..90
087:
088:                //correct number of classes
089:                assertEquals(3, ranged.getSize());
090:                //correct titles
091:                assertEquals("4..32.667", ranged.getTitle(0));
092:                assertEquals("32.667..61.333", ranged.getTitle(1));
093:                assertEquals("61.333..90", ranged.getTitle(2));
094:                //check classifier binning
095:                assertEquals(0, ranged.classify(new Double(4)));
096:                assertEquals(2, ranged.classify(expr1, testFeatures[1])); //90
097:                assertEquals(0, ranged.classify(new Double(20)));
098:                assertEquals(1, ranged.classify(new Double(43)));
099:                assertEquals(0, ranged.classify(new Double(29)));
100:                assertEquals(1, ranged.classify(new Double(61)));
101:                assertEquals(0, ranged.classify(expr1, testFeatures[6])); //8
102:                assertEquals(0, ranged.classify(new Double(12)));
103:
104:                //try again with foo        
105:            }
106:
107:            /** FIXME: Please for the love on binpop */
108:            public void XtestEvaulateWithStrings() throws Exception {
109:                org.opengis.filter.expression.Expression function = ff
110:                        .function("EqualInterval", ff.property("group"), ff
111:                                .literal(5));
112:                Classifier classifier = (Classifier) function
113:                        .evaluate(featureCollection);
114:                assertNotNull(classifier);
115:
116:                Classifier classifier2 = (Classifier) function.evaluate(
117:                        featureCollection, Classifier.class);
118:                assertNotNull(classifier2);
119:
120:                Integer number = (Integer) function.evaluate(featureCollection,
121:                        Integer.class);
122:                assertNull(number);
123:            }
124:
125:            public void testUpgradeExample() {
126:                Function function = ff.function("equalInterval", ff
127:                        .property("foo"), ff.literal(12));
128:                Object value = function.evaluate(featureCollection);
129:                assertNotNull("classifier failed", value);
130:
131:                Classifier split = (Classifier) value;
132:                Function classify = ff.function("classify", ff.property("foo"),
133:                        ff.literal(split));
134:
135:                Feature victim = testFeatures[2]; //foo = 20
136:                assertEquals("Feature was placed in wrong bin", new Integer(2),
137:                        classify.evaluate(victim));
138:            }
139:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.