Source Code Cross Referenced for GeocentricTranslationTest.java in  » GIS » GeoTools-2.4.1 » org » geotools » referencing » operation » transform » 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.operation.transform 
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; either
010:         *    version 2.1 of the License, or (at your option) any later version.
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.operation.transform;
018:
019:        // JUnit dependencies
020:        import junit.framework.Test;
021:        import junit.framework.TestCase;
022:        import junit.framework.TestSuite;
023:
024:        // OpenGIS dependencies
025:        import org.opengis.parameter.ParameterValueGroup;
026:        import org.opengis.referencing.FactoryException;
027:        import org.opengis.referencing.datum.Ellipsoid;
028:        import org.opengis.referencing.operation.TransformException;
029:        import org.opengis.referencing.operation.MathTransform;
030:        import org.opengis.referencing.operation.MathTransformFactory;
031:
032:        // Geotools dependencies
033:        import org.geotools.referencing.ReferencingFactoryFinder;
034:        import org.geotools.referencing.operation.TestTransform;
035:        import org.geotools.referencing.datum.DefaultEllipsoid;
036:        import org.geotools.geometry.GeneralDirectPosition;
037:
038:        /**
039:         * Tests the {@link GeocentricTranslation} class.
040:         *
041:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/referencing/src/test/java/org/geotools/referencing/operation/transform/GeocentricTranslationTest.java $
042:         * @version $Id: GeocentricTranslationTest.java 25050 2007-04-06 00:41:49Z jgarnett $
043:         * @author Martin Desruisseaux
044:         */
045:        public final class GeocentricTranslationTest extends TestCase {
046:            /**
047:             * Runs the tests with the textual test runner.
048:             */
049:            public static void main(String args[]) {
050:                junit.textui.TestRunner.run(suite());
051:            }
052:
053:            /**
054:             * Returns the test suite.
055:             */
056:            public static Test suite() {
057:                return new TestSuite(GeocentricTranslationTest.class);
058:            }
059:
060:            /**
061:             * Constructs a test case with the given name.
062:             */
063:            public GeocentricTranslationTest(final String name) {
064:                super (name);
065:            }
066:
067:            /**
068:             * Test case using example from EPSG Guidance Note number 7 part 2 (May 2005),
069:             * section 2.4.3.1.
070:             */
071:            public void testTranslation() throws FactoryException,
072:                    TransformException {
073:                final String classification = "Geocentric translations";
074:                final MathTransformFactory factory = ReferencingFactoryFinder
075:                        .getMathTransformFactory(null);
076:                final ParameterValueGroup param = factory
077:                        .getDefaultParameters(classification);
078:
079:                param.parameter("dx").setValue(84.87);
080:                param.parameter("dy").setValue(96.49);
081:                param.parameter("dz").setValue(116.95);
082:
083:                final MathTransform test = factory
084:                        .createParameterizedTransform(param);
085:                final GeneralDirectPosition position = new GeneralDirectPosition(
086:                        3);
087:                position.setOrdinate(0, 3771793.97);
088:                position.setOrdinate(1, 140253.34);
089:                position.setOrdinate(2, 5124304.35);
090:                assertSame(position, test.transform(position, position));
091:                assertEquals(3771878.84, position.getOrdinate(0), 1E-5);
092:                assertEquals(140349.83, position.getOrdinate(1), 1E-5);
093:                assertEquals(5124421.30, position.getOrdinate(2), 1E-5);
094:            }
095:
096:            /**
097:             * Test case using example from EPSG Guidance Note number 7 part 2 (May 2005),
098:             * section 2.4.3.2.1.
099:             */
100:            public void testSevenParam() throws FactoryException,
101:                    TransformException {
102:                final String classification = "Position Vector 7-param. transformation";
103:                final MathTransformFactory factory = ReferencingFactoryFinder
104:                        .getMathTransformFactory(null);
105:                final ParameterValueGroup param = factory
106:                        .getDefaultParameters(classification);
107:
108:                param.parameter("dx").setValue(0.000);
109:                param.parameter("dy").setValue(0.000);
110:                param.parameter("dz").setValue(4.5);
111:                param.parameter("ex").setValue(0.000);
112:                param.parameter("ey").setValue(0.000);
113:                param.parameter("ez").setValue(0.554);
114:                param.parameter("ppm").setValue(0.219);
115:
116:                final MathTransform test = factory
117:                        .createParameterizedTransform(param);
118:                final GeneralDirectPosition position = new GeneralDirectPosition(
119:                        3);
120:                position.setOrdinate(0, 3657660.66);
121:                position.setOrdinate(1, 255768.55);
122:                position.setOrdinate(2, 5201382.11);
123:                assertSame(position, test.transform(position, position));
124:                assertEquals(3657660.78, position.getOrdinate(0), 1E-2);
125:                assertEquals(255778.43, position.getOrdinate(1), 1E-5);
126:                assertEquals(5201387.75, position.getOrdinate(2), 1E-2);
127:            }
128:
129:            /**
130:             * Test case using example from EPSG Guidance Note number 7 part 2 (May 2005),
131:             * section 2.4.3.2.2.
132:             */
133:            public void testFrameRotation() throws FactoryException,
134:                    TransformException {
135:                final String classification = "Coordinate Frame rotation";
136:                final MathTransformFactory factory = ReferencingFactoryFinder
137:                        .getMathTransformFactory(null);
138:                final ParameterValueGroup param = factory
139:                        .getDefaultParameters(classification);
140:
141:                param.parameter("dx").setValue(0.000);
142:                param.parameter("dy").setValue(0.000);
143:                param.parameter("dz").setValue(4.5);
144:                param.parameter("ex").setValue(0.000);
145:                param.parameter("ey").setValue(0.000);
146:                param.parameter("ez").setValue(-0.554);
147:                param.parameter("ppm").setValue(0.219);
148:
149:                final MathTransform test = factory
150:                        .createParameterizedTransform(param);
151:                final GeneralDirectPosition position = new GeneralDirectPosition(
152:                        3);
153:                position.setOrdinate(0, 3657660.66);
154:                position.setOrdinate(1, 255768.55);
155:                position.setOrdinate(2, 5201382.11);
156:                assertSame(position, test.transform(position, position));
157:                assertEquals(3657660.78, position.getOrdinate(0), 1E-2);
158:                assertEquals(255778.43, position.getOrdinate(1), 1E-5);
159:                assertEquals(5201387.75, position.getOrdinate(2), 1E-2);
160:            }
161:
162:            /**
163:             * Tests the creation with geocentric transforms.
164:             * Note: the expected values here are approximatives since we didn't used
165:             * an external source of test points for this test.
166:             */
167:            public void testGeotoolsExtensions() throws FactoryException,
168:                    TransformException {
169:                final String classification = "Coordinate Frame rotation";
170:                final MathTransformFactory factory = ReferencingFactoryFinder
171:                        .getMathTransformFactory(null);
172:                final ParameterValueGroup param = factory
173:                        .getDefaultParameters(classification);
174:                final Ellipsoid sourceEllipsoid = DefaultEllipsoid.INTERNATIONAL_1924;
175:                final Ellipsoid targetEllipsoid = DefaultEllipsoid.WGS84;
176:
177:                param.parameter("dx").setValue(0.000);
178:                param.parameter("dy").setValue(0.000);
179:                param.parameter("dz").setValue(4.5);
180:                param.parameter("ex").setValue(0.000);
181:                param.parameter("ey").setValue(0.000);
182:                param.parameter("ez").setValue(-0.554);
183:                param.parameter("ppm").setValue(0.219);
184:
185:                param.parameter("src_dim").setValue(3);
186:                param.parameter("tgt_dim").setValue(3);
187:                param.parameter("src_semi_major").setValue(
188:                        sourceEllipsoid.getSemiMajorAxis());
189:                param.parameter("src_semi_minor").setValue(
190:                        sourceEllipsoid.getSemiMinorAxis());
191:                param.parameter("tgt_semi_major").setValue(
192:                        targetEllipsoid.getSemiMajorAxis());
193:                param.parameter("tgt_semi_minor").setValue(
194:                        targetEllipsoid.getSemiMinorAxis());
195:
196:                final MathTransform test = factory
197:                        .createParameterizedTransform(param);
198:                final GeneralDirectPosition position = new GeneralDirectPosition(
199:                        3);
200:                position.setOrdinate(0, 4.00); // Longitude
201:                position.setOrdinate(1, 55.00); // Latitude
202:                position.setOrdinate(2, -191.61); // Height
203:
204:                assertSame(position, test.transform(position, position));
205:                assertEquals(4.00, position.getOrdinate(0), 1E-2);
206:                assertEquals(55.00, position.getOrdinate(1), 1E-2);
207:                assertEquals(3.23, position.getOrdinate(2), 1E-2);
208:            }
209:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.