-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from open-dis/coordinate-tests
Coordinate tests
- Loading branch information
Showing
2 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/test/java/edu/nps/moves/disutil/CoordinateConversionsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package edu.nps.moves.disutil; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class CoordinateConversionsTest { | ||
|
||
final double DELTA = 0.1; // acceptable amount of error | ||
|
||
double[] xyz = {1071401.9738714, -4450059.11156203, 4427050.83344532}; | ||
double[] latlonheightDegrees = {44.2368804, -76.4630307, 91}; | ||
double[] latlonheightRadians; | ||
|
||
public CoordinateConversionsTest() { | ||
latlonheightRadians = latlonheightDegrees.clone(); | ||
latlonheightRadians[0] *= CoordinateConversions.DEGREES_TO_RADIANS; | ||
latlonheightRadians[1] *= CoordinateConversions.DEGREES_TO_RADIANS; | ||
} | ||
|
||
@Test | ||
public void xyzToLatLonRadiansTest() { | ||
Assert.assertArrayEquals(latlonheightRadians, CoordinateConversions.xyzToLatLonRadians(xyz), DELTA); | ||
} | ||
|
||
@Test | ||
public void xyzToLatLonDegreesTest() { | ||
Assert.assertArrayEquals(latlonheightDegrees, CoordinateConversions.xyzToLatLonDegrees(xyz), DELTA); | ||
} | ||
|
||
@Test | ||
public void getXYZfromLatLonDegreesTest() { | ||
Assert.assertArrayEquals(xyz, CoordinateConversions.getXYZfromLatLonDegrees(latlonheightDegrees[0], latlonheightDegrees[1], latlonheightDegrees[2]), DELTA); | ||
} | ||
|
||
@Test | ||
public void getXYZfromLatLonRadiansTest() { | ||
Assert.assertArrayEquals(xyz, CoordinateConversions.getXYZfromLatLonRadians(latlonheightRadians[0], latlonheightRadians[1], latlonheightRadians[2]), DELTA); | ||
} | ||
} |