Source Code Cross Referenced for CRSTest.java in  » GIS » GeoTools-2.4.1 » org » geotools » referencing » factory » wms » 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.referencing.factory.wms 
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.referencing.factory.wms;
017:
018:        // J2SE dependencies
019:        import java.util.Collection;
020:        import java.util.logging.Level;
021:
022:        // JUnit dependencies
023:        import junit.framework.Test;
024:        import junit.framework.TestCase;
025:        import junit.framework.TestSuite;
026:
027:        // OpenGIS dependencies
028:        import org.opengis.referencing.FactoryException;
029:        import org.opengis.referencing.crs.GeographicCRS;
030:        import org.opengis.referencing.crs.CRSAuthorityFactory;
031:        import org.opengis.referencing.crs.CoordinateReferenceSystem;
032:
033:        // Geotools dependencies
034:        import org.geotools.referencing.CRS;
035:        import org.geotools.resources.Arguments;
036:        import org.geotools.referencing.ReferencingFactoryFinder;
037:        import org.geotools.referencing.crs.DefaultGeographicCRS;
038:        import org.geotools.referencing.factory.IdentifiedObjectFinder;
039:        import org.geotools.referencing.factory.AbstractAuthorityFactory;
040:        import org.geotools.referencing.factory.BufferedAuthorityFactory;
041:
042:        /**
043:         * Tests {@link WebCRSFactory}.
044:         *
045:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/referencing/src/test/java/org/geotools/referencing/factory/wms/CRSTest.java $
046:         * @version $Id: CRSTest.java 27848 2007-11-12 13:10:32Z desruisseaux $
047:         * @author Martin Desruisseaux
048:         */
049:        public final class CRSTest extends TestCase {
050:            /**
051:             * The factory to test.
052:             */
053:            private AbstractAuthorityFactory factory;
054:
055:            /**
056:             * Run the suite from the command line.
057:             */
058:            public static void main(final String[] args) {
059:                final Arguments arguments = new Arguments(args);
060:                final boolean log = arguments.getFlag("-log");
061:                arguments.getRemainingArguments(0);
062:                org.geotools.util.logging.Logging.GEOTOOLS
063:                        .forceMonolineConsoleOutput(log ? Level.CONFIG : null);
064:                junit.textui.TestRunner.run(suite());
065:            }
066:
067:            /**
068:             * Returns the test suite.
069:             */
070:            public static Test suite() {
071:                return new TestSuite(CRSTest.class);
072:            }
073:
074:            /**
075:             * Creates a suite of the given name.
076:             */
077:            public CRSTest(final String name) {
078:                super (name);
079:            }
080:
081:            /**
082:             * Initializes the factory to test.
083:             */
084:            protected void setUp() throws Exception {
085:                super .setUp();
086:                factory = new WebCRSFactory();
087:            }
088:
089:            /**
090:             * Tests the registration in {@link ReferencingFactoryFinder}.
091:             */
092:            public void testFactoryFinder() {
093:                final Collection authorities = ReferencingFactoryFinder
094:                        .getAuthorityNames();
095:                assertTrue(authorities.contains("CRS"));
096:                CRSAuthorityFactory found = ReferencingFactoryFinder
097:                        .getCRSAuthorityFactory("CRS", null);
098:                assertTrue(found instanceof  WebCRSFactory);
099:            }
100:
101:            /**
102:             * Checks the authority names.
103:             */
104:            public void testAuthority() {
105:                final Collection identifiers = factory.getAuthority()
106:                        .getIdentifiers();
107:                assertTrue(identifiers.contains("CRS"));
108:                assertFalse(identifiers.contains("EPSG"));
109:                assertFalse(identifiers.contains("AUTO"));
110:                assertFalse(identifiers.contains("AUTO2"));
111:            }
112:
113:            /**
114:             * Tests the CRS:84 code.
115:             */
116:            public void testCRS84() throws FactoryException {
117:                GeographicCRS crs = factory.createGeographicCRS("CRS:84");
118:                assertSame(crs, factory.createGeographicCRS("84"));
119:                assertSame(crs, factory.createGeographicCRS("CRS84"));
120:                assertSame(crs, factory.createGeographicCRS("CRS:CRS84"));
121:                assertSame(crs, factory.createGeographicCRS("crs : crs84"));
122:                assertNotSame(crs, factory.createGeographicCRS("CRS:83"));
123:                assertFalse(DefaultGeographicCRS.WGS84.equals(crs));
124:                assertTrue(CRS.equalsIgnoreMetadata(DefaultGeographicCRS.WGS84,
125:                        crs));
126:            }
127:
128:            /**
129:             * Tests the CRS:83 code.
130:             */
131:            public void testCRS83() throws FactoryException {
132:                GeographicCRS crs = factory.createGeographicCRS("CRS:83");
133:                assertSame(crs, factory.createGeographicCRS("83"));
134:                assertSame(crs, factory.createGeographicCRS("CRS83"));
135:                assertSame(crs, factory.createGeographicCRS("CRS:CRS83"));
136:                assertNotSame(crs, factory.createGeographicCRS("CRS:84"));
137:                assertFalse(CRS.equalsIgnoreMetadata(
138:                        DefaultGeographicCRS.WGS84, crs));
139:            }
140:
141:            /**
142:             * Tests the {@link IdentifiedObjectFinder#find} method.
143:             */
144:            public void testFind() throws FactoryException {
145:                final GeographicCRS CRS84 = factory
146:                        .createGeographicCRS("CRS:84");
147:                final IdentifiedObjectFinder finder = factory
148:                        .getIdentifiedObjectFinder(CoordinateReferenceSystem.class);
149:                assertTrue("Newly created finder should default to full scan.",
150:                        finder.isFullScanAllowed());
151:
152:                finder.setFullScanAllowed(false);
153:                assertSame(
154:                        "Should find without the need for scan, since we can use the CRS:84 identifier.",
155:                        CRS84, finder.find(CRS84));
156:
157:                finder.setFullScanAllowed(true);
158:                assertSame(
159:                        "Allowing scanning should not make any difference for this CRS84 instance.",
160:                        CRS84, finder.find(CRS84));
161:
162:                assertNotSame("Required condition for next test.", CRS84,
163:                        DefaultGeographicCRS.WGS84);
164:                assertFalse("Required condition for next test.", CRS84
165:                        .equals(DefaultGeographicCRS.WGS84));
166:                assertTrue("Required condition for next test.",
167:                        CRS.equalsIgnoreMetadata(CRS84,
168:                                DefaultGeographicCRS.WGS84));
169:
170:                finder.setFullScanAllowed(false);
171:                assertNull(
172:                        "Should not find WGS84 without a full scan, since it doesn't contains the CRS:84 identifier.",
173:                        finder.find(DefaultGeographicCRS.WGS84));
174:
175:                finder.setFullScanAllowed(true);
176:                assertSame(
177:                        "A full scan should allow us to find WGS84, since it is equals ignoring metadata to CRS:84.",
178:                        CRS84, finder.find(DefaultGeographicCRS.WGS84));
179:
180:                finder.setFullScanAllowed(false);
181:                assertNull("The scan result should not be cached.", finder
182:                        .find(DefaultGeographicCRS.WGS84));
183:
184:                // --------------------------------------------------
185:                // Same test than above, using a CRS created from WKT
186:                // --------------------------------------------------
187:
188:                String wkt = "GEOGCS[\"WGS 84\",\n"
189:                        + "  DATUM[\"WGS84\",\n"
190:                        + "    SPHEROID[\"WGS 84\", 6378137.0, 298.257223563]],\n"
191:                        + "  PRIMEM[\"Greenwich\", 0.0],\n"
192:                        + "  UNIT[\"degree\", 0.017453292519943295]]";
193:                CoordinateReferenceSystem search = CRS.parseWKT(wkt);
194:                assertFalse("Required condition for next test.", CRS84
195:                        .equals(search));
196:                assertTrue("Required condition for next test.", CRS
197:                        .equalsIgnoreMetadata(CRS84, search));
198:
199:                finder.setFullScanAllowed(false);
200:                assertNull(
201:                        "Should not find WGS84 without a full scan, since it doesn't contains the CRS:84 identifier.",
202:                        finder.find(search));
203:
204:                finder.setFullScanAllowed(true);
205:                assertSame(
206:                        "A full scan should allow us to find WGS84, since it is equals ignoring metadata to CRS:84.",
207:                        CRS84, finder.find(search));
208:
209:                assertEquals("CRS:84", finder.findIdentifier(search));
210:            }
211:
212:            /**
213:             * Tests the {@link IdentifiedObjectFinder#find} method through a buffered authority factory.
214:             * The objects found are expected to be cached.
215:             */
216:            public void testBufferedFind() throws FactoryException {
217:                final AbstractAuthorityFactory factory = new Buffered(
218:                        this .factory);
219:                final GeographicCRS CRS84 = factory
220:                        .createGeographicCRS("CRS:84");
221:                final IdentifiedObjectFinder finder = factory
222:                        .getIdentifiedObjectFinder(CoordinateReferenceSystem.class);
223:
224:                finder.setFullScanAllowed(false);
225:                assertSame(
226:                        "Should find without the need for scan, since we can use the CRS:84 identifier.",
227:                        CRS84, finder.find(CRS84));
228:
229:                finder.setFullScanAllowed(false);
230:                assertNull(
231:                        "Should not find WGS84 without a full scan, since it doesn't contains the CRS:84 identifier.",
232:                        finder.find(DefaultGeographicCRS.WGS84));
233:
234:                finder.setFullScanAllowed(true);
235:                assertSame(
236:                        "A full scan should allow us to find WGS84, since it is equals ignoring metadata to CRS:84.",
237:                        CRS84, finder.find(DefaultGeographicCRS.WGS84));
238:
239:                finder.setFullScanAllowed(false);
240:                assertSame(
241:                        "At the contrary of testFind(), the scan result should be cached.",
242:                        CRS84, finder.find(DefaultGeographicCRS.WGS84));
243:
244:                assertEquals("CRS:84", finder
245:                        .findIdentifier(DefaultGeographicCRS.WGS84));
246:            }
247:
248:            /**
249:             * For {@link #testBufferedFind}.
250:             */
251:            private static final class Buffered extends
252:                    BufferedAuthorityFactory implements  CRSAuthorityFactory {
253:                Buffered(final AbstractAuthorityFactory factory) {
254:                    super(factory);
255:                }
256:            }
257:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.