Source Code Cross Referenced for OperationFactoryTest.java in  » GIS » GeoTools-2.4.1 » org » geotools » referencing » factory » epsg » 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.epsg 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2005-2006, GeoTools Project Managment Committee (PMC)
005:         *    (C) 2005, Institut de Recherche pour le Développement
006:         *
007:         *    This library is free software; you can redistribute it and/or
008:         *    modify it under the terms of the GNU Lesser General Public
009:         *    License as published by the Free Software Foundation;
010:         *    version 2.1 of the License.
011:         *
012:         *    This library is distributed in the hope that it will be useful,
013:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         *    Lesser General Public License for more details.
016:         */
017:        package org.geotools.referencing.factory.epsg;
018:
019:        // J2SE dependencies
020:        import java.util.Iterator;
021:        import java.util.logging.Level;
022:
023:        // JUnit dependencies
024:        import junit.framework.Test;
025:        import junit.framework.TestCase;
026:        import junit.framework.TestSuite;
027:
028:        // OpenGIS dependencies
029:        import org.opengis.metadata.Identifier;
030:        import org.opengis.referencing.FactoryException;
031:        import org.opengis.referencing.IdentifiedObject;
032:        import org.opengis.referencing.crs.CRSAuthorityFactory;
033:        import org.opengis.referencing.crs.CoordinateReferenceSystem;
034:        import org.opengis.referencing.operation.Conversion;
035:        import org.opengis.referencing.operation.Transformation;
036:        import org.opengis.referencing.operation.CoordinateOperation;
037:        import org.opengis.referencing.operation.CoordinateOperationFactory;
038:        import org.opengis.referencing.operation.ConcatenatedOperation;
039:
040:        // Geotools dependencies
041:        import org.geotools.referencing.operation.BufferedCoordinateOperationFactory;
042:        import org.geotools.referencing.operation.AbstractCoordinateOperation;
043:        import org.geotools.referencing.operation.AuthorityBackedFactory;
044:        import org.geotools.referencing.ReferencingFactoryFinder;
045:        import org.geotools.factory.Hints;
046:        import org.geotools.resources.Arguments;
047:        import org.geotools.resources.Utilities;
048:
049:        /**
050:         * Tests the usage of {@link CoordinateOperationFactory} with the help of the
051:         * EPSG database. Any EPSG plugin should fit. However, this test live in the
052:         * {@code plugin/epsg-hsql} module since the HSQL plugin is the only one which
053:         * is garantee to work on any machine running Maven.
054:         *
055:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/plugin/epsg-hsql/src/test/java/org/geotools/referencing/factory/epsg/OperationFactoryTest.java $
056:         * @version $Id: OperationFactoryTest.java 27848 2007-11-12 13:10:32Z desruisseaux $
057:         * @author Martin Desruisseaux
058:         */
059:        public class OperationFactoryTest extends TestCase {
060:            /**
061:             * Run the suite from the command line. If {@code "-log"} flag is specified on the
062:             * command-line, then the logger will be set to {@link Level#CONFIG}. This is usefull
063:             * for tracking down which data source is actually used.
064:             */
065:            public static void main(final String[] args) {
066:                final Arguments arguments = new Arguments(args);
067:                final boolean log = arguments.getFlag("-log");
068:                arguments.getRemainingArguments(0);
069:                org.geotools.util.logging.Logging.GEOTOOLS
070:                        .forceMonolineConsoleOutput(log ? Level.CONFIG : null);
071:                junit.textui.TestRunner.run(suite());
072:            }
073:
074:            /**
075:             * Returns the test suite.
076:             */
077:            public static Test suite() {
078:                return new TestSuite(OperationFactoryTest.class);
079:            }
080:
081:            /**
082:             * Constructs a test case with the given name.
083:             */
084:            public OperationFactoryTest(final String name) {
085:                super (name);
086:            }
087:
088:            /**
089:             * Returns the first identifier for the specified object.
090:             */
091:            private static String getIdentifier(final IdentifiedObject object) {
092:                return ((Identifier) object.getIdentifiers().iterator().next())
093:                        .getCode();
094:            }
095:
096:            /**
097:             * Tests the creation of an operation from EPSG:4230 to EPSG:4326. They are the same
098:             * CRS than the one tested in {@link DefaultDataSourceTest#testTransformations}.
099:             */
100:            public void testCreate() throws FactoryException {
101:                final CRSAuthorityFactory crsFactory;
102:                final CoordinateOperationFactory opFactory;
103:                CoordinateReferenceSystem sourceCRS;
104:                CoordinateReferenceSystem targetCRS;
105:                CoordinateOperation operation;
106:
107:                crsFactory = ReferencingFactoryFinder.getCRSAuthorityFactory(
108:                        "EPSG", null);
109:                opFactory = ReferencingFactoryFinder
110:                        .getCoordinateOperationFactory(null);
111:                sourceCRS = crsFactory.createCoordinateReferenceSystem("4230");
112:                targetCRS = crsFactory.createCoordinateReferenceSystem("4326");
113:                operation = opFactory.createOperation(sourceCRS, targetCRS);
114:
115:                assertSame(sourceCRS, operation.getSourceCRS());
116:                assertSame(targetCRS, operation.getTargetCRS());
117:                assertSame(operation, opFactory.createOperation(sourceCRS,
118:                        targetCRS));
119:                assertTrue("Expected a buffered factory but got "
120:                        + opFactory.getClass().getName(),
121:                        opFactory instanceof  BufferedCoordinateOperationFactory);
122:                assertTrue(
123:                        "EPSG authority factory not found.",
124:                        ((BufferedCoordinateOperationFactory) opFactory)
125:                                .getImplementationHints().get(
126:                                        Hints.COORDINATE_OPERATION_FACTORY) instanceof  AuthorityBackedFactory);
127:                assertEquals("1612", getIdentifier(operation)); // See comment in DefaultDataSourceTest.
128:                assertEquals(1.0, AbstractCoordinateOperation
129:                        .getAccuracy(operation), 1E-6);
130:                assertTrue(operation instanceof  Transformation);
131:                /*
132:                 * Tests a transformation not backed directly by an authority factory.
133:                 * However, the inverse transform may exist in the authority factory.
134:                 */
135:                sourceCRS = crsFactory.createCoordinateReferenceSystem("4326");
136:                targetCRS = crsFactory.createCoordinateReferenceSystem("2995");
137:                operation = opFactory.createOperation(sourceCRS, targetCRS);
138:                assertTrue(
139:                        "This test needs an operation not backed by the EPSG factory.",
140:                        operation.getIdentifiers().isEmpty());
141:                // Should contains exactly one transformations and an arbitrary number of conversions.
142:                assertTrue(operation instanceof  ConcatenatedOperation);
143:                int count = 0;
144:                for (final Iterator it = ((ConcatenatedOperation) operation)
145:                        .getOperations().iterator(); it.hasNext();) {
146:                    final CoordinateOperation op = (CoordinateOperation) it
147:                            .next();
148:                    if (op instanceof  Transformation) {
149:                        count++;
150:                    } else {
151:                        assertTrue(
152:                                "Expected Conversion but got "
153:                                        + Utilities
154:                                                .getShortName(AbstractCoordinateOperation
155:                                                        .getType(op)) + ". ",
156:                                (op instanceof  Conversion));
157:                    }
158:                }
159:                assertEquals(
160:                        "The coordinate operation should contains exactly 1 transformation",
161:                        1, count);
162:                assertTrue(AbstractCoordinateOperation.getAccuracy(operation) <= 25);
163:            }
164:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.