01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 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.referencing.operation.transform;
17:
18: // JUnit dependencies
19: import junit.framework.TestCase;
20:
21: // OpenGIS dependencies
22: import org.opengis.parameter.ParameterValueGroup;
23: import org.opengis.referencing.FactoryException;
24: import org.opengis.referencing.operation.MathTransform;
25: import org.opengis.referencing.operation.MathTransformFactory;
26: import org.opengis.referencing.operation.TransformException;
27: import org.opengis.geometry.DirectPosition;
28:
29: // Geotools dependencies
30: import org.geotools.referencing.ReferencingFactoryFinder;
31: import org.geotools.geometry.GeneralDirectPosition;
32:
33: /**
34: * Tests the {@link EarthGravitationalModel} class.
35: *
36: * @since 2.3
37: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/plugin/referencing3D/src/test/java/org/geotools/referencing/operation/transform/EarthGravitationalModelTest.java $
38: * @version $Id: EarthGravitationalModelTest.java 25050 2007-04-06 00:41:49Z jgarnett $
39: * @author Martin Desruisseaux
40: */
41: public class EarthGravitationalModelTest extends TestCase {
42: /**
43: * Tests the {@link EarthGravitationalModel#heightOffset} method for WGS 84.
44: */
45: public void testHeightOffsetWGS84() throws Exception {
46: final EarthGravitationalModel gh = new EarthGravitationalModel();
47: gh.load("EGM180.nor");
48: assertEquals(1.505, gh.heightOffset(45, 45, 0), 0.001);
49: assertEquals(1.515, gh.heightOffset(45, 45, 1000), 0.001);
50: assertEquals(46.908, gh.heightOffset(0, 45, 0), 0.001);
51: }
52:
53: /**
54: * Tests the {@link EarthGravitationalModel#heightOffset} method for WGS 72.
55: */
56: public void testHeightOffsetWGS72() throws Exception {
57: final EarthGravitationalModel gh = new EarthGravitationalModel(
58: 180, false);
59: gh.load("EGM180.nor");
60: assertEquals(1.475, gh.heightOffset(45, 45, 0), 0.001);
61: assertEquals(46.879, gh.heightOffset(0, 45, 0), 0.001);
62: assertEquals(23.324, gh.heightOffset(3, 10, 10), 0.001);
63: assertEquals(0.380, gh.heightOffset(75, -30, 0), 0.001);
64: }
65:
66: /**
67: * Tests the creation of the math transform from the factory.
68: */
69: public void testMathTransform() throws FactoryException,
70: TransformException {
71: final MathTransformFactory mtFactory = ReferencingFactoryFinder
72: .getMathTransformFactory(null);
73: final ParameterValueGroup p = mtFactory
74: .getDefaultParameters("Earth gravitational model");
75: final MathTransform mt = mtFactory
76: .createParameterizedTransform(p);
77: DirectPosition pos = new GeneralDirectPosition(new double[] {
78: 45, 45, 1000 });
79: pos = mt.transform(pos, pos);
80: assertEquals(45.000, pos.getOrdinate(0), 0.001);
81: assertEquals(45.000, pos.getOrdinate(1), 0.001);
82: assertEquals(1001.515, pos.getOrdinate(2), 0.001);
83: }
84: }
|